tentative fix for issue 3 (ex 53)
[mplib] / src / texk / kpathsea / Makefile.in
1 # $Id: Makefile.in 6449 2008-01-30 14:56:21Z martin $
2 # @configure_input@
3 # Makefile for kpathsea.  Public domain.
4 version = @KPSEVERSION@
5
6 # Add -DNO_DEBUG to disable debugging, for vanishingly better performance.
7
8 kpse_include ../make/paths.mk
9 kpse_include ../make/makevars.mk
10 kpse_include ../make/common.mk
11 kpse_include ../make/library.mk
12 kpse_include ../make/programs.mk
13 kpse_include ../make/texi.mk
14
15 @MAINT@warn_more = -Wmissing-prototypes -Wwrite-strings -Wshadow
16 @MAINT@MAKEINFO_FLAGS := $(MAKEINFO_FLAGS) --no-split
17
18 # Install these header files (except acconfig.h).
19 install_headers = *.h $(srcdir)/*.h
20
21 # Put tex-file.o first, because it's what depends on the paths, and may
22 # reduce frustration if the paths are wrong by doing it first.
23
24 objects = tex-file.lo absolute.lo atou.lo cnf.lo concat.lo concat3.lo \
25 concatn.lo db.lo debug.lo dir.lo elt-dirs.lo expand.lo extend-fname.lo \
26 file-p.lo find-suffix.lo fn.lo fontmap.lo getopt.lo getopt1.lo hash.lo \
27 kdefault.lo line.lo magstep.lo make-suffix.lo path-elt.lo \
28 pathsearch.lo proginit.lo progname.lo readable.lo rm-suffix.lo \
29 str-list.lo str-llist.lo tex-glyph.lo tex-hush.lo tex-make.lo \
30 tilde.lo truncate.lo uppercasify.lo variable.lo version.lo xbasename.lo \
31 xcalloc.lo xdirname.lo xfopen.lo xfseek.lo xftell.lo xgetcwd.lo xmalloc.lo \
32 xopendir.lo xputenv.lo xrealloc.lo xstat.lo xstrdup.lo $(liblobjs) $(malloc) \
33 error.lo filename.lo home.lo lookcmd.lo string.lo system.lo time.lo user.lo \
34 volume.lo
35 liblobjs = @LTLIBOBJS@
36
37 library = kpathsea
38
39 # We want to compile almost everything with libtool ...
40 KPATHSEA_CC = $(LIBTOOL) --mode=compile $(CC)
41 .SUFFIXES: .lo
42 .c.lo:
43         $(KPATHSEA_CC) $(ALL_CFLAGS) -DMAKE_KPSE_DLL -c $<
44
45 default all: kpsewhich kpsestat kpseaccess kpsereadlink $(library).info manfiles
46
47 kpsewhich: $(kpathsea) kpsewhich.o
48         $(kpathsea_link) kpsewhich.o $(LOADLIBES)
49
50 kpsestat: kpsestat.o
51         $(link_command) kpsestat.o
52
53 kpseaccess: access.o
54         $(link_command) access.o
55
56 kpsereadlink: readlink.o
57         $(link_command) readlink.o
58
59 $(kpathsea): $(objects)
60         $(kpathsea_link) -rpath $(libdir) -version-info 4:0:0 $(objects)
61
62 # Make variable substitutions for paths.h.
63 texmf.cnf: texmf.in texmf.sed
64         sed -f texmf.sed $(srcdir)/texmf.in >$@
65
66 # The idea is to turn each var=value into s%@var@%value%g. Seems simpler
67 # to put the substitutions in a file than to play shell quoting games.
68 texmf.sed: Makefile
69         rm -f texmf.sed
70         echo $(makevars) \
71         | tr ' ' '\012' \
72         | sed -e 's/^/s%@/' -e 's/=/@%/' -e 's/$$/%g/' \
73         >$@
74 # Insert $TEXMF in as many of the hardwired paths as possible.  We could
75 # use the slightly different rule 's%$(texmf)/%\$$TEXMF/%g' and avoid
76 # the need for the corrections below.  But if texmf.in is edited
77 # the heuristic may no longer work.
78         echo 's%$(texmf)%\$$TEXMF%g' >>$@
79 # Now we repair the damage this may have caused.  Don't replace the rhs of
80 # the TEXMFMAIN assignment itself, then we'd end up with TEXMFMAIN = $TEXMF
81 # and TEXMF = $TEXMFMAIN.  The (commented) assignment of TEXMFLOCAL is
82 # likely to have been mangled as well.
83         echo '/^ *TEXMFMAIN[ =]/s%\$$TEXMF%$(texmf)%' >>$@
84         echo '/^[% ]*TEXMFLOCAL[ =]/s%\$$TEXMF%$(texmf)%' >>$@
85         echo '/^[% ]*TEXMFDIST[ =]/s%\$$TEXMF%$(texmf)%' >>$@
86         echo '/^[% ]*VARTEXMF[ =]/s%\$$TEXMF%$(texmf)%' >>$@
87         echo '/^[% ]*TEXMFSYSVAR[ =]/s%\$$TEXMF%$(texmf)%' >>$@
88         echo '/^[% ]*TEXMFSYSCONFIG[ =]/s%\$$TEXMF%$(texmf)%' >>$@
89         echo '/^[% ]*TEXMFSYSVAR[ =]/s%$(texmf)MAIN%\$$TEXMFMAIN%' >>$@
90         echo '/^[% ]*TEXMFSYSCONFIG[ =]/s%$(texmf)MAIN%\$$TEXMFMAIN%' >>$@
91         echo '/^[% ]*TEXMFVAR[ =]/s%\$$TEXMF%$(texmf)%' >>$@
92         echo '/^[% ]*TEXMFCONFIG[ =]/s%\$$TEXMF%$(texmf)%' >>$@
93         echo '/^[% ]*TEXMFVAR[ =]/s%$(texmf)MAIN%\$$TEXMFMAIN%' >>$@
94         echo '/^[% ]*TEXMFCONFIG[ =]/s%$(texmf)MAIN%\$$TEXMFMAIN%' >>$@
95         echo '/^[% ]*TEXMFCNF[ =]/s%\$$TEXMF%$(texmf)%' >>$@
96 # And fill in the last clause of TEXMFCNF with an absolute path.
97         echo '/^ *TEXMFCNF[ =]/s%@web2c@%$(web2cdir)%' >>$@
98
99 # First null out comments and leading/trailing whitespace, then remove
100 # lines that define invalid C identifiers, then remove blank lines and
101 # lines that define lowercase values (those are never path values). Each
102 # line remaining looks like
103 # <name> = <value>
104 # (but = and surrounding spaces are optional, hence can't remove all spaces).
105 # Change this to #ifndef DEFAULT_name@#define DEFAULT_name "value"@#endif,
106 # then change the @'s to newlines (sed isn't good at multiline replacements).
107
108 # No backslash-newline escapes in the long sed replacement because that
109 # will turn into a space in the output.
110
111 # Without the $TEXMF/prefix/etc. substitutions, if the cnf file was
112 # not found, the compile-time paths would be of little use, since TEXMF
113 # (etc.) wouldn't be defined. Alternatively, we could have a way to
114 # specify compile-time default values for variables in general, but I
115 # think it's better to keep the last-resort paths as simple as possible.
116
117 # The definition of DEFAULT_TEXMF (and other variables)
118 # that winds up in the final paths.h will not be used.
119 #
120 # We don't want to rewrite paths.h when we have only changed comments
121 # in texmf.in that have no effect on paths.h, since that would cause
122 # almost everything to be rebuilt.
123 #
124 # We also replace all semicolons with colons in the paths.  Ultimately
125 # the path-splitting code should be changed to understand both.
126 $(kpathsea_dir)/paths.h: stamp-paths
127 stamp-paths: texmf.cnf
128         echo "/* paths.h: Generated from texmf.cnf. */" >paths.tmp
129         sed -e 's/%.*//' -e 's/^[       ]*//' -e 's/[   ]*$$//' texmf.cnf \
130         | grep '^[      ]*[A-Z0-9_]*[   =]' \
131         | sed '/^$$/d' \
132         | sed 's/^\([^  =]*\)[  ]*=*[   ]*\(.*\)/#ifndef DEFAULT_\1%#define DEFAULT_\1 "\2"%#endif/' \
133         | tr '%' '\012' \
134         | sed -e 's%\$$TEXMFMAIN%$(texmf)%g' \
135               -e 's%\$$TEXMF%$(texmf)%g' \
136               -e 's%\$$VARTEXFONTS%$(vartexfonts)%g' \
137               -e 's%\$$web2cdir%$(web2cdir)%g' \
138               -e 's%\$$prefix%$(prefix)%g' \
139         | sed -e 's%;%:%g' \
140         >>paths.tmp
141         @if cmp -s paths.h paths.tmp 2>/dev/null; then \
142           echo "paths.h is unchanged"; \
143         else \
144           echo "cp paths.tmp paths.h"; \
145           cp paths.tmp paths.h; \
146         fi
147         rm -f paths.tmp
148         date >stamp-paths
149
150 # Need an extra definition for this. Dependencies included below.
151 tex-file.o:
152         $(KPATHSEA_CC) -DDEFAULT_FONT_SIZES='\"$(default_texsizes)\"' $(srcdir)/tex-file.c
153
154 check: kpsewhich
155         ./kpsewhich -expand-var '$$TEXMF'
156
157 install: install-exec install-data
158 uninstall: uninstall-exec uninstall-data
159
160 install-exec: kpsewhich
161         $(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir) $(scriptdir) \
162           $(libdir) $(web2cdir)
163         if grep 'original mktexpk --' $(scriptdir)/mktexpk >/dev/null 2>&1\
164            || test ! -r $(scriptdir)/mktexpk; then \
165           $(INSTALL_SCRIPT) $(srcdir)/mktexpk $(scriptdir)/mktexpk; \
166         else true; fi
167         if grep 'original mktexmf --' $(scriptdir)/mktexmf >/dev/null 2>&1\
168            || test ! -r $(scriptdir)/mktexmf; then \
169           $(INSTALL_SCRIPT) $(srcdir)/mktexmf $(scriptdir)/mktexmf; \
170         else true; fi
171         if grep 'original mktextfm --' $(scriptdir)/mktextfm >/dev/null 2>&1\
172            || test ! -r $(scriptdir)/mktextfm; then \
173           $(INSTALL_SCRIPT) $(srcdir)/mktextfm $(scriptdir)/mktextfm; \
174         else true; fi
175         if grep 'original mktexlsr --' $(scriptdir)/mktexlsr >/dev/null 2>&1\
176            || test ! -r $(scriptdir)/mktexlsr; then \
177           $(INSTALL_SCRIPT) $(srcdir)/mktexlsr $(scriptdir)/mktexlsr; \
178         else true; fi
179 #       if grep 'original mktexfmt --' $(scriptdir)/mktexfmt > /dev/null 2>&1\
180 #          || test ! -r $(scriptdir)/mktexfmt; then \
181 #         $(INSTALL_SCRIPT) $(srcdir)/mktexfmt $(scriptdir)/mktexfmt; \
182 #       else true; fi
183         $(INSTALL_DATA) $(srcdir)/mktex.opt $(web2cdir)/mktex.opt
184         $(INSTALL_SCRIPT) $(srcdir)/mktexdir $(web2cdir)/mktexdir
185         $(INSTALL_DATA) $(srcdir)/mktexdir.opt $(web2cdir)/mktexdir.opt
186         $(INSTALL_SCRIPT) $(srcdir)/mktexnam $(web2cdir)/mktexnam
187         $(INSTALL_DATA) $(srcdir)/mktexnam.opt $(web2cdir)/mktexnam.opt
188         $(INSTALL_SCRIPT) $(srcdir)/mktexupd $(web2cdir)/mktexupd
189         $(INSTALL_LIBTOOL_LIBS) lib$(library).la $(libdir)
190         $(INSTALL_LIBTOOL_PROG) kpsewhich $(bindir)
191         $(INSTALL_PROGRAM) kpsestat $(bindir)
192         $(INSTALL_PROGRAM) kpseaccess $(bindir)
193         $(INSTALL_PROGRAM) kpsereadlink $(bindir)
194 uninstall-exec:
195         $(UNINSTALL_LIBTOOL_LIBS) $(libdir)/lib$(library).la
196         $(UNINSTALL_LIBTOOL_PROG) $(bindir)/kpsewhich
197         $(UNINSTALL_PROGRAM) $(bindir)/kpsestat
198         $(UNINSTALL_PROGRAM) $(bindir)/kpseaccess
199         $(UNINSTALL_PROGRAM) $(bindir)/kpsereadlink
200
201 install-data: texmf.cnf kpathsea.info install-man
202         $(SHELL) $(top_srcdir)/../mkinstalldirs $(texmf) $(infodir) $(web2cdir)
203         if grep 'original texmf.cnf --' $(web2cdir)/texmf.cnf >/dev/null 2>&1 \
204            || test ! -r $(web2cdir)/texmf.cnf; then \
205           $(INSTALL_DATA) texmf.cnf $(web2cdir)/texmf.cnf; \
206         else true; fi
207         test -r ./kpathsea.info || cd $(srcdir) && for i in kpathsea.i*; do \
208           $(INSTALL_DATA) $$i $(infodir)/$$i; done
209 # Should we install the headers?  They are not just system-dependent,
210 # which is bad enough, but even compiler-dependent.
211         $(SHELL) $(top_srcdir)/../mkinstalldirs $(includedir)/kpathsea
212         for f in $(install_headers); do \
213           $(INSTALL_DATA) $$f $(includedir)/kpathsea/; done
214         rm -f $(includedir)/kpathsea/acconfig.h
215         $(POST_INSTALL)
216         test -r $(infodir)/dir || $(INSTALL_DATA) $(top_srcdir)/../dir $(infodir)
217         if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
218           install-info --info-dir=$(infodir) $(infodir)/kpathsea.info; \
219         else true; fi
220
221 uninstall-data:
222         $(PRE_UNINSTALL)
223         if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
224           install-info --delete --info-dir=$(infodir) $(infodir)/kpathsea.info; \
225         else true; fi
226         $(NORMAL_UNINSTALL)
227         rm -f $(infodir)/kpathsea.i*
228 #       for f in $(install_headers); do rm -f $(includedir)/`basename $$f`; done
229
230 # distdir is used by other distributions; they define $(distdir).
231 distdir: doc $(library).dvi $(library).h
232         rm -rf $(distdir)
233         mkdir -p $(distdir)
234         ln $(ln_files) $(distdir)
235         touch *.info*
236         ln mktex* *.info* *.texi *.ftp $(library).aux $(library).cps $(distdir)
237         rm -f $(distdir)/*.1 $(distdir)/*.man
238         ln *.man $(distdir)
239         ln BUGS README.CONFIGURE HIER PROJECTS *.ac $(distdir)
240         touch kpathsea.h # to avoid .cps.h rule on Solaris
241         cd $(distdir) && rm -f paths.h
242
243 # I don't use this, but other programmers want it.  acconfig.h is an
244 # autoheader input file, not an includable C header. Bad name.
245 $(library).h: always
246         rm -f $@
247         echo '/* This is a generated file */' >$@
248         echo '/* collecting all kpathsea headers. */' >>$@
249         echo '#include <kpathsea/config.h>' >>$@
250         ls -1 *.h \
251           | grep -v '\(acconfig\|config\|kpathsea\|win32lib\)\.h' \
252           | sed -e 's,^,#include <kpathsea/,' -e s',$$,>,' >>$@
253         touch -r `ls -1t *.h | tail +2 | head -1` $@ 
254 always:
255 .PHONY: always
256
257 kpse_include ../make/config.mk
258
259 info: $(library).info
260 dvi: $(library).dvi
261
262 $(library).info: bugs.texi hier.texi install.texi unixtex.texi
263
264 @MAINT@INSTALL: install.texi
265 @MAINT@ $(MAKEINFO) $(one_info) $(MAKEINFO_FLAGS) $< -o $@
266 @MAINT@ $(top_srcdir)/../add-info-toc $@
267 @MAINT@BUGS: bugs.texi
268 @MAINT@ $(MAKEINFO) $(one_info) $(MAKEINFO_FLAGS) $< -o $@
269 @MAINT@ $(top_srcdir)/../add-info-toc $@
270 @MAINT@HIER: hier.texi
271 @MAINT@ $(MAKEINFO) $(one_info) $(MAKEINFO_FLAGS) $< -o $@
272 @MAINT@unixtex.ftp: unixtex.texi
273 @MAINT@ $(MAKEINFO) $(one_info) $(MAKEINFO_FLAGS) $< -o $@
274 @MAINT@doc: info HIER BUGS INSTALL unixtex.ftp
275
276 kpse_include ../make/clean.mk
277
278 mostlyclean::
279         rm -f kpsewhich kpsestat kpseaccess kpsereadlink *.lo
280         $(LIBTOOL) --mode=clean $(RM) lib$(library).la
281 distclean::
282         rm -f paths.h texmf.cnf texmf.sed stamp-paths
283
284 # The manual pages
285 manfiles = kpseaccess.1 kpsestat.1 kpsewhich.1 kpsereadlink.1 \
286            mktexlsr.1 mktexmf.1 mktextfm.1 mktexpk.1
287
288 kpse_include ../make/man.mk
289
290 kpse_include ../make/rdepend.mk
291 kpse_include depend.mk