]> Dogcows Code - chaz/yoink/blob - Makefile
optionally install man pages
[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 # Include current directory to allow sources to #include "config.h".
76 CFLAGS += -I.
77 CXXFLAGS += -I.
78
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
88 COMMAND_RM = rm -f $1
89 COMMAND_IN = sed -f config.sed <"$1" >"$2"
90
91 ifeq ($(verbose),true)
92 DO_CC = $(COMMAND_CC)
93 DO_CXX = $(COMMAND_CXX)
94 DO_LD = $(COMMAND_LD)
95 DO_LDX = $(COMMAND_LDX)
96 DO_CCLD = $(COMMAND_CCLD)
97 DO_CXXLD = $(COMMAND_CXXLD)
98 DO_AR = $(COMMAND_AR)
99 DO_RC = $(COMMAND_RC)
100 DO_INSTALL = $(COMMAND_INSTALL)
101 DO_RM = $(COMMAND_RM)
102 DO_IN = $(COMMAND_IN)
103 SHELL_LINE_PREFIX =
104 else
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 = @
117 endif
118
119
120 #
121 # Define the implicit rules.
122 #
123
124 %.o: %.c
125 $(DO_CC)
126 %.o: %.cc
127 $(DO_CXX)
128 %.o: %.cpp
129 $(DO_CXX)
130 %.o: %.rc
131 $(DO_RC)
132 %$(EXEEXT): %.o
133 $(DO_LD)
134 %$(EXEEXT): %.c
135 $(DO_CCLD)
136 %$(EXEEXT): %.cc
137 $(DO_CXXLD)
138 %$(EXEEXT): %.cpp
139 $(DO_CXXLD)
140 %.a: %.o
141 $(DO_AR)
142 %: %.in config.sed
143 $(call DO_IN,$<,$@)
144
145
146 #
147 # Define the phony targets.
148 #
149
150 .PHONY: clean
151 clean:
152 $(SHELL_LINE_PREFIX)files='$(CLEAN)'; for file in $$files; \
153 do \
154 $(call remove_silencer,$(call DO_RM,$$file)); \
155 done
156
157 .PHONY: distclean
158 distclean: clean
159 $(call DO_RM,config.h)
160 $(call DO_RM,config.mk)
161 $(call DO_RM,config.sed)
162
163 .PHONY: all_
164 all_: $(BINARIES) $(MANPAGES)
165
166 .PHONY: install
167 install: all
168 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
169 do \
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)); \
173 done
174 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
175 do \
176 $(call remove_silencer,$(call DO_INSTALL,755,$$file,$(DESTDIR)$(bindir))); \
177 done
178 ifeq ($(install_man),true)
179 $(SHELL_LINE_PREFIX)files='$(MANPAGES)'; for file in $$files; \
180 do \
181 $(call remove_silencer,$(call DO_INSTALL,644,$$file,$(DESTDIR)$(mandir))); \
182 done
183 endif
184
185 .PHONY: uninstall
186 uninstall:
187 $(SHELL_LINE_PREFIX)files='$(BINARIES)'; for file in $$files; \
188 do \
189 base="/`basename $$file`"; \
190 $(call remove_silencer,$(call DO_RM,$(DESTDIR)$(bindir)$$base)); \
191 done
192 $(SHELL_LINE_PREFIX)files='$(DATAFILES)'; for file in $$files; \
193 do \
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)); \
197 done
198
199 .PHONY: dist-bzip2
200 dist-bzip2:
201 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | bzip2 > "$(TARNAME).tar.bz2"
202
203 .PHONY: dist-gzip
204 dist-gzip:
205 $(SHELL_LINE_PREFIX)git archive HEAD --prefix='$(TARNAME)/' | gzip > "$(TARNAME).tar.gz"
206
207 .PHONY: dist
208 dist: dist-bzip2
209
210
211 #
212 # Prevent make from removing any build targets.
213 #
214
215 .SECONDARY: $(CLEAN)
216
This page took 0.039728 seconds and 4 git commands to generate.