]> Dogcows Code - chaz/yoink/blobdiff - src/rules.mk
build system enhancements
[chaz/yoink] / src / rules.mk
index 8bffe04960838d5974c27f62ca4fba5915d34534..f6bd89b6c47fb2a953c2ea07da09254b7f48b689 100644 (file)
@@ -1,63 +1,45 @@
 
-#########################
-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.
 
-ifeq ($(PLATFORM),win32)
-OBJECTS_$(d) += $(d)/yoink.o
-endif
+objects                = $(patsubst %.c,$(builddir)/%.o,$(patsubst %.cc,$(builddir)/%.o,$(wildcard $d/*.c $d/*.cc)))
 
-PROGRAM_$(d) := $(call add_exe_suffix,$(d)/yoink)
+ifeq (win32,$(platform))
+objects                += $b/win32.o                   # Also compile win32 resource file.
+endif
 
-BINARIES     := $(BINARIES) $(PROGRAM_$(d))
-CLEAN        := $(CLEAN)    $(OBJECTS_$(d)) $(D_FILES_$(d)) $(PROGRAM_$(d))
+ifeq (true,$(includeConfig))
+objects                += $b/config.o                  # Also compile in the configuration.
+exec           += $b/config.c                  # Make config.c a build target.
+$b/config.c: config.mk
+       $(Q)$(xxd)
+endif
 
-$(OBJECTS_$(d)): CF_TGT := -I$(d)
-$(OBJECTS_$(d)): $(d)/rules.mk
+$(objects): TGT_CFLAGS := -I$d
+$(objects): config.h $(this) | $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.
 
-$(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
 
This page took 0.021542 seconds and 4 git commands to generate.