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 files README, COPYING and CREDITS in the root of the source
23 # tree for related information and legal notices. It is expected
24 # that future 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 := config.h config.log config.status stamp-h
86 ac += $(basename $(filter %.in, $(src)))
87 ac += $(srcdir)/autom4te.cache $(srcdir)/src/client/autom4te.cache
88 acdist := aclocal.m4 config.h.in configure stamp-h.in
89 acdistcli := $(addprefix src/client/, aclocal.m4 config.h.in configure)
90 obj := $(csrc:.c=.o) $(filter %.o, $(ac:.c=.o))
91 # TODO AIX needs lwpInit.o lwpRestore.o lwpSave.o unless UCONTEXT
93 libs := $(addprefix lib/, libcommon.a libgen.a libglobal.a)
94 util := $(addprefix src/util/, $(addsuffix $(EXEEXT), fairland files pconfig))
95 client := src/client/empire$(EXEEXT)
96 server := src/server/emp_server$(EXEEXT)
97 tsubj := $(addprefix info/, $(addsuffix .t, $(subjects)))
99 info.nr := $(addprefix info.nr/, $(info))
100 info.html := $(addprefix info.html/, $(addsuffix .html, $(info)))
102 ifeq ($(empthread),LWP)
103 empth_obj := src/lib/empthread/lwp.o
104 empth_lib := lib/liblwp.a
106 ifeq ($(empthread),POSIX)
107 empth_obj := src/lib/empthread/pthread.o
110 ifeq ($(empthread),Windows)
111 empth_obj := src/lib/empthread/ntthread.o
116 # Each generated file should be in one of the following sets.
118 clean := $(obj) $(deps) $(libs) $(util) $(client) $(server) $(tsubj) \
119 $(ttop) $(info.nr) $(info.html) $(empth_obj) $(empth_lib)
120 # Removed by distclean:
121 distclean := $(ac) subjects.mk
122 # Distributed by dist-source from $(srcdir)
123 src_distgen := $(acdist)
124 # Distributed by dist-source from .
125 bld_distgen := sources.mk
126 # Distributed by dist-client from $(srcdir)/src/client
127 cli_distgen := $(acdistcli)
130 CPPFLAGS += -I$(srcdir)/include -I.
131 ifeq ($(have_gcc),yes)
132 CFLAGS += -fno-builtin-carg # conflicts with our carg()
133 CFLAGS += -fno-common
134 CFLAGS += -Wall -W -Wno-unused -Wpointer-arith -Wstrict-prototypes \
135 -Wmissing-prototypes -Wnested-externs -Wredundant-decls
142 all: $(util) $(client) $(server) info
157 install: all installdirs
158 $(INSTALL_PROGRAM) $(util) $(server) $(sbindir)
159 $(INSTALL_PROGRAM) $(client) $(bindir)
160 $(INSTALL_DATA) $(info.nr) $(einfodir)
161 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man1)) $(mandir)/man1
162 $(INSTALL_DATA) $(addprefix $(srcdir)/, $(man6)) $(mandir)/man6
163 if test -e $(econfig); then \
164 if src/util/pconfig $(econfig) >$(econfig).new; then \
165 if cmp -s $(econfig) $(econfig).new; then \
168 echo "Check out $(econfig).new"; \
171 echo "Your $(econfig) doesn't work"; \
174 src/util/pconfig >$(econfig); \
179 mkdir -p $(bindir) $(sbindir) $(edatadir) $(einfodir) $(mandir)/man1 $(mandir)/man6 $(dir $(econfig))
182 install-html: html | $(ehtmldir)
183 $(INSTALL_DATA) $(info.html) $(ehtmldir)
190 dist: dist-source dist-client dist-info
195 # Compile with dependencies as side effect, i.e. create %.d in
197 ifeq ($(how_to_dep),fast)
199 $(COMPILE.c) -MT $@ -MMD -MP $(OUTPUT_OPTION) $<
201 ifeq ($(how_to_dep),depcomp)
203 source='$<' object='$@' depfile='$(@:.o=.d)' $(CCDEPMODE) $(depcomp) \
204 $(COMPILE.c) $(OUTPUT_OPTION) $<
206 # Cancel the rule to compile %.c straight to %, it interferes with
207 # automatic dependency generation
210 # Work around MinGW Make's broken built-in link rule:
212 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
216 $(NROFF) -I $(srcdir)/info $(filter %/CRT.MAC, $^) $< | $(AWK) -f $(filter %/Blank.awk, $^) >$@
217 # FIXME AT&T nroff doesn't grok -I
219 info.html/%.html: info/%.t
220 perl $(filter %.pl, $^) $< >$@
227 $(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)
228 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
230 $(client): $(filter src/client/%, $(obj)) $(termlibs)
231 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
235 lib/libcommon.a: $(filter src/lib/common/%, $(obj))
236 lib/libgen.a: $(filter src/lib/gen/%, $(obj))
237 lib/libglobal.a: $(filter src/lib/global/%, $(obj))
238 lib/liblwp.a: $(filter src/lib/lwp/%, $(obj))
240 $(libs) $(empth_lib): | lib
246 subjects.mk: $(tsrc) info/findsubj.pl sources.mk
247 perl $(srcdir)/info/findsubj.pl
248 # If sources.mk is out of date, $(tsrc) is. If it contains files that
249 # went away, make can't remake subjects.mk. Tell it to ignore such
253 $(tsubj): info/mksubj.pl
254 perl $(srcdir)/info/mksubj.pl $@ $(filter %.t, $^)
257 perl $(srcdir)/info/mktop.pl $@ $(filter %.t, $^)
259 info.nr/all: $(filter-out info.nr/all, $(info.nr))
260 (cd info.nr && ls -CF $(info)) >$@
261 # FIXME shouldn't use ls
263 info.html/all.html: $(filter-out info.html/all.html, $(info.html)) info/ls2html.pl
264 (cd info.html && ls -CF $(notdir $(info.html))) | expand | perl $(filter %.pl, $^) >$@
265 # FIXME shouldn't use ls
267 $(info.nr): info/CRT.MAC info/INFO.MAC info/Blank.awk | info.nr
269 $(subjects.html) info.html/TOP.html: info/subj2html.pl | info.html
270 $(topics.html): info/emp2html.pl | info.html
272 info.nr info.html lib:
275 ifeq ($(cvs_controlled),yes)
276 # Find files and directories under CVS control
277 sources.mk: $(scripts)/cvsfiles.awk $(addprefix $(srcdir)/, $(addsuffix CVS/Entries, $(dirs)))
278 echo 'src := ' `cd $(srcdir) && $(AWK) -f src/scripts/cvsfiles.awk` >$@
280 sources.mk: $(srcdir)/sources.mk
286 dist-source: check-version $(src_distgen) $(bld_distgen)
287 $(tarball) $(TARNAME)-$(VERSION) $(bld_distgen) -C $(srcdir) $(src_distgen) $(src)
290 dist-client: $(cli_distgen)
291 $(tarball) $(TARNAME)-client-$(VERSION) \
292 -C $(srcdir)/src/client \
293 $(notdir $(filter src/client/%, $(src)) $(cli_distgen)) \
294 -C $(srcdir)/include proto.h \
295 -C $(srcdir)/man empire.6 \
296 -C $(srcdir) COPYING INSTALL install-sh
300 $(tarball) $(TARNAME)-info-text-$(VERSION) -C info.nr $(info)
301 $(tarball) $(TARNAME)-info-html-$(VERSION) -C info.html $(addsuffix .html, $(info))
304 if [ $(VERSION) != `sed -n '/EMP_VERS_/s/#define EMP_VERS_\([A-Z]*\)[ \t]*//p' <$(srcdir)/include/version.h | tr '\012' . | sed 's/\.$$//'` ]; \
305 then echo version.h does not match configure.ac >&2; false; \
313 # Automatic remake of configuration
314 # See (autoconf)Automatic Remaking.
315 # This requires sufficiently recent versions of autoconf and automake
317 $(srcdir)/configure: configure.ac aclocal.m4
318 cd $(srcdir) && autoconf
320 # autoheader might not change config.h.in, so touch a stamp file.
321 $(srcdir)/config.h.in: stamp-h.in
322 $(srcdir)/stamp-h.in: configure.ac aclocal.m4
323 cd $(srcdir) && autoheader
326 $(srcdir)/aclocal.m4: $(filter m4/%.m4, $(src))
327 cd $(srcdir) && aclocal -I m4
329 # config.status might not change config.h; use the stamp file.
331 stamp-h: config.h.in config.status
332 ./config.status config.h stamp-h
334 GNUmakefile: GNUmakefile.in config.status
337 config.status: configure
338 ./config.status --recheck
340 src/lib/global/path.c src/client/ipglob.c: %: %.in GNUmakefile
344 # Make files for standalone client distribution
346 $(srcdir)/src/client/configure: src/client/configure.ac src/client/aclocal.m4
347 cd $(dir $@) && autoconf
349 $(srcdir)/src/client/config.h.in: src/client/configure.ac src/client/aclocal.m4
350 cd $(dir $@) && autoheader
353 $(srcdir)/src/client/aclocal.m4: m4/lib_socket_nsl.m4