]> Dogcows Code - chaz/yoink/blob - Makefile
mesh and other random adjustments
[chaz/yoink] / Makefile
1
2 #
3 # Yoink
4 # Use this file with make to compile and install Yoink.
5 #
6 # This makefile supports these targets:
7 # all, install, clean, distclean, run, debug, dist, dist-gzip, dist-bzip2
8 #
9 # This build system incorporates the ideas written by Emile van Bergen:
10 # http://www.xs4all.nl/~evbergen/nonrecursive-make.html
11 #
12
13 # Set this to `true' to echo each build command in full.
14 verbose := false
15
16 # Set this to `false' to avoid installing manual pages.
17 install_man := true
18
19
20 #
21 # Include the configuration file, config.mk.
22 #
23
24 SHELL := /bin/sh
25
26 have_config := $(wildcard config.mk)
27 ifneq ($(strip $(have_config)),)
28 include config.mk
29 else
30 $(error You must run the configure script before you can make anything)
31 endif
32
33
34 #
35 # Declare the default targets and implicit rules.
36 #
37
38 .PHONY: all
39 all: all_
40
41 .SUFFIXES:
42 .SUFFIXES: .a .c .cc .cpp .in .o .rc
43
44
45 #
46 # Define some useful functions.
47 #
48
49 add_exe_suffix = $(addsuffix $(EXEEXT),$1)
50 remove_silencer = $(1:@%=%)
51
52
53 #
54 # Include the subdirectories--order is not important.
55 #
56
57 dir := src
58 include $(dir)/rules.mk
59
60 dir := data
61 include $(dir)/rules.mk
62
63 dir := doc
64 include $(dir)/rules.mk
65
66
67 #
68 # Define some common rules.
69 #
70
71 ifeq ($(DEP_TRACKING),true)
72 COMPILE = ./tools/compile.lua
73 endif
74
75 ifeq ($(DEP_MINIMIZING),true)
76 LINK = ./tools/link.lua
77 endif
78
79 INSTALL = ./tools/install.lua
80
81 # Include current directory to allow sources to #include "config.h".
82 CFLAGS += -I.
83 CXXFLAGS += -I.
84
85 COMMAND_CC = $(COMPILE) $(CC) $(CFLAGS) $(CF_TGT) -o $@ -c $<
86 COMMAND_CXX = $(COMPILE) $(CXX) $(CXXFLAGS) $(CF_TGT) -o $@ -c $<
87 COMMAND_LD = $(LINK) $(CC) $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
88 COMMAND_LDX = $(LINK) $(CXX) $(LDFLAGS) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LIBS)
89 COMMAND_CCLD = $(COMPILE) $(CC) $(CFLAGS) $(CF_TGT) $(LDFLAGS) $(LF_TGT) -o $@ $< $(LL_TGT) $(LIBS)
90 COMMAND_CXXLD = $(COMPILE) $(CXX) $(CXXFLAGS) $(CF_TGT) $(LDFLAGS) $(LF_TGT) -o $@ $< $(LL_TGT) $(LIBS)
91 COMMAND_AR = $(AR) rcs $@ $^; $(RANLIB) $@
92 COMMAND_RC = $(WINDRES) -I. $(DF_TGT) -o $@ -i $<
93 COMMAND_INSTALL = $(INSTALL) -m $1 $2 $3/
94 COMMAND_RM = rm -f $1
95 COMMAND_IN = sed -f config.sed <"$1" >"$2"
96
97 ifeq ($(verbose),true)
98 DO_CC = $(COMMAND_CC)
99 DO_CXX = $(COMMAND_CXX)
100 DO_LD = $(COMMAND_LD)
101 DO_LDX = $(COMMAND_LDX)
102 DO_CCLD = $(COMMAND_CCLD)
103 DO_CXXLD = $(COMMAND_CXXLD)
104 DO_AR = $(COMMAND_AR)
105 DO_RC = $(COMMAND_RC)
106 DO_INSTALL = $(COMMAND_INSTALL)
107 DO_RM = $(COMMAND_RM)
108 DO_IN = $(COMMAND_IN)
109 SHELL_LINE_PREFIX =
110 else
111 DO_CC = @echo " CC $@"; $(COMMAND_CC)
112 DO_CXX = @echo " CXX $@"; $(COMMAND_CXX)
113 DO_LD = @echo " LINK $@"; $(COMMAND_LD)
114 DO_LDX = @echo " LINK $@"; $(COMMAND_LDX)
115 DO_CCLD = @echo " LINK $@"; $(COMMAND_CCLD)
116 DO_CXXLD = @echo " LINK $@"; $(COMMAND_CXXLD)
117 DO_AR = @echo " AR $@"; $(COMMAND_AR)
118 DO_RC = @echo " RC $@"; $(COMMAND_RC)
119 DO_INSTALL = @echo " CP $2"; $(COMMAND_INSTALL)
120 DO_RM = @echo " RM $1"; $(COMMAND_RM)
121 DO_IN = @echo " GEN $2"; $(COMMAND_IN)
122 SHELL_LINE_PREFIX = @
123 endif
124
125
126 #
127 # Define the implicit rules.
128 #
129
130 %.o: %.c
131 $(DO_CC)
132 %.o: %.cc
133 $(DO_CXX)
134 %.o: %.cpp
135 $(DO_CXX)
136 %.o: %.rc
137 $(DO_RC)
138 %$(EXEEXT): %.o
139 $(DO_LD)
140 %$(EXEEXT): %.c
141 $(DO_CCLD)
142 %$(EXEEXT): %.cc
143 $(DO_CXXLD)
144 %$(EXEEXT): %.cpp
145 $(DO_CXXLD)
146 %.a: %.o
147 $(DO_AR)
148 %: %.in config.sed
149 $(call DO_IN,$<,$@)
150
151
152 #
153 # Define the phony targets.
154 #
155
156 .PHONY: clean
157 clean:
158 $(SHELL_LINE_PREFIX)files='$(CLEAN)'; for file in $$files; \
159 do \
160 $(call remove_silencer,$(call DO_RM,$$file)); \
161 done
162
163 .PHONY: distclean
164 distclean: clean
165 $(call DO_RM,config.h)
166 $(call DO_RM,config.mk)
167 $(call DO_RM,config.sed)
168
169 .PHONY: all_
170 all_: $(BINARIES) $(MANPAGES)
171
172 .PHONY: install
173 install: all
174 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
175 do \
176 full=`echo "$$file" | cut -d\; -f1`; \
177 base=`echo "$$file" | cut -d\; -f2`; \
178 $(call remove_silencer,$(call DO_INSTALL,644,$$full,$(DESTDIR)$(datadir)$$base)); \
179 done
180 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
181 do \
182 $(call remove_silencer,$(call DO_INSTALL,755,$$file,$(DESTDIR)$(bindir))); \
183 done
184 ifeq ($(install_man),true)
185 $(SHELL_LINE_PREFIX)files='$(MANPAGES)'; for file in $$files; \
186 do \
187 $(call remove_silencer,$(call DO_INSTALL,644,$$file,$(DESTDIR)$(mandir))); \
188 done
189 endif
190
191 .PHONY: uninstall
192 uninstall:
193 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
194 do \
195 base="/`basename $$file`"; \
196 $(call remove_silencer,$(call DO_RM,$(DESTDIR)$(bindir)$$base)); \
197 done
198 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
199 do \
200 full="`echo "$$file" | cut -d\; -f1`"; \
201 base="`echo "$$file" | cut -d\; -f2`/`basename $$full`"; \
202 $(call remove_silencer,$(call DO_RM,$(DESTDIR)$(datadir)$$base)); \
203 done
204
205 .PHONY: dist-bzip2
206 dist-bzip2:
207 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | bzip2 > "$(TARNAME).tar.bz2"
208
209 .PHONY: dist-gzip
210 dist-gzip:
211 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | gzip > "$(TARNAME).tar.gz"
212
213 .PHONY: dist
214 dist: dist-bzip2
215
216
217 #
218 # Prevent make from removing any build targets.
219 #
220
221 .SECONDARY: $(CLEAN)
222
This page took 0.047472 seconds and 4 git commands to generate.