1#    catdvi - get text from DVI files
2#    Copyright (C) 1999 J.H.M. Dassen (Ray) <jdassen@wi.LeidenUniv.nl>
3#    Copyright (C) 1999, 2000, 2001 Antti-Juhani Kaijanaho <gaia@iki.fi>
4#    Copyright (C) 2000-2002 Bjoern Brill <brill@fs.math.uni-frankfurt.de>
5#
6#    This program is free software; you can redistribute it and/or modify
7#    it under the terms of the GNU General Public License as published by
8#    the Free Software Foundation; either version 2 of the License, or
9#    (at your option) any later version.
10#
11#    This program is distributed in the hope that it will be useful,
12#    but WITHOUT ANY WARRANTY; without even the implied warranty of
13#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14#    GNU General Public License for more details.
15#
16#    You should have received a copy of the GNU General Public License
17#    along with this program; if not, write to the Free Software
18#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20#CC = gcc
21#CFLAGS = -Wall -W -Wshadow -Wpointer-arith -Wbad-function-cast \
22# 	-Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes \
23# 	-Wmissing-declarations -ansi -pedantic -g
24
25include config.mk
26
27ifeq ($(CFG_HAS_GETOPT_LONG),yes)
28GETOPT = # nothing
29CPPFLAGS += -DCFG_HAS_GETOPT_LONG
30else
31ifeq ($(CFG_KPATHSEA_HAS_GETOPT_LONG),yes)
32GETOPT = # nothing
33CPPFLAGS += -DCFG_KPATHSEA_HAS_GETOPT_LONG
34else
35GETOPT = getopt.c getopt1.c
36endif
37endif
38
39ifeq ($(CFG_HAS_KPATHSEA),yes)
40FINDTFM = kpathsea.o
41LDLIBS = -lkpathsea
42else
43$(error Sorry) # Implement a replacement for kpathsea.c yourself...
44endif
45
46ifeq ($(CFG_SHOW_PSE2UNIC_WARNINGS),yes)
47PSE2UNICFLAGS = # nothing
48else
49PSE2UNICFLAGS = -w
50endif
51
52programs := catdvi pse2unic adobe2h tfminfo
53tests := $(wildcard test/*.tex)
54sources := $(wildcard *.c)
55encfiles := $(wildcard enc/*.enc)
56
57all1 : $(programs) $(tests:.tex=.dvi)
58
59catdvi : bytesex.o catdvi.o fixword.o fntenc.o fontinfo.o outenc.o \
60	page.o readdvi.o regsta.o util.o glyphops.o linebuf.o\
61	density.o sparse.o pageref.o vlist.o canvas.o layout.o\
62	$(GETOPT) $(FINDTFM)
63
64# fontinfo : fontinfo.o bytesex.o util.o
65tfminfo : tfminfo.o bytesex.o fixword.o fontinfo.o util.o fntenc.o $(FINDTFM)
66
67pse2unic : pse2unic.o util.o
68
69adobe2h : adobe2h.o
70
71fntenc.o fntenc.d : $(encfiles:.enc=.h)
72
73glyphops.o glyphops.d : glyphenm.h
74
75glyphenm.h : adobe2h
76	./adobe2h > glyphenm.h
77
78config.mk : config.mk.in
79	./config.status
80
81ChangeLog :
82	CVS_RSH=ssh $(CVS2CL) -U changelog-authors -W 1200 -b --gmt -w --ignore ChangeLog
83
84.PHONY : ChangeLog
85
86clean :
87	$(RM) *.o $(programs) core tags test/*.log test/*.aux
88	$(RM) enc/*.log enc/*.aux
89	find . -name '*~' -or -name '*.bck' | xargs $(RM)
90
91distclean : clean
92	$(RM) *.d test/*.dvi test/*.log test/*.aux 1
93	$(RM) enc/*.dvi enc/*.tex
94	$(RM) glyphenm.h $(encfiles:.enc=.h)
95	$(RM) config.cache config.status config.mk version.h config.log
96	$(RM) -r $(package)-$(version)
97	$(RM) -r test/auto
98
99maintainer-clean : distclean
100	$(RM) test/*.dvi configure ChangeLog
101
102%.d: %.c
103	set -e; $(CC) -MM $(CPPFLAGS) $< | \
104	  sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
105	  [ -s $@ ] || rm -f $@
106
107test/%.dvi : test/%.tex
108	cd test && latex $(notdir $<)
109
110enc/%.h enc/%.tex : enc/%.enc pse2unic
111	./pse2unic $(PSE2UNICFLAGS) $< $(<:.enc=.h) $(<:.enc=.tex)
112
113# autogenerated documentation
114#
115enc/%.dvi : enc/%.tex
116	cd enc && latex $(notdir $<)
117
118encreports : $(encfiles:.enc=.dvi)
119
120catdvi.txt : catdvi.1
121	man -l catdvi.1 -Tascii | col -b -x > catdvi.txt
122
123catdvi.html: catdvi.1
124	troff2html -man catdvi.1 > catdvi.html
125
126# release packaging
127#
128dist : distdir=$(package)-$(version)
129dist : $(sources:.c=.d) ChangeLog
130	rm -rf $(distdir)
131	$(RM) $(distdir).tar
132	$(RM) $(distdir).tar.bz2
133	$(RM) $(distdir).tar.gz
134	mkdir $(distdir)
135	set -e ; for d in $(shell cat Manifest | xargs -l1 dirname | sort | uniq) ;\
136	do \
137	    echo -n "Making directory $(distdir)/$$d ..." ;\
138	    mkdir -p $(distdir)/$$d ;\
139	    echo "done." ;\
140	done
141	set -e ; for f in $(shell cat Manifest);\
142	do \
143	    echo -n "Copying $$f ..." ;\
144	    ln $$f $(distdir)/$$f ;\
145	    echo "done." ;\
146	done
147	tar cf $(distdir).tar $(distdir)
148	bzip2 -9k $(distdir).tar
149	gzip -9 $(distdir).tar
150
151install: catdvi
152	$(INSTALL_PROGRAM) catdvi $(bindir)/catdvi
153	$(INSTALL_DATA) catdvi.1 $(man1dir)/catdvi.1
154
155uninstall:
156	$(RM) $(bindir)/catdvi
157	$(RM) $(man1dir)/catdvi.1
158
159# For fun ;-)
160linecount :
161	rmccmt $(filter-out getopt.c getopt.h getopt1.c adobetbl.h, \
162	        $(wildcard *.c *.h)) | indent | uniq | wc -l
163
164Manifest:
165	rm -f $@.new $@.edi
166	./cvsparser.pl | ./manifest-filter.pl > $@.edi
167	sort $@.edi -o $@.new
168	mv $@.new $@
169	rm -f $@.edi
170
171.PHONY: Manifest MD5SUMS
172
173SIGN=gpg --clearsign
174MD5SUMS: Manifest
175	rm -f $@.new
176	set -e; for f in `egrep -v '^$@$$' Manifest `;\
177	     do \
178	         sum=$$(md5sum $$f | awk '{ print $$1; }'); \
179	         size=$$(ls -l $$f | awk '{ print $$5; }'); \
180	         printf "%s %5i %s\n" $$sum $$size $$f >> $@.new;\
181	     done
182	if [ "$(NOSIGN)" = "" ] ;\
183	then\
184		$(SIGN) $@.new ;\
185		rm -f $@.new ;\
186		mv $@.new.asc $@ ;\
187	else\
188		mv $@.new $@ ;\
189	fi
190
191CVSTAG=none
192official-release : VERSION=$(shell echo $(CVSTAG) \
193			           | sed -e 's/^rel_//' -e 's/_/./g')
194official-release : grbdir=catdvi-release-build
195official-release :
196	rm -rf $(grbdir)
197	set -e ;\
198	  if $$(echo $(VERSION) \
199	        | egrep '^[0-9]+\.[0-9]+(\.(pre)?[0-9]+)?$$' >/dev/null);\
200	  then\
201	      :; \
202	  else \
203	      echo "Bad VERSION"; \
204	      exit 1; \
205	  fi
206	cvs -z3 -d$(shell cat CVS/Root) checkout -r $(CVSTAG) \
207	                                         -d $(grbdir) catdvi
208	cd $(grbdir) && autoconf && ./configure
209	make -C $(grbdir) Manifest
210	make -C $(grbdir) `egrep -v '^(Manifest|MD5SUMS)$$' $(grbdir)/Manifest`
211	make -C $(grbdir) -o Manifest NOSIGN=$(NOSIGN) MD5SUMS
212	make -C $(grbdir) -o ChangeLog dist
213	ln -f $(grbdir)/catdvi-$(VERSION).tar.gz
214	ln -f $(grbdir)/catdvi-$(VERSION).tar.bz2
215	rm -rf $(grbdir)
216
217
218include $(sources:.c=.d)
219
220