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 `='.
45 # Delete target on error. Every Makefile should have this.
50 dirs := $(sort $(dir $(src)))
51 csrc := $(filter %.c, $(src))
52 tsrc := $(filter %.t, $(src))
53 man1 := $(filter man/%.1, $(src))
54 man6 := $(filter man/%.6, $(src))
56 # Info topics and subjects
60 topics := $(patsubst %.t,%,$(notdir $(tsrc)))
61 info := $(topics) $(subjects) all TOP
62 subjects.html := $(addprefix info.html/, $(addsuffix .html, $(subjects)))
63 topics.html := $(addprefix info.html/, $(addsuffix .html, $(topics)))
64 scripts = $(srcdir)/src/scripts
65 depcomp = $(SHELL) $(srcdir)/depcomp
66 tarball = $(SHELL) $(scripts)/tarball
67 econfig := $(sysconfdir)/empire/econfig
68 edatadir := $(localstatedir)/empire
69 einfodir := $(datadir)/empire/info.nr
70 ehtmldir := $(datadir)/empire/info.html
72 # How to substitute Autoconf output variables
73 # Recursively expanded so that $@ and $< work.
75 -e 's?@configure_input\@?$(notdir $@). Generated from $(notdir $<) by GNUmakefile.?g' \
76 -e 's?@econfig\@?$(econfig)?g' \
77 -e 's?@edatadir\@?$(edatadir)?g' \
78 -e 's?@einfodir\@?$(einfodir)?g' \
79 -e 's/@EMPIREHOST\@/$(EMPIREHOST)/g' \
80 -e 's/@EMPIREPORT\@/$(EMPIREPORT)/g'
83 # See `Cleanliness' below
84 mk := sources.mk subjects.mk
85 ac := $(srcdir)/autom4te.cache config.h config.log config.status \
86 stamp-h $(basename $(filter %.in, $(src)))
87 acdist := aclocal.m4 config.h.in configure stamp-h.in
88 obj := $(csrc:.c=.o) $(filter %.o, $(ac:.c=.o))
89 # TODO AIX needs lwpInit.o lwpRestore.o lwpSave.o unless UCONTEXT
91 libs := $(addprefix lib/, libcommon.a libgen.a libglobal.a)
92 util := $(addprefix src/util/, $(addsuffix $(EXEEXT), fairland files pconfig))
93 client := src/client/empire$(EXEEXT)
94 server := src/server/emp_server$(EXEEXT)
95 tsubj := $(addprefix info/, $(addsuffix .t, $(subjects)))
97 info.nr := $(addprefix info.nr/, $(info))
98 info.html := $(addprefix info.html/, $(addsuffix .html, $(info)))
100 ifeq ($(empthread),LWP)
101 empth_obj := src/lib/empthread/lwp.o
102 empth_lib := lib/liblwp.a
104 ifeq ($(empthread),POSIX)
105 empth_obj := src/lib/empthread/pthread.o
108 ifeq ($(empthread),Windows)
109 empth_obj := src/lib/empthread/ntthread.o
114 # Each generated file should be in one of the following sets.
116 clean := $(obj) $(deps) $(libs) $(util) $(client) $(server) $(tsubj) \
117 $(ttop) $(info.nr) $(info.html) $(empth_obj) $(empth_lib)
118 # Removed by distclean:
120 # Distributed by dist from $(srcdir)
121 src_distgen := $(acdist)
122 # Distributed by dist from .
126 CPPFLAGS += -I$(srcdir)/include -I.
127 ifeq ($(have_gcc),yes)
128 CFLAGS += -fno-builtin-carg # conflicts with our carg()
129 CFLAGS += -fno-common
130 CFLAGS += -Wall -W -Wno-unused -Wpointer-arith -Wstrict-prototypes \
131 -Wmissing-prototypes -Wnested-externs -Wredundant-decls
138 all: $(util) $(client) $(server) info
153 install: all installdirs
154 $(INSTALL_PROGRAM) $(util) $(server) $(sbindir)
155 $(INSTALL_PROGRAM) $(client) $(bindir)
156 $(INSTALL_DATA) $(info.nr) $(einfodir)
157 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man1)) $(mandir)/man1
158 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man6)) $(mandir)/man6
159 if test -e $(econfig); then \
160 if src/util/pconfig $(econfig) >$(econfig).new; then \
161 if cmp -s $(econfig) $(econfig).new; then \
164 echo "Check out $(econfig).new"; \
167 echo "Your $(econfig) doesn't work"; \
170 src/util/pconfig >$(econfig); \
175 mkdir -p $(bindir) $(sbindir) $(edatadir) $(einfodir) $(mandir)/man1 $(mandir)/man6 $(dir $(econfig))
178 install-html: html | $(ehtmldir)
179 $(INSTALL_DATA) $(info.html) $(ehtmldir)
186 dist: dist-source dist-client dist-info
191 # Compile with dependencies as side effect, i.e. create %.d in
193 ifeq ($(how_to_dep),fast)
195 $(COMPILE.c) -MT $@ -MMD -MP $(OUTPUT_OPTION) $<
197 ifeq ($(how_to_dep),depcomp)
199 source='$<' object='$@' depfile='$(@:.o=.d)' $(CCDEPMODE) $(depcomp) \
200 $(COMPILE.c) $(OUTPUT_OPTION) $<
202 # Cancel the rule to compile %.c straight to %, it interferes with
203 # automatic dependency generation
206 # Work around MinGW Make's broken built-in link rule:
208 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
212 $(NROFF) -I $(srcdir)/info $(filter %/CRT.MAC, $^) $< | $(AWK) -f $(filter %/Blank.awk, $^) >$@
213 # FIXME AT&T nroff doesn't grok -I
215 info.html/%.html: info/%.t
216 perl $(filter %.pl, $^) $< >$@
221 $(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)
222 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
224 $(client): $(filter src/client/%, $(obj)) $(termlibs)
225 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
229 lib/libcommon.a: $(filter src/lib/common/%, $(obj))
230 lib/libgen.a: $(filter src/lib/gen/%, $(obj))
231 lib/libglobal.a: $(filter src/lib/global/%, $(obj))
232 lib/liblwp.a: $(filter src/lib/lwp/%, $(obj))
234 $(libs) $(empth_lib): | lib
238 subjects.mk: $(tsrc) info/findsubj.pl sources.mk
239 perl $(srcdir)/info/findsubj.pl
240 # If sources.mk is out of date, $(tsrc) is. If it contains files that
241 # went away, make can't remake subjects.mk. Tell it to ignore such
245 $(tsubj): info/mksubj.pl
246 perl $(srcdir)/info/mksubj.pl $@ $(filter %.t, $^)
249 perl $(srcdir)/info/mktop.pl $@ $(filter %.t, $^)
251 info.nr/all: $(filter-out info.nr/all, $(info.nr))
252 (cd info.nr && ls -CF) >$@
253 # FIXME should use $^ and not ls
255 info.html/all.html: $(filter-out info.html/all.html, $(info.html)) info/ls2html.pl
256 (cd info.html && ls -CF *.html) | expand | perl $(filter %.pl, $^) >$@
257 # FIXME should use $^ and not ls
259 $(info.nr): info/CRT.MAC info/INFO.MAC info/Blank.awk | info.nr
261 $(subjects.html) info.html/TOP.html: info/subj2html.pl | info.html
262 $(topics.html): info/emp2html.pl | info.html
264 info.nr info.html lib:
267 ifeq ($(cvs_controlled),yes)
268 # Find files and directories under CVS control
269 sources.mk: $(scripts)/cvsfiles.awk $(addprefix $(srcdir)/, $(addsuffix CVS/Entries, $(dirs)))
270 echo 'src := ' `cd $(srcdir) && $(AWK) -f src/scripts/cvsfiles.awk` >$@
274 dist-source: check-version
275 $(tarball) $(TARNAME)-$(VERSION) $(bld_distgen) -C $(srcdir) $(src_distgen) $(src)
279 $(tarball) $(TARNAME)-client-$(VERSION) -C $(srcdir) $(filter src/client/%, $(src))
283 $(tarball) $(TARNAME)-info-text-$(VERSION) -C info.nr $(info)
284 $(tarball) $(TARNAME)-info-html-$(VERSION) -C info.html $(addsuffix .html, $(info))
287 if [ $(VERSION) != `sed -n '/EMP_VERS_/s/#define EMP_VERS_\([A-Z]*\)[ \t]*//p' <include/version.h | tr '\012' . | sed 's/\.$$//'` ]; \
288 then echo version.h does not match configure.ac >&2; false; \
295 # Automatic remake of configuration
296 # See (autoconf)Automatic Remaking.
297 # This requires sufficiently recent versions of autoconf and automake
299 $(srcdir)/configure: configure.ac aclocal.m4
300 cd $(srcdir) && autoconf
302 # autoheader might not change config.h.in, so touch a stamp file.
303 $(srcdir)/config.h.in: stamp-h.in
304 $(srcdir)/stamp-h.in: configure.ac aclocal.m4
305 cd $(srcdir) && autoheader
308 $(srcdir)/aclocal.m4: $(filter m4/%.m4, $(src))
309 cd $(srcdir) && aclocal -I m4
311 # config.status might not change config.h; use the stamp file.
313 stamp-h: config.h.in config.status
314 ./config.status config.h stamp-h
316 GNUmakefile: GNUmakefile.in config.status
319 config.status: configure
320 ./config.status --recheck
322 src/lib/global/path.c src/client/ipglob.c: %: %.in GNUmakefile