1# Top-level makefile for Unix- and Cygwin-hosted interfaces to Xconq.
2# Copyright (C) 1991-1995, 1998-2000 Stanley T. Shebs.
3# Copyright (C) 2003, 2004 Eric A. McDonald.
4
5# Xconq is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2, or (at your option)
8# any later version.
9
10prefix = @prefix@
11
12exec_prefix = @exec_prefix@
13bindir = @bindir@
14libdir = @libdir@
15datadir = $(prefix)/share/xconq
16mandir = @mandir@
17man6dir = $(mandir)/man6
18infodir = @infodir@
19docdir = $(datadir)/doc
20
21#appdefaultsdir = /usr/lib/X11/app-defaults
22appdefaultsdir = @x11_app_defaults_dir@
23
24gamelibdir = $(datadir)/lib
25imagesdir = $(datadir)/images
26tcltkdir = $(datadir)/tcltk
27BWidgetdir = $(datadir)/tcltk/BWidget
28BWidgetimagesdir = $(datadir)/tcltk/BWidget/images
29BWidgetlangdir = $(datadir)/tcltk/BWidget/lang
30
31scoresdir = @scoresdir@
32
33srcdir = @srcdir@
34VPATH = @srcdir@
35
36GAMEUID = @gameuser@
37GAMEGRP = @gamegrp@
38
39GAMEPERM = 04755
40DIRPERM  = 0755
41FILEPERM = 0644
42
43SHELL = /bin/sh
44
45INSTALL = install -c
46INSTALL_PROGRAM = $(INSTALL)
47INSTALL_DATA = $(INSTALL) -m 644
48
49SELFILE = SelFile
50
51SUBDIRS =   kernel \
52	    $(SELFILE) \
53	    x11 \
54	    curses \
55	    tcl \
56	    tk \
57	    tcltk \
58	    sdl \
59	    lib \
60	    images \
61	    doc \
62	    test \
63	    misc
64
65CC = @CXX@
66CXX = @CXX@
67
68CFLAGS = @CXXFLAGS@
69CXXFLAGS = @CXXFLAGS@
70
71RANLIB = ranlib
72
73AR = ar
74
75AR_FLAGS = rcu
76
77ALLTARGET = all-@CONFIGTARGET@
78INSTALLTARGET = install-@CONFIGTARGET@
79
80# Host and target-dependent makefile fragments come in here.
81####
82# End of host and target-dependent makefile fragments
83
84FLAGS_TO_PASS = \
85	"prefix=$(prefix)" \
86	"exec_prefix=$(exec_prefix)" \
87	"bindir=$(bindir)" \
88	"appdefaultsdir=$(appdefaultsdir)" \
89	"scoresdir=$(scoresdir)" \
90	"AR=$(AR)" \
91	"AR_FLAGS=$(AR_FLAGS)" \
92	"CC=$(CC)" \
93	"CFLAGS=$(CFLAGS)" \
94	"REQD_CFLAGS=$(REQD_CFLAGS)" \
95	"CXX=$(CXX)" \
96	"CXXFLAGS=$(CXXFLAGS)" \
97	"RANLIB=$(RANLIB)" \
98	"MAKEINFO=$(MAKEINFO)" \
99	"INSTALL=$(INSTALL)" \
100	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
101	"INSTALL_DATA=$(INSTALL_DATA)"
102
103UI_TARGET = @UI_TARGET@
104
105all:	all-$(UI_TARGET)
106
107all-xconq: all-$(UI_TARGET)
108
109all-tkconq all-sdlconq all-cconq all-tcltk all-SelFile all-kernel:
110
111# Target for building Tcl/Tk Xconq.
112
113all-tkconq:     all-tcltk all-tcl all-tk
114	@dir=tcltk; \
115	if [ -f ./$${dir}/Makefile ] ; then \
116	  r=`pwd`; export r; \
117	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
118	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) all-xconq); \
119	else \
120	  true; \
121	fi
122
123# Target for building SDL Xconq.
124
125all-sdlconq:    all-sdl
126	@dir=sdl; \
127	if [ -f ./$${dir}/Makefile ] ; then \
128	  r=`pwd`; export r; \
129	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
130	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) all-xconq); \
131	else \
132	  true; \
133	fi
134
135# Target for building Curses Xconq
136
137all-cconq:
138	@dir=curses; \
139	if [ -f ./$${dir}/Makefile ] ; then \
140	  r=`pwd`; export r; \
141	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
142	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) all); \
143	else \
144	  true; \
145	fi
146
147all-tcltk:
148	@dir=`echo $@ | sed -e 's/all-//'`; \
149	if [ -f ./$${dir}/Makefile ] ; then \
150	  r=`pwd`; export r; \
151	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
152	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) all-libs); \
153	else \
154	  true; \
155	fi
156
157all-sdl:
158	@dir=`echo $@ | sed -e 's/all-//'`; \
159	if [ -f ./$${dir}/Makefile ] ; then \
160	  r=`pwd`; export r; \
161	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
162	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) all-libs); \
163	else \
164	  true; \
165	fi
166
167all-kernel:
168	@dir=`echo $@ | sed -e 's/all-//'`; \
169	if [ -f ./$${dir}/Makefile ] ; then \
170	  r=`pwd`; export r; \
171	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
172	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) all); \
173	else \
174	  true; \
175	fi
176
177all-SelFile:
178	@dir=`echo $@ | sed -e 's/all-//'`; \
179	if [ -f ./$${dir}/Makefile ] ; then \
180	  r=`pwd`; export r; \
181	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
182	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) all); \
183	else \
184	  true; \
185	fi
186
187all-tcl:
188	@dir=`echo $@ | sed -e 's/all-//'`; \
189	if [ -f ./$${dir}/Makefile ] ; then \
190	  r=`pwd`; export r; \
191	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
192	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) all); \
193	else \
194	  true; \
195	fi
196
197all-tk:
198	@dir=`echo $@ | sed -e 's/all-//'`; \
199	if [ -f ./$${dir}/Makefile ] ; then \
200	  r=`pwd`; export r; \
201	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
202	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) all); \
203	else \
204	  true; \
205	fi
206
207installcheck:
208
209check: force
210	cd kernel && make skelconq
211	@if [ -f test/Makefile ]; then \
212	  rootme=`pwd`; export rootme; \
213	  cd test; \
214	  $(MAKE) $(TARGET_FLAGS_TO_PASS) check; \
215	else true; fi
216
217info dvi html install-info clean-info clean-dvi clean-html: force
218	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=doc" subdir_do
219
220install: all install-$(UI_TARGET)
221
222install-only: install-$(UI_TARGET)
223
224install-xconq: all install-$(UI_TARGET)
225
226install-tkconq:	all-tkconq install-lib install-images install-dirs
227	@dir=tcltk; \
228	if [ -f ./$${dir}/Makefile ] ; then \
229	  r=`pwd`; export r; \
230	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
231	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) install-xconq); \
232	else \
233	  true; \
234	fi
235
236install-sdlconq:    all-sdlconq install-lib install-images install-dirs
237	@dir=sdl; \
238	if [ -f ./$${dir}/Makefile ] ; then \
239	  r=`pwd`; export r; \
240	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
241	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) install-xconq); \
242	else \
243	  true; \
244	fi
245
246install-cconq:	all-cconq install-lib install-dirs
247	@dir=curses; \
248	if [ -f ./$${dir}/Makefile ] ; then \
249	  r=`pwd`; export r; \
250	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
251	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) install-cconq); \
252	else \
253	  true; \
254	fi
255
256install-lib: install-dirs
257	@dir=lib; \
258	if [ -f ./$${dir}/Makefile ] ; then \
259	  r=`pwd`; export r; \
260	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
261	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) install-only); \
262	else \
263	  true; \
264	fi
265
266install-images: install-dirs
267	@dir=images; \
268	if [ -f ./$${dir}/Makefile ] ; then \
269	  r=`pwd`; export r; \
270	  srcroot=`cd $(srcdir); pwd`; export srcroot; \
271	  (cd $${dir} && $(MAKE) $(FLAGS_TO_PASS) install-only); \
272	else \
273	  true; \
274	fi
275
276MAKEDIRS= \
277	$(DESTDIR)$(prefix) \
278	$(DESTDIR)$(exec_prefix) \
279	$(DESTDIR)$(bindir) \
280	$(DESTDIR)$(datadir) \
281	$(DESTDIR)$(gamelibdir) \
282	$(DESTDIR)$(imagesdir) \
283	$(DESTDIR)$(mandir) \
284	$(DESTDIR)$(man6dir) \
285	$(DESTDIR)$(infodir) \
286	$(DESTDIR)$(tcltkdir) \
287	$(DESTDIR)$(BWidgetdir) \
288	$(DESTDIR)$(BWidgetimagesdir) \
289	$(DESTDIR)$(BWidgetlangdir)
290
291.PHONY: install-dirs
292install-dirs:
293	@for i in $(MAKEDIRS) ; do \
294		echo Making $$i... ; \
295		parent=`echo $$i | sed -e 's@/[^/]*$$@@' | sed -e 's@^$$@/@'`; \
296		if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi ; \
297		if [ ! -d $$i ] ; then \
298			if mkdir $$i ; then \
299				true ; \
300			else \
301				exit 1 ; \
302			fi ; \
303		else \
304			true ; \
305		fi ; \
306	done
307
308# Build a source distribution.
309DIST_VERSION=@XCONQ_VERSION_FULL@
310DIST_NAME=xconq-$(DIST_VERSION)
311
312dist: info html check-cvs
313	(cd .. && \
314	cvs -z3 -d`cat xconq/CVS/Root` export -d $(DIST_NAME) -r HEAD xconq && \
315	cp xconq/doc/*.info xconq/doc/*.html $(DIST_NAME)/doc && \
316	tar czvf $(DIST_NAME).tar.gz $(DIST_NAME) && \
317	rm -rf $(DIST_NAME))
318
319bz2dist: info html check-cvs
320	(cd .. && \
321	cvs -z3 -d`cat xconq/CVS/Root` export -d $(DIST_NAME) -r HEAD xconq && \
322	cp xconq/doc/*.info xconq/doc/*.html $(DIST_NAME)/doc && \
323	tar cjvf $(DIST_NAME).tar.bz2 $(DIST_NAME) && \
324	rm -rf $(DIST_NAME))
325
326lzmadist: info html check-cvs
327	(cd .. && \
328	cvs -z3 -d`cat xconq/CVS/Root` export -d $(DIST_NAME) -r HEAD xconq && \
329	cp xconq/doc/*.info xconq/doc/*.html $(DIST_NAME)/doc && \
330	7z a $(DIST_NAME).7z -r $(DIST_NAME) && \
331	rm -rf $(DIST_NAME))
332
333check-cvs:
334	@if [ ! -d CVS ]; then exit 1; fi; \
335	if [ ! -f CVS/Root ]; then exit 1; fi; \
336	true
337
338clean:
339	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(SUBDIRS)" subdir_do
340
341distclean: clean
342	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(SUBDIRS)" subdir_do
343	rm -f Makefile config.status config.cache
344
345extraclean: distclean
346	rm -f *~* .*~* #* %*
347	rm -f */*~* */.*~* */#* */%*
348	rm -f Makefile config.status
349
350realclean: distclean
351	@$(MAKE) $(FLAGS_TO_PASS) DO=realclean "DODIRS=$(SUBDIRS)" subdir_do
352	rm -f Makefile
353
354subdir_do: force
355	@srcroot=`cd $(srcdir); pwd`; export srcroot; \
356	for i in $(DODIRS); do \
357		if [ -f ./$$i/Makefile ] ; then \
358			if (cd ./$$i && \
359				$(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
360			else exit 1 ; fi ; \
361		else true ; fi ; \
362	done
363
364Makefile: Makefile.in $(host_makefile_frag) $(target_makefile_frag)
365	$(SHELL) ./config.status
366
367force:
368