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))
52 ac := autom4te.cache config.h config.status config.log stamp-h \
53 $(basename $(filter %.in, $(src)))
54 obj := $(csrc:.c=.o) $(filter %.o, $(ac:.c=.o))
55 # TODO AIX needs lwpInit.o lwpRestore.o lwpSave.o unless UCONTEXT
57 libs := $(addprefix lib/, libcommon.a libgen.a libglobal.a)
58 util := $(addprefix src/util/, fairland files pconfig)
59 progs := $(util) src/client/empire src/server/emp_server
61 ifeq ($(empthread),POSIX)
62 empth_obj := src/lib/empthread/pthread.o
65 empth_obj := src/lib/empthread/lwp.o
66 empth_lib := lib/liblwp.a
70 scripts = $(srcdir)/src/scripts
71 clean := $(obj) $(deps) $(libs) $(progs) $(empth_lib)
75 CPPFLAGS += -I$(srcdir)/include -Iinclude
76 ifeq ($(have_gcc),yes)
78 CFLAGS += -Wall -W -Wno-unused -Wpointer-arith -Wstrict-prototypes \
79 -Wmissing-prototypes -Wnested-externs -Wredundant-decls
86 all: $(progs) # FIXME info
100 .PHONY: install install-html
117 # Compile with dependencies as side effect, i.e. create %.d in
119 ifeq ($(how_to_dep),fast)
121 $(COMPILE.c) -MT $@ -MMD -MP $(OUTPUT_OPTION) $<
123 ifeq ($(how_to_dep),depcomp)
125 source='$<' object='$@' depfile='$(@:.o=.d)' $(CCDEPMODE) $(depcomp) \
126 $(COMPILE.c) $(OUTPUT_OPTION) $<
128 # Cancel the rule to compile %.c straight to %, it interferes with
129 # automatic dependency generation
135 src/server/emp_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)
136 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
138 src/client/empire: $(filter src/client/%, $(obj)) $(termlibs)
139 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
143 lib/libcommon.a: $(filter src/lib/common/%, $(obj))
144 lib/libgen.a: $(filter src/lib/gen/%, $(obj))
145 lib/libglobal.a: $(filter src/lib/global/%, $(obj))
146 lib/liblwp.a: $(filter src/lib/lwp/%, $(obj))
148 $(libs) $(empth_lib): | lib
155 ifeq ($(cvs_controlled),yes)
156 # Find files and directories under CVS control
157 sources.mk: $(scripts)/cvsfiles.awk $(addprefix $(srcdir)/, $(addsuffix CVS/Entries, $(dirs)))
158 echo 'src := ' `cd $(srcdir) && $(AWK) -f src/scripts/cvsfiles.awk` >$@
165 # Automatic remake of configuration
166 # See (autoconf)Automatic Remaking.
167 # This requires sufficiently recent versions of autoconf and automake
169 $(srcdir)/configure: configure.ac aclocal.m4
170 cd $(srcdir) && autoconf
172 # autoheader might not change config.h.in, so touch a stamp file.
173 $(srcdir)/config.h.in: stamp-h.in
174 $(srcdir)/stamp-h.in: configure.ac aclocal.m4
175 cd $(srcdir) && autoheader
178 $(srcdir)/aclocal.m4: $(filter m4/%.m4, $(src))
179 cd $(srcdir) && aclocal -I m4
181 # config.status might not change config.h; use the stamp file.
183 stamp-h: config.h.in config.status
184 ./config.status config.h stamp-h
186 GNUmakefile: GNUmakefile.in config.status
189 config.status: configure
190 ./config.status --recheck
192 src/lib/global/path.c src/client/ipglob.c: %: %.in GNUmakefile