File: Makefile

package info (click to toggle)
bibclean 2.11.4-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 5,212 kB
  • ctags: 1,545
  • sloc: ansic: 10,737; makefile: 817; perl: 66; sh: 40; awk: 27; sed: 6
file content (975 lines) | stat: -rw-r--r-- 33,245 bytes parent folder | download | duplicates (10)
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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
# Generated automatically from Makefile.in by configure.
#=======================================================================
# Makefile for BibTeX .bib file prettyprinter
#
# Current target list: (these include all GNU Project standard targets)
#	all			build bibclean
#	bclproto		obsolete; build an early prototype of bibclean
#	bibclean		executable for bibclean
#	bibclean.h		documentation strings for help() function
#	bibclean.hlp		VAX VMS help file (automatically converted
#				from bibclean.txt)
#	bibclean.html		HTML version of formatted manual pages
#	bibclean.i		C preprocessor output from bibclean.c
#	bibclean.pdf		Adobe Portable Document Format version 
#				of bibclean.man
#	bibclean.ps		PostScript version of bibclean.man
#	bibclean.tar		tar archive file for ftp distribution
#	bibclean.txt		nroff'ed bibclean.man manual page file
#	bibclean.zip		Info-zip archive file for ftp distribution
#	bibclean.zoo		zoo archive file for ftp distribution
#	check			same as test (see below)
#	clean			clean up all but executables and time stamps
#	clobber			clean up everything
#	distclean		remove everything make can rebuild at remote site
#	docs			make bibclean.txt, bibclean.hlp, and bibclean.ps
#	install			install executable and man pages
#	install.time		internal target for install
#	install-exe		install executable
#	install-man		install man pages
#	install-ftp		install .tar, .zip, and .zoo files in ftp tree
#	install-ftp.time	internal target for install-ftp
#	lint			check for code problems
#	mostlyclean		same as clean
#	maintainer-clean	for program author only: remove everything
#				make can rebuild at author's site
#	romtol			build and run test program for romtol()
#	TAGS			GNU Emacs tags file
#	test			test bibclean on BibTeX and Scribe
#				bibliographies
#	test-bibtex		test 1,2,3 bibclean on BibTeX bibliographies
#	test-bibtex-1		test 1 bibclean on BibTeX bibliographies
#	test-bibtex-2		test 2 bibclean on BibTeX bibliographies
#	test-bibtex-3		test 3 ISBN and ISSN verification
#	test-scribe		test 1,2,3 bibclean on Scribe bibliographies
#	test-scribe-1		test 1 bibclean on Scribe bibliographies
#	test-scribe-2		test 2 bibclean on Scribe bibliographies
#	test-scribe-3		test 3 bibclean on Scribe bibliographies
#	test-version		test extraction of version number
#	uninstall		remove files installed by "make install"
#	uninstall-ftp		remove installed files in anonymous ftp
#				directory
#
# [01-Jul-1996] -- add targets bibclean.pdf and DISTILL macro, and update
# 		   DIST-FILES list
# [03-May-1996] -- add targets match, romtol, test-match, and test-romtol,
#		   and update DIST-FILES list for version 2.11.3 release
# [25-Apr-1996] -- add target for bibclean.html, with associated
#		   support Makefile variables
# [20-Sep-1995] -- revise to use GNU autoconf and configure
# [08-Mar-1995] -- Change TARGET to TARGETS to avoid conflict with
#		   built-in macro on Cray systems. Add -D_POSIX_SOURCE
#		   to dec-alpha-osf1-c++ CC definition to work around
#		   bug in C++ signal.h header file on OSF/1 3.x.
# [21-Nov-1994] -- add cray-el94 target
# [11-Nov-1994] -- add sun-sparc-solaris2-lcc and sun-sparc-sunos5-lcc
# 		   targets
# [18-Oct-1994] -- add isbn.[co] to file lists
# [16-Oct-1994] -- add strist.[co] to file lists
# [04-Jun-1994] -- update for version 2.10
#		   add lint target
# [31-Dec-1993] -- final polishing of Makefile for public release
#                  after TUGboat publication
# [24-Sep-1993]
#=======================================================================
#### Start of system configuration section. ####

prefix          = /usr/local
exec_prefix     = $(prefix)

bindir          = $(exec_prefix)/bin
datadir         = $(prefix)/lib
infodir         = $(prefix)/info
libdir          = $(prefix)/lib
srcdir          = .

# This setting is specific to the developer's site, and not needed elsewhere
FTPDIR		= /u/ftp/pub/tex/bib

# Need new awk (nawk) or gawk here:
AWK		= /usr/local/bin/gawk
CC              = CC
CXX             = c++
CFLAGS          = -g $(OPT)
CHARSET         = @CHARSET@
CXXFLAGS	= -g -O2 $(OPT)

DEFS            = -DHAVE_CONFIG_H

INSTALL         = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA    = @INSTALL_DATA@

LDFLAGS         = $(OPT)
LIBOBJS		=  strtol.o
LIBS            = 

OPT		=


# Where to install the manual pages.
mandir          = $(prefix)/man/man1
# Extension (not including `.') for the installed manual page filenames.
manext          = 1

#### End of system configuration section. ####

# For testing purposes, make sure we always have the same
# initialization file
BIBCLEAN	= ./bibclean -init-file bibclean.ini

BIBTEX		= bibtex

BIBTEX-TESTS	= testbib1.org testbib2.org testbib3.org testbib4.org \
		  testbib5.org testbib6.org testisxn.org testcodn.org

# This program is freely available at ftp://ftp.math.utah.edu/pub/misc/checksum-x-y.*
CHECKSUM	= checksum

CHMOD		= chmod

COMPRESS	= compress

# Use the -p flag where available to preserve file time stamps
# All known UNIX implementations have an rcp that supports -p,
# but not all have similar support in cp.
CP		= /bin/cp -p
CP		= /bin/cp
CP		= rcp -p

DIST-FILES      = ChangeLog README Makefile Makefile.in bibclean.c \
		  bibclean.h bibclean.hlp bibclean.html bibclean.ini \
		  bibclean.man bibclean.pdf bibclean.ps bibclean.reg \
		  bibclean.txt build-all.sh ch.h chek.c config.h \
		  config.hin configure configure.in configure.sed \
		  custom.h delete.h do.c fix.c fndfil.c isbn.c \
		  keybrd.c keybrd.h match.c match.dat match.h \
		  match.lok option.c pattern.h rofvms.awk romtol.c \
		  romtol.dat romtol.lok strist.c strtol.c token.h \
		  toklst.h vaxvms.c vmswild.c xctype.h xerrno.h \
		  xlimits.h xpwd.h xstat.h xstdlib.h xstring.h \
		  xtypes.h xunistd.h yesorno.h $(BIBTEX-TESTS) \
		  $(BIBTEX-TESTS:.org=.bok) $(BIBTEX-TESTS:.org=.eok) \
		  testbib2.ltx $(SCRIBE-TESTS) \
		  $(SCRIBE-TESTS:.org=.bok) $(SCRIBE-TESTS:.org=.eok) \
		  testscr2.bo2 testscr2.eo2 doc/Makefile \
		  doc/bibclean.aux doc/bibclean.bbl doc/bibclean.bib \
		  doc/bibclean.blg doc/bibclean.dvi doc/bibclean.idx \
		  doc/bibclean.ilg doc/bibclean.ind doc/bibclean.log \
		  doc/bibclean.lot doc/bibclean.ltx doc/bibclean.sok \
		  doc/bibclean.sty doc/bibclean.toc doc/is-plain.bst \
		  doc/ltugboat.sty doc/path.sty doc/texnames.sty \
		  doc/tugboat.cmn ibmpc/dos/README \
		  ibmpc/dos/msc5p1/bibclean.exe \
		  ibmpc/dos/msc5p1/config.h \
		  ibmpc/dos/msc5p1/ibmclean.bat \
		  ibmpc/dos/msc5p1/ibmtest.bat \
		  ibmpc/dos/msc5p1/msc51bld.bat \
		  ibmpc/dos/msc5p1/msc51pth.bat \
		  ibmpc/dos/msc6p0/bibclean.exe \
		  ibmpc/dos/msc6p0/bibclean.map \
		  ibmpc/dos/msc6p0/config.h \
		  ibmpc/dos/msc6p0/ibmclean.bat \
		  ibmpc/dos/msc6p0/ibmtest.bat \
		  ibmpc/dos/msc6p0/msc60bld.bat \
		  ibmpc/dos/msc6p0/msc60pth.bat \
		  ibmpc/dos/msc7p0/config.h \
		  ibmpc/dos/msc7p0/ibmclean.bat \
		  ibmpc/dos/msc7p0/ibmtest.bat \
		  ibmpc/dos/msc7p0/msc70bld.bat \
		  ibmpc/dos/msc7p0/msc70pth.bat \
		  ibmpc/dos/tcc2p0/bibclean.exe \
		  ibmpc/dos/tcc2p0/config.h \
		  ibmpc/dos/tcc2p0/ibmclean.bat \
		  ibmpc/dos/tcc2p0/ibmtest.bat \
		  ibmpc/dos/tcc2p0/tcc20bld.bat \
		  ibmpc/dos/tcc2p0/tcc20pth.bat \
		  ibmpc/dos/tcc3p0/bibclean.exe \
		  ibmpc/dos/tcc3p0/config.h \
		  ibmpc/dos/tcc3p0/ibmclean.bat \
		  ibmpc/dos/tcc3p0/ibmtest.bat \
		  ibmpc/dos/tcc3p0/tcc30bld.bat \
		  ibmpc/dos/tcc3p0/tcc30pth.bat \
		  ibmpc/dos/tpp3p0/bibclean.exe \
		  ibmpc/dos/tpp3p0/config.h \
		  ibmpc/dos/tpp3p0/ibmclean.bat \
		  ibmpc/dos/tpp3p0/ibmtest.bat \
		  ibmpc/dos/tpp3p0/tcc30pth.bat \
		  ibmpc/dos/tpp3p0/tpp30bld.bat \
		  ibmpc/dos/wat10/wcc/bibclean.exe \
		  ibmpc/dos/wat10/wcc/bibclean.map \
		  ibmpc/dos/wat10/wcc/config.h \
		  ibmpc/dos/wat10/wcc/ibmclean.bat \
		  ibmpc/dos/wat10/wcc/ibmtest.bat \
		  ibmpc/dos/wat10/wcc/watcpp.bat \
		  ibmpc/dos/wat10/wcc/watpath.bat \
		  ibmpc/dos/wat10/wcc/watwcc.bat \
		  ibmpc/dos/wat10/wcc386/bibclean.exe \
		  ibmpc/dos/wat10/wcc386/config.h \
		  ibmpc/dos/wat10/wcc386/dos4gw.doc \
		  ibmpc/dos/wat10/wcc386/dos4gw.exe \
		  ibmpc/dos/wat10/wcc386/ibmclean.bat \
		  ibmpc/dos/wat10/wcc386/ibmtest.bat \
		  ibmpc/dos/wat10/wcc386/wat10bld.bat \
		  ibmpc/dos/wat10/wcc386/watpath.bat \
		  ibmpc/dos/wat10/wpp386/bibclean.exe \
		  ibmpc/dos/wat10/wpp386/config.h \
		  ibmpc/dos/wat10/wpp386/dos4gw.doc \
		  ibmpc/dos/wat10/wpp386/dos4gw.exe \
		  ibmpc/dos/wat10/wpp386/ibmclean.bat \
		  ibmpc/dos/wat10/wpp386/ibmtest.bat \
		  ibmpc/dos/wat10/wpp386/w386cpp.bat \
		  ibmpc/dos/wat10/wpp386/watpath.bat ibmpc/linux/bibclean \
		  save/Makefile save/config.h save/configure \
		  vms/alpha/recomp.com vms/alpha/vmsclean.com \
		  vms/alpha/vmsmake.com vms/alpha/vmstest.com vms/vax/README \
		  vms/vax/bibclean.exe vms/vax/bibclean.obj vms/vax/chek.obj \
		  vms/vax/config.h vms/vax/do.obj vms/vax/fix.obj \
		  vms/vax/fndfil.obj vms/vax/getoneheader.com \
		  vms/vax/getvmsheaders.com vms/vax/isbn.obj \
		  vms/vax/keybrd.obj vms/vax/match.obj vms/vax/option.obj \
		  vms/vax/recomp.com vms/vax/romtol.obj vms/vax/strist.obj \
		  vms/vax/vaxvms.obj vms/vax/vmsclean.com vms/vax/vmsmake.com \
		  vms/vax/vmstest.com vms/vax/vmswild.obj

DISTILL		= distill

DITROFF		= ditroff	## AT&T
DITROFF		= groff		## GNU

# Some systems define HOST or HOSTNAME, but others don't, so we
# generate it at compile time with the hostname utility.
HOST		= `hostname`

# This program is freely available at ftp://ftp.math.utah.edu/pub/sgml/sp-*
HTML-NCHECK	= html-ncheck

# This program is freely available at ftp://ftp.math.utah.edu/pub/sgml/htmlpty-x.y.*
HTML-PRETTY	= html-pretty

LATEX		= latex

LINT		= lint

LINTFLAGS	= -bchx -I.

LN		= ln

# This program will not likely be available at other than the author's
# site, so the .html file is preserved unless a "make maintainer-clean"
# is done.  It may be freely distributed at some point, so if you want
# it, ask the author about its status.
MAN2HTML	= $(AWK) -f $$HOME/public_html/support/myman2html/man2html.awk

MV		= /bin/mv

NROFF		= nroff

RM		= /bin/rm -f

SCRIBE-TESTS-1	= testscr1.org testscr2.org

# Do NOT use SCRIBE-TESTS-1 in this list, because MIPS 6280 RISCos 5.0
# make then fails to correctly expand $(SCRIBE-TESTS:.org=.xyz).
SCRIBE-TESTS	= testscr1.org testscr2.org testscr3.org

SED		= /bin/sed

SHELL		= /bin/sh

SRC             = bibclean.c chek.c do.c fix.c fndfil.c isbn.c \
		  keybrd.c match.c option.c romtol.c strist.c strtol.c

STRIP		= strip

# Only the subdirectories with Makefiles are listed here
SUBDIRS		= doc

TAGS-FILES      = bibclean.c bibclean.h ch.h chek.c config.h custom.h \
		  delete.h do.c fix.c fndfil.c isbn.c keybrd.c \
		  keybrd.h match.c match.h option.c pattern.h romtol.c \
		  strist.c strtol.c token.h toklst.h vaxvms.c \
		  vmswild.c xctype.h xerrno.h xlimits.h xpwd.h xstat.h \
		  xstdlib.h xstring.h xtypes.h xunistd.h yesorno.h

UNZIP		= unzip

VERSION		= `$(AWK) '/^[ \t]*version *= *"[0-9.]+", *$$/ \
		{ gsub(/[^0-9.]/,"",$$3); print $$3 }' bibclean.c`

ZIP		= zip

ZOO		= zoo

#=======================================================================

.SUFFIXES:

.SUFFIXES: .o .i .c .bib-new .bib-old .bib

.bib.bib-new:
	-$(BIBCLEAN) <$< >$@

.bib.bib-old:
	./bclproto <$< >$@

.c.i:
	$(CC) -E -I. -I$(srcdir) $(DEFS) $(CPPFLAGS) $(CFLAGS) $< 2>&1 | \
		grep -v '^[ 	]*$$' >$@

.c.o:
	$(CC) -c -I. -I$(srcdir) $(DEFS) $(CPPFLAGS) $(CFLAGS) $<

#=======================================================================

all: bibclean

### bibclean-specific building targets ###

bibclean.dvi: bibclean.texi
	cd $(srcdir); texi2dvi bibclean.texi

bibclean.html:	bibclean.man
	-$(CHMOD) u+w $@
	$(MAN2HTML) $$PWD/$< | $(HTML-PRETTY)  -f $$PWD/$@ | $(CHECKSUM) >$@
	$(CHMOD) a-w $@
	$(HTML-NCHECK) $@

bibclean.info: bibclean.texi
	cd $(srcdir); makeinfo bibclean.texi

BIBCLEAN-OBJS   = bibclean.o chek.o do.o fix.o fndfil.o isbn.o \
		  keybrd.o match.o option.o romtol.o strist.o \
		  $(LIBOBJS)

bibclean:         $(BIBCLEAN-OBJS)
	$(CC) -o bibclean $(CFLAGS) $(BIBCLEAN-OBJS) $(LIBS)

# This target converts the option descriptions from the manual pages
# to C code for inclusion in bibclean.c.  The first awk command
# augments the bibclean.man file in a pipe with some small changes
# after the .TH line (which sets page dimensions) to get longer
# unhyphenated ragged-right lines without page headers, and reduces
# the option description indentation.
#
# Here are the magic nroff incantations:
#
# .pl 100i	set page length to 100in
# .nr LL 7.2i	set LL register (page width) to 7.2in
# .nh		no hyphenation
# .na		no right-adjusting
#
# That output feeds into nroff for formatting, col for removal of
# underlining and escape sequences, expand for tab removal, sed to
# backslash all quotes, and a final awk step to select the lines
# between OPTIONS and ERROR headers for conversion to C code.

bibclean.h:	bibclean.man
	-$(RM) $@
	echo '/* WARNING: Do NOT edit this file.  It was created automatically'\
		>$@
	echo '   with the command "make bibclean.h" by '$$USER@`hostname` \
		>>$@
	echo '   in '$$PWD' on '`date`' */' >>$@
	echo >>$@
	$(AWK) '{ if ($$0 ~ /^.TH/) \
		printf("%s\n.pl 100i\n.nr LL 7.2i\n.nh\n.na",$$0); \
	    else if ($$0 ~ /^.TP .*remove-OPT-prefixes.*/) \
		print ".TP 1in"; \
	    else \
			print $$0}' <bibclean.man | \
	$(NROFF) -man | col -b | expand | $(SED) -e 's/"/\\"/g' | \
		$(SED) -e 's/\\n/|n/g' -e 's/\\"/|"/g' \
			-e 's/\\/\\\\/g' -e 's/|n/\\n/g' -e 's/|"/\\"/g' | \
		$(AWK) '/^OPTION/,/^ERROR/ {if ($$0 !~ /^[A-Z]/) \
			printf("\t\"%s\\n\",\n",substr($$0,6))}' >>$@
	echo '	(const char*)NULL,' >>$@

# VAX VMS help file format from bibclean.txt
bibclean.hlp:	bibclean.txt rofvms.awk
	$(AWK) -f rofvms.awk <bibclean.txt >bibclean.hlp

bibclean.i:	bibclean.c ch.h config.h custom.h delete.h keybrd.h \
		match.h pattern.h token.h toklst.h xctype.h \
		xlimits.h xstdlib.h xstring.h xtypes.h xunistd.h \
		Makefile

bibclean.o:     bibclean.c ch.h config.h custom.h delete.h keybrd.h \
		match.h pattern.h token.h toklst.h xctype.h \
		xlimits.h xstdlib.h xstring.h xtypes.h xunistd.h

bibclean.pdf:	bibclean.ps
	$(DISTILL) bibclean.ps

bibclean.ps:	bibclean.man
	$(DITROFF) -Tps -man $? >$@

bibclean.tar:	subdist $(DIST-FILES)
	-$(RM) bibclean.tar bibclean.tar-lst
	tar chf bibclean.tar $(DIST-FILES)
	-mkdir bibclean-$(VERSION)
	cd bibclean-$(VERSION); tar xf ../bibclean.tar
	tar cf bibclean-$(VERSION).tar bibclean-$(VERSION)
	-$(RM) -r bibclean-$(VERSION)
	-$(RM) bibclean.tar
	$(LN) bibclean-$(VERSION).tar bibclean.tar

bibclean.txt:	bibclean.man
	$(NROFF) -man bibclean.man | col -b | expand >$@

bibclean.zip:	subdist $(DIST-FILES)
	-$(RM) bibclean*.zip
	-$(RM) bibclean*.zip-lst
	$(ZIP) bibclean-$(VERSION).zip $(DIST-FILES)
	$(UNZIP) -v bibclean-$(VERSION).zip >bibclean-$(VERSION).zip-lst
	$(LN) bibclean-$(VERSION).zip bibclean.zip

bibclean.zoo:	subdist $(DIST-FILES)
	-$(RM) bibclean*.zoo
	-$(RM) bibclean*.zoo-lst
	$(ZOO) a bibclean-$(VERSION).zoo $(DIST-FILES)
	$(ZOO) v bibclean-$(VERSION).zoo >bibclean-$(VERSION).zoo-lst
	$(LN) bibclean-$(VERSION).zoo bibclean.zoo

clean:
	-$(RM) $(BIBTEX-TESTS:.org=.bib)
	-$(RM) $(SCRIBE-TESTS:.org=.bib)
	-$(RM) *.aux
	-$(RM) *.bbl
	-$(RM) *.blg
	-$(RM) *.dvi
	-$(RM) *.err
	-$(RM) *.i
	-$(RM) *.log
	-$(RM) *.o
	-$(RM) *~
	-$(RM) \#*
	-$(RM) bibclean.tar bibclean-?.??.tar
	-$(RM) bibclean.tar-lst
	-$(RM) bibclean-$(VERSION).tar
	-$(RM) bibclean.zip bibclean-?.??.zip
	-$(RM) bibclean.zip-lst bibclean-?.??.zip-lst
	-$(RM) bibclean.zoo bibclean-?.??.zoo
	-$(RM) bibclean.zoo-lst bibclean-?.??.zoo-lst
	-$(RM) configure.tmp
	-$(RM) core
	-$(RM) match match.lst
	-$(RM) romtol romtol.lst
	-$(RM) testcodn.bib
	-$(RM) testisxn.bib
	-$(RM) testscr2.bi2 testscr2.er2
	-for d in $(SUBDIRS) ; do (cd $$d ; make clean ) ; done

clobber:	clean
	-$(RM) bclproto bibclean match
	-$(RM) bibclean.hlp
	-$(RM) bibclean.ps
	-$(RM) bibclean.txt
	-$(RM) install.time install-ftp.time
	-for d in $(SUBDIRS) ; do (cd $$d ; make clobber ) ; done

docs:	bibclean.txt bibclean.hlp bibclean.ps

chek.i:		chek.c config.h custom.h match.h token.h xctype.h \
		xstat.h xstring.h yesorno.h Makefile

chek.o:		chek.c config.h custom.h match.h token.h xctype.h \
		xstat.h xstring.h yesorno.h

do.i:		do.c ch.h config.h custom.h delete.h keybrd.h \
		match.h pattern.h token.h toklst.h xctype.h \
		xstdlib.h xstring.h xunistd.h yesorno.h Makefile

do.o:		do.c ch.h config.h custom.h delete.h keybrd.h \
		match.h pattern.h token.h toklst.h xctype.h \
		xstdlib.h xstring.h xunistd.h yesorno.h

fix.i:		fix.c config.h custom.h token.h xctype.h xstring.h \
		yesorno.h Makefile

fix.o:		fix.c config.h custom.h token.h xctype.h xstring.h \
		yesorno.h

fndfil.i:	fndfil.c config.h custom.h xctype.h xpwd.h xstdlib.h \
		xstring.h xunistd.h Makefile

fndfil.o:	fndfil.c config.h custom.h xpwd.h xstdlib.h \
		xstring.h xunistd.h

isbn.i:		isbn.c config.h custom.h xctype.h xstring.h xstdlib.h \
		Makefile

isbn.o:		isbn.c config.h custom.h xctype.h xstring.h xstdlib.h

keybrd.i:	ch.h config.h custom.h xstring.h xunistd.h yesorno.h \
		Makefile

keybrd.o:	ch.h config.h custom.h xctype.h xstring.h xunistd.h yesorno.h

# Build a test program for match()
match:	match.c romtol.o
	-$(RM) match.O
	if [ -f match.o ] ; then $(MV) match.o match.O ; fi
	-$(RM) match.o
	$(CC) -I. -I$(srcdir) $(DEFS) $(CPPFLAGS) $(CFLAGS) -DTEST -o match \
		match.c romtol.o
	-$(RM) match.o
	if [ -f match.O ] ; then $(MV) match.O match.o ; fi


match.i:	match.c config.h custom.h match.h xctype.h xstdlib.h \
		xstring.h Makefile

match.o:	match.c config.h custom.h match.h xctype.h xstdlib.h \
		xstring.h

mostlyclean:	clean
	-for d in $(SUBDIRS) ; do (cd $$d ; make mostlyclean ) ; done

option.i:	option.c bibclean.h ch.h config.h custom.h xstdlib.h \
		xstring.h yesorno.h Makefile

# When HOST, USER, __DATE__, and __TIME__ are available,
# bibclean preserves them for its version output
option.o:	option.c bibclean.h ch.h config.h custom.h xstdlib.h \
		xstring.h yesorno.h
	$(CC) -I. -I$(srcdir) $(CFLAGS) -c -DHOST=\"$(HOST)\" -DUSER=\"$(USER)\" option.c

# Build a test program for romtol()
romtol:	romtol.c
	-$(RM) romtol.O
	if [ -f romtol.o ] ; then $(MV) romtol.o romtol.O ; fi
	-$(RM) romtol.o
	$(CC) -I. -I$(srcdir) $(DEFS) $(CPPFLAGS) $(CFLAGS) -DTEST -o romtol romtol.c
	-$(RM) romtol.o
	if [ -f romtol.O ] ; then $(MV) romtol.O romtol.o ; fi

romtol.i:	romtol.c config.h custom.h xctype.h xstring.h xstdlib.h \
		Makefile

romtol.o:	romtol.c config.h custom.h xctype.h xstring.h xstdlib.h

strist.i:	strist.c config.h custom.h xctype.h xstring.h Makefile

strist.o:	strist.c config.h custom.h xctype.h xstring.h

strtol.i:	strtol.c config.h custom.h xctype.h xstdlib.h xstring.h \
		Makefile

strtol.o:	strtol.c config.h custom.h xctype.h xstdlib.h xstring.h

# Subdirectory makes needed for distribution file creation
subdist:
	-for d in $(SUBDIRS) ; do (cd $$d ; make ) ; done

#=======================================================================
### targets required by GNU Coding standards ###

Makefile: Makefile.in config.status
	./config.status

config.status: configure
	$(srcdir)/configure --srcdir=$(srcdir) --no-create

configure: configure.in configure.sed
	cd $(srcdir); autoconf
# Apply needed fixup for C++ with configure
	mv configure configure.tmp
	$(SED) -f configure.sed <configure.tmp >configure
	-$(RM) configure.tmp
	$(CHMOD) +x configure

distclean: clobber
	-$(RM) Makefile
	-$(RM) config.status
	-$(RM) config.cache
	-for d in $(SUBDIRS) ; do (cd $$d ; make distclean ) ; done

maintainer-clean: distclean
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."
	-$(CHMOD) u+w bibclean.html
	-$(RM) bibclean.html
	-$(RM) bibclean.pdf
	-$(RM) TAGS
	-$(RM) configure
	-for d in $(SUBDIRS) ; do (cd $$d ; make maintainer-clean ) ; done

TAGS:	Makefile $(TAGS-FILES)
	cd $(srcdir); etags $(TAGS-FILES)

#=======================================================================

install:	install.time

install.time:	install-exe install-man
	touch install.time

install-exe:	bibclean
	if test -f $(bindir)/bibclean ; \
	then \
		$(MV) $(bindir)/bibclean $(bindir)/bibclean.old ; \
	fi
	-$(RM) $(bindir)/bibclean-$(VERSION)
	$(CP) bibclean $(bindir)/bibclean
	-$(STRIP) $(bindir)/bibclean
	$(LN) $(bindir)/bibclean $(bindir)/bibclean-$(VERSION)
	$(CHMOD) 775 $(bindir)/bibclean
	$(CP) bibclean.ini $(bindir)/.bibcleanrc
	$(CHMOD) 664 $(bindir)/.bibcleanrc

install-man:	bibclean.man
	if test -f $(mandir)/bibclean.$(manext) ; \
	then \
		$(MV) $(mandir)/bibclean.$(manext) $(mandir)/bibclean.old.$(manext) ; \
	fi
	$(CP) bibclean.man $(mandir)/bibclean.$(manext)
	-$(RM) $(mandir)/../cat$(manext)/bibclean.$(manext)
	-$(RM) $(mandir)/bibclean-$(VERSION).$(manext)
	$(LN) $(mandir)/bibclean.$(manext) $(mandir)/bibclean-$(VERSION).$(manext)
	$(CHMOD) 664 $(mandir)/bibclean.$(manext)

install-ftp:	install-ftp.time

install-ftp.time:	bibclean.tar bibclean.zip bibclean.zoo
	tar tvf bibclean-$(VERSION).tar >$(FTPDIR)/bibclean-$(VERSION).tar-lst
	$(COMPRESS) <bibclean-$(VERSION).tar \
		>$(FTPDIR)/bibclean-$(VERSION).tar.gz
	$(CP) bibclean-$(VERSION).zip $(FTPDIR)
	$(CP) bibclean-$(VERSION).zip-lst $(FTPDIR)
	$(CP) bibclean-$(VERSION).zoo $(FTPDIR)
	$(CP) bibclean-$(VERSION).zoo-lst $(FTPDIR)
	ls -l $(FTPDIR)/bibclean*
	date >install-ftp.time

lint:
	$(LINT) $(LINTFLAGS) $(SRC)

test check:	test-match test-romtol test-bibtex test-scribe

# Test bibclean on Part 1 of the Reduce bibliography, testbib2.org.  The
# output file, testbib2.bib, is compared against a correct output file,
# testbib2.bok, from the author's site, and then the bibliography is
# additionally tested by LaTeX and BibTeX.

test-bibtex:	bibclean test-bibtex-1 test-bibtex-2 test-bibtex-3 \
		test-bibtex-4 test-bibtex-5 test-bibtex-6 test-bibtex-7 \
		test-bibtex-8

test-bibtex-1:	bibclean testbib1.org
	@echo
	@echo "==================== begin BibTeX test 1 ====================="
	@echo
	-@$(RM) testbib1.err testbib1.bib
	@echo
	-$(BIBCLEAN) testbib1.org >testbib1.bib 2>testbib1.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib1.bok testbib1.bib"
	-@if diff testbib1.bok testbib1.bib ; then $(RM) testbib1.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib1.eok testbib1.err"
	-@if diff testbib1.eok testbib1.err ; then $(RM) testbib1.err ; fi
	@echo
	@echo "===================== end BibTeX test 1 ======================"
	@echo

test-bibtex-2:	bibclean testbib2.org
	@echo
	@echo "==================== begin BibTeX test 2 ====================="
	@echo
	@-$(RM) testbib2.aux testbib2.bbl testbib2.bib testbib2.blg \
		testbib2.dvi testbib2.log
	@echo
	-$(BIBCLEAN) -no-check-values testbib2.org >testbib2.bib 2>testbib2.err
	@echo
	@echo "There should be no differences found:"
	-diff testbib2.bok testbib2.bib
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib2.eok testbib2.err"
	-@if diff testbib2.eok testbib2.err ; then $(RM) testbib2.err ; fi
	@echo
	$(LATEX) testbib2.ltx >/dev/null
	@echo
	@echo "Expect 6 BibTeX warnings:"
	-$(BIBTEX) testbib2
	@if cmp testbib2.bok testbib2.bib 2>/dev/null ; \
		then $(RM) testbib2.bib ; fi
	@echo
	$(LATEX) testbib2.ltx >/dev/null
	@echo
	$(LATEX) testbib2.ltx
	@echo
	@echo "===================== end BibTeX test 2 ======================"
	@echo

test-bibtex-3:	bibclean testbib3.org
	@echo
	@echo "==================== begin BibTeX test 3 ====================="
	@echo
	@-$(RM) testbib3.bib testbib3.err
	@echo
	-$(BIBCLEAN) -fix-font-change testbib3.org >testbib3.bib 2>testbib3.err
	@echo
	@echo "There should be no differences found:"
	-@if diff testbib3.bok testbib3.bib ; then $(RM) testbib3.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib3.eok testbib3.err"
	-@if diff testbib3.eok testbib3.err ; then $(RM) testbib3.err ; fi
	@echo
	@echo "===================== end BibTeX test 3 ======================"
	@echo

test-bibtex-4:	bibclean testbib4.org
	@echo
	@echo "==================== begin BibTeX test 4 ====================="
	@echo
	@-$(RM) testbib4.bib testbib4.err
	@echo
	-$(BIBCLEAN) -fix-font-change testbib4.org >testbib4.bib 2>testbib4.err
	@echo
	@echo "There should be no differences found:"
	-@if diff testbib4.bok testbib4.bib ; then $(RM) testbib4.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib4.eok testbib4.err"
	-@if diff testbib4.eok testbib4.err ; then $(RM) testbib4.err ; fi
	@echo
	@echo "===================== end BibTeX test 4 ======================"
	@echo

test-bibtex-5:	bibclean testbib5.org
	@echo
	@echo "==================== begin BibTeX test 5 ====================="
	@echo
	@-$(RM) testbib5.bib testbib5.err
	@echo
	-$(BIBCLEAN) -German-style testbib5.org >testbib5.bib 2>testbib5.err
	@echo
	@echo "There should be no differences found:"
	-@if diff testbib5.bok testbib5.bib ; then $(RM) testbib5.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib5.eok testbib5.err"
	-@if diff testbib5.eok testbib5.err ; then $(RM) testbib5.err ; fi
	@echo
	@echo "===================== end BibTeX test 5 ======================"
	@echo

test-bibtex-6:	bibclean testbib6.org
	@echo
	@echo "==================== begin BibTeX test 6 ====================="
	@echo
	-$(BIBCLEAN) testbib6.org >testbib6.bib 2>testbib6.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib6.bok testbib6.bib"
	-@if diff testbib6.bok testbib6.bib ; then $(RM) testbib6.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib6.eok testbib6.err"
	-@if diff testbib6.eok testbib6.err ; then $(RM) testbib6.err ; fi
	@echo
	@echo "===================== end BibTeX test 6 ======================"
	@echo

# Test bibclean verification of ISBN and ISSN values.  The test file,
# testisxn.org, contains several hundred correct values, and also
# several hundred erroneous values.  We therefore discard error and
# warning messages, we ignore the return code, and we don't try to use
# the output with LaTeX or BibTeX.
test-bibtex-7:	bibclean testisxn.org
	@echo
	@echo "==================== begin BibTeX test 7 ====================="
	@echo
	-$(BIBCLEAN) testisxn.org >testisxn.bib 2>testisxn.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testisxn.bok testisxn.bib"
	-@if diff testisxn.bok testisxn.bib ; then $(RM) testisxn.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testisxn.eok testisxn.err"
	-@if diff testisxn.eok testisxn.err ; then $(RM) testisxn.err ; fi
	@echo
	@echo "===================== end BibTeX test 7 ======================"
	@echo

# Test bibclean verification of CODEN values.  The test file,
# testcodn.org, contains about 1200 correct values, and also several
# hundred erroneous values.  We therefore discard error and warning
# messages, we ignore the return code, and we don't try to use the
# output with LaTeX or BibTeX.
test-bibtex-8:	bibclean testcodn.org
	@echo
	@echo "==================== begin BibTeX test 8 ====================="
	@echo
	-$(BIBCLEAN) testcodn.org >testcodn.bib 2>testcodn.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testcodn.bok testcodn.bib"
	-@if diff testcodn.bok testcodn.bib ; then $(RM) testcodn.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testcodn.eok testcodn.err"
	-@if diff testcodn.eok testcodn.err ; then $(RM) testcodn.err ; fi
	@echo
	@echo "===================== end BibTeX test 8 ======================"
	@echo

test-match:	match
	@echo
	@echo "===================== begin match test ======================="
	@echo
	./match <match.dat >match.lst
	@echo "There should be no differences found:"
	diff match.lok match.lst
	@if cmp match.lok match.lst 2>/dev/null ; then $(RM) match.lst ; fi
	@echo
	@echo "====================== end match test ========================"
	@echo

test-romtol:	romtol
	@echo
	@echo "===================== begin romtol test ======================"
	@echo
	./romtol <romtol.dat >romtol.lst
	@echo "There should be no differences found:"
	diff romtol.lok romtol.lst
	@if cmp romtol.lok romtol.lst 2>/dev/null ; then $(RM) romtol.lst ; fi
	@echo
	@echo "====================== end romtol test ======================="
	@echo

# Test bibclean on a collection of Scribe bibliographies containing
# test cases to exhibit variations in Scribe bibliography syntax.

test-scribe:	bibclean test-scribe-1 test-scribe-2 test-scribe-3

# The peculiar step using tr to prepare the .aux files is needed to
# overcome inconsistencies in the handling of backslashes by the IBM
# RS/6000 shell.  The documented behavior in the SunOS 4.1.1 manual
# pages is (emphasis mine):
#     All characters enclosed between a pair of single quote marks
#     (''), except a single quote, are quoted by the shell.  BACKSLASH
#     HAS NO SPECIAL MEANING INSIDE A PAIR OF SINGLE QUOTES.  A single
#     quote may be quoted inside a pair of double quote marks (for
#     example, "'").
# On SunOS, HP UX, IBM 3090 AIX, NeXT Mach, and SGI IRIX, the shells
# csh, sh, bash, and ksh agree with this.  However, on IBM RS/6000
# AIX 3.2, backslashes in single quotes are untouched by csh, but
# expanded by sh and ksh.  This is clearly a bug, because the INFO
# hypertext node on bsh/rsh says:
#     All characters, except the enclosing single quotation marks, are
#     taken literally, with any special meaning removed.
#
test-scribe-1:	bibclean $(SCRIBE-TESTS-1)
	@echo
	@echo "==================== begin Scribe test 1 ====================="
	@echo
	-@for f in $(SCRIBE-TESTS-1) ; \
	do \
		BASENAME=`basename $$f .org` ; \
		echo ; \
		echo "----------------------------------------------------" ; \
		echo ; \
		echo "$(BIBCLEAN) -scribe -no-check $$f >$$BASENAME.bib" ; \
		$(BIBCLEAN) -scribe -no-check $$f >$$BASENAME.bib \
			2>$$BASENAME.err; \
		echo ; \
		echo "There should be no differences found:" ; \
		echo "diff $$BASENAME.bok $$BASENAME.bib" ; \
		diff $$BASENAME.bok $$BASENAME.bib ; \
		echo ; \
		echo "There should be no differences found:" ; \
		echo "diff $$BASENAME.eok $$BASENAME.err" ; \
		if diff $$BASENAME.eok $$BASENAME.err ; \
			then $(RM) $$BASENAME.err ; fi ; \
		echo ; \
		echo 'Bbibstyle{plain}NBcitation{*}NBbibdata{'$$BASENAME'}' | \
			tr BN '\134\012' >$$BASENAME.aux ; \
		if [ "$$BASENAME" = "testscr1" ] ; \
			then echo "Expect 5 BibTeX warnings" ; fi ; \
		if [ "$$BASENAME" = "testscr2" ] ; \
			then echo "There should be no BibTeX warnings:" ; fi ; \
		echo "$(BIBTEX) $$BASENAME" ; \
		$(BIBTEX) $$BASENAME; \
		if cmp $$BASENAME.bok $$BASENAME.bib 2>/dev/null ; \
			then $(RM) $$BASENAME.bib ; fi ; \
	done
	@echo "===================== end Scribe test 1 ======================"
	@echo

test-scribe-2:	bibclean testscr2.org
	@echo
	@echo "==================== begin Scribe test 2 ====================="
	@echo
	-$(BIBCLEAN) -scribe -file -no-check testscr2.org \
		>testscr2.bib 2>testscr2.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr2.bok testscr2.bib"
	-@if diff testscr2.bok testscr2.bib ; then $(RM) testscr2.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr2.eok testscr2.err"
	-@if diff testscr2.eok testscr2.err ; then $(RM) testscr2.err ; fi
	@echo
	@echo
	-$(BIBCLEAN) -scribe -file -no-check -no-par testscr2.org \
		>testscr2.bi2 2>testscr2.er2
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr2.bo2 testscr2.bi2"
	-@if diff testscr2.bo2 testscr2.bi2 ; then $(RM) testscr2.bi2 ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr2.eo2 testscr2.er2"
	-@if diff testscr2.eo2 testscr2.er2 ; then $(RM) testscr2.er2 ; fi
	@echo
	@echo "===================== end Scribe test 2 ======================"
	@echo

test-scribe-3:	bibclean testscr3.org
	@echo
	@echo "==================== begin Scribe test 3 ====================="
	@echo
	-$(BIBCLEAN) -scribe -no-check testscr3.org >testscr3.bib 2>testscr3.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr3.bok testscr3.bib"
	-@if diff testscr3.bok testscr3.bib ; then $(RM) testscr3.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr3.eok testscr3.err"
	-@if diff testscr3.eok testscr3.err ; then $(RM) testscr3.err ; fi
	@echo
	@echo "===================== end Scribe test 3 ======================"
	@echo

test-version:	Makefile
	@echo "Version number is ""'"$(VERSION)"'"

uninstall:
	-$(RM) $(bindir)/bibclean $(bindir)/bibclean-$(VERSION) \
		$(bindir)/.bibcleanrc \
		$(mandir)/bibclean.$(manext) \
		$(mandir)/bibclean-$(VERSION).$(manext) \
		$(mandir)/../cat$(manext)/bibclean.$(manext) \
		$(mandir)/../cat$(manext)/bibclean-$(VERSION).$(manext)
	-$(RM) install.time

uninstall-ftp:
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).tar
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).tar-lst
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).zip
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).zip-lst
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).zoo
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).zoo-lst
	-$(RM) install-ftp.time

# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT: