File: Makefile

package info (click to toggle)
foo2zjs 20050217-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,364 kB
  • ctags: 2,122
  • sloc: ansic: 15,074; xml: 1,751; makefile: 503; sh: 269; perl: 102
file content (667 lines) | stat: -rw-r--r-- 16,740 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
UNAME := $(shell uname)
MACH := $(shell uname -m | sed 's/i.86/ia32/')
EUID := $(shell id -u)

# No version number yet...
VERSION=0.0

# Installation prefix...
PREFIX=/usr/local
PREFIX=$(DESTDIR)/usr

# Pathnames for this package...
BIN=$(PREFIX)/bin
SHAREZJS=$(PREFIX)/share/foo2zjs
SHAREOAK=$(PREFIX)/share/foo2oak
MANDIR=$(PREFIX)/share/man
DOCDIR=$(PREFIX)/share/doc/foo2zjs/

# Pathnames for referenced packages...
FOODB=$(DESTDIR)/usr/share/foomatic/db/source

# User ID's
LPuid=-olp
LPgid=-glp
ifeq ($(UNAME),Darwin)
    LPuid=-oroot
    LPgid=-gwheel
endif
# If we aren't root, don't try to set ownership
ifneq ($(EUID),0)
    LPuid=
    LPgid=
endif

#
# Files for tarball
#
NULL=
FILES	=	\
		README \
		README.in \
		INSTALL \
		INSTALL.in \
		INSTALL.osx \
		COPYING \
		foo2zjs.html.in \
		style.css \
		arch.fig \
		2300.png \
		arch.gif \
		ChangeLog \
		Makefile \
		foo2zjs.c \
		foo2zjs.1in \
		jbig.c \
		jbig.h \
		jbig_tab.c \
		zjsdecode.c \
		zjsdecode.1in \
		zjs.h \
		foo2zjs-wrapper.in \
		foo2zjs-wrapper.1in \
		gamma.ps \
		gamma-lookup.ps \
		align.ps \
		testpage.ps \
		foomatic-db/*/*.xml \
		foomatic-test \
		getweb.in \
		icc2ps/*.[ch] \
		icc2ps/Makefile \
		icc2ps/AUTHORS \
		icc2ps/COPYING \
		icc2ps/README \
		icc2ps/README.foo2zjs \
		PPD/*.ppd \
		crd/2300w-1200@150-l250-kx,ucr100,0-per.crd \
		crd/2300w-1200@150-l250-kx,ucr100,50-per.crd \
		crd/2300w-1200@150-l250-kx,ucr100,75-per.crd \
		crd/2300w-1200@150-l250-kx,ucr125,75-per.crd \
		crd/kh.crd \
		crd/kx.crd \
		crd/prolog.ps \
		crd/screen1200.ps \
		crd/screen2400.ps \
		arm2hpdl.c \
		usb_printerid.c \
		hplj1000 \
		msexpand \
		foo2oak.o \
		foo2oak.1in \
		foo2oak-wrapper.in \
		foo2oak-wrapper.1in \
		oakdecode.o \
		oakdecode.1in \
		foo2oak.html.in \
		1500.gif \
		archoak.fig \
		archoak.gif \
		$(NULL)

# Programs and libraries
PROGS=		foo2zjs zjsdecode arm2hpdl
SHELLS=		foo2zjs-wrapper foo2oak-wrapper
MANPAGES=	foo2zjs-wrapper.1 foo2zjs.1 zjsdecode.1
MANPAGES+=	foo2oak-wrapper.1 foo2oak.1 oakdecode.1
LIBJBG	=	jbig.o jbig_tab.o

ifeq ($(UNAME),Linux)
	PROGS += usb_printerid
#	ifeq ($(MACH),ia32)
#	    PROGS += foo2oak oakdecode
#	endif
endif

# Compiler flags
CFLAGS +=	-O2 -Wall

#
# Rules to create test documents
#
GX=10200
GY=6600
GXR=1200
GYR=600
GSOPTS=	-q -dBATCH -dSAFER -dQUIET -dNOPAUSE -sPAPERSIZE=letter -r$(GXR)x$(GYR)
JBGOPTS=-m 16 -d 0 -p 92	# Equivalent options for pbmtojbg

.SUFFIXES: .ps .pbm .pgm .pgm2 .ppm .ppm2 .zjs .cmyk .pksm .zc .zm .jbg .1 .1in

.ps.pbm:
	gs $(GSOPTS) -sDEVICE=pbmraw -sOutputFile=$*.pbm $*.ps

.ps.ppm:
	gs $(GSOPTS) -sDEVICE=ppmraw -sOutputFile=$*.ppm $*.ps

.ps.pgm:
	gs $(GSOPTS) -sDEVICE=pgmraw -sOutputFile=- $*.ps \
	| pnmdepth 3 > $*.pgm

.ps.pgm2:
	gs.rick $(GSOPTS) -sDEVICE=pgmraw2 -sOutputFile=$*.pgm2 $*.ps

.ps.cmyk:
	gs $(GSOPTS) -sDEVICE=bitcmyk -sOutputFile=$*.cmyk $*.ps

.ps.pksm:
	gs $(GSOPTS) -sDEVICE=pksmraw -sOutputFile=$*.pksm $*.ps

.ps.zc:
	gs $(GSOPTS) -sDEVICE=bitcmyk -sOutputFile=- - < $*.ps \
	| ./foo2zjs -r1200x600 -g10200x6600 -p1 >$*.zc

.ps.zm:
	gs $(GSOPTS) -sDEVICE=pbmraw -sOutputFile=- - < $*.ps \
	| ./foo2zjs -r1200x600 -g10200x6600 -p1 >$*.zm

.pbm.zjs:
	./foo2zjs < $*.pbm > $*.zjs

.cmyk.zjs:
	./foo2zjs < $*.cmyk > $*.zjs

.pksm.zjs:
	./foo2zjs < $*.pksm > $*.zjs

.zc.jbg:
	./zjsdecode -r $* <$*.zc

.zm.jbg:
	./zjsdecode -r $* <$*.zm

#
# The usual build rules
#
all:	$(PROGS) $(SHELLS) getweb all-icc2ps man doc

foo2zjs: foo2zjs.o $(LIBJBG)
	$(CC) $(CFLAGS) -o $@ foo2zjs.o $(LIBJBG)

zjsdecode: zjsdecode.o $(LIBJBG)
	$(CC) $(CFLAGS) zjsdecode.o $(LIBJBG) -o $@

foo2zjs-wrapper: foo2zjs-wrapper.in Makefile
	[ ! -f $@ ] || chmod +w $@
	sed < $@.in > $@ \
	    -e 's@^PREFIX=.*@PREFIX=$(PREFIX)@' || (rm -f $@ && exit 1)
	chmod 555 $@

getweb: getweb.in Makefile
	[ ! -f $@ ] || chmod +w $@
	sed < $@.in > $@ \
	    -e "s@\$${URLZJS}@$(URLZJS)@" \
	    -e 's@^PREFIX=.*@PREFIX=$(PREFIX)@' || (rm -f $@ && exit 1)
	chmod 555 $@

all-icc2ps:
	cd icc2ps; $(MAKE) all

#
# Installation rules
#
install: all install-prog install-icc2ps install-extra install-crd \
	    install-foo install-ppd install-man install-doc
	#
	# Now use your printer configuration GUI to create a new printer.
	#
	# On Redhat 7.2/7.3/8.0/9.0 and Fedora Core 1, run "printconf-gui".
	# On Mandrake, run "printerdrake"
	# On Suse 9.0, run "yast"

install-prog:
	#
	# Install driver, wrapper, and development tools
	#
	install -c $(PROGS) $(SHELLS) $(BIN)/
	#
	# Install gamma correction files.  These are just templates,
	# and don't actually do anything right now.  If anybody wants
	# to tune them or point me at a process for doing that, please...
	#
	install -d $(SHAREZJS)/
	install -c -m 644 gamma.ps $(SHAREZJS)/
	install -c -m 644 gamma-lookup.ps $(SHAREZJS)/
	install -d $(SHAREOAK)/

install-foo:
	#
	# Remove obsolete foomatic database files from previous versions
	#
	rm -f $(FOODB)/opt/foo2zjs-Media.xml
	rm -f $(FOODB)/opt/foo2zjs-PaperSize.xml
	rm -f $(FOODB)/opt/foo2zjs-Source.xml
	rm -f $(FOODB)/opt/foo2zjs-DitherPPI.xml
	#
	# Install current database files
	#
	@if [ -d $(FOODB) ]; then \
	    for dir in driver printer opt; do \
		echo install -m 644 foomatic-db/$$dir/*.xml $(FOODB)/$$dir/; \
		install -c -m 644 foomatic-db/$$dir/*.xml $(FOODB)/$$dir/; \
	    done \
	else \
	    echo "***"; \
	    echo "*** WARNING! You don't have directory $(FOODB)/"; \
	    echo "*** If you want support for foomatic printer configuration,";\
	    echo "*** then you will have to manually install these files..."; \
	    echo "***"; \
	    ls foomatic-db/*/*.xml | sed 's/^/	/'; \
	    echo "***"; \
	    echo "*** ... wherever foomatic is stashed on your machine."; \
	    echo "***"; \
	fi
	#
	# Clear foomatic cache and rebuild database if needed
	#
	#rm -rf /var/cache/foomatic/*/*
	#if [ -d /var/cache/foomatic/compiled ]; then \
	#    cd /var/cache/foomatic/compiled; \
	#    foomatic-combo-xml -O >overview.xml; \
	#fi

install-icc2ps:
	#
	# Install ICM to Postscript file conversion utility
	#
	cd icc2ps; $(MAKE) PREFIX=$(PREFIX) install

install-crd:
	#
	# Install prebuilt CRD files (from m2300w project)
	#
	install -d $(SHAREZJS)/
	install $(LPuid) $(LPgid) -m 775 -d $(SHAREZJS)/crd/
	for i in crd/*.*; do \
	    install -c -m 644 $$i $(SHAREZJS)/crd/; \
	done

install-extra:
	#
	# Install extra files (ICM and firmware), if any exist here.
	#
	# Get files from the printer manufacturer, i.e. www.minolta-qms.com,
	# or use the "./getweb" convenience script.
	#
	install -d $(SHAREZJS)/
	# foo2zjs ICM files (if any)
	install $(LPuid) $(LPgid) -m 775 -d $(SHAREZJS)/icm/
	for i in DL*.icm CP*.icm; do \
	    if [ -f $$i ]; then \
		install -c -m 644 $$i $(SHAREZJS)/icm/; \
	    fi; \
	done
	# foo2zjs Firmware files (if any)
	install $(LPuid) $(LPgid) -m 775 -d $(SHAREZJS)/firmware/
	for i in sihp*.img; do \
	    if [ -f $$i ]; then \
		base=`basename $$i .img`; \
		./arm2hpdl $$i >$$base.dl; \
		install -c -m 644 $$base.dl $(SHAREZJS)/firmware/; \
	    fi; \
	done
	# foo2oak ICM files (if any)
	install $(LPuid) $(LPgid) -m 775 -d $(SHAREOAK)/icm/

USBDIR=/etc/hotplug/usb
install-hotplug:
	[ -d $(USBDIR) ] || install -d -m 755 $(USBDIR)/
	install -c -m 755 hplj1000 $(USBDIR)/
	ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1005
	$(USBDIR)/hplj1000 install-usermap
	$(USBDIR)/hplj1005 install-usermap

clean:
	-rm -f foo2zjs zjsdecode
	-rm -f *.zc *.zm
	-rm -f xxx.* xxxomatic
	-rm -f foo2zjs.o jbig.o jbig_tab.o zjsdecode.o
	-#rm -f *.o
	-rm -f foo2oak.html foo2zjs.html index.html
	-rm -f sihp*.dl
	-rm -f *.tar.gz
	-rm -f getweb
	-rm -f patch.db
	-rm -f $(MANPAGES) manual.pdf
	-rm -f *.zjs *.zm *.zc *.zc? *.zc?? *.oak *.pbm *.pksm *.cmyk
	-rm -f pksm2bitcmyk
	-rm -f *.icm.*.ps
	-rm -f arm2hpdl usb_printerid foo2oak oakdecode foo2oak.o oakdecode.o
	cd icc2ps; $(MAKE) $@

#
# Header dependencies
#
zjsdecode.o: zjs.h jbig.h
foo2zjs.o: zjs.h jbig.h
jbig.o: jbig.h

#
# foo2zjs Regression tests
#
test:		testpage.zm \
		testpage.zc10 testpage.zc1 testpage.zc2 testpage.zc3 \
		lj1000.zm
	#
	# All regression tests passed.
	#
	# Send the appropriate test page .zm/.zc ZjStream file(s) to
	# your printer using a *RAW* printer queue.

testpage.zm: testpage.ps foo2zjs-wrapper foo2zjs Makefile FRC
	#
	# Tests will pass only if you are using ghostscript-7.05-24.7
	#
	# Monochrome test page for Minolta 2200/2300 DL
	PATH=.:$$PATH time -p foo2zjs-wrapper -b gs testpage.ps > $@
	@want="c4cf1940d6fb854cc3efdd6283388ea4  $@"; got=`md5sum $@`; \
	[ "$$want" = "$$got" ] || \
	    { echo "*** Test failure, got $$got"; exit 1; }

testpage.zc10: testpage.ps foo2zjs-wrapper foo2zjs Makefile FRC
	#
	# Color test page for Minolta 2200/2300 DL
	PATH=.:$$PATH time -p foo2zjs-wrapper -b gs -c -C10 testpage.ps > $@
	@want="3d3b6fc08d9a1c9f80a99fec867596df  $@"; got=`md5sum $@`; \
	[ "$$want" = "$$got" ] || \
	    { echo "*** Test failure, got $$got"; exit 1; }

testpage.zc1: testpage.ps foo2zjs-wrapper foo2zjs Makefile FRC
	PATH=.:$$PATH time -p foo2zjs-wrapper -c -C1 testpage.ps > $@
	@want="3d3b6fc08d9a1c9f80a99fec867596df  $@"; got=`md5sum $@`; \
	#[ "$$want" = "$$got" ] || \
	#    { echo "*** Test failure, got $$got"; exit 1; }

testpage.zc2: testpage.ps foo2zjs-wrapper foo2zjs Makefile FRC
	PATH=.:$$PATH time -p foo2zjs-wrapper -c -C2 testpage.ps > $@
	@want="3d3b6fc08d9a1c9f80a99fec867596df  $@"; got=`md5sum $@`; \
	#[ "$$want" = "$$got" ] || \
	#    { echo "*** Test failure, got $$got"; exit 1; }

testpage.zc3: testpage.ps foo2zjs-wrapper foo2zjs Makefile FRC
	PATH=.:$$PATH time -p foo2zjs-wrapper -c -C3 testpage.ps > $@
	@want="3d3b6fc08d9a1c9f80a99fec867596df  $@"; got=`md5sum $@`; \
	#[ "$$want" = "$$got" ] || \

lj1000.zm: testpage.ps foo2zjs-wrapper foo2zjs Makefile FRC
	#
	# Monochrome test page for HP LJ1000
	PATH=.:$$PATH time -p foo2zjs-wrapper -b gs -r600x600 -P testpage.ps > $@
	@want="e458bacac57331ec5206cacd0181fe8a  $@"; got=`md5sum $@`; \
	[ "$$want" = "$$got" ] || \
	    { echo "*** Test failure, got $$got"; exit 1; }

#
# foo2oak Regression tests
#
testoak: pprtest-0.oak pprtest-1.oak pprtest-2.oak pprtest-3.oak

pprtest-0.oak: FRC
	#
	# 1-bit Monochrome test page for OAKT
	PATH=.:$$PATH foo2oak-wrapper -b1 -D12345678 pprtest.ps > $@
	@want="fbd4c1a560985a6ad47ff23b018c7ce8  $@"; got=`md5sum $@`; \
	[ "$$want" = "$$got" ] || \
	    { echo "*** Test failure, got $$got"; exit 1; }

pprtest-1.oak: FRC
	#
	# 2-bit Monochrome test page for OAKT
	PATH=.:$$PATH foo2oak-wrapper -b2 -D12345678 pprtest.ps > $@
	@want="bec9a24ee1ce0d388b773f83609a4d01  $@"; got=`md5sum $@`; \
	[ "$$want" = "$$got" ] || \
	    { echo "*** Test failure, got $$got"; exit 1; }

pprtest-2.oak: FRC
	#
	# 1-bit color test page for OAKT
	PATH=.:$$PATH foo2oak-wrapper -c -b1 -D12345678 pprtest.ps > $@
	@want="c714bcd69fe5f3b2b257d7435eb938d1  $@"; got=`md5sum $@`; \
	[ "$$want" = "$$got" ] || \
	    { echo "*** Test failure, got $$got"; exit 1; }

pprtest-3.oak: FRC
	#
	# 2-bit color test page for OAKT
	PATH=.:$$PATH foo2oak-wrapper -c -b2 -D12345678 pprtest.ps > $@
	@want="ed89abcd873979bc9337e02263511964  $@"; got=`md5sum $@`; \
	[ "$$want" = "$$got" ] || \
	    { echo "*** Test failure, got $$got"; exit 1; }

#
#	icc2ps regression tests
#
ICC2PS=./icc2ps/foo2zjs-icc2ps
icctest:
	for g in *.icm; do \
	    for i in 0 1 2 3; do \
		$(ICC2PS) -o $$g -t$$i \
		| sed '/Created:/d' > $$g.$$i.ps; \
	    done; \
	done


#
# Make phony print devices for testing full spooler interface without printing
#
tmpdev:
	DEV=/tmp/OAK; > $$DEV; chmod 666 $$DEV
	DEV=/tmp/OAKCM; > $$DEV; chmod 666 $$DEV
	DEV=/tmp/testfile; > $$DEV; chmod 666 $$DEV

#
# Test files for debugging
#
testpage.pbm: testpage.ps Makefile
xxx.zc: FRC
xxx.zm: FRC

#
#	PPD files
#
ppd:
	./getweb ppd

MODEL=/usr/share/cups/model
install-ppd:
	#
	# Install PPD files for CUPS
	#
	if [ -d $(MODEL) ]; then \
	    cd PPD; \
	    for ppd in *.ppd; do \
		gzip < $$ppd > $(MODEL)/$$ppd.gz; \
	    done; \
	fi

#
# Manpage generation.  No, I am not interested in "info" files or
# HTML documentation.
#
man: $(MANPAGES)

.1in.1:
	-rm -f $*.1
	modtime() { ls --full-time $$1 | cut -c 44-67; }; \
	MODpage=`modtime $*.1in`; \
	MODver=$(VERSION); \
	sed < $*.1in > $*.1 \
	    -e "s@\$${URLOAK}@$(URLOAK)@" \
	    -e "s@\$${URLZJS}@$(URLZJS)@" \
	    -e "s/\$${MODpage}/$$MODpage/" \
	    -e "s/\$${MODver}/$$MODver/"
	chmod -w $*.1

install-man: man
	#
	# Install manual pages
	#
	install -d -m 755 $(MANDIR)
	install -d -m 755 $(MANDIR)/man1/
	install -c -m 644 foo2zjs.1 $(MANDIR)/man1/
	install -c -m 644 foo2zjs-wrapper.1 $(MANDIR)/man1/
	install -c -m 644 zjsdecode.1 $(MANDIR)/man1/
	install -c -m 644 foo2oak.1 $(MANDIR)/man1/
	install -c -m 644 foo2oak-wrapper.1 $(MANDIR)/man1/
	install -c -m 644 oakdecode.1 $(MANDIR)/man1/

doc: README INSTALL manual.pdf

install-doc: doc
	#
	# Install documentation
	#
	install -d -m 755 $(DOCDIR)
	install -c -m 644 manual.pdf $(DOCDIR)
	install -c -m 644 COPYING $(DOCDIR)
	install -c -m 644 INSTALL $(DOCDIR)
	install -c -m 644 INSTALL.osx $(DOCDIR)
	install -c -m 644 README $(DOCDIR)
	install -c -m 644 ChangeLog $(DOCDIR)

GROFF=/usr/local/test/bin/groff
GROFF=groff
manual.pdf: $(MANPAGES)
	-$(GROFF) -t -man $(MANPAGES) | ps2pdf - $@

README: README.in
	rm -f $@
	sed < $@.in > $@ \
	    -e "s@\$${URLOAK}@$(URLOAK)@" \
	    -e "s@\$${URLZJS}@$(URLZJS)@"
	chmod -w $@

INSTALL: INSTALL.in
	rm -f $@
	sed < $@.in > $@ \
	    -e "s@\$${URLOAK}@$(URLOAK)@" \
	    -e "s@\$${URLZJS}@$(URLZJS)@"
	chmod -w $@

#
#	Check db files against current foomatic to see if any changes
#	need to be made or reported.
#
MYFOODB=../foomatic/foomatic-db/db/source
checkdb:
	@for dir in driver printer opt; do \
	    for file in foomatic-db/$$dir/*.xml ; do \
		ofile=$(MYFOODB)/$$dir/`basename $$file`; \
		: echo diff -N -u $$ofile $$file; \
		if [ ! -f  $$ofile ]; then \
		    ofile=/dev/null; \
		fi; \
		diff -N -u $$ofile $$file; \
	    done \
	done

#
#	Mail my latest foomatic-db entries to Till.
#
WHO=rickr@mn.rr.com
WHO=till.kamppeter@gmx.net
maildb:
	$(MAKE) -s checkdb > patch.db
	echo "Here is a patch for the foomatic-db foo2zjs/foo2oak entries." | \
	mutt -a patch.db \
	    -s "foo2zjs/foo2oak - patch for foomatic database" $(WHO)

#
# Create tarball
#
tar:	
	HERE=`basename $$PWD`; \
	/bin/ls $(FILES) | \
	sed -e "s?^?$$HERE/?" | \
	(cd ..; tar -c -z -f $$HERE/$$HERE.tar.gz -T-)

#
# Populate the web site
#
URLOAK=http://foo2oak.rkkda.com
URLZJS=http://foo2zjs.rkkda.com
FTPSITE=~/.ncftp-website

foo2zjs.html: FRC
	rm -f $@
	HERE=`basename $$PWD`; \
	TZ=`date | cut -c 21-24`; \
	modtime() { ls --full-time $$1 | cut -c 44-67; }; \
	MODindex=`modtime $@.in`; \
	MODtarball=`modtime $$HERE.tar.gz`; \
	sed < $@.in > $@ \
	    -e "s@\$${URLOAK}@$(URLOAK)@g" \
	    -e "s@\$${URLZJS}@$(URLZJS)@g" \
	    -e "s/\$${MODindex}/$$MODindex $$TZ/" \
	    -e "s/\$${MODtarball}/$$MODtarball $$TZ/"
	chmod -w $@

foo2oak.html: FRC
	rm -f $@
	HERE=`basename $$PWD`; \
	TZ=`date | cut -c 21-24`; \
	modtime() { ls --full-time $$1 | cut -c 44-67; }; \
	MODindex=`modtime $@.in`; \
	MODtarball=`modtime $$HERE.tar.gz`; \
	sed < $@.in > $@ \
	    -e "s@\$${URLOAK}@$(URLOAK)@g" \
	    -e "s@\$${URLZJS}@$(URLZJS)@g" \
	    -e "s/\$${MODindex}/$$MODindex $$TZ/" \
	    -e "s/\$${MODtarball}/$$MODtarball $$TZ/"
	chmod -w $@

web: test tar manual.pdf webindex
	ncftpput -m -f $(FTPSITE) foo2zjs \
	    ChangeLog INSTALL manual.pdf *.tar.gz;
	cd redhat; $(MAKE) web FTPSITE=$(FTPSITE)

webt: tar manual.pdf webindex
	ncftpput -m -f $(FTPSITE) foo2zjs \
	    ChangeLog INSTALL manual.pdf *.tar.gz;
	cd redhat; $(MAKE) web FTPSITE=$(FTPSITE)

webindex: INSTALL zjsindex oakindex

zjsindex: foo2zjs.html
	ln -sf foo2zjs.html index.html
	ncftpput -m -f $(FTPSITE) foo2zjs \
	    index.html style.css arch.gif INSTALL;

oakindex: foo2oak.html
	ln -sf foo2oak.html index.html
	ncftpput -m -f $(FTPSITE) foo2oak \
	    index.html style.css archoak.gif INSTALL;

FRC:

#
#	Target for building Oak Technologies encoder/decoder (for HP1500)
#
#	This source code will not be made available unless someone sponsors
#	me to finish the work on it.
#
LIBJBGOAK	=	jbig.o jbig_tab.o
o: oakdecode foo2oak foo2oak-wrapper
	root install oakdecode foo2oak foo2oak-wrapper $(BIN)/
oakdecode: oakdecode.o $(LIBJBGOAK)
	$(CC) $(CFLAGS) oakdecode.o $(LIBJBGOAK) -o $@
foo2oak: foo2oak.o $(LIBJBGOAK)
	$(CC) $(CFLAGS) -o $@ foo2oak.o $(LIBJBGOAK)
foo2oak-wrapper: foo2oak-wrapper.in Makefile
	[ ! -f $@ ] || chmod +w $@
	sed < $@.in > $@ \
	    -e 's@^PREFIX=.*@PREFIX=$(PREFIX)@' || (rm -f $@ && exit 1)
	chmod 555 $@

SYSNAME := $(shell uname -n)
ifeq ($(SYSNAME),ipcroe.rkkda.com)
foo2oak.o: oak.h jbig.h
endif

#
# Misc
#
misc: pksm2bitcmyk

pksm2bitcmyk: pksm2bitcmyk.c
	$(CC) $(CFLAGS) pksm2bitcmyk.c -lpbm -o $@