Skip to content

Commit

Permalink
framework: add parallel make compilation
Browse files Browse the repository at this point in the history
Interesting for large application
Closes SynoCommunity#49
  • Loading branch information
ymartin59 committed Aug 3, 2019
1 parent 536c783 commit 4cf516f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ local.mk:
@echo "DISTRIBUTOR_URL=" >> $@
@echo "REPORT_URL=" >> $@
@echo "DEFAULT_TC=" >> $@
@echo "#PARALLEL_MAKE=max" >> $@

dsm-%: local.mk
@echo "Setting default toolchain version to DSM-$*"
Expand Down
12 changes: 12 additions & 0 deletions mk/spksrc.common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,15 @@ LOCAL_CONFIG_MK = ../../local.mk
ifneq ($(wildcard $(LOCAL_CONFIG_MK)),)
include $(LOCAL_CONFIG_MK)
endif

# Relocate to set conditionally according to existing parallel options in caller
ifneq ($(PARALLEL_MAKE),)
ifeq ($(PARALLEL_MAKE),max)
NCPUS = $(shell grep -c ^processor /proc/cpuinfo)
else
NCPUS = $(PARALLEL_MAKE)
endif
ifeq ($(filter $(NCPUS),0 1),)
COMPILE_MAKE_OPTIONS = -j$(NCPUS)
endif
endif
6 changes: 3 additions & 3 deletions mk/spksrc.compile.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Compile rules
# Invoke make to (cross-) compile the software.
# Invoke make to (cross-) compile the software.
# Target are executed in the following order:
# compile_msg_target
# pre_compile_target (override with PRE_COMPILE_TARGET)
Expand Down Expand Up @@ -32,8 +32,8 @@ compile_msg:

pre_compile_target: compile_msg

compile_target: $(PRE_COMPILE_TARGET)
@$(RUN) $(MAKE)
compile_target: $(PRE_COMPILE_TARGET)
@$(RUN) $(MAKE) $(COMPILE_MAKE_OPTIONS)

post_compile_target: $(COMPILE_TARGET)

Expand Down
4 changes: 4 additions & 0 deletions mk/spksrc.cross-env.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ $(TC_VARS_MK):
ENV += TC=$(TC)
ENV += $(TC_ENV)
endif

#ifneq ($(COMPILE_MAKE_OPTIONS),)
#ENV += MAKEFLAGS="$(COMPILE_MAKE_OPTIONS)"
#endif
8 changes: 8 additions & 0 deletions mk/spksrc.directories.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ endif
STAGING_DIR = $(WORK_DIR)/staging

ifndef INSTALL_PREFIX
ifneq ($(strip $(SPK_NAME)),)
INSTALL_PREFIX = /var/packages/$(SPK_NAME)/target
else
ifneq ($(strip $(PKG_NAME)),)
INSTALL_PREFIX = /usr/local/$(PKG_NAME)
else
INSTALL_PREFIX = /usr/local
endif
endif
endif

ifndef KERNEL_DIR
Expand Down

0 comments on commit 4cf516f

Please sign in to comment.