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-common
129 CFLAGS += -Wall -W -Wno-unused -Wpointer-arith -Wstrict-prototypes \
130 -Wmissing-prototypes -Wnested-externs -Wredundant-decls
137 all: $(util) $(client) $(server) info
152 install: all installdirs
153 $(INSTALL_PROGRAM) $(util) $(server) $(sbindir)
154 $(INSTALL_PROGRAM) $(client) $(bindir)
155 $(INSTALL_DATA) $(info.nr) $(einfodir)
156 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man1)) $(mandir)/man1
157 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man6)) $(mandir)/man6
158 if test -e $(econfig); then \
159 if src/util/pconfig $(econfig) >$(econfig).new; then \
160 if cmp -s $(econfig) $(econfig).new; then \
163 echo "Check out $(econfig).new"; \
166 echo "Your $(econfig) doesn't work"; \
169 src/util/pconfig >$(econfig); \
174 mkdir -p $(bindir) $(sbindir) $(edatadir) $(einfodir) $(mandir)/man1 $(mandir)/man6 $(dir $(econfig))
177 install-html: html | $(ehtmldir)
178 $(INSTALL_DATA) $(info.html) $(ehtmldir)
185 dist: dist-source dist-client dist-info
190 # Compile with dependencies as side effect, i.e. create %.d in
192 ifeq ($(how_to_dep),fast)
194 $(COMPILE.c) -MT $@ -MMD -MP $(OUTPUT_OPTION) $<
196 ifeq ($(how_to_dep),depcomp)
198 source='$<' object='$@' depfile='$(@:.o=.d)' $(CCDEPMODE) $(depcomp) \
199 $(COMPILE.c) $(OUTPUT_OPTION) $<
201 # Cancel the rule to compile %.c straight to %, it interferes with
202 # automatic dependency generation
205 # Work around MinGW Make's broken built-in link rule:
207 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
211 $(NROFF) -I $(srcdir)/info $(filter %/CRT.MAC, $^) $< | $(AWK) -f $(filter %/Blank.awk, $^) >$@
212 # FIXME AT&T nroff doesn't grok -I
214 info.html/%.html: info/%.t
215 perl $(filter %.pl, $^) $< >$@
220 $(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)
221 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
223 $(client): $(filter src/client/%, $(obj)) $(termlibs)
224 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
228 lib/libcommon.a: $(filter src/lib/common/%, $(obj))
229 lib/libgen.a: $(filter src/lib/gen/%, $(obj))
230 lib/libglobal.a: $(filter src/lib/global/%, $(obj))
231 lib/liblwp.a: $(filter src/lib/lwp/%, $(obj))
233 $(libs) $(empth_lib): | lib
237 subjects.mk: $(tsrc) info/findsubj.pl sources.mk
238 perl $(srcdir)/info/findsubj.pl
239 # If sources.mk is out of date, $(tsrc) is. If it contains files that
240 # went away, make can't remake subjects.mk. Tell it to ignore such
244 $(tsubj): info/mksubj.pl
245 perl $(srcdir)/info/mksubj.pl $@ $(filter %.t, $^)
248 perl $(srcdir)/info/mktop.pl $@ $(filter %.t, $^)
250 info.nr/all: $(filter-out info.nr/all, $(info.nr))
251 (cd info.nr && ls -CF) >$@
252 # FIXME should use $^ and not ls
254 info.html/all.html: $(filter-out info.html/all.html, $(info.html)) info/ls2html.pl
255 (cd info.html && ls -CF *.html) | expand | perl $(filter %.pl, $^) >$@
256 # FIXME should use $^ and not ls
258 $(info.nr): info/CRT.MAC info/INFO.MAC info/Blank.awk | info.nr
260 $(subjects.html) info.html/TOP.html: info/subj2html.pl | info.html
261 $(topics.html): info/emp2html.pl | info.html
263 info.nr info.html lib:
266 ifeq ($(cvs_controlled),yes)
267 # Find files and directories under CVS control
268 sources.mk: $(scripts)/cvsfiles.awk $(addprefix $(srcdir)/, $(addsuffix CVS/Entries, $(dirs)))
269 echo 'src := ' `cd $(srcdir) && $(AWK) -f src/scripts/cvsfiles.awk` >$@
273 dist-source: check-version
274 $(tarball) $(TARNAME)-$(VERSION) $(bld_distgen) -C $(srcdir) $(src_distgen) $(src)
278 $(tarball) $(TARNAME)-client-$(VERSION) -C $(srcdir) $(filter src/client/%, $(src))
282 $(tarball) $(TARNAME)-info-text-$(VERSION) -C info.nr $(info)
283 $(tarball) $(TARNAME)-info-html-$(VERSION) -C info.html $(addsuffix .html, $(info))
286 if [ $(VERSION) != `sed -n '/EMP_VERS_/s/#define EMP_VERS_\([A-Z]*\)[ \t]*//p' <include/version.h | tr '\012' . | sed 's/\.$$//'` ]; \
287 then echo version.h does not match configure.ac >&2; false; \
294 # Automatic remake of configuration
295 # See (autoconf)Automatic Remaking.
296 # This requires sufficiently recent versions of autoconf and automake
298 $(srcdir)/configure: configure.ac aclocal.m4
299 cd $(srcdir) && autoconf
301 # autoheader might not change config.h.in, so touch a stamp file.
302 $(srcdir)/config.h.in: stamp-h.in
303 $(srcdir)/stamp-h.in: configure.ac aclocal.m4
304 cd $(srcdir) && autoheader
307 $(srcdir)/aclocal.m4: $(filter m4/%.m4, $(src))
308 cd $(srcdir) && aclocal -I m4
310 # config.status might not change config.h; use the stamp file.
312 stamp-h: config.h.in config.status
313 ./config.status config.h stamp-h
315 GNUmakefile: GNUmakefile.in config.status
318 config.status: configure
319 ./config.status --recheck
321 src/lib/global/path.c src/client/ipglob.c: %: %.in GNUmakefile