2 # Empire - A multi-player, client/server Internet based war game.
3 # Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 # Ken Stevens, Steve McClure
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.
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.
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
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.
30 # Known contributors to this file:
31 # Markus Armbruster, 2005
34 # This makefile was inspired by `Recursive Make Considered Harmful',
36 # http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html
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 `='.
42 # Delete target on error. Every Makefile should have this.
47 dirs := $(sort $(dir $(src)))
48 csrc := $(filter %.c, $(src))
49 tsrc := $(filter %.t, $(src))
50 man1 := $(filter man/%.1, $(src))
51 man6 := $(filter man/%.6, $(src))
53 # Info topics and subjects
55 topics := $(patsubst %.t,%,$(notdir $(tsrc)))
56 info := $(topics) $(subjects) all TOP
59 mk := sources.mk subjects.mk
60 ac := autom4te.cache config.h config.status config.log stamp-h \
61 $(basename $(filter %.in, $(src)))
62 obj := $(csrc:.c=.o) $(filter %.o, $(ac:.c=.o))
63 # TODO AIX needs lwpInit.o lwpRestore.o lwpSave.o unless UCONTEXT
65 libs := $(addprefix lib/, libcommon.a libgen.a libglobal.a)
66 util := $(addprefix src/util/, fairland files pconfig)
67 client := src/client/empire
68 server := src/server/emp_server
69 progs := $(util) $(client) $(server)
70 tsubj := $(addprefix info/, $(addsuffix .t, $(subjects)))
72 info.nr := $(addprefix info.nr/, $(info))
73 subjects.html := $(addprefix info.html/, $(addsuffix .html, $(subjects)))
74 topics.html := $(addprefix info.html/, $(addsuffix .html, $(topics)))
75 info.html := $(addprefix info.html/, $(addsuffix .html, $(info)))
77 ifeq ($(empthread),LWP)
78 empth_obj := src/lib/empthread/lwp.o
79 empth_lib := lib/liblwp.a
81 ifeq ($(empthread),POSIX)
82 empth_obj := src/lib/empthread/pthread.o
85 ifeq ($(empthread),Windows)
86 empth_obj := src/lib/empthread/ntthread.o
91 scripts = $(srcdir)/src/scripts
92 depcomp = $(SHELL) $(srcdir)/depcomp
93 clean := $(obj) $(deps) $(libs) $(progs) $(empth_lib) $(tsubj) \
94 $(info.nr) $(info.html)
95 distclean := $(ac) info/stamp $(ttop)
96 econfig := $(sysconfdir)/empire/econfig
97 edatadir := $(localstatedir)/empire
98 einfodir := $(datadir)/empire/info.nr
99 ehtmldir := $(datadir)/empire/info.html
100 # Recursively expanded so that $@ and $< work.
102 -e 's?@configure_input\@?$(notdir $@). Generated from $(notdir $<) by GNUmakefile.?g' \
103 -e 's?@econfig\@?$(econfig)?g' \
104 -e 's?@edatadir\@?$(edatadir)?g' \
105 -e 's?@einfodir\@?$(einfodir)?g' \
106 -e 's/@EMPIREHOST\@/$(EMPIREHOST)/g' \
107 -e 's/@EMPIREPORT\@/$(EMPIREPORT)/g'
110 CPPFLAGS += -I$(srcdir)/include -I.
111 ifeq ($(have_gcc),yes)
112 CFLAGS += -fno-common
113 CFLAGS += -Wall -W -Wno-unused -Wpointer-arith -Wstrict-prototypes \
114 -Wmissing-prototypes -Wnested-externs -Wredundant-decls
136 install: all installdirs
137 $(INSTALL_PROGRAM) $(util) $(server) $(sbindir)
138 $(INSTALL_PROGRAM) $(client) $(bindir)
139 $(INSTALL_DATA) $(info.nr) $(einfodir)
140 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man1)) $(mandir)/man1
141 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man6)) $(mandir)/man6
142 if test -e $(econfig); then \
143 if src/util/pconfig $(econfig) >$(econfig).new; then \
144 if cmp -s $(econfig) $(econfig).new; then \
147 echo "Check out $(econfig).new"; \
150 echo "Your $(econfig) doesn't work"; \
153 src/util/pconfig >$(econfig); \
158 mkdir -p $(bindir) $(sbindir) $(edatadir) $(einfodir) $(mandir)/man1 $(mandir)/man6 $(dir $(econfig))
161 install-html: html | $(ehtmldir)
162 $(INSTALL_DATA) $(info.html) $(ehtmldir)
175 # Compile with dependencies as side effect, i.e. create %.d in
177 ifeq ($(how_to_dep),fast)
179 $(COMPILE.c) -MT $@ -MMD -MP $(OUTPUT_OPTION) $<
181 ifeq ($(how_to_dep),depcomp)
183 source='$<' object='$@' depfile='$(@:.o=.d)' $(CCDEPMODE) $(depcomp) \
184 $(COMPILE.c) $(OUTPUT_OPTION) $<
186 # Cancel the rule to compile %.c straight to %, it interferes with
187 # automatic dependency generation
191 $(NROFF) -I $(srcdir)/info $(filter %/CRT.MAC, $^) $< | $(AWK) -f $(filter %/Blank.awk, $^) >$@
192 # FIXME AT&T nroff doesn't grok -I
194 info.html/%.html: info/%.t
195 perl $(filter %.pl, $^) $< >$@
200 $(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)
201 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
203 $(client): $(filter src/client/%, $(obj)) $(termlibs)
204 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
208 lib/libcommon.a: $(filter src/lib/common/%, $(obj))
209 lib/libgen.a: $(filter src/lib/gen/%, $(obj))
210 lib/libglobal.a: $(filter src/lib/global/%, $(obj))
211 lib/liblwp.a: $(filter src/lib/lwp/%, $(obj))
213 $(libs) $(empth_lib): | lib
217 # info.pl reads $(tsrc) and writes subjects.mk $(ttop) $(tsubj). The
219 # subjects.mk $(ttop) $(tsubj): $(tsrc)
221 # runs COMMAND once for each target. That's because multiple targets
222 # in an explicit rule is just a shorthand for one rule per target,
223 # each with the same prerequisites and commands. A pattern rule with
224 # multiple targets does what we want. So we artificially turn the
225 # explicit rule into a pattern rule: we replace info with %, and
226 # insert a touch target info/stamp.
227 # FIXME if sources.mk is out-of-date, $(tsubj) is, and the bogus deps can prevent remaking of subjects.mk and thus sources.mk
228 $(patsubst info/%, \%/%, $(ttop) $(tsubj)): %/stamp
229 perl $(srcdir)/info/info.pl
230 info/stamp: $(tsrc) info/info.pl sources.mk
235 info.nr/all: $(filter-out info.nr/all, $(info.nr))
236 (cd info.nr && ls -CF) >$@
237 # FIXME should use $^ and not ls
239 info.html/all.html: $(filter-out info.html/all.html, $(info.html)) info/ls2html.pl
240 (cd info.html && ls -CF *.html) | expand | perl $(filter %.pl, $^) >$@
241 # FIXME should use $^ and not ls
243 $(info.nr): info/CRT.MAC info/INFO.MAC info/Blank.awk | info.nr
245 $(subjects.html): info/subj2html.pl | info.html
246 $(topics.html): info/emp2html.pl | info.html
248 info.nr info.html lib:
251 ifeq ($(cvs_controlled),yes)
252 # Find files and directories under CVS control
253 sources.mk: $(scripts)/cvsfiles.awk $(addprefix $(srcdir)/, $(addsuffix CVS/Entries, $(dirs)))
254 echo 'src := ' `cd $(srcdir) && $(AWK) -f src/scripts/cvsfiles.awk` >$@
261 # Automatic remake of configuration
262 # See (autoconf)Automatic Remaking.
263 # This requires sufficiently recent versions of autoconf and automake
265 $(srcdir)/configure: configure.ac aclocal.m4
266 cd $(srcdir) && autoconf
268 # autoheader might not change config.h.in, so touch a stamp file.
269 $(srcdir)/config.h.in: stamp-h.in
270 $(srcdir)/stamp-h.in: configure.ac aclocal.m4
271 cd $(srcdir) && autoheader
274 $(srcdir)/aclocal.m4: $(filter m4/%.m4, $(src))
275 cd $(srcdir) && aclocal -I m4
277 # config.status might not change config.h; use the stamp file.
279 stamp-h: config.h.in config.status
280 ./config.status config.h stamp-h
282 GNUmakefile: GNUmakefile.in config.status
285 config.status: configure
286 ./config.status --recheck
288 src/lib/global/path.c src/client/ipglob.c: %: %.in GNUmakefile