X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Frules.mk;h=cbf2776361555ee78e6d48162d83b12f3956dc6d;hp=8bffe04960838d5974c27f62ca4fba5915d34534;hb=44b3014bce798789e795242d1556cb7449e6386a;hpb=51069fee9139ab8d14ecc80dffbe5deecb73d9e0 diff --git a/src/rules.mk b/src/rules.mk index 8bffe04..cbf2776 100644 --- a/src/rules.mk +++ b/src/rules.mk @@ -1,63 +1,51 @@ -######################### -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -######################### - -# -# Include the subdirectories--order is not important. -# - -dir := $(d)/moof -include $(dir)/rules.mk - -dir := $(d)/stlplus -include $(dir)/rules.mk - - # # Define rules and targets for Yoink. # -OBJECTS_$(d) := $(patsubst %.c,%.o,$(wildcard $(d)/*.c)) \ - $(patsubst %.cc,%.o,$(wildcard $(d)/*.cc)) -D_FILES_$(d) := $(OBJECTS_$(d):%=%.d) +$(call include,moof stlplus) # Recurse into subdirectories. + +objects = $(patsubst %.c,$(builddir)/%.o,$(patsubst %.cc,$(builddir)/%.o,$(wildcard $d/*.c $d/*.cc))) -ifeq ($(PLATFORM),win32) -OBJECTS_$(d) += $(d)/yoink.o +ifeq (win32,$(platform)) +objects += $b/win32.o # Also compile win32 resource file. endif -PROGRAM_$(d) := $(call add_exe_suffix,$(d)/yoink) +ifeq (true,$(includeConfig)) +objects += $b/config.o # Also compile in the configuration. +exec += $b/config.gz +exec += $b/config.c # Make config.c a build target. +$b/config.gz: config.mk + $(Q)$(gzip) +$b/config.c: $b/config.gz + $(Q)$(xxd) +endif -BINARIES := $(BINARIES) $(PROGRAM_$(d)) -CLEAN := $(CLEAN) $(OBJECTS_$(d)) $(D_FILES_$(d)) $(PROGRAM_$(d)) +$(objects): TGT_CFLAGS := -I$b -I$d +$(objects): config.h | $b +# Make all objects depend on config.h; it's excessive, but config.h won't be +# remade otherwise if dependencies are not being generated. The alternative +# is to maintain an accurate list of objects with a dependency on config.h. -$(OBJECTS_$(d)): CF_TGT := -I$(d) -$(OBJECTS_$(d)): $(d)/rules.mk +ifeq (true,$(pch)) +$(objects): $b/moof/precompile.hh.gch +endif -$(PROGRAM_$(d)): $(OBJECTS_$(d)) $(d)/moof/libmoof.a $(d)/stlplus/libstlplus.a - $(DO_LDX) +exec += $(objects) # Make the objects build targets. +bindir_$b := $b/$(projectName)$(EXEEXT) # Install executable to bindir. +$(bindir_$b): $(objects) $b/moof/libmoof.a $b/stlplus/libstlplus.a + $(Q)$(link_cc) # # Define the run and debug targets. # -YOINK_ENVIRONMENT = YOINK_DATADIR="./data" - -.PHONY: run -run: $(PROGRAM_$(d)) - @$(YOINK_ENVIRONMENT) $< $(YOINK_OPTS) - -.PHONY: debug -debug: $(PROGRAM_$(d)) - @$(YOINK_ENVIRONMENT) gdb $< +run: $(bindir_$b) + $(Q)$< $(YOINKFLAGS) +debug: $(bindir_$b) + $(Q)gdb $< -######################## --include $(D_FILES_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) -######################## +.PHONY: run debug