Update Makefiles

This commit is contained in:
2019-04-18 20:51:50 +02:00
parent add3087de3
commit ea71693886
2 changed files with 104 additions and 71 deletions
+97 -66
View File
@@ -6,15 +6,20 @@ ROOTPATH := /opt/build/PresenceDetection
COMMANDLINE := $(shell ps -o args= $$PPID) COMMANDLINE := $(shell ps -o args= $$PPID)
ARCHS := $(shell ls $(ROOTPATH)/Makefile.conf.* | grep -v base | sed 's/.*Makefile\.conf\.//g') ARCHS := $(shell ls $(ROOTPATH)/Makefile.conf.* | grep -v base | sed 's/.*Makefile\.conf\.//g')
ARCHS += any
ARCH := $(filter $(ARCHS),$(MAKECMDGOALS)) ARCH := $(filter $(ARCHS),$(MAKECMDGOALS))
MAKECMDGOALS := $(filter-out $(ARCH),$(MAKECMDGOALS))
ARCHS := $(filter-out any,$(ARCHS))
ifeq ($(ARCH),) ifeq ($(ARCH),)
ARCH := x86-64 ARCH := x86-64
endif endif
ifeq (,$(findstring -S,$(COMMANDLINE))) ifeq (,$(findstring -S,$(COMMANDLINE)))
ifneq ($(ARCH),)
$(info ARCH: $(ARCH)) $(info ARCH: $(ARCH))
endif endif
endif
-include $(ROOTPATH)/Makefile.conf.$(ARCH) -include $(ROOTPATH)/Makefile.conf.$(ARCH)
-include $(ROOTPATH)/Makefile.conf.base -include $(ROOTPATH)/Makefile.conf.base
@@ -44,7 +49,7 @@ OBJECTS = $(SOURCES:.cpp=.o.$(ARCH))
DEPENDS = $(OBJECTS:.o.$(ARCH)=.d.$(ARCH)) DEPENDS = $(OBJECTS:.o.$(ARCH)=.d.$(ARCH))
TARGETS = TARGETS =
define target define build_target_arch
$(eval $@_DATETIME := $(DATETIME)) $(eval $@_DATETIME := $(DATETIME))
@echo -n " [LD] $(1)\n" @echo -n " [LD] $(1)\n"
@$(PREFIX) $(CC) -o $(1) $(2) $(LFLAGS) $(CFLAGS) $(POSTFIX) @$(PREFIX) $(CC) -o $(1) $(2) $(LFLAGS) $(CFLAGS) $(POSTFIX)
@@ -54,6 +59,18 @@ define target
@chmod -x $(DEBUGDIR)/$(1)-$($@_DATETIME).debug @chmod -x $(DEBUGDIR)/$(1)-$($@_DATETIME).debug
endef endef
define build_target
@if [ "$(ARCH)" = "any" ]; then \
for arch in $(ARCHS); do \
echo "ARCH: $$arch"; \
$(MAKE) -s -S $(1) $$arch; \
done; \
true; \
else \
$(MAKE) -s -S $(1).$(ARCH) $(ARCH); \
fi
endef
$(LOCALOBJECTS): | $(SUBDIRS) $(LOCALOBJECTS): | $(SUBDIRS)
$(OBJECTS): | $(SUBDIRS) $(OBJECTS): | $(SUBDIRS)
@@ -68,14 +85,16 @@ ifneq ($(MAKECMDGOALS),clean)
endif endif
%.d.$(ARCH): %.cpp %.d.$(ARCH): %.cpp
@depth=$(MAKELEVEL); \ @if [ "$(ARCH)" != "any" ]; then \
while [ $${depth} -gt 0 ] ; do \ depth=$(MAKELEVEL); \
echo -n " "; \ while [ $${depth} -gt 0 ] ; do \
depth=`expr $$depth - 1`; \ echo -n " "; \
done; \ depth=`expr $$depth - 1`; \
true done; \
@echo -n " [MM] $@\n" true; \
@$(PREFIX) $(CC) $(CFLAGS) $< -MM -MT $(@:.d.$(ARCH)=.o.$(ARCH)) >$@ $(POSTFIX) echo -n " [MM] $@\n"; \
$(PREFIX) $(CC) $(CFLAGS) $< -MM -MT $(@:.d.$(ARCH)=.o.$(ARCH)) >$@ $(POSTFIX); \
fi
%.o.$(ARCH): %.cpp %.o.$(ARCH): %.cpp
@depth=$(MAKELEVEL); \ @depth=$(MAKELEVEL); \
@@ -88,14 +107,16 @@ endif
@$(PREFIX) $(CC) -c $(CFLAGS) $< -o $@ $(POSTFIX) @$(PREFIX) $(CC) -c $(CFLAGS) $< -o $@ $(POSTFIX)
%.d.$(ARCH): %.cc %.d.$(ARCH): %.cc
@depth=$(MAKELEVEL); \ @if [ "$(ARCH)" != "any" ]; then \
while [ $${depth} -gt 0 ] ; do \ depth=$(MAKELEVEL); \
echo -n " "; \ while [ $${depth} -gt 0 ] ; do \
depth=`expr $$depth - 1`; \ echo -n " "; \
done; \ depth=`expr $$depth - 1`; \
true done; \
@echo -n " [MM] $@\n" true; \
@$(PREFIX) $(CC) $(CFLAGS) $< -MM -MT $(@:.d.$(ARCH)=.o.$(ARCH)) >$@ $(POSTFIX) echo -n " [MM] $@\n"; \
$(PREFIX) $(CC) $(CFLAGS) $< -MM -MT $(@:.d.$(ARCH)=.o.$(ARCH)) >$@ $(POSTFIX); \
fi
%.o.$(ARCH): %.cc %.o.$(ARCH): %.cc
@depth=$(MAKELEVEL); \ @depth=$(MAKELEVEL); \
@@ -140,64 +161,74 @@ all: $(TARGETS)
.PHONY: clean .PHONY: clean
clean: clean:
@for dir in $(SUBDIRS); do \ @if [ "$(ARCH)" = "any" ]; then \
depth=$(MAKELEVEL); \ for arch in $(ARCHS); do \
while [ $${depth} -gt 0 ] ; do \ echo "ARCH: $$arch"; \
echo -n " "; \ $(MAKE) -s -S $(MAKECMDGOALS) $$arch; \
depth=`expr $$depth - 1`; \
done; \ done; \
echo " <$$dir>"; \ true; \
$(MAKE) -s -S -C $$dir $@ $(ARCH); \ else \
while [ $${depth} -gt 0 ] ; do \ for dir in $(SUBDIRS); do \
echo -n " "; \ depth=$(MAKELEVEL); \
depth=`expr $$depth - 1`; \ while [ $${depth} -gt 0 ] ; do \
echo -n " "; \
depth=`expr $$depth - 1`; \
done; \
echo " <$$dir>"; \
$(MAKE) -s -S -C $$dir $@ $(ARCH); \
while [ $${depth} -gt 0 ] ; do \
echo -n " "; \
depth=`expr $$depth - 1`; \
done; \
echo " </$$dir>"; \
done; \ done; \
echo " </$$dir>"; \ for target in $(TARGETS); do \
done; \ rm -f $$target.$(ARCH); \
true done; \
@rm -f $(LOCALOBJECTS) $(LOCALDEPENDS) $(ARNAME) $(TARGETS) || true true; \
fi
@rm -f $(LOCALOBJECTS) $(LOCALDEPENDS) $(ARNAME) || true
.PHONY: cleandeps .PHONY: cleandeps
cleandeps: cleandeps:
@for dir in $(SUBDIRS); do \ @if [ "$(ARCH)" = "any" ]; then \
depth=$(MAKELEVEL); \ for arch in $(ARCHS); do \
while [ $${depth} -gt 0 ] ; do \ echo "ARCH: $$arch"; \
echo -n " "; \ $(MAKE) -s -S $(MAKECMDGOALS) $$arch; \
depth=`expr $$depth - 1`; \
done; \ done; \
echo " <$$dir>"; \ true; \
$(MAKE) -s -S -C $$dir $@ $(ARCH); \ else \
while [ $${depth} -gt 0 ] ; do \ for dir in $(SUBDIRS); do \
echo -n " "; \ depth=$(MAKELEVEL); \
depth=`expr $$depth - 1`; \ while [ $${depth} -gt 0 ] ; do \
echo -n " "; \
depth=`expr $$depth - 1`; \
done; \
echo " <$$dir>"; \
$(MAKE) -s -S -C $$dir $@ $(ARCH); \
while [ $${depth} -gt 0 ] ; do \
echo -n " "; \
depth=`expr $$depth - 1`; \
done; \
echo " </$$dir>"; \
done; \ done; \
echo " </$$dir>"; \ for target in $(TARGETS); do \
done; \ rm -f $$target.$(ARCH); \
true
@rm -f $(LOCALDEPENDS) $(TARGETS) || true
.PHONY: cleanall
cleanall:
@for dir in $(SUBDIRS); do \
depth=$(MAKELEVEL); \
while [ $${depth} -gt 0 ] ; do \
echo -n " "; \
depth=`expr $$depth - 1`; \
done; \ done; \
echo " <$$dir>"; \ true; \
$(MAKE) -s -S -C $$dir $@ $(ARCH); \ fi
while [ $${depth} -gt 0 ] ; do \ @rm -f $(LOCALDEPENDS) || true
echo -n " "; \
depth=`expr $$depth - 1`; \
done; \
echo " </$$dir>"; \
done; \
true
@rm -f *.d.* *.o.*
@rm -f $(ARNAME) $(TARGETS) || true
.PHONY: $(ARCH) .PHONY: $(ARCH)
$(ARCH): $(ARCH):
@if [ "$(words $(MAKECMDGOALS))" = "1" ]; then \ @if [ "$(words $(MAKECMDGOALS))" = "0" ]; then \
$(MAKE) -s -S $(.DEFAULT_GOAL) $(ARCH); \ if [ "$(ARCH)" = "any" ]; then \
for arch in $(ARCHS); do \
echo "ARCH: $$arch"; \
$(MAKE) -s -S $(.DEFAULT_GOAL) $$arch; \
done; \
true; \
else \
$(MAKE) -s -S $(.DEFAULT_GOAL) $(ARCH); \
fi \
fi fi
+7 -5
View File
@@ -3,15 +3,17 @@
# #
PresenceDetection.$(ARCH): $(OBJECTS) Application/PresenceDetection.o.$(ARCH) PresenceDetection.$(ARCH): $(OBJECTS) Application/PresenceDetection.o.$(ARCH)
$(call target,$@,$^) $(call build_target_arch,$@,$^)
test.$(ARCH): $(OBJECTS) Application/Test.o.$(ARCH) test.$(ARCH): $(OBJECTS) Application/Test.o.$(ARCH)
$(call target,$@,$^) $(call build_target_arch,$@,$^)
PresenceDetection: PresenceDetection.$(ARCH) PresenceDetection:
test: test.$(ARCH) $(call build_target,$@)
test:
$(call build_target,$@)
.DEFAULT_GOAL := PresenceDetection .DEFAULT_GOAL := PresenceDetection
TARGETS += PresenceDetection test TARGETS += PresenceDetection test