# http://www.xs4all.nl/~evbergen/nonrecursive-make.html
#
-# Set this to `yes' to echo each build command in full.
-verbose := no
+# Set this to `true' to echo each build command in full.
+verbose := false
#
COMPILE = ./tools/compile.lua
endif
+# Include current directory to allow sources to #include "config.h".
+CFLAGS += -I.
+CXXFLAGS += -I.
+
COMMAND_CC = $(COMPILE) $(CC) $(CFLAGS) $(CF_TGT) -o $@ -c $<
COMMAND_CXX = $(COMPILE) $(CXX) $(CXXFLAGS) $(CF_TGT) -o $@ -c $<
COMMAND_LD = $(CC) $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
COMMAND_RM = rm -f $1
COMMAND_IN = sed -f config.sed <"$1" >"$2"
-ifeq ($(verbose),yes)
+ifeq ($(verbose),true)
DO_CC = $(COMMAND_CC)
DO_CXX = $(COMMAND_CXX)
DO_LD = $(COMMAND_LD)
$(DO_CXX)
%.o: %.rc
$(DO_RC)
-%: %.o
+%$(EXEEXT): %.o
$(DO_LD)
-%: %.c
+%$(EXEEXT): %.c
$(DO_CCLD)
-%: %.cc
+%$(EXEEXT): %.cc
$(DO_CXXLD)
-%: %.cpp
+%$(EXEEXT): %.cpp
$(DO_CXXLD)
%.a: %.o
$(DO_AR)
-%: %.in
+%: %.in config.sed
$(call DO_IN,$<,$@)