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
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),POSIX)
78 empth_obj := src/lib/empthread/pthread.o
81 empth_obj := src/lib/empthread/lwp.o
82 empth_lib := lib/liblwp.a
86 scripts = $(srcdir)/src/scripts
87 depcomp = $(SHELL) $(srcdir)/depcomp
88 clean := $(obj) $(deps) $(libs) $(progs) $(empth_lib) $(tsubj) \
89 $(info.nr) $(info.html)
90 distclean := $(ac) info/stamp $(ttop)
91 econfig := $(sysconfdir)/empire/econfig
92 edatadir := $(localstatedir)/empire
93 einfodir := $(datadir)/empire/info.nr
94 ehtmldir := $(datadir)/empire/info.html
95 # Recursively expanded so that $@ and $< work.
97 -e 's?@configure_input\@?$(notdir $@). Generated from $(notdir $<) by GNUmakefile.?g' \
98 -e 's?@econfig\@?$(econfig)?g' \
99 -e 's?@edatadir\@?$(edatadir)?g' \
100 -e 's?@einfodir\@?$(einfodir)?g' \
101 -e 's/@EMPIREHOST\@/$(EMPIREHOST)/g' \
102 -e 's/@EMPIREPORT\@/$(EMPIREPORT)/g'
105 CPPFLAGS += -I$(srcdir)/include -I.
106 ifeq ($(have_gcc),yes)
107 CFLAGS += -fno-common
108 CFLAGS += -Wall -W -Wno-unused -Wpointer-arith -Wstrict-prototypes \
109 -Wmissing-prototypes -Wnested-externs -Wredundant-decls
131 install: all installdirs
132 $(INSTALL_PROGRAM) $(util) $(server) $(sbindir)
133 $(INSTALL_PROGRAM) $(client) $(bindir)
134 $(INSTALL_DATA) $(info.nr) $(einfodir)
135 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man1)) $(mandir)/man1
136 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man6)) $(mandir)/man6
137 if test -e $(econfig); then \
138 if src/util/pconfig $(econfig) >$(econfig).new; then \
139 if cmp -s $(econfig) $(econfig).new; then \
142 echo "Check out $(econfig).new"; \
145 echo "Your $(econfig) doesn't work"; \
148 src/util/pconfig >$(econfig); \
153 mkdir -p $(bindir) $(sbindir) $(edatadir) $(einfodir) $(mandir)/man1 $(mandir)/man6 $(dir $(econfig))
156 install-html: html | $(ehtmldir)
157 $(INSTALL_DATA) $(info.html) $(ehtmldir)
170 # Compile with dependencies as side effect, i.e. create %.d in
172 ifeq ($(how_to_dep),fast)
174 $(COMPILE.c) -MT $@ -MMD -MP $(OUTPUT_OPTION) $<
176 ifeq ($(how_to_dep),depcomp)
178 source='$<' object='$@' depfile='$(@:.o=.d)' $(CCDEPMODE) $(depcomp) \
179 $(COMPILE.c) $(OUTPUT_OPTION) $<
181 # Cancel the rule to compile %.c straight to %, it interferes with
182 # automatic dependency generation
186 $(NROFF) -I $(srcdir)/info $(filter %/CRT.MAC, $^) $< | $(AWK) -f $(filter %/Blank.awk, $^) >$@
187 # FIXME AT&T nroff doesn't grok -I
189 info.html/%.html: info/%.t
190 perl $(filter %.pl, $^) $< >$@
195 $(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)
196 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
198 $(client): $(filter src/client/%, $(obj)) $(termlibs)
199 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
203 lib/libcommon.a: $(filter src/lib/common/%, $(obj))
204 lib/libgen.a: $(filter src/lib/gen/%, $(obj))
205 lib/libglobal.a: $(filter src/lib/global/%, $(obj))
206 lib/liblwp.a: $(filter src/lib/lwp/%, $(obj))
208 $(libs) $(empth_lib): | lib
212 # info.pl reads $(tsrc) and writes subjects.mk $(ttop) $(tsubj). The
214 # subjects.mk $(ttop) $(tsubj): $(tsrc)
216 # runs COMMAND once for each target. That's because multiple targets
217 # in an explicit rule is just a shorthand for one rule per target,
218 # each with the same prerequisites and commands. A pattern rule with
219 # multiple targets does what we want. So we artificially turn the
220 # explicit rule into a pattern rule: we replace info with %, and
221 # insert a touch target info/stamp.
222 # FIXME if sources.mk is out-of-date, $(tsubj) is, and the bogus deps can prevent remaking of subjects.mk and thus sources.mk
223 $(patsubst info/%, \%/%, $(ttop) $(tsubj)): %/stamp
224 perl $(srcdir)/info/info.pl
225 info/stamp: $(tsrc) info/info.pl sources.mk
230 info.nr/all: $(filter-out info.nr/all, $(info.nr))
231 (cd info.nr && ls -CF) >$@
232 # FIXME should use $^ and not ls
234 info.html/all.html: $(filter-out info.html/all.html, $(info.html)) info/ls2html.pl
235 (cd info.html && ls -CF *.html) | expand | perl $(filter %.pl, $^) >$@
236 # FIXME should use $^ and not ls
238 $(info.nr): info/CRT.MAC info/INFO.MAC info/Blank.awk | info.nr
240 $(subjects.html): info/subj2html.pl | info.html
241 $(topics.html): info/emp2html.pl | info.html
243 info.nr info.html lib:
246 ifeq ($(cvs_controlled),yes)
247 # Find files and directories under CVS control
248 sources.mk: $(scripts)/cvsfiles.awk $(addprefix $(srcdir)/, $(addsuffix CVS/Entries, $(dirs)))
249 echo 'src := ' `cd $(srcdir) && $(AWK) -f src/scripts/cvsfiles.awk` >$@
256 # Automatic remake of configuration
257 # See (autoconf)Automatic Remaking.
258 # This requires sufficiently recent versions of autoconf and automake
260 $(srcdir)/configure: configure.ac aclocal.m4
261 cd $(srcdir) && autoconf
263 # autoheader might not change config.h.in, so touch a stamp file.
264 $(srcdir)/config.h.in: stamp-h.in
265 $(srcdir)/stamp-h.in: configure.ac aclocal.m4
266 cd $(srcdir) && autoheader
269 $(srcdir)/aclocal.m4: $(filter m4/%.m4, $(src))
270 cd $(srcdir) && aclocal -I m4
272 # config.status might not change config.h; use the stamp file.
274 stamp-h: config.h.in config.status
275 ./config.status config.h stamp-h
277 GNUmakefile: GNUmakefile.in config.status
280 config.status: configure
281 ./config.status --recheck
283 src/lib/global/path.c src/client/ipglob.c: %: %.in GNUmakefile