4 # Use this file with make to compile and install Yoink.
6 # This makefile supports these targets:
7 # all, install, clean, distclean, run, debug, dist, dist-gzip, dist-bzip2
9 # This build system incorporates the ideas written by Emile van Bergen:
10 # http://www.xs4all.nl/~evbergen/nonrecursive-make.html
13 # Set this to `true' to echo each build command in full.
16 # Set this to `false' to avoid installing manual pages.
21 # Include the configuration file, config.mk.
26 have_config := $(wildcard config.mk)
27 ifneq ($(strip $(have_config)),)
30 $(error You must run the configure script before you can make anything)
35 # Declare the default targets and implicit rules.
42 .SUFFIXES: .a .c .cc .cpp .in .o .rc
46 # Define some useful functions.
49 add_exe_suffix = $(addsuffix $(EXEEXT),$1)
50 remove_silencer = $(1:@%=%)
54 # Include the subdirectories--order is not important.
58 include $(dir)/rules.mk
61 include $(dir)/rules.mk
64 include $(dir)/rules.mk
68 # Define some common rules.
71 ifeq ($(DEP_TRACKING),true)
72 COMPILE = ./tools/compile.lua
75 # Include current directory to allow sources to #include "config.h".
79 COMMAND_CC = $(COMPILE) $(CC) $(CFLAGS) $(CF_TGT) -o $@ -c $<
80 COMMAND_CXX = $(COMPILE) $(CXX) $(CXXFLAGS) $(CF_TGT) -o $@ -c $<
81 COMMAND_LD = $(CC) $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
82 COMMAND_LDX = $(CXX) $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
83 COMMAND_CCLD = $(COMPILE) $(CC) $(CFLAGS) $(CF_TGT) $(LDFLAGS) $(LF_TGT) -o $@ $< $(LL_TGT) $(LIBS)
84 COMMAND_CXXLD = $(COMPILE) $(CXX) $(CXXFLAGS) $(CF_TGT) $(LDFLAGS) $(LF_TGT) -o $@ $< $(LL_TGT) $(LIBS)
85 COMMAND_AR = $(AR) rcs $@ $^; $(RANLIB) $@
86 COMMAND_RC = $(WINDRES) -I. $(DF_TGT) -o $@ -i $<
87 COMMAND_INSTALL = ./tools/install.sh -m $1 $2 -d $3
89 COMMAND_IN = sed -f config.sed <"$1" >"$2"
91 ifeq ($(verbose),true)
93 DO_CXX = $(COMMAND_CXX)
95 DO_LDX = $(COMMAND_LDX)
96 DO_CCLD = $(COMMAND_CCLD)
97 DO_CXXLD = $(COMMAND_CXXLD)
100 DO_INSTALL = $(COMMAND_INSTALL)
101 DO_RM = $(COMMAND_RM)
102 DO_IN = $(COMMAND_IN)
105 DO_CC = @echo " CC $@"; $(COMMAND_CC)
106 DO_CXX = @echo " CXX $@"; $(COMMAND_CXX)
107 DO_LD = @echo " LINK $@"; $(COMMAND_LD)
108 DO_LDX = @echo " LINK $@"; $(COMMAND_LDX)
109 DO_CCLD = @echo " LINK $@"; $(COMMAND_CCLD)
110 DO_CXXLD = @echo " LINK $@"; $(COMMAND_CXXLD)
111 DO_AR = @echo " AR $@"; $(COMMAND_AR)
112 DO_RC = @echo " RC $@"; $(COMMAND_RC)
113 DO_INSTALL = @echo " CP $2"; $(COMMAND_INSTALL)
114 DO_RM = @echo " RM $1"; $(COMMAND_RM)
115 DO_IN = @echo " GEN $2"; $(COMMAND_IN)
116 SHELL_LINE_PREFIX = @
121 # Define the implicit rules.
147 # Define the phony targets.
152 $(SHELL_LINE_PREFIX)files='$(CLEAN)'; for file in $$files; \
154 $(call remove_silencer,$(call DO_RM,$$file)); \
159 $(call DO_RM,config.h)
160 $(call DO_RM,config.mk)
161 $(call DO_RM,config.sed)
164 all_: $(BINARIES) $(MANPAGES)
168 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
170 full=`echo "$$file" | cut -d\; -f1`; \
171 base=`echo "$$file" | cut -d\; -f2`; \
172 $(call remove_silencer,$(call DO_INSTALL,644,$$full,$(DESTDIR)$(datadir)$$base)); \
174 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
176 $(call remove_silencer,$(call DO_INSTALL,755,$$file,$(DESTDIR)$(bindir))); \
178 ifeq ($(install_man),true)
179 $(SHELL_LINE_PREFIX)files='$(MANPAGES)'; for file in $$files; \
181 $(call remove_silencer,$(call DO_INSTALL,644,$$file,$(DESTDIR)$(mandir))); \
187 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
189 base="/`basename $$file`"; \
190 $(call remove_silencer,$(call DO_RM,$(DESTDIR)$(bindir)$$base)); \
192 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
194 full="`echo "$$file" | cut -d\; -f1`"; \
195 base="`echo "$$file" | cut -d\; -f2`/`basename $$full`"; \
196 $(call remove_silencer,$(call DO_RM,$(DESTDIR)$(datadir)$$base)); \
201 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | bzip2 > "$(TARNAME).tar.bz2"
205 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | gzip > "$(TARNAME).tar.gz"
212 # Prevent make from removing any build targets.