|
|
@@ -1,11 +1,14 @@
|
|
|
+#
|
|
|
# Makefile
|
|
|
#
|
|
|
|
|
|
-DATETIME := `date +'%y%m%d-%H%M'`
|
|
|
-MAKEFILEPATH := $(strip $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))))
|
|
|
+# ---------- Base Defines ----------
|
|
|
+
|
|
|
ROOTPATH := $(shell git rev-parse --show-toplevel)
|
|
|
COMMANDLINE := $(shell ps -o args= $$PPID)
|
|
|
|
|
|
+# ---------- Architectures ----------
|
|
|
+
|
|
|
ARCHS := $(shell ls $(ROOTPATH)/Makefiles/Makefile.conf.* | grep -v base | sed 's/.*Makefile\.conf\.//g')
|
|
|
ARCHS += any
|
|
|
|
|
|
@@ -19,9 +22,10 @@ $(info ARCH: $(ARCH))
|
|
|
endif
|
|
|
endif
|
|
|
|
|
|
--include $(ROOTPATH)/Makefiles/Makefile.conf.$(ARCH)
|
|
|
--include $(ROOTPATH)/Makefiles/Makefile.conf.base
|
|
|
--include $(ROOTPATH)/Makefile.conf
|
|
|
+# ---------- Defines ----------
|
|
|
+
|
|
|
+DATETIME := `date +'%y%m%d-%H%M'`
|
|
|
+MAKEFILEPATH := $(strip $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))))
|
|
|
|
|
|
PID := $(shell echo $$$$)
|
|
|
PREFIX = nice -n 19 /usr/bin/time --format='%E (%U)' -o /dev/shm/t-$(PID)
|
|
|
@@ -46,6 +50,23 @@ OBJECTS = $(SOURCES:.cpp=.o.$(ARCH))
|
|
|
DEPENDS = $(OBJECTS:.o.$(ARCH)=.d.$(ARCH))
|
|
|
TARGETS =
|
|
|
|
|
|
+# ---------- Recursive Targets ----------
|
|
|
+
|
|
|
+$(LOCALOBJECTS): | $(SUBDIRS)
|
|
|
+$(OBJECTS): | $(SUBDIRS)
|
|
|
+
|
|
|
+artifacts: $(LOCALOBJECTS)
|
|
|
+
|
|
|
+.DEFAULT_GOAL := artifacts
|
|
|
+
|
|
|
+# ---------- Includes ----------
|
|
|
+
|
|
|
+-include $(ROOTPATH)/Makefiles/Makefile.conf.$(ARCH)
|
|
|
+-include $(ROOTPATH)/Makefiles/Makefile.conf.base
|
|
|
+-include $(ROOTPATH)/Makefile.conf
|
|
|
+
|
|
|
+# ---------- Libraries ----------
|
|
|
+
|
|
|
define build_target_library_arch
|
|
|
$(eval $@_DATETIME := $(DATETIME))
|
|
|
@echo -n " [AR] $(1)\n"
|
|
|
@@ -54,6 +75,9 @@ define build_target_library_arch
|
|
|
@mv $(1) $$(echo $(ROOTPATH)/lib/$(ARCH)/lib$(1) | sed 's/\.$(ARCH)//g')
|
|
|
endef
|
|
|
|
|
|
+
|
|
|
+# ---------- Targets ----------
|
|
|
+
|
|
|
define build_target_arch
|
|
|
$(eval $@_DATETIME := $(DATETIME))
|
|
|
@echo -n " [LD] $(1)\n"
|
|
|
@@ -78,12 +102,7 @@ define build_target
|
|
|
fi
|
|
|
endef
|
|
|
|
|
|
-$(LOCALOBJECTS): | $(SUBDIRS)
|
|
|
-$(OBJECTS): | $(SUBDIRS)
|
|
|
|
|
|
-artifacts: $(LOCALOBJECTS)
|
|
|
-
|
|
|
-.DEFAULT_GOAL := artifacts
|
|
|
|
|
|
-include Makefile.target
|
|
|
|
|
|
@@ -91,6 +110,8 @@ ifneq ($(MAKECMDGOALS),clean)
|
|
|
-include $(LOCALDEPENDS)
|
|
|
endif
|
|
|
|
|
|
+# ---------- Object Rules ----------
|
|
|
+
|
|
|
%.d.$(ARCH): %.cpp
|
|
|
@if [ "$(ARCH)" != "any" ]; then \
|
|
|
depth=$(MAKELEVEL); \
|
|
|
@@ -145,6 +166,8 @@ $(ARNAME): $(SUBDIRS) $(LOCALOBJECTS)
|
|
|
@echo -n " [AR] $@\n"
|
|
|
@$(PREFIX) $(AR) rcuT $@ $(LOCALOBJECTS) $(SUBDIRARS) $(POSTFIX)
|
|
|
|
|
|
+# ---------- Recursive Rules ----------
|
|
|
+
|
|
|
.PHONY: $(SUBDIRS)
|
|
|
$(SUBDIRS):
|
|
|
@if [ -e "$@/Makefile" ]; then \
|
|
|
@@ -169,8 +192,7 @@ $(SUBDIRS):
|
|
|
echo " </$@>"; \
|
|
|
fi
|
|
|
|
|
|
-.PHONY: all
|
|
|
-all: $(TARGETS)
|
|
|
+# ---------- Clean Rules ----------
|
|
|
|
|
|
.PHONY: clean
|
|
|
clean:
|
|
|
@@ -237,6 +259,8 @@ cleandeps:
|
|
|
fi
|
|
|
@rm -f $(LOCALDEPENDS) || true
|
|
|
|
|
|
+# ---------- Architecture Rules ----------
|
|
|
+
|
|
|
.PHONY: $(ARCH)
|
|
|
$(ARCH):
|
|
|
@if [ "$(words $(MAKECMDGOALS))" = "0" ]; then \
|
|
|
@@ -250,3 +274,9 @@ $(ARCH):
|
|
|
$(MAKE) -s -S $(.DEFAULT_GOAL) $(ARCH); \
|
|
|
fi \
|
|
|
fi
|
|
|
+
|
|
|
+# ---------- All Rule ----------
|
|
|
+
|
|
|
+.PHONY: all
|
|
|
+all: $(TARGETS)
|
|
|
+
|