File: rules

package info (click to toggle)
sam 4.3-14
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,456 kB
  • ctags: 1,673
  • sloc: ansic: 14,328; sh: 1,307; makefile: 315
file content (243 lines) | stat: -rwxr-xr-x 8,296 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
#! /usr/bin/make -f
## debian/rules for the Debian packages version of sam
## (C) 2002 Gergely Nagy <algernon@debian.org>,
## Based on the work of Raul Miller <moth@debian.org>
##
## Released under the terms of the GNU GPLv2.

PACKAGE = sam
DEB_SAM = ${CURDIR}/debian/sam
DEB_XG  = ${CURDIR}/debian/libxg-dev

CFLAGS = -O2
ifneq (,$(findstring debug,${DEB_BUILD_OPTIONS}))
	CFLAGS += -g
endif

ADD_3G_LINKS	= Dx Dy Pt Rect Rpt divpt eqpt eqrect inset mul ptinrect \
		raddp rcanon rdiv rectXrect rectclip rectinrect rmul \
		rshift rsubp sub
BALLOC_3G_LINKS = bfree rdbitmap rdbitmapfile wrbitmap wrbitmapfile
BITBLT_3G_LINKS	= Fcode arc bitbltclip border circle clipline copymasked \
		disc ellipse point polysegment segment string strsize \
		strwidth texture
CACHECHARS_3G_LINKS = Cachesubf Font Fontchar Subfont
EVENT_3G_LINKS	= Event Menu Mouse ecankbd ecanmouse ecanread einit ekbd \
		emouse eread ereshaped estart etimer getrect menuhit
FRAME_3G_LINKS	= frcharofpt frclear frdelete frgetmouse frinit frinsert \
		frptofchar frselect frselectf frselectp frsetrects
GRAPHICS_3G_LINKS = Bitmap Cursor Point Rectangle bclose berror bflush \
		bscreenrect charwidth clipr cursorset cursorswitch ffree \
		getsubfont mkfont rdfontfile scrollfwdbut xtbinit
RUNE_3G_LINKS	= chartorune fullrune runelen runetochar utflen utfrrune \
		utfrune utfutf

#######################
## BUILD THE PACKAGE ##
#######################
build: patch
	test -e debian/control
	${MAKE} CFLAGS="-D_LIBXG_EXTENSION -I../include ${CFLAGS}" \
		XLIBS="-L/usr/X11R6/lib -lXt -lX11" \
		TERMNAME="/usr/lib/sam/samterm" RXNAME="ssh" \
		RXPATHNAME="/usr/bin/ssh" TMP="/var/tmp"

#############
## CLEANUP ##
#############
clean: clean1 unpatch
	test xroot = x`whoami`
	test -e debian/control
	rm -rf debian/patched
clean1: 
	test xroot = x`whoami`
	rm -f build
	${MAKE} nuke
	rm -rf debian/files* core debian/*substvars debian/sam \
	       debian/libxg-dev

#####################
## BUILD libxg-dev ##
#####################
binary-libxg-dev: build
	test xroot = x`whoami`
	test -e debian/control
## Create directories
	install -d ${DEB_XG}/usr/lib ${DEB_XG}/usr/include/plan9 \
		${DEB_XG}/usr/share/man/man3 ${DEB_XG}/DEBIAN \
		${DEB_XG}/usr/share/doc/libxg-dev
## Install the libraries
	install -m 0644 libXg/libXg.a libframe/libframe.a \
		${DEB_XG}/usr/lib/
## Install headers
	install -m 0644 include/*.h ${DEB_XG}/usr/include/plan9
## Install manual pages
	for f in doc/*.3; do \
		gzip -9fc $$f > ${DEB_XG}/usr/share/man/man3/`basename $$f`g.gz; \
	done
## Make a sh*tload of symlinks
	for f in ${ADD_3G_LINKS}; do \
		ln -sf add.3g.gz ${DEB_XG}/usr/share/man/man3/$$f.3g.gz; \
	done
	for f in ${BALLOC_3G_LINKS}; do \
		ln -sf balloc.3g.gz ${DEB_XG}/usr/share/man/man3/$$f.3g.gz; \
	done
	for f in ${BITBLT_3G_LINKS}; do \
		ln -sf bitblt.3g.gz ${DEB_XG}/usr/share/man/man3/$$f.3g.gz; \
	done
	for f in ${CACHECHARS_3G_LINKS}; do \
		ln -sf cachechars.3g.gz ${DEB_XG}/usr/share/man/man3/$$f.3g.gz; \
	done
	for f in ${EVENT_3G_LINKS}; do \
		ln -sf event.3g.gz ${DEB_XG}/usr/share/man/man3/$$f.3g.gz; \
	done
	for f in ${FRAME_3G_LINKS}; do \
		ln -sf frame.3g.gz ${DEB_XG}/usr/share/man/man3/$$f.3g.gz; \
	done
	for f in ${GRAPHICS_3G_LINKS}; do \
		ln -sf graphics.3g.gz ${DEB_XG}/usr/share/man/man3/$$f.3g.gz; \
	done
	for f in ${RUNE_3G_LINKS}; do \
		ln -sf rune.3g.gz ${DEB_XG}/usr/share/man/man3/$$f.3g.gz; \
	done
## Install documentation
	gzip -9fc README > ${DEB_XG}/usr/share/doc/libxg-dev/README.gz
	install -m 0644 debian/copyright ${DEB_XG}/usr/share/doc/libxg-dev/
	gzip -9fc debian/changelog > ${DEB_XG}/usr/share/doc/libxg-dev/changelog.Debian.gz
## Strip binaries
ifeq (,$(findstring nostrip,${DEB_BUILD_OPTIONS}))
	strip --strip-unneeded ${DEB_XG}/usr/lib/*.a
endif
## Install files into DEBIAN/
	install -m 0755 debian/maint/libxg-dev/* ${DEB_XG}/DEBIAN/
## Generate DEBIAN/md5sums
	cd ${DEB_XG} >/dev/null; \
	  find * -type f ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums
## Generate DEBIAN/control
	dpkg-gencontrol -isp -plibxg-dev -Tdebian/libxg-dev.substvars \
		-P${DEB_XG}
## And finally build it
	dpkg --build ${DEB_XG} ..

###############
## BUILD sam ##
###############
binary-sam: build
	test xroot = x`whoami`
	test -e debian/control
## Install directories
	install -d ${DEB_SAM}/etc/X11/app-defaults ${DEB_SAM}/usr/bin \
		${DEB_SAM}/usr/lib/sam ${DEB_SAM}/usr/share/doc/sam \
		${DEB_SAM}/usr/share/man/man1 ${DEB_SAM}/usr/share/man/man5 \
		${DEB_SAM}/usr/share/man/man7 ${DEB_SAM}/usr/lib/menu \
		${DEB_SAM}/DEBIAN/
	${MAKE} install DESTDIR=${DEB_SAM} SHARE=/share \
			SAMTERM=${DEB_SAM}/usr/lib/sam/samterm \
			RSAMNAME=sam.real SAMSAVEDIR=${DEB_SAM}/usr/lib/sam \
			SAMDIR=${DEB_SAM}/usr/bin
	install -m 0755 debian/local/sam ${DEB_SAM}/usr/bin/sam
	install -m 0755 sam/B.sh ${DEB_SAM}/usr/bin/B
## Install manual pages
	gzip -9fc doc/sam.1 >${DEB_SAM}/usr/share/man/man1/sam.1.gz
	ln -sf sam.1.gz ${DEB_SAM}/usr/share/man/man1/sam.real.1.gz
	ln -sf sam.1.gz ${DEB_SAM}/usr/share/man/man1/B.1.gz
	for f in doc/*.4; do \
		gzip -9fc $$f >${DEB_SAM}/usr/share/man/man5/`basename $$f .4`.5g.gz; \
	done
	for f in doc/*.6; do \
		gzip -9fc $$f >${DEB_SAM}/usr/share/man/man7/`basename $$f .6`.7g.gz; \
	done
	ln -sf font.5g.gz ${DEB_SAM}/usr/share/man/man5/subfont.5g.gz
	ln -sf utf.5g.gz ${DEB_SAM}/usr/share/man/man5/rune.5g.gz
## Install misc. stuff
	install -m 0644 doc/Sam.ad ${DEB_SAM}/etc/X11/app-defaults
	install -m 0644 doc/sam.ps doc/sam.tut.ms doc/se.ps \
		${DEB_SAM}/usr/share/doc/sam/
## Install docs
	install -m 0644 README.dist debian/README.Debian \
		debian/copyright ${DEB_SAM}/usr/share/doc/sam/
	gzip -9fc README >${DEB_SAM}/usr/share/doc/sam/README.gz
	gzip -9fc debian/changelog \
		  >${DEB_SAM}/usr/share/doc/sam/changelog.Debian.gz
## Install menu-file
	install -m 0644 debian/local/menu/sam ${DEB_SAM}/usr/lib/menu
## Strip binaries
ifeq (,$(findstring nostrip,${DEB_BUILD_OPTIONS}))
	strip --remove-section=.note --remove-section=.comment \
		${DEB_SAM}/usr/bin/sam.real ${DEB_SAM}/usr/lib/sam/samterm
endif
## Generate ${shlibs:Depends}
	dpkg-shlibdeps -Tdebian/sam.substvars -dDepends \
			${DEB_SAM}/usr/bin/sam.real \
			${DEB_SAM}/usr/lib/sam/samterm
## Install files into DEBIAN/
	install -m 0755 debian/maint/sam/p* ${DEB_SAM}/DEBIAN/
	install -m 0644 debian/maint/sam/conffiles ${DEB_SAM}/DEBIAN/
## Generate DEBIAN/md5sums
	cd ${DEB_SAM} >/dev/null; \
	  find * -type f ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums
## Generate DEBIAN/control
	dpkg-gencontrol -isp -psam -Tdebian/sam.substvars \
		-P${DEB_SAM}
## And finally build it
	dpkg --build ${DEB_SAM} ..

######################
## REQUIRED TARGETS ##
######################
binary-indep: ;
binary-arch: binary-libxg-dev binary-sam
binary:	binary-indep binary-arch

##################
## HELPER RULES ##
##################
patch: patch-stamp
patch-stamp:
	test -d debian/patched || install -d debian/patched
	@echo "Patches applied in the Debian version of ${PACKAGE}:" > $@T
	@for patch in `cat debian/patches/00list`; do \
		stamp=debian/patched/$$patch.dpatch; \
		patch=debian/patches/$$patch.dpatch; \
		author=`sed -n "s,^## *.*dpatch by *,,p" $$patch`; \
		test -x $$patch || chmod +x $$patch; \
		if test -f $$stamp; then \
			echo "$$patch already applied."; \
			echo -e "\n$$patch ($$author):" >> $@T; \
			sed -n 's/^## *DP: */  /p' $$patch >> $@T; \
		else \
			echo -n "applying patch $$patch..."; \
			if $$patch -patch >$$stamp.new 2>&1; then \
				mv $$stamp.new $$stamp; \
				touch $$stamp; \
				echo -e "\n$$patch ($$author):" >> $@T; \
				sed -n 's/^## *DP: */  /p' $$patch >> $@T; \
				echo " ok."; \
			else \
				echo " failed."; \
				exit 1; \
			fi; \
		fi; \
	done
	mv -f $@T $@

unpatch:
	@for patch in `tac debian/patches/00list`; do \
		stamp=debian/patched/$$patch.dpatch; \
		patch=debian/patches/$$patch.dpatch; \
		test -x $$patch || chmod +x $$patch; \
		if test -f $$stamp; then \
			echo -n "reverting patch $$patch..."; \
			if $$patch -unpatch 2>&1 >/dev/null; then \
				rm -f $$stamp; \
				echo " ok."; \
			else \
				echo " failed."; \
				exit 1; \
			fi; \
		fi; \
	done
	rm -f patch-stamp

.PHONY: binary binary-arch binary-indep clean patch unpatch clean1 \
	binary-sam binary-libxg-dev