]> Dogcows Code - chaz/yoink/blobdiff - src/rules.mk
pch support
[chaz/yoink] / src / rules.mk
index e452ae44fc45ab92db3e7d0f15011c0de7c5f6d4..cbf2776361555ee78e6d48162d83b12f3956dc6d 100644 (file)
@@ -1,75 +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.
 #
 
-OBJS_$(d) := \
-             $(d)/Animation.o \
-             $(d)/Character.o \
-             $(d)/GameLayer.o \
-             $(d)/Heroine.o \
-             $(d)/Hud.o \
-             $(d)/Main.o \
-             $(d)/Scene.o \
-             $(d)/TilemapFont.o \
-             $(d)/TitleLayer.o \
-             $(d)/Typesetter.o \
-             $(d)/version.o \
-                        $(_END_)
+$(call include,moof stlplus)   # Recurse into subdirectories.
 
-ifeq ($(HOST),win32)
-OBJS_$(d) += $(d)/yoink.o
-endif
+objects        = $(patsubst %.c,$(builddir)/%.o,$(patsubst %.cc,$(builddir)/%.o,$(wildcard $d/*.c $d/*.cc)))
 
-TGTS_$(d) := $(d)/yoink$(EXEEXT)
-DEPS_$(d) := $(OBJS_$(d):%=%.d)
+ifeq (win32,$(platform))
+objects        += $b/win32.o           # Also compile win32 resource file.
+endif
 
-TGT_BIN   := $(TGT_BIN) $(TGTS_$(d))
-CLEAN     := $(CLEAN) $(OBJS_$(d)) $(DEPS_$(d)) $(TGTS_$(d))
+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
 
+$(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.
 
-$(OBJS_$(d)): CF_TGT := -I$(d)
-$(OBJS_$(d)): $(d)/rules.mk
+ifeq (true,$(pch))
+$(objects): $b/moof/precompile.hh.gch
+endif
 
-$(TGTS_$(d)): $(OBJS_$(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: $(TGTS_$(d))
-       @$(YOINK_ENVIRONMENT) $< $(YOINK_OPTS)
-
-.PHONY: debug
-debug: $(TGTS_$(d))
-       @$(YOINK_ENVIRONMENT) gdb $<
+run: $(bindir_$b)
+       $(Q)$< $(YOINKFLAGS)
 
+debug: $(bindir_$b)
+       $(Q)gdb $<
 
-#######################
--include $(DEPS_$(d))
-d  := $(dirstack_$(sp))
-sp := $(basename $(sp))
-#######################
+.PHONY: run debug
 
This page took 0.018195 seconds and 4 git commands to generate.