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 `yes' to echo each build command in full.
18 # Include the configuration file, config.mk.
23 have_config := $(wildcard config.mk)
24 ifneq ($(strip $(have_config)),)
27 $(error You must run the configure script before you can make anything)
32 # Declare the default targets and implicit rules.
39 .SUFFIXES: .a .c .cc .cpp .in .o .rc
43 # Define some useful functions.
46 add_exe_suffix = $(addsuffix $(EXEEXT),$1)
47 remove_silencer = $(1:@%=%)
51 # Include the subdirectories--order is not important.
55 include $(dir)/rules.mk
58 include $(dir)/rules.mk
61 include $(dir)/rules.mk
65 # Define some common rules.
68 ifeq ($(DEP_TRACKING),true)
69 COMPILE = ./tools/compile.lua
72 COMMAND_CC = $(COMPILE) $(CC) $(CFLAGS) $(CF_TGT) -o $@ -c $<
73 COMMAND_CXX = $(COMPILE) $(CXX) $(CXXFLAGS) $(CF_TGT) -o $@ -c $<
74 COMMAND_LD = $(CC) $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
75 COMMAND_LDX = $(CXX) $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
76 COMMAND_CCLD = $(COMPILE) $(CC) $(CFLAGS) $(CF_TGT) $(LDFLAGS) $(LF_TGT) -o $@ $< $(LL_TGT) $(LIBS)
77 COMMAND_CXXLD = $(COMPILE) $(CXX) $(CXXFLAGS) $(CF_TGT) $(LDFLAGS) $(LF_TGT) -o $@ $< $(LL_TGT) $(LIBS)
78 COMMAND_AR = $(AR) rcs $@ $^; $(RANLIB) $@
79 COMMAND_RC = $(WINDRES) $(DDEFINES) $(DF_TGT) -o $@ -i $<
80 COMMAND_INSTALL = ./tools/install.sh -m $1 $2 -d $3
82 COMMAND_IN = sed -f config.sed <"$1" >"$2"
86 DO_CXX = $(COMMAND_CXX)
88 DO_LDX = $(COMMAND_LDX)
89 DO_CCLD = $(COMMAND_CCLD)
90 DO_CXXLD = $(COMMAND_CXXLD)
93 DO_INSTALL = $(COMMAND_INSTALL)
98 DO_CC = @echo -e " CC \t$@"; $(COMMAND_CC)
99 DO_CXX = @echo -e " CXX \t$@"; $(COMMAND_CXX)
100 DO_LD = @echo -e " LD \t$@"; $(COMMAND_LD)
101 DO_LDX = @echo -e " LD \t$@"; $(COMMAND_LDX)
102 DO_CCLD = @echo -e " CCLD \t$@"; $(COMMAND_CCLD)
103 DO_CXXLD = @echo -e " CXXLD \t$@"; $(COMMAND_CXXLD)
104 DO_AR = @echo -e " AR \t$@"; $(COMMAND_AR)
105 DO_RC = @echo -e " RC \t$@"; $(COMMAND_RC)
106 DO_INSTALL = @echo -e " CP \t$2"; $(COMMAND_INSTALL)
107 DO_RM = @echo -e " RM \t$1"; $(COMMAND_RM)
108 DO_IN = @echo -e " MAKE \t$2"; $(COMMAND_IN)
109 SHELL_LINE_PREFIX = @
114 # Define the implicit rules.
140 # Define the phony targets.
145 $(SHELL_LINE_PREFIX)files='$(CLEAN)'; for file in $$files; \
147 $(call remove_silencer,$(call DO_RM,$$file)); \
152 $(call DO_RM,config.h)
153 $(call DO_RM,config.mk)
154 $(call DO_RM,config.sed)
157 all_: $(BINARIES) $(MANPAGES)
161 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
163 full=`echo "$$file" | cut -d\; -f1`; \
164 base=`echo "$$file" | cut -d\; -f2`; \
165 $(call remove_silencer,$(call DO_INSTALL,644,$$full,$(DESTDIR)$(datadir)$$base)); \
167 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
169 $(call remove_silencer,$(call DO_INSTALL,755,$$file,$(DESTDIR)$(bindir))); \
171 $(SHELL_LINE_PREFIX)files='$(MANPAGES)'; for file in $$files; \
173 $(call remove_silencer,$(call DO_INSTALL,644,$$file,$(DESTDIR)$(mandir))); \
178 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
180 base="/`basename $$file`"; \
181 $(call remove_silencer,$(call DO_RM,$(DESTDIR)$(bindir)$$base)); \
183 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
185 full="`echo "$$file" | cut -d\; -f1`"; \
186 base="`echo "$$file" | cut -d\; -f2`/`basename $$full`"; \
187 $(call remove_silencer,$(call DO_RM,$(DESTDIR)$(datadir)$$base)); \
192 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | bzip2 > "$(TARNAME).tar.bz2"
196 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | gzip > "$(TARNAME).tar.gz"
203 # Prevent make from removing any build targets.