ubuntu doesn't like echo's -e flag in the makefile
[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 `yes' to echo each build command in full.
14 verbose := no
15
16
17 #
18 # Include the configuration file, config.mk.
19 #
20
21 SHELL := /bin/sh
22
23 have_config := $(wildcard config.mk)
24 ifneq ($(strip $(have_config)),)
25 include config.mk
26 else
27 $(error You must run the configure script before you can make anything)
28 endif
29
30
31 #
32 # Declare the default targets and implicit rules.
33 #
34
35 .PHONY: all
36 all: all_
37
38 .SUFFIXES:
39 .SUFFIXES: .a .c .cc .cpp .in .o .rc
40
41
42 #
43 # Define some useful functions.
44 #
45
46 add_exe_suffix = $(addsuffix $(EXEEXT),$1)
47 remove_silencer = $(1:@%=%)
48
49
50 #
51 # Include the subdirectories--order is not important.
52 #
53
54 dir := src
55 include $(dir)/rules.mk
56
57 dir := data
58 include $(dir)/rules.mk
59
60 dir := doc
61 include $(dir)/rules.mk
62
63
64 #
65 # Define some common rules.
66 #
67
68 ifeq ($(DEP_TRACKING),true)
69 COMPILE = ./tools/compile.lua
70 endif
71
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
81 COMMAND_RM = rm -f $1
82 COMMAND_IN = sed -f config.sed <"$1" >"$2"
83
84 ifeq ($(verbose),yes)
85 DO_CC = $(COMMAND_CC)
86 DO_CXX = $(COMMAND_CXX)
87 DO_LD = $(COMMAND_LD)
88 DO_LDX = $(COMMAND_LDX)
89 DO_CCLD = $(COMMAND_CCLD)
90 DO_CXXLD = $(COMMAND_CXXLD)
91 DO_AR = $(COMMAND_AR)
92 DO_RC = $(COMMAND_RC)
93 DO_INSTALL = $(COMMAND_INSTALL)
94 DO_RM = $(COMMAND_RM)
95 DO_IN = $(COMMAND_IN)
96 SHELL_LINE_PREFIX =
97 else
98 DO_CC = @echo " CC $@"; $(COMMAND_CC)
99 DO_CXX = @echo " CXX $@"; $(COMMAND_CXX)
100 DO_LD = @echo " LD $@"; $(COMMAND_LD)
101 DO_LDX = @echo " LD $@"; $(COMMAND_LDX)
102 DO_CCLD = @echo " CCLD $@"; $(COMMAND_CCLD)
103 DO_CXXLD = @echo " CXXLD $@"; $(COMMAND_CXXLD)
104 DO_AR = @echo " AR $@"; $(COMMAND_AR)
105 DO_RC = @echo " RC $@"; $(COMMAND_RC)
106 DO_INSTALL = @echo " CP $2"; $(COMMAND_INSTALL)
107 DO_RM = @echo " RM $1"; $(COMMAND_RM)
108 DO_IN = @echo " MAKE $2"; $(COMMAND_IN)
109 SHELL_LINE_PREFIX = @
110 endif
111
112
113 #
114 # Define the implicit rules.
115 #
116
117 %.o: %.c
118 $(DO_CC)
119 %.o: %.cc
120 $(DO_CXX)
121 %.o: %.cpp
122 $(DO_CXX)
123 %.o: %.rc
124 $(DO_RC)
125 %: %.o
126 $(DO_LD)
127 %: %.c
128 $(DO_CCLD)
129 %: %.cc
130 $(DO_CXXLD)
131 %: %.cpp
132 $(DO_CXXLD)
133 %.a: %.o
134 $(DO_AR)
135 %: %.in
136 $(call DO_IN,$<,$@)
137
138
139 #
140 # Define the phony targets.
141 #
142
143 .PHONY: clean
144 clean:
145 $(SHELL_LINE_PREFIX)files='$(CLEAN)'; for file in $$files; \
146 do \
147 $(call remove_silencer,$(call DO_RM,$$file)); \
148 done
149
150 .PHONY: distclean
151 distclean: clean
152 $(call DO_RM,config.h)
153 $(call DO_RM,config.mk)
154 $(call DO_RM,config.sed)
155
156 .PHONY: all_
157 all_: $(BINARIES) $(MANPAGES)
158
159 .PHONY: install
160 install: all
161 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
162 do \
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)); \
166 done
167 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
168 do \
169 $(call remove_silencer,$(call DO_INSTALL,755,$$file,$(DESTDIR)$(bindir))); \
170 done
171 $(SHELL_LINE_PREFIX)files='$(MANPAGES)'; for file in $$files; \
172 do \
173 $(call remove_silencer,$(call DO_INSTALL,644,$$file,$(DESTDIR)$(mandir))); \
174 done
175
176 .PHONY: uninstall
177 uninstall:
178 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
179 do \
180 base="/`basename $$file`"; \
181 $(call remove_silencer,$(call DO_RM,$(DESTDIR)$(bindir)$$base)); \
182 done
183 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
184 do \
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)); \
188 done
189
190 .PHONY: dist-bzip2
191 dist-bzip2:
192 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | bzip2 > "$(TARNAME).tar.bz2"
193
194 .PHONY: dist-gzip
195 dist-gzip:
196 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | gzip > "$(TARNAME).tar.gz"
197
198 .PHONY: dist
199 dist: dist-bzip2
200
201
202 #
203 # Prevent make from removing any build targets.
204 #
205
206 .SECONDARY: $(CLEAN)
207
This page took 0.036746 seconds and 4 git commands to generate.