vgbc/Makefile

46 lines
854 B
Makefile
Raw Permalink Normal View History

2023-09-05 21:30:58 +02:00
.DEFAULT_GOAL := all
2023-09-05 12:51:24 +02:00
2023-08-26 19:04:02 +02:00
include Makeconf
2023-09-01 09:18:32 +02:00
# Auto tracking of headers
2023-09-09 19:20:41 +02:00
CXXFLAGS += -MMD
2023-09-05 12:51:24 +02:00
all-modules := $(foreach t,$(TARGETS),$(modules_$(t)))
depfiles := $(patsubst %.o,%.d,$(filter %.o,$(all-modules)))
-include $(depfiles)
clean-objs := $(TARGETS) $(all-modules) $(depfiles)
2023-09-09 19:20:41 +02:00
cmd = $(VERBOSE)g++ $(CXXFLAGS) $(LDFLAGS_$@) -o $@ $^
2023-09-01 09:18:32 +02:00
msg = $(or $(verb_$@),finalize) $@
2023-08-29 23:22:20 +02:00
2023-09-01 09:18:32 +02:00
ifneq ($V,1)
VERBOSE := @
endif
.PHONY: all test clean
2023-09-01 09:18:32 +02:00
all: $(or $(DEFAULT_TARGETS),$(TARGETS))
-include $(depfiles)
clean:
rm -rf $(clean-objs)
2023-08-28 22:31:24 +02:00
test: vgbc.test
2023-09-01 09:18:32 +02:00
@echo " ... run test $<"
$(VERBOSE)./$< $(if $(V),-s)
2023-09-01 09:18:32 +02:00
%.o: %.cpp
@echo " ... build $@"
2023-09-09 19:20:41 +02:00
$(VERBOSE)g++ $(CXXFLAGS) -c -o $@ $<
2023-09-01 09:18:32 +02:00
define target_rule
$(1): $$(modules_$(1))
@echo " ..." $$(or $$(msg_$(1)),$$(msg))
$$(VERBOSE)$$(or $$(cmd_$(1)),$$(cmd))
endef
2023-09-01 09:18:32 +02:00
$(foreach t,$(TARGETS),$(eval $(call target_rule,$(t))))