diff --git a/.gitignore b/.gitignore index 794f52e36c0..6bdd5c46442 100644 --- a/.gitignore +++ b/.gitignore @@ -19,9 +19,11 @@ *.sym *.su *~ +.built .context .depend .kconfig +/*.lock /bin /boot_romfsimg.h /external diff --git a/Application.mk b/Application.mk index b3b4d11b8a7..4c2ac8ba1f7 100644 --- a/Application.mk +++ b/Application.mk @@ -142,7 +142,7 @@ VPATH += :. # Targets follow -all:: $(OBJS) +all:: .built @: .PHONY: clean depend distclean .PRECIOUS: $(BIN) @@ -208,11 +208,12 @@ $(ZIGOBJS): %$(ZIGEXT)$(SUFFIX)$(OBJEXT): %$(ZIGEXT) $(if $(and $(CONFIG_BUILD_LOADABLE), $(CELFFLAGS)), \ $(call ELFCOMPILEZIG, $<, $@), $(call COMPILEZIG, $<, $@)) -archive: +.built: $(OBJS) $(call SPLITVARIABLE,ALL_OBJS,$(OBJS),100) $(foreach BATCH, $(ALL_OBJS_TOTAL), \ - $(call ARCHIVE_ADD, $(call CONVERT_PATH,$(BIN)), $(ALL_OBJS_$(BATCH))) \ + $(call ARLOCK, $(call CONVERT_PATH,$(BIN)), $(ALL_OBJS_$(BATCH))) \ ) + $(Q) touch $@ ifeq ($(BUILD_MODULE),y) @@ -295,6 +296,7 @@ depend:: .depend @: clean:: + $(call DELFILE, .built) $(call CLEAN) distclean:: clean diff --git a/Directory.mk b/Directory.mk index 81d39fd56a5..87a80d7bd12 100644 --- a/Directory.mk +++ b/Directory.mk @@ -24,6 +24,7 @@ include $(APPDIR)/Make.defs SUBDIRS := $(dir $(wildcard */Makefile)) CONFIGSUBDIRS := $(filter-out $(dir $(wildcard */Kconfig)),$(SUBDIRS)) +CLEANSUBDIRS := $(dir $(wildcard *$(DELIM).built)) CLEANSUBDIRS += $(dir $(wildcard */.depend)) CLEANSUBDIRS += $(dir $(wildcard */.kconfig)) CLEANSUBDIRS := $(sort $(CLEANSUBDIRS)) diff --git a/Make.defs b/Make.defs index abb70016ace..6f3807def4d 100644 --- a/Make.defs +++ b/Make.defs @@ -152,3 +152,7 @@ define SPLITVARIABLE $(eval $(PREFIX)_$(idx)=$(wordlist $(FROMINDEX), $(shell expr $(FROMINDEX) + $(BATCH_SIZE) - 1), $(2))) \ ) endef + +define ARLOCK + flock $1.lock $(call ARCHIVE, $1, $(2)) +endef diff --git a/Makefile b/Makefile index e502fad350e..d34e3ea4a21 100644 --- a/Makefile +++ b/Makefile @@ -42,9 +42,7 @@ SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT)) # We first remove libapps.a before letting the other rules add objects to it # so that we ensure libapps.a does not contain objects from prior build -all: - $(RM) $(BIN) - $(MAKE) $(BIN) +all: $(BIN) .PHONY: import install dirlinks export .depdirs preconfig depend clean distclean .PHONY: context clean_context context_all register register_all @@ -74,9 +72,6 @@ ifeq ($(CONFIG_BUILD_KERNEL),y) install: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_install) $(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all) - $(Q) for app in ${CONFIGURED_APPS}; do \ - $(MAKE) -C "$${app}" archive ; \ - done .import: $(BIN) $(Q) install libapps.a $(APPDIR)$(DELIM)import$(DELIM)libs @@ -96,21 +91,14 @@ else ifeq ($(CONFIG_BUILD_LOADABLE),) ifeq ($(CONFIG_WINDOWS_NATIVE),y) $(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all) - $(Q) for %%G in ($(CONFIGURED_APPS)) do ( $(MAKE) -C %%G archive ) else $(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all) - $(Q) for app in ${CONFIGURED_APPS}; do \ - $(MAKE) -C "$${app}" archive ; \ - done $(call LINK_WASM) endif else $(SYMTABSRC): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all) - $(Q) for app in ${CONFIGURED_APPS}; do \ - $(MAKE) -C "$${app}" archive ; \ - done $(Q) $(MAKE) install $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) >$@.tmp $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) @@ -119,7 +107,7 @@ $(SYMTABOBJ): %$(OBJEXT): %.c $(call COMPILE, $<, $@, -fno-lto -fno-builtin) $(BIN): $(SYMTABOBJ) - $(call ARCHIVE_ADD, $(call CONVERT_PATH,$(BIN)), $^) + $(call ARLOCK, $(call CONVERT_PATH,$(BIN)), $^) $(call LINK_WASM) endif # !CONFIG_BUILD_LOADABLE @@ -208,6 +196,7 @@ clean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_clean) $(call CLEAN) distclean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_distclean) + $(call DELFILE, *.lock) $(call DELFILE, .depend) $(call DELFILE, $(SYMTABSRC)) $(call DELFILE, $(SYMTABOBJ))