1#
2# Makefile, in GNU make syntax
3# by pts@fazekas.hu at Sun Feb 24 16:20:15 CET 2002
4# Sat Apr 20 19:14:11 CEST 2002
5# ccdep.pl at Sat Jun  1 15:51:36 CEST 2002
6#
7# To clean .o files and some more, run: make clean
8# To clean all, procsets and configure outputs, run: make allclean
9# To create a .tar.gz, run: make dist-noautoconf
10# To install dist, run: make dist-install
11#
12
13# Magic to convert `make clean' to `make MAKE_DIST=x clean' so that
14# `make clean' won't depend on the file Makedep to exist.
15ifeq ($(MAKECMDGOALS),clean)
16MAKE_DIST=000
17endif
18ifeq ($(MAKECMDGOALS),allclean)
19MAKE_DIST=000
20endif
21ifeq ($(MAKECMDGOALS),dist-noautoconf)
22MAKE_DIST=000
23endif
24ifeq ($(MAKECMDGOALS),dist-install)
25MAKE_DIST=000
26endif
27ifeq ($(MAKECMDGOALS),Makedep.force)
28MAKE_DIST=000
29endif
30
31BASH=bash
32PERL_BADLANG=x
33export PERL_BADLANG
34
35CXXX=$(CXD_assert)
36LDALL=$(LDXX) -s $(LDFLAGS) $(LIBS)
37ifeq ($(ENABLE_DEBUG), no)
38CXXX=$(CXD_no)
39endif
40ifeq ($(ENABLE_DEBUG), yes)
41CXXX=$(CXD_yes)
42LDALL=$(LDXX) $(LDFLAGS) $(LIBS)
43endif
44ifeq ($(ENABLE_DEBUG), checker)
45CXXX=$(CXD_checker)
46LDALL=checkerg++ $(LDFLAGS) $(LIBS)
47endif
48
49CXXALL=$(CXXX) $(CXXFLAGS) $(CXXFLAGSB)
50CCALL =$(CXXX) $(CXXFLAGS) $(CXXFLAGSB)
51CXDFAL=$(CXXFLAGS) $(CXXFLAGSB) $(LDFLAGS) $(LIBS)
52
53.PHONY: clean dist dist-noautoconf dist-more allclean distclean dist-install
54.PHONY: most all all1 install
55
56ALL_FALLBACK=jpegdump ps_tiny sam2p test testfax
57ALL=
58# Used my Makehedep to add dependencies to .o files.
59GLOBFILES=Makefile Makehelp Makedep
60
61MAKEDEP_CMD = perl -x -S ./ccdep.pl --FAL=assert,no,yes,checker $(CXX)
62ifeq ($(MAKE_DIST),)
63  most all: sam2p  # First target, build this target by default `make'.
64  # Actually ./configure creates Makehelp as well, but by adding it to the
65  # left side below, make 3.81 would run configure twice (once for each
66  # `include' below).
67  #
68  # echo to config.h is needed to make config.h younger than config.h.in;
69  # configure doesn't change the timestamp of config.h if it's unchanged.
70  Makedep config.h: configure Makehelp.in config.h.in ccdep.pl sam2p_version.h; ./configure --enable-gif --enable-lzw && echo "" >>config.h
71  Makehelp:;
72  include Makehelp  # Defines CXX. File generated by ./configure.
73  include Makedep   # Contains ALL+=... .
74else
75  #ifeq ($(wildcard Makedep),Makedep)
76  ifeq ($(wildcard Makehelp Makedep),Makehelp Makedep)
77    # Do an `include Makedep' anyway, to get the proper value for ALL.
78    #Makehelp:;
79    Makedep:;
80    #include Makehelp  # Defines CXX. File generated by ./configure.
81    include Makedep  # Contains ALL+=... .
82  else
83    # For `make MAKE_DIST=x clean'.
84    ALL=$(ALL_FALLBACK)
85    # This forces an error for `make MAKE_DIST=x Makedep'. Just run
86    # `make Makedep' to build Makedep. We can't build it here, because we don't
87    # have Makehelp (which would be generated ./configure, but with MAKE_DIST=x
88    # we don't assume that ./configure has been run.)
89    Makedep: .Makedep.not.here.;
90  endif
91  most all:;  # `make MAKE_DIST=x' should be a no-op by default.
92endif
93
94.PHONY: Makedep.force
95# Called by ./configure
96Makedep.force: sam2p_version.h; $(MAKEDEP_CMD)
97
98all1: $(ALL)
99# vvv for Epsilon at Thu Oct 31 09:58:58 CET 2002
100IDE_MODES := release debug
101IDE_TARGETS_debug := $(patsubst %,%.yes, $(TARGETS))
102IDE_TARGETS_release := $(TARGETS)
103
104CXD_assert =$(CXX) -s -O2
105CXD_no     =$(CXX) -s -DNDEBUG -O3
106# CXD_yes    =$(CXX) $(GFLAG) -lefence
107CXD_yes    =$(CXX) $(GFLAG)
108CXD_checker=checkerg++ $(GFLAG)
109
110# .PHONY: clean dist allclean distclean
111
112SAM2P_VERSION=$(shell $(BASH) ./mkdist.sh --getversion)
113sam2p_version.h: debian/changelog mkdist.sh
114	(echo '/* Generated automatically by Makefile. */' && \
115	 echo '#ifndef SAM2P_VERSION_H' && \
116	 echo '#define SAM2P_VERSION_H 1' && \
117	 echo '#define SAM2P_VERSION "$(SAM2P_VERSION)"' && \
118	 echo '#endif') >$@
119
120xpmc.h: cols2.pl
121	perl -x ./cols2.pl >xpmc.h
122
123#HQ=perl -e'$$_=join"",<STDIN>; s@([^\w\.\/\-])@sprintf"\\%03o",ord$$1@ge; print "\"$$_\"\n"'
124HQ=perl -x ./hq.pl
125#%.tth: %.tte
126#	<$< >$@	$(HQ)
127#%.tth: %.ttm
128#	<$< >$@	$(HQ)
129%.tth: %.ttt
130	$(HQ) <$< >$@
131
132# Sun Sep 22 01:16:20 CEST 2002
133L1_LIST=l1g8z.pst l1ghz.pst l1gbz.pst \
134        l1g8l.pst l1ghl.pst l1gbl.pst
135PREPROC_STRIP=perl -ne's@/\s+(?=\w)@/@g;print if!/^\#/&&!/^\s*\Z/'
136L1_FLAGS=-DCFG_FMT_ZLIB_ONLY=1 -DNDEBUG=1 \
137  -DCFG_NO_VAR_S=1 -DUSE_NO_BIND=1 -DUSE_SHORT_NAMES=1 \
138  -DUSE_CURRENTFILE=1 -DUSE_NO_EOF=1 \
139  -DUSE_UNITLENGTH_8 -DUSE_EARLYCHANGE_1 -DUSE_LOWBITFIRST_FALSE \
140  -DUSE_NO_NULLDEF=1 -DUSE_PIN=1
141# TTT_QUOTE=perl -e '$$s=$$_=join"",<STDIN>; s@%.*@@g; s@[(][^()]*[)]@@g; die if /[()\\]/ or $$ARGV[0]!~/^(\w+)/; print "\n% TTT_QUOTE\n/$$1 ($$s)\n\n"' --
142TTT_QUOTE=perl -e '$$s=$$_=join"",<STDIN>; $$s=~s@([()\\])@\\$$1@g; die if $$ARGV[0]!~/^(\w+)/; print "\n% TTT_QUOTE\n/$$1 ($$s)\n\n"' --
143# vvv Dat: input file for `g++ -E' must have .h extension
144l1g8z.pst: l1zip.psm psmlib.psm ps_tiny
145	<$< >$@.tmp.h perl -pe0
146	$(CXX) -E $(L1_FLAGS) -DUSE_A85D=1 $@.tmp.h >$@.tmp.i
147	<$@.tmp.i >$@.tmp.pin $(PREPROC_STRIP)
148	<$@.tmp.pin >$@.tmp.ps0 ./ps_tiny
149	<$@.tmp.ps0 >$@.tmp.pst $(TTT_QUOTE) $@
150	mv -f $@.tmp.pst $@
151l1ghz.pst: l1zip.psm psmlib.psm ps_tiny
152	<$< >$@.tmp.h perl -pe0
153	$(CXX) -E $(L1_FLAGS) -DUSE_HEXD=1 $@.tmp.h >$@.tmp.i
154	<$@.tmp.i >$@.tmp.pin $(PREPROC_STRIP)
155	<$@.tmp.pin >$@.tmp.ps0 ./ps_tiny
156	<$@.tmp.ps0 >$@.tmp.pst $(TTT_QUOTE) $@
157	mv -f $@.tmp.pst $@
158l1gbz.pst: l1zip.psm psmlib.psm ps_tiny
159	<$< >$@.tmp.h perl -pe0
160	$(CXX) -E $(L1_FLAGS) -DUSE_BINARY=1 $@.tmp.h >$@.tmp.i
161	<$@.tmp.i >$@.tmp.pin $(PREPROC_STRIP)
162	<$@.tmp.pin >$@.tmp.ps0 ./ps_tiny
163	<$@.tmp.ps0 >$@.tmp.pst $(TTT_QUOTE) $@
164	mv -f $@.tmp.pst $@
165l1g8l.pst: l1lzw.psm psmlib.psm ps_tiny
166	<$< >$@.tmp.h perl -pe0
167	$(CXX) -E $(L1_FLAGS) -DUSE_A85D=1 $@.tmp.h >$@.tmp.i
168	<$@.tmp.i >$@.tmp.pin $(PREPROC_STRIP)
169	<$@.tmp.pin >$@.tmp.ps0 ./ps_tiny
170	<$@.tmp.ps0 >$@.tmp.pst $(TTT_QUOTE) $@
171	mv -f $@.tmp.pst $@
172l1ghl.pst: l1lzw.psm psmlib.psm ps_tiny
173	<$< >$@.tmp.h perl -pe0
174	$(CXX) -E $(L1_FLAGS) -DUSE_HEXD=1 $@.tmp.h >$@.tmp.i
175	<$@.tmp.i >$@.tmp.pin $(PREPROC_STRIP)
176	<$@.tmp.pin >$@.tmp.ps0 ./ps_tiny
177	<$@.tmp.ps0 >$@.tmp.pst $(TTT_QUOTE) $@
178	mv -f $@.tmp.pst $@
179l1gbl.pst: l1lzw.psm psmlib.psm ps_tiny
180	<$< >$@.tmp.h perl -pe0
181	$(CXX) -E $(L1_FLAGS) -DUSE_BINARY=1 $@.tmp.h >$@.tmp.i
182	<$@.tmp.i >$@.tmp.pin $(PREPROC_STRIP)
183	<$@.tmp.pin >$@.tmp.ps0 ./ps_tiny
184	<$@.tmp.ps0 >$@.tmp.pst $(TTT_QUOTE) $@
185	mv -f $@.tmp.pst $@
186# vvv copy the .ttt, not the .tth
187#     The perl program down there is a portable cat(1) implementation.
188bts1.ttt: bts.ttt $(L1_LIST)
189	perl -pe0 $^ >$@
190bts2.ttt: bts1.ttt ps_tiny
191	./ps_tiny --copy <$< >$@
192
193clean:
194	# Not removing sam2p_version.h, because it would trigger the rerun of ./configure at the next `make'.
195	rm -f *~ a.out DEADJOE core *.o *.tth *.tmp.pin *.tmp.i *.tmp.ps0 *.tmp.h *.tmp.pst autom4te.cache/*
196	rm -f sam2p.yes sam2p.no
197	rm -f debian/changelog.dch debian/*~
198	rm -f $(ALL) $(ALL:=.yes) $(ALL:=.no) $(ALL:=.assert) $(ALL:=.checker)
199	test ! -d autom4te.cache || rmdir autom4te.cache
200allclean: clean
201	rm -f config.h Makehelp Makedep config.cache config.log \
202	    config.status test.eps test.pdf build build-stamp \
203	    bts2.tth bts1.ttt bts2.ttt *.pst.tmp.* *.pst
204
205distclean: allclean
206	rm -f configure
207	-autoconf
208dist: distclean dist-noautoconf
209dist-noautoconf:
210	chmod 755 configure
211	$(BASH) ./mkdist.sh
212# vvv Create a distribution with more files to aid compilation
213dist-more: bts2.tth
214	$(BASH) ./mkdist.sh sam2p-more bts2.tth
215dist-install: dist-noautoconf
216	chmod 600 ../sam2p-*.tar.gz
217	scp ../sam2p-*.tar.gz kozma:public_html
218
219# Mac OS/X cp doesn't have -a, so we don't use it
220install: sam2p
221	-mkdir -p '$(bindir)'
222	cp sam2p '$(bindir)'
223	chmod 755 '$(bindir)'/sam2p
224
225# __END__ of Makefile
226