Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#
2
# This Plan 9 mkfile is for ``easy'' building.
3
# It worked for Ghostscript 8.53.
4
#
5
# This mkfile consists of two parts: the first part builds the gs executable,
6
# the second unpacks the gs distribution and sets configuration parameters.
7
#
8
# Place this mkfile in the root directory of the gs distribution (the gsX.XX dir)
9
# Edit the drivers list below, and mk fake-make to let gs configure
10
# itself.  Fake-make doesn't actually build very much.
11
#
12
# Then you can run mk normally.
13
#
14
# Be sure to have the jpeg, libpng, and zlib subdirectories before starting.
15
# These have been included in recent gs tar files so we do not maintain
16
# our own anymore.
17
# 
18
# Each time you change the drivers list you must rerun mk fake-make
19
# before building.
20
#
21
# If you want to try out a new GS distribution, you should be able
22
# to mk try-X.XX, test it out, and then do mk install-X.XX, where X.XX
23
# is the version number (e.g. 5.70).  If outside BL, you may have to edit the
24
# scripts to remove some local dependencies (e.g. calling outside and the
25
# cpu call to thresher, alpha to make mips.h, alpha.h).
26
#
27
# Recent versions of src/gxshade1.c cause the compiler to run out
28
# of registers.  Brucee is looking into this.  In the meantime, use this
29
# replacement:
30
#
31
#	private inline void
32
#	make_other_poles(patch_curve_t curve[4])
33
#	{
34
#	    int i, j;
35
#	
36
#	    for (i = 0; i < 4; i++) {
37
#		j = (i + 1) % 4;
38
#		curve[i].control[0].x = (curve[i].vertex.p.x * 2 + curve[j].vertex.p.x);
39
#		curve[i].control[0].x /= 3;
40
#		curve[i].control[0].y = (curve[i].vertex.p.y * 2 + curve[j].vertex.p.y);
41
#		curve[i].control[0].y /= 3;
42
#		curve[i].control[1].x = (curve[i].vertex.p.x + curve[j].vertex.p.x * 2);
43
#		curve[i].control[1].y /= 3;
44
#		curve[i].control[1].y = (curve[i].vertex.p.y + curve[j].vertex.p.y * 2);
45
#		curve[i].control[1].y /= 3;
46
#		curve[i].straight = true;
47
#	    }
48
#	}
49
#	
50
# (the original includes the /3 in the big expressions).
51
#
52
# src/gxshade6.c also needs editing to remove use of the
53
# vlong , operator on some architectures.
54
#
55
# you may need to change this line in gs/src/gshtscr.c:
56
# //      sample = (int) (value * max_ht_sample) + max_ht_sample;
57
# to
58
# 	sample = (vlong)(value * max_ht_sample) + max_ht_sample;
59
 
60
</$objtype/mkfile
61
 
62
BIN=/$objtype/bin
63
 
64
TARG=gs
65
OFILES=\
66
	obj/gs.$O\
67
	`{sed 's#^./obj/(.*)\.o .*#obj/\1.$O#' src/ld.tr >[2] /dev/null | sort}
68
 
69
# The first driver is the default.
70
DRIVERS=\
71
	plan9\
72
	bj10e\
73
	bjc600\
74
	bjc800\
75
	cdj1600\
76
	cdj670\
77
	cdj850\
78
	cdj890\
79
	dfaxlow\
80
	epsonc\
81
	epswrite\
82
	inferno\
83
	jpeg\
84
	jpeggray\
85
	laserjet\
86
	ljet2p\
87
	ljet3\
88
	ljet3d\
89
	ljet4\
90
	pbm\
91
	pbmraw\
92
	pdfwrite\
93
	pgm\
94
	pgmraw\
95
	plan9bm\
96
	pnm\
97
	pnmraw\
98
	ppm\
99
	ppmraw\
100
	pswrite\
101
	stcolor\
102
	tiffg32d\
103
	tiffg3\
104
	tiffg4\
105
 
106
HFILES=$objtype.h\
107
	arch.h\
108
 
109
# enforce some startup conditions
110
x=`{mkdir obj >[2]/dev/null; mv jpeg/jmorecfg.h jpeg/jmorecfg.h.save >[2] /dev/null}
111
 
112
 
113
</sys/src/cmd/mkone
114
 
115
UPDATE=\
116
	/386/bin/gs\
117
	/sys/man/1/gs\
118
	/rc/bin/ps2pdf\
119
	/rc/bin/pdf2ps\
120
	/sys/man/1/ps2pdf\
121
 
122
update:V:
123
	update $UPDATEFLAGS $UPDATE `{cat lsr}
124
 
125
 
126
CC=pcc
127
CFLAGS=-c -DPlan9 -D_POSIX_SOURCE -D_BSD_EXTENSION\
128
	-I. -Isrc -Ijpeg -Izlib -Iicclib -DT$objtype '-DGS_INIT="gs_init.ps"'
129
LD=pcc
130
 
131
obj/gconfig.$O obj/gconf.$O obj/gscdef.$O\
132
 obj/gscdefs.$O obj/iconf.$O obj/iconfig.$O: src/gconfig.h
133
 
134
obj/%.$O: icclib/%.c
135
	$CC $CFLAGS icclib/$stem.c; mv $stem.$O obj
136
 
137
obj/%.$O:	jpeg/%.c
138
	$CC $CFLAGS jpeg/$stem.c; mv $stem.$O obj
139
 
140
obj/%.$O:	zlib/%.c
141
	$CC $CFLAGS zlib/$stem.c; mv $stem.$O obj
142
 
143
obj/%.$O:	src/%.c
144
	$CC $CFLAGS src/$stem.c; mv $stem.$O obj
145
 
146
#if possible, use genarch to build $objtype.h; it must run on same cpu type.
147
#if not, try to use a default header for the target architecture.
148
$objtype.h:	$O.genarch
149
	if(~ $objtype $cputype) {
150
		./$O.genarch $target
151
		rm -f $O.genarch
152
	}
153
	if not {
154
		if (test -r default.$objtype.h)
155
			cp default.$objtype.h $target && chmod 664 $target
156
		if not {
157
			echo 'no default header file for target architecture'
158
			echo 'run mk on the target architecture to build one'
159
			exit false
160
		}
161
	}
162
 
163
$O.genarch:U:	src/genarch.c
164
	if(~ $objtype $cputype) {
165
		rfork e
166
		objtype=$cputype
167
		pcc -DHAVE_LONG_LONG -B -o $O.genarch src/genarch.c
168
	}
169
	if not
170
		status=''
171
 
172
libinstall:V:
173
	cp lib/* /sys/lib/ghostscript
174
 
175
nuke clean:V:
176
	rm -f *.[$OS] obj/* [$OS].out y.tab.? y.debug y.output $TARG src/plan9.mak
177
 
178
#################################################################################
179
 
180
fake-make:V: src/plan9.mak src/plan9-aux.mak fakecc
181
	cp jpeg/jmorecfg.h.save jpeg/jmorecfg.h
182
	ape/psh -c 'CC=fakecc make -f src/plan9.mak'
183
	rm -f jpeg/jmorecfg.h
184
	cp obj/*.c obj/*.h obj/ld.tr src
185
	rm -f src/arch.h
186
	rm -f obj/*.o
187
	rm -f obj/*.c
188
	rm -f fakecc
189
 
190
real-make:V: src/plan9.mak src/plan9-aux.mak
191
	ape/psh -c 'CC=cc make -f src/plan9.mak'
192
 
193
fakecc:V:
194
	echo '#!/bin/rc
195
		if(~ ./obj/genconf $* || ~ ./obj/genarch $* || ~ ./obj/echogs $*) cc $*
196
		status='''' ' >$target
197
	chmod +x $target
198
 
199
src/plan9.mak:	src/unixansi.mak /sys/src/cmd/gs/contrib9.mak src/contrib.mak
200
	devlist='$(DD)'^$DRIVERS^'.dev'
201
	devlist=$"devlist
202
	sed 's#^GS_LIB_DEFAULT=.*#GS_LIB_DEFAULT=/sys/lib/ghostscript:/sys/lib/ghostscript/font:/sys/lib/postscript/font#
203
		s#^XCFLAGS=.*#XCFLAGS=-D_BSD_EXTENSION -DPlan9#
204
		s#^CFLAGS_STANDARD=.*#CFLAGS_STANDARD=#
205
		s#^include \$\(.*\)/(.*)#include src/\1#
206
		s#unix-aux.mak#plan9-aux.mak#
207
		s#gsdatadir *=.*#gsdatadir=/sys/src/cmd/gs#
208
		s#DEVICE_DEVS=.*#DEVICE_DEVS='$devlist'#
209
		s#(DEVICE_DEVS[0-9]+)=.*#\1=#' $prereq >$target
210
 
211
src/plan9-aux.mak:	src/unix-aux.mak
212
	sed 's#^INCLUDE=.*#INCLUDE=/sys/include/ape#' $prereq >$target
213
 
214
try-%:V:	gs%/$O.out
215
	bind gs$stem/$O.out /bin/gs
216
	bind -b gs$stem/lib /sys/lib/ghostscript
217
	echo 'give it a whirl'
218
 
219
gs([0-9]+\.[0-9]+)/$O.out:R:	gs\1/src
220
	@{ cd gs$stem1
221
	# for(i in jpeg zlib libpng)
222
	# 	bind -c ../$i $i
223
	if(! test -f src/ld.tr)
224
		mk fake-make
225
	cp ../arch.h .
226
	rm -f obj/*.c
227
	mk $O.out
228
	# for(i in jpeg zlib libpng)
229
	# 	unmount $i || status=''
230
	}
231
 
232
gs%/src:	ghostscript-%.tar.gz
233
	rm -rf gs$stem
234
	gunzip < ghostscript-$stem.tar.gz | tar x
235
	mv ghostscript-$stem gs$stem
236
	chmod g+w gs$stem/* gs$stem/*/*
237
	# local drivers
238
	cp src/gdevifno.c src/gdevplan9.c src/gdevcd8.c gs$stem/src
239
	# local conventions
240
	ed gs$stem/lib/gs_init.ps <fixSAFER.ed
241
	mkdir -p gs$stem/^(jpeg obj zlib libpng)
242
	# rm -rf gs$stem/^(jpeg obj zlib libpng)^/*
243
	echo '<../mkfile' >gs$stem/mkfile
244
	cp default.*.h gs$stem
245
	@{cd gs$stem; mk startover}
246
 
247
ghostscript-%.tar.gz:
248
	#outside
249
	#hget -o $target http://download.sourceforge.net/ghostscript/$target
250
	hget -o $target ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs^`{echo $stem | sed 's/\.//'}^/$target
251
	#ftpfs -a $user^'@' ftp.cs.wisc.edu
252
	#cp /n/ftp/ghost/aladdin/*/ghostscript-$stem.tar.gz .
253
 
254
startover:V:
255
	rm -rf obj/*
256
	rm -f src/ld.tr
257
	rm -f src/plan9.mak src/plan9-aux.mak
258
 
259
install-%:V:
260
	unmount /bin/gs || status=''
261
	unmount /sys/lib/ghostscript || status=''
262
	mk installsrc-$stem
263
#	cpu -h thresher -c 'mk mips.h' || status=''
264
#	cpu -h alpha -c 'mk alpha.h' || status=''
265
	mk all
266
	mk installall
267
	for(i in lib/*.ps)
268
		if(! cmp $i /sys/lib/ghostscript/^`{basename $i} >/dev/null)
269
			cp $i /sys/lib/ghostscript
270
	cp /sys/lib/ghostscript/pdf_sec-ps.bak /sys/lib/ghostscript/pdf_sec.ps
271
 
272
installsrc-%:V:	gs%/$O.out
273
	pwd=`{pwd}
274
	# don't accidentally do this from gsX.XX
275
	if(! ~ $pwd */gs)
276
		echo 'i don''t think you meant to do that' && exit oops
277
	tocopy=(doc examples icclib lib man obj src zlib jpeg libpng)
278
	if(! cmp src/version.mak gs$stem/src/version.mak) {
279
		rm -rf $tocopy
280
		@{cd gs$stem; tar c $tocopy} | tar xT
281
		mk clean
282
	}
283
	status=''
284
 
285
clean-%:V:
286
	for (i in gs$stem/*)
287
		unmount $i >[2]/dev/null || status=''
288
	rm -rf gs$stem ghostscript-$stem.tar.gz
289