File: rules

package info (click to toggle)
xbat 1.11-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,236 kB
  • ctags: 796
  • sloc: ansic: 6,298; makefile: 654; sh: 63
file content (323 lines) | stat: -rwxr-xr-x 7,106 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#!/usr/bin/make -f
#
# $Id: rules,v 1.3 1998/11/26 09:24:05 kooij Exp $
# Makefile for Debian package xbat.
#
# Copyright (C) 1998 by Joost Kooij.
# This program is free software; you can redistribute it and/or 
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 
# of the License, or (at your option) any later version.


default: 
	@echo "no default target.  exiting (error)." >&2
	@echo "usage: debian/rules <target>" >&2
	@echo "possible targets are: clean build binary" >&2
	@false


checkdir := $(shell \
		if ! [ -f xev.c -a -f debian/rules ]; then \
			printf "Error: Not in correct source directory!\n" >&2 ;\
			printf "Start only from within top-level source directory.\n" >&2 ;\
			printf "Killing make: " >&2 ;\
			kill $$PPID ;\
		fi ;\
	)
	

RULES_DEBUG := 1

ifdef RULES_DEBUG
    define debugtarget
	@echo "making $@ (updated $? from $^)"
    endef
endif


	#########################
	#			#
	#      Definitions.	#
	#			#
	#########################

#
# Convenient defines for targets and rules.
#

# Filesystem definitions: 
debian_doc_dir	:= /usr/share/doc/xbat
debian_bin_dir	:= /usr/games
debian_lib_dir	:= /usr/share/games/xbat
debian_man_dir	:= /usr/share/man
debian_var_dir	:= /var/games/xbat
debian_menu_dir	:= /usr/lib/menu
debian_image_dir:= $(debian_lib_dir)/Image
debian_map_dir	:= $(debian_lib_dir)/Map
debian_domo_dir	:= $(debian_lib_dir)/Domo
debian_score_dir:= $(debian_var_dir)

# Package build-area defines:
tmp		:= debian/tmp
bindir		:= $(tmp)$(debian_bin_dir)
docdir		:= $(tmp)$(debian_doc_dir)
mandir		:= $(tmp)$(debian_man_dir)
menudir		:= $(tmp)$(debian_menu_dir)
scorevardir	:= $(tmp)$(debian_var_dir)
scorelibdir	:= $(tmp)$(debian_lib_dir)/Score
controldir	:= $(tmp)/DEBIAN

# Target files:
xbat_build	:= xbat
xbat_binary	:= $(bindir)/xbat

# Dependency files:
xbat_docs	:= README README.jp 
pkg_docs	:= debian/README debian/changelog debian/copyright 
manpage		:= debian/xbat.6
menufile	:= debian/menufile
controlfiles	:= debian/postinst debian/postrm


#
# Variable overrides for use with the xbat Makefile.
#

# Use FHS-compliant locations instead of /usr/local from Imakefile
FHS_DEFINES :=     \
  SCORE_DIR=$(debian_score_dir) \
  IMAGE_DIR=$(debian_image_dir) \
  MAP_DIR=$(debian_map_dir)     \
  DOMO_DIR=$(debian_domo_dir)   \
  BINDIR=$(debian_bin_dir) 

# UNION is a compile flag.  It cannot be evaluated in the Imakefile,
# because imake doesn't give cpp a nice $ARCH flag to evaluate.  
architecture:=$(shell dpkg --print-architecture)
ifeq ($(architecture),i386)
  UNION=1
else
  UNION=0
endif


#
# Utility defines
#

install_file	:= install -p -o root -g root -m 644
install_program	:= install -p -o root -g root -m 755
make_directory	:= install -d -o root -g root -m 755



	#################################
	#				#
	#	Targets and rules	#
	#				#
	#################################


#
# Rules for mandated debian package build targets.
#

clean: sourceclean
	$(debugtarget)

build: $(xbat_build)
	$(debugtarget)

binary:	binary-indep binary-arch
	$(debugtarget)

binary-indep:	$(docdir) $(mandir) $(menudir) $(controldir)
	$(debugtarget)

binary-arch:	debian/files
	$(debugtarget)

.PHONY: clean build binary binary-arch binary-indep



#
# Rules for this package.
#

debian/files:	$(docdir) $(mandir) $(menudir) $(controldir) $(xbat_binary)

$(docdir):	$(xbat_docs) $(pkg_docs)

$(mandir):	$(manpage)

$(menudir):	$(menufile)

$(controldir):	$(controlfiles)

$(xbat_binary):	$(xbat_build)

$(xbat_build):	Makefile


#
# Commands for targets that build Debian-added parts of the package.
#

$(docdir):
	#
	# Install the documentation.
	#
	$(debugtarget)
	rm -rf $(docdir)
	$(make_directory) $(docdir)
	$(install_file) README $(docdir)/README
	$(install_file) README.jp $(docdir)/README.jp
	$(install_file) debian/README $(docdir)/README.Debian
	$(install_file) debian/changelog $(docdir)/changelog.Debian
	# Compress all docs,
	gzip -9rfq $(docdir)
	# except for the copyright file
	$(install_file) debian/copyright $(docdir)/copyright

$(mandir):
	#
	# Install the manpage.
	#
	$(debugtarget)
	rm -rf $(mandir)
	$(make_directory) $(mandir)/man6
	$(install_file) debian/xbat.6 $(mandir)/man6/xbat.6
	# Compress manpage
	gzip -9rfq $(mandir)/man6

$(menudir):
	#
	# Install the menufile for the debian menu system
	#
	$(debugtarget)
	rm -rf $(menudir)
	$(make_directory) $(menudir)
	$(install_file) debian/menufile $(menudir)/xbat

$(controldir):
	#
	# Install the package (de)installation scripts.
	#
	$(debugtarget)
	rm -rf $(controldir)
	$(make_directory) $(controldir)
	$(install_program) debian/postinst $(controldir)/postinst
	$(install_program) debian/postrm $(controldir)/postrm


#
# Commands for targets that build the program and install it.
#

Makefile:
	#
	# Generate Makefile from Imakefile template
	#
	$(debugtarget)
	rm -f Makefile
	xmkmf

$(xbat_build):
	#
	# Build the program from sources.
	#
	$(debugtarget)
	# With the right hints, make does all our work:
	$(MAKE) UNION=$(UNION) $(FHS_DEFINES) depend
	$(MAKE) UNION=$(UNION) $(FHS_DEFINES) xbat

$(xbat_binary):
	#
	# Install the actual program and data files.
	#
	$(debugtarget)
	# Make install with prefix DESTDIR.
	$(MAKE) $(FHS_DEFINES) DESTDIR=$(tmp) install
	# It is important that the user's saved highscore data is
	# replaced during package upgrades.  A template location
	# is created for the default highscore data.  Live data 
	# will be initialised with proper permissions and ownership 
	# by the postinst script at initial installation time.
	$(make_directory) $(scorelibdir)
	mv $(scorevardir)/* $(scorelibdir)


#
# Commands that create the Debian package binary.
#

debian/files: 
	#
	# Complete the Debian binary package from all the parts.
	#
	$(debugtarget)
	# Need root (or at least fakeroot):
	test root = "`whoami`" || (echo need root privileges; exit 1)
	# Fix some permissions set by the xbat Makefile: 
	chown -R root.root $(tmp)
	find $(tmp) -type d | xargs chmod 755 
	# (careful not touch the postinst etc.)
	find $(tmp) -type f | grep -v $(controldir) | xargs chmod 644 
	# Strip the compiled binaries:
	strip --strip-unneeded -R .comment $(xbat_binary)
	chmod 755 $(xbat_binary)
	# Have dpkg finish the package.
	dpkg-shlibdeps $(xbat_binary)
	dpkg-gencontrol -isp
	dpkg --build $(tmp) ..


#
# Commands for some cleanup targets. 
#

buildclean:
	#
	# Clean up the effects of compiling (building).
	#
	$(debugtarget)
	@# The Makefile may not even be there yet, catch error with "-"
	-$(MAKE) -i clean
	rm -f Makefile
	rm -f xbat *.o

binaryclean: 
	#
	# Clean up the effects of assembling a package.
	#
	$(debugtarget)
	rm -f debian/files* debian/substvars
	rm -rf $(tmp)

sourceclean: buildclean binaryclean
	#
	# Clean up everything, leaving pristine source.
	#
	$(debugtarget)
	rm -rf *~ .[^.]* debian/*~ debian/.[^.]*

.PHONY: sourceclean buildclean binaryclean



#
# Convenient target aliases.
#

configure config: Makefile
	$(debugtarget)

distclean pristine: sourceclean
	$(debugtarget)

.PHONY: distclean pristine configure config


# End of debian/rules.