Improve Makefile.
This commit is contained in:
@@ -1,29 +1,39 @@
|
|||||||
SRC_DIR := src/
|
SRC_DIR := src/
|
||||||
ALL_FOLDERS := $(shell find $(SRC_DIR) -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0)
|
ALL_FOLDERS := $(sort $(shell find $(SRC_DIR) -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0))
|
||||||
ALL_MODULES := $(sort $(subst $(SRC_DIR),,$(ALL_FOLDERS)))
|
ALL_MODULES := $(sort $(subst $(SRC_DIR),,$(ALL_FOLDERS)))
|
||||||
ALL_TARGETS := ${shell bin/findtargets.py build/ $(ALL_FOLDERS)}
|
ALL_TARGETS := $(shell bin/findtargets.py build/ $(ALL_FOLDERS))
|
||||||
|
|
||||||
all: $(ALL_TARGETS)
|
all: $(ALL_TARGETS)
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
|
|
||||||
.PHONY: clean show_targets
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
-rm ./build/*.mkp
|
-rm ./build/*.mkp
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
|
|
||||||
|
.PHONY: show_targets
|
||||||
show_targets:
|
show_targets:
|
||||||
@echo $(ALL_FOLDERS)
|
@echo $(ALL_FOLDERS)
|
||||||
@echo $(ALL_TARGETS)
|
@echo $(ALL_TARGETS)
|
||||||
@echo $(ALL_MODULES)
|
@echo $(ALL_MODULES)
|
||||||
|
|
||||||
|
# https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile
|
||||||
|
.PHONY: list
|
||||||
|
list:
|
||||||
|
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
|
||||||
|
|
||||||
# setup
|
# setup
|
||||||
|
|
||||||
define make-goal
|
define make-targets
|
||||||
${shell bin/findtargets.py build/ $(SRC_DIR)$1}: $(SRC_DIR)$1
|
$(eval OUTPUT_FILE := $(shell bin/findtargets.py build/ $(SRC_DIR)$(1)))
|
||||||
|
|
||||||
|
$(OUTPUT_FILE): $(SRC_DIR)$(1)
|
||||||
@echo "Building $$@"
|
@echo "Building $$@"
|
||||||
bin/makemkp.py $$< ./build/
|
@bin/makemkp.py $$< ./build/
|
||||||
|
|
||||||
|
$(1): $(OUTPUT_FILE)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach mod,$(ALL_MODULES),$(eval $(call make-goal,$(mod))))
|
$(foreach mod,$(ALL_MODULES),$(eval $(call make-targets,$(mod))))
|
||||||
|
|||||||
Reference in New Issue
Block a user