]> git.pond.sub.org Git - empserver/blob - Make.mk
(info): TOP was missing.
[empserver] / Make.mk
1
2 #   Empire - A multi-player, client/server Internet based war game.
3 #   Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 #                            Ken Stevens, Steve McClure
5
6 #   This program is free software; you can redistribute it and/or modify
7 #   it under the terms of the GNU General Public License as published by
8 #   the Free Software Foundation; either version 2 of the License, or
9 #   (at your option) any later version.
10
11 #   This program is distributed in the hope that it will be useful,
12 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #   GNU General Public License for more details.
15
16 #   You should have received a copy of the GNU General Public License
17 #   along with this program; if not, write to the Free Software
18 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20 #   ---
21
22 #   See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 #   related information and legal notices. It is expected that any future
24 #   projects/authors will amend these files as needed.
25
26 #   ---
27
28 #   Make.mk: 
29 #  
30 #   Known contributors to this file:
31 #      Markus Armbruster, 2005
32
33
34 # This makefile was inspired by `Recursive Make Considered Harmful',
35 # Peter Miller, 1997.
36 # http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html
37
38 # Recursively expanded variables are occasionally useful, but can be
39 # slow and tricky.  Do not use them gratuitously.  If you don't
40 # understand this, always use `:=' rather than `='.
41
42 # Delete target on error.  Every Makefile should have this.
43 .DELETE_ON_ERROR:
44
45 # Source files
46 -include sources.mk
47 dirs := $(sort $(dir $(src)))
48 csrc := $(filter %.c, $(src))
49 tsrc := $(filter %.t, $(src))
50
51 # Info topics and subjects
52 -include subjects.mk
53 topics := $(patsubst %.t,%,$(notdir $(tsrc)))
54 info := $(topics) $(subjects) all TOP
55
56 # Generated files
57 mk := sources.mk subjects.mk
58 ac := autom4te.cache config.h config.status config.log stamp-h  \
59 $(basename $(filter %.in, $(src)))
60 obj := $(csrc:.c=.o) $(filter %.o, $(ac:.c=.o))
61 # TODO AIX needs lwpInit.o lwpRestore.o lwpSave.o unless UCONTEXT
62 deps := $(obj:.o=.d)
63 libs := $(addprefix lib/, libcommon.a libgen.a libglobal.a)
64 util := $(addprefix src/util/, fairland files pconfig)
65 progs := $(util) src/client/empire src/server/emp_server
66 tsubj := $(addprefix info/, $(addsuffix .t, $(subjects)))
67 ttop := info/TOP.t
68 info.nr := $(addprefix info.nr/, $(info))
69 subjects.html := $(addprefix info.html/, $(addsuffix .html, $(subjects)))
70 topics.html := $(addprefix info.html/, $(addsuffix .html, $(topics)))
71 info.html := $(addprefix info.html/, $(addsuffix .html, $(info)))
72
73 ifeq ($(empthread),POSIX)
74 empth_obj := src/lib/empthread/pthread.o
75 empth_lib :=
76 else
77 empth_obj := src/lib/empthread/lwp.o
78 empth_lib := lib/liblwp.a
79 endif
80
81 # Abbreviations
82 scripts = $(srcdir)/src/scripts
83 depcomp = $(SHELL) $(top_srcdir)/depcomp
84 clean := $(obj) $(deps) $(libs) $(progs) $(empth_lib) $(tsubj)  \
85 $(info.nr) $(info.html)
86 distclean := $(ac) info/stamp $(ttop)
87
88 # Compiler flags
89 CPPFLAGS += -I$(srcdir)/include -Iinclude
90 ifeq ($(have_gcc),yes)
91 CFLAGS += -fno-common
92 CFLAGS += -Wall -W -Wno-unused -Wpointer-arith -Wstrict-prototypes      \
93 -Wmissing-prototypes -Wnested-externs -Wredundant-decls
94 endif
95 LDLIBS += -lm
96
97 ### Advertized goals
98
99 .PHONY: all
100 all: $(progs) info
101
102 .PHONY: info html
103 info: $(info.nr)
104 html: $(info.html)
105
106 .PHONY: clean
107 clean:
108         rm -f $(clean)
109
110 .PHONY: distclean
111 distclean: clean
112         rm -rf $(distclean)
113
114 .PHONY: install install-html
115 install: all
116         false # FIXME
117 install-html: html
118         false # FIXME
119
120 .PHONY: uninstall
121 uninstall:
122         false # FIXME
123
124 .PHONY: dist
125 dist:
126         false # FIXME
127
128
129 ### Implicit rules
130
131 # Compile with dependencies as side effect, i.e. create %.d in
132 # addition to %.o.
133 ifeq ($(how_to_dep),fast)
134 %.o: %.c
135         $(COMPILE.c) -MT $@ -MMD -MP $(OUTPUT_OPTION) $<
136 endif
137 ifeq ($(how_to_dep),depcomp)
138 %.o: %.c
139         source='$<' object='$@' depfile='$(@:.o=.d)' $(CCDEPMODE) $(depcomp) \
140         $(COMPILE.c) $(OUTPUT_OPTION) $<
141 endif
142 # Cancel the rule to compile %.c straight to %, it interferes with
143 # automatic dependency generation
144 %: %.c
145
146 info.nr/%: info/%.t
147         $(NROFF) -I $(srcdir)/info $(filter %/CRT.MAC, $^) $< | $(AWK) -f $(filter %/Blank.awk, $^) >$@
148 # FIXME AT&T nroff doesn't grok -I
149
150 info.html/%.html: info/%.t
151         perl $(filter %.pl, $^) $< >$@
152
153
154 ### Explicit rules
155
156 src/server/emp_server: $(filter src/server/% src/lib/as/% src/lib/commands/% src/lib/player/% src/lib/subs/% src/lib/update/%, $(obj)) $(empth_obj) $(libs) $(empth_lib)
157         $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
158
159 src/client/empire: $(filter src/client/%, $(obj)) $(termlibs)
160         $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
161
162 $(util): $(libs)
163
164 lib/libcommon.a: $(filter src/lib/common/%, $(obj))
165 lib/libgen.a: $(filter src/lib/gen/%, $(obj))
166 lib/libglobal.a: $(filter src/lib/global/%, $(obj))
167 lib/liblwp.a: $(filter src/lib/lwp/%, $(obj))
168
169 $(libs) $(empth_lib): | lib
170         $(AR) rc $@ $?
171         $(RANLIB) $@
172
173 # info.pl reads $(tsrc) and writes subjects.mk $(ttop) $(tsubj).  The
174 # naive rule
175 #     subjects.mk $(ttop) $(tsubj): $(tsrc)
176 #           COMMAND
177 # runs COMMAND once for each target.  That's because multiple targets
178 # in an explicit rule is just a shorthand for one rule per target,
179 # each with the same prerequisites and commands.  A pattern rule with
180 # multiple targets does what we want.  So we artificially turn the
181 # explicit rule into a pattern rule: we replace info with %, and
182 # insert a touch target info/stamp.
183 $(patsubst info/%, \%/%, $(ttop) $(tsubj)): %/stamp
184         perl $(srcdir)/info/info.pl
185 info/stamp: $(tsrc) info/info.pl sources.mk
186         >$@
187 subjects.mk: $(ttop)
188         :
189
190 info.nr/all: $(filter-out info.nr/all, $(info.nr))
191         (cd info.nr && ls -CF) >$@
192 # FIXME should use $^ and not ls
193
194 info.html/all.html: $(filter-out info.html/all.html, $(info.html)) info/ls2html.pl
195         (cd info.html && ls -CF *.html) | expand | perl $(filter %.pl, $^) >$@
196 # FIXME should use $^ and not ls
197
198 $(info.nr): info/CRT.MAC info/INFO.MAC info/Blank.awk | info.nr
199
200 $(subjects.html): info/subj2html.pl | info.html
201 $(topics.html): info/emp2html.pl | info.html
202
203 info.nr info.html lib:
204         mkdir -p $@
205
206 ifeq ($(cvs_controlled),yes)
207 # Find files and directories under CVS control
208 sources.mk: $(scripts)/cvsfiles.awk $(addprefix $(srcdir)/, $(addsuffix CVS/Entries, $(dirs)))
209         echo 'src := ' `cd $(srcdir) && $(AWK) -f src/scripts/cvsfiles.awk` >$@
210 endif
211
212 ifneq ($(deps),)
213 -include $(deps)
214 endif
215
216 # Automatic remake of configuration
217 # See (autoconf)Automatic Remaking.
218 # This requires sufficiently recent versions of autoconf and automake
219
220 $(srcdir)/configure: configure.ac aclocal.m4
221         cd $(srcdir) && autoconf
222
223 # autoheader might not change config.h.in, so touch a stamp file.
224 $(srcdir)/config.h.in: stamp-h.in
225 $(srcdir)/stamp-h.in: configure.ac aclocal.m4
226         cd $(srcdir) && autoheader
227         >$@
228
229 $(srcdir)/aclocal.m4: $(filter m4/%.m4, $(src))
230         cd $(srcdir) && aclocal -I m4
231
232 # config.status might not change config.h; use the stamp file.
233 config.h: stamp-h
234 stamp-h: config.h.in config.status
235         ./config.status config.h stamp-h
236
237 GNUmakefile: GNUmakefile.in config.status
238         ./config.status $@
239
240 config.status: configure
241         ./config.status --recheck
242
243 src/lib/global/path.c src/client/ipglob.c: %: %.in GNUmakefile
244         $(subst.in) <$< >$@