summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea/win32.mak
blob: cd9fe7a6a4d65ce20f27f16871522d2652171a3e (plain)
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
################################################################################
#
# Makefile  : Web2C / Kpathsea
# Author    : Fabrice Popineau <Fabrice.Popineau@supelec.fr>
# Platform  : Win32, Microsoft VC++ 6.0, depends upon fpTeX 0.5 sources
# Time-stamp: <03/06/22 01:11:48 popineau>
#
################################################################################
root_srcdir=..\..
!ifdef DEVELOPMENT
INCLUDE=$(INCLUDE);$(root_srcdir)\texk.development
!else
INCLUDE=$(INCLUDE);$(root_srcdir)\texk
!endif

# Add -DNO_DEBUG to disable debugging, for vanishingly better performance.

USE_KPATHSEA = 1
USE_GNUW32 = 1
MAKE_KPATHSEA = 1
USE_GETURL = 1
USE_REGEX = 1
USE_GSW32 = 1
USE_INET = 1
#USE_NETWORK = 1
#USE_NETWORK2 = 1
# USE_MKTEX = 1

!include <msvc/common.mak>

kpathseadir=.

{$(root_srcdir)/libs/libgnuw32}.c{$(objdir)}.obj:
	$(compile) $<

{$(root_srcdir)/libs/regex}.c{$(objdir)}.obj:
	$(compile) $<

DEFS = $(DEFS) -DHAVE_CONFIG_H -DHAVE_GETURL \
	-DNO_MULTIPLE_EXTENSIONS -UNORMALIZED \
	-DHASH_SHARED -DHASH_MAPPING_NAME=\"$(library_prefix)_hash_mapping\"

# Put $(objdir)\tex-file.obj first, because it's what depends on the paths, and may
# reduce frustration if the paths are wrong by doing it first.

objects = $(objdir)\tex-file.obj	\
	$(objdir)\absolute.obj		\
	$(objdir)\atou.obj	 	\
	$(objdir)\cnf.obj		\
	$(objdir)\concat.obj		\
	$(objdir)\concat3.obj		\
	$(objdir)\concatn.obj		\
	$(objdir)\db.obj		\
	$(objdir)\debug.obj		\
	$(objdir)\dir.obj		\
	$(objdir)\elt-dirs.obj		\
	$(objdir)\expand.obj		\
	$(objdir)\extend-fname.obj	\
	$(objdir)\find-suffix.obj	\
	$(objdir)\fn.obj		\
	$(objdir)\fontmap.obj		\
	$(objdir)\getopt.obj		\
	$(objdir)\getopt1.obj		\
	$(objdir)\hash.obj		\
	$(objdir)\win32hash.obj		\
	$(objdir)\kdefault.obj		\
	$(objdir)\line.obj		\
	$(objdir)\magstep.obj		\
	$(objdir)\make-suffix.obj	\
	$(objdir)\path-elt.obj		\
	$(objdir)\pathsearch.obj	\
	$(objdir)\proginit.obj		\
	$(objdir)\progname.obj		\
	$(objdir)\readable.obj		\
	$(objdir)\remote.obj		\
	$(objdir)\rm-suffix.obj		\
	$(objdir)\str-list.obj		\
	$(objdir)\str-llist.obj		\
	$(objdir)\tex-glyph.obj		\
	$(objdir)\tex-hush.obj		\
	$(objdir)\tex-make.obj		\
	$(objdir)\tilde.obj		\
	$(objdir)\truncate.obj		\
	$(objdir)\uppercasify.obj	\
	$(objdir)\variable.obj		\
	$(objdir)\version.obj		\
	$(objdir)\xbasename.obj		\
	$(objdir)\xcalloc.obj		\
	$(objdir)\xdirname.obj		\
	$(objdir)\xfopen.obj		\
	$(objdir)\xfseek.obj		\
	$(objdir)\xftell.obj 		\
	$(objdir)\xgetcwd.obj		\
	$(objdir)\xmalloc.obj		\
	$(objdir)\xputenv.obj		\
	$(objdir)\xrealloc.obj		\
	$(objdir)\xstrdup.obj		\
	$(liblobjs)                     \
	$(malloc)

liblobjs = 	\
	$(objdir)\error.obj  	\
	$(objdir)\lookcmd.obj  	\
	$(objdir)\stat.obj 	\
	$(objdir)\system.obj    \
	$(objdir)\popen.obj	\
#	$(objdir)\dirent.obj	\
	$(objdir)\user.obj	\
	$(objdir)\time.obj	\
	$(objdir)\volume.obj	\
	$(objdir)\filename.obj	\
	$(objdir)\home.obj	

programs = \
	$(objdir)\kpsewhich.exe	\
	$(objdir)\kpsecheck.exe	\
	$(objdir)\kpsestat.exe	\
	$(objdir)\access.exe

default: all

all: $(objdir) $(kpathsea) $(programs) info man

lib: $(objdir) $(kpathsealib)

!ifdef KPSE_DLL
DEFS = $(DEFS) -DMAKE_KPSE_DLL

$(kpathsealib): $(objects)
	$(archive) /DEF $(objects)

$(kpathseadll): $(objects) $(objdir)\kpathsea.res $(geturllib) # $(mktexlib)
	$(link_dll) $(**) $(kpathsealib:.lib=.exp) $(conlibs)
!else
$(kpathsealib): $(objects) $(geturllib) # $(mktexlib)
	$(archive) $(**)
!endif

$(objdir)\kpsewhich.exe: $(objdir)\kpsewhich.obj $(objdir)\kpsewhich.res $(kpathsealib)
	$(link) $(**) $(conlibs)

$(objdir)\kpsecheck.exe: $(objdir)\kpsecheck.obj $(objdir)\fnmatch.obj $(gsw32lib) $(kpathsealib)
	$(link) $(**) $(conlibs)

$(objdir)\kpsestat.exe: $(objdir)\kpsestat.obj $(gnuw32lib)
	$(link) $(**) $(conlibs)

$(objdir)\access.exe: $(objdir)\access.obj
	$(link) $(objdir)\access.obj $(conlibs)

$(objdir)\kpsewhich.obj: kpsewhich.c
	$(compile) -UMAKE_KPSE_DLL kpsewhich.c

$(objdir)\kpsecheck.obj: kpsecheck.c
	$(compile) -UMAKE_KPSE_DLL kpsecheck.c

$(objdir)\kpsestat.obj: kpsestat.c
	$(compile) -UMAKE_KPSE_DLL -UKPSE_DLL kpsestat.c

$(objdir)\access.obj: access.c
	$(compile) access.c


# Make variable substitutions for paths.h.
texmf.cnf: texmf.in texmf.sed
	$(sed) -e "/^[^%]/s/:/;/g" texmf.in \
	| $(sed) -e "/^TEXMFMAIN/s/@texmf@/$$SELFAUTOPARENT\/texmf/" \
	| $(sed) -e "/^TEXMFCNF/s/\(.*\);[^;]*;\([^;]*\);@web2c@/\1;\2;@web2c@/" \
	| $(sed) -f texmf.sed \
# Better to ensure c:/TeX is choosen, instead of e:/...
#	| $(sed) -e "s%$(prefix:\=/)%c:/TeX%g" \
	>$@

# makevars.mk -- the directory names we pass.
# It's important that none of these values contain [ @%], for the sake
# of kpathsea/texmf.sed.
makevars = prefix=$(prefix) exec_prefix=$(exec_prefix) \
  bindir=$(bindir) scriptdir=$(scriptdir) libdir=$(libdir) \
  datadir=$(datadir) infodir=$(infodir) includedir=$(includedir) \
  manext=$(manext) mandir=$(mandir) \
  texmf=$(texmf) web2cdir=$(web2cdir) vartexfonts=$(vartexfonts)\
  texinputdir=$(texinputdir) mfinputdir=$(mfinputdir) mpinputdir=$(mpinputdir)\
  fontdir=$(fontdir) fmtdir=$(fmtdir) basedir=$(basedir) memdir=$(memdir) \
  texpooldir=$(texpooldir) mfpooldir=$(mfpooldir) mppooldir=$(mppooldir) \
  dvips_plain_macrodir=$(dvips_plain_macrodir) \
  dvilj_latex2e_macrodir=$(dvilj_latex2e_macrodir) \
  dvipsdir=$(dvipsdir) psheaderdir=$(psheaderdir) \
  default_texsizes="$(default_texsizes)"
# End of makevars.mk.

# The idea is to turn each var=value into s%@var@%value%g. Seems simpler
# to put the substitutions in a file than to play shell quoting games.
texmf.sed: $(win32makedir)/paths.mak
	-@$(del) texmf.sed
	@echo <<makevars.txt
$(makevars)
<<KEEP 
	type makevars.txt \
	| $(sed) -e "s%$(prefix:\=/)%$$PREFIX%g" \
	| $(sed) -e "s/ [ ]*/ /g" -e "s@\\@/@g" \
	| $(tr) " " "\012" \
	| $(sed) -e "s%$$PREFIX%$(prefix:\=/)%g" \
	| $(sed) -f $(win32seddir)/texmfsed.sed \
#	| $(sed)  -e "s/^/s%@/" -e "s/=/@%/" -e "s/$$/%/" -e "s/$$/g/" \
	> $@
# Insert $TEXMF in as many of the hardwired paths as possible.  We could
# use the slightly different rule 's%$(texmf)/%\$$TEXMF/%g' and avoid
# the need for the corrections below.  But if texmf.in is edited
# the heuristic may no longer work.
	echo s%$(texmf:\=/)%$$TEXMF%g>>$@
# Now we repair the damage this may have caused.  Don't replace the rhs of
# the TEXMFMAIN assignment itself, then we'd end up with TEXMFMAIN = $TEXMF
# and TEXMF = $TEXMFMAIN.  The (commented) assignment of TEXMFLOCAL is
# likely to have been mangled as well.
	echo /^ *TEXMFMAIN[ =]/s%\$$TEXMF%$(texmf:\=/)%>>$@
	echo /^[% ]*TEXMFLOCAL[ =]/s%\$$TEXMF%$(texmf:\=/)%>>$@
#	echo /^[% ]*TEXMF_CNF[ =]/s%\$$TEXMF%$(texmf:\=/)%>>$@
#	echo /^[% ]*TEXMFCNF[ =]/s%\$$TEXMF%$(texmf:\=/)%>>$@
# And fill in the last clause of TEXMFCNF with an absolute path.
	echo /^ *TEXMFCNF[ =]/s%@web2c@%$(web2cdir:\=/)%>>$@
	-@$(del) makevars.txt

# First null out comments and leading/trailing whitespace, then remove
# lines that define invalid C identifiers, then remove blank lines and
# lines that define lowercase values (those are never path values). Each
# line remaining looks like
# <name> = <value>
# (but = and surrounding spaces are optional, hence can't remove all spaces).
# Change this to #ifndef DEFAULT_name@#define DEFAULT_name "value"@#endif,
# then change the @'s to newlines (sed isn't good at multiline replacements).
# 
# No backslash-newline escapes in the long sed replacement because that
# will turn into a space in the output.
# 
# Without the $TEXMF/prefix/etc. substitutions, if the cnf file was
# not found, the compile-time paths would be of little use, since TEXMF
# (etc.) wouldn't be defined. Alternatively, we could have a way to
# specify compile-time default values for variables in general, but I
# think it's better to keep the last-resort paths as simple as possible.
# 
# The definition of DEFAULT_TEXMF (and other variables)
# that winds up in the final paths.h will not be used.
#
# We don't want to rewrite paths.h when we have only changed comments
# in texmf.in that have no effect on paths.h, since that would cause
# almost everything to be rebuilt.
#
# We also replace all semicolons with colons in the paths.  Ultimately
# the path-splitting code should be changed to understand both.
$(kpathseadir)/paths.h: stamp-paths
stamp-paths: texmf.cnf
	echo /* paths.h: Generated from texmf.cnf.  */ > paths.tmp
	$(sed) -e "s/%.*//" -e "s/^[ 	]*//" -e "s/[ 	]*$$//" texmf.cnf \
	| $(grep) "^[ 	]*[A-Z0-9_]*[ 	=]" \
	| $(sed) "/^$$/d" \
	| $(sed) "s/^\([^ 	=]*\)[ 	]*=*[ 	]*\(.*\)/#ifndef DEFAULT_\1@#define DEFAULT_\1 \"\2\"@#endif/" \
	| $(tr) @ "\012" \
	| $(sed) -e "s@\$$TEXMFMAIN@$(texmf:\=/)@g" \
	      -e "s@\$$TEXMF@$(texmf:\=/)@g" \
	      -e "s@\$$VARTEXFONTS@c:/tex/fonts@g" \
	      -e "s@\$$web2cdir@$(web2cdir:\=/)@g" \
	      -e "s@\$$prefix@$(prefix:\=/)@g" \
# Better to ensure c:/Program Files/TeXLive is choosen, instead of e:/...
	      -e "s@$(prefix:\=/)@c:/Program Files/TeXLive@g" \
#	| $(sed) -e "s%;%:%g" \
	>>paths.tmp
#	fc paths.h paths.tmp > nul
#	if %ERRORLEVEL% NEQ 0 \
#	  echo copying paths.tmp paths.h\
#	  & $(CP) paths.tmp paths.h
#	$(del) paths.tmp
	$(copy) paths.tmp paths.h & $(del) paths.tmp
	date /t > stamp-paths
	time /t >> stamp-paths

!include <msvc/config.mak>

# Need an extra definition for this. Dependencies included below.
$(objdir)\tex-file.obj:
	$(compile) -DDEFAULT_FONT_SIZES=\"$(default_texsizes)\" tex-file.c

check: $(objdir)\kpsewhich.exe
	.\$(objdir)\kpsewhich -expand-var $$TEXMF

install:: all install-exec install-data

install-exec::
	-@$(mkdir) $(bindir) $(libdir) $(web2cdir) 2>nul
	-@echo $(verbose) & for %i in ($(kpathseadll) $(programs)) do \
		$(copy) %i $(bindir) $(redir_stdout)

install-data:: install-info install-doc install-man kpathsea.h
# Should we install the headers?  They are not just system-dependent,
# which is bad enough, but even compiler-dependent.
	-@$(mkdir) $(includedir)\kpathsea 2>nul
	-@echo $(verbose) & for %f in (*.h) do \
	  $(copy) %f $(includedir)\kpathsea $(redir_stdout)
	-@$(del) $(includedir)\kpathsea\acconfig.h

# I don't use this, but other programmers want it.  acconfig.h is an
# autoheader input file, not an includable C header. Bad name.
kpathsea.h: always
	-@$(del) $@
	@echo off <<$@
#include <kpathsea/config.h>
<<KEEP
	dir /b *.h | grep -v "\(acconfig\|config\|kpathsea\|win32lib\|c-auto\)\.h" \
	  | $(sed) -e "s,^,#include <kpathsea/," -e s",$$,>," >>$@	  
#	touch -r `ls -1t *.h | tail +2 | head -1` $@ 
always:
.PHONY: always

# The manual pages
manfiles = access.1 kpsestat.1 kpsewhich.1 \
           mktexlsr.1 mktexmf.1 mktextfm.1 mktexpk.1

infofiles = kpathsea.info
docsubdir = kpathsea
pdfdocfiles = kpathsea.pdf
htmldocfiles = kpathsea.html

!include <msvc/install.mak>

info:	kpathsea.info
dvi:	kpathsea.dvi
ps:	kpathsea.ps

kpathsea.info: kpathsea.texi bugs.texi hier.texi install.texi unixtex.texi
	-$(makeinfo) $(makeinfo_flags) kpathsea.texi -o $@

!IFDEF MAINT
INSTALL.txt: install.texi
	$(makefinfo) $(one_info) $(MAKEINFO_FLAGS) install.texi -o $@
	$(perl) $(win32perldir)\add-info-toc.pl $@
	$(copy) $@ $(@:.txt=) $(redir_stderr)
BUGS: bugs.texi
	$(makefinfo) $(one_info) $(MAKEINFO_FLAGS) bugs.texi -o $@
	$(perl) $(win32perldir)\add-info-toc.pl $@
HIER: hier.texi
	$(makefinfo) $(one_info) $(MAKEINFO_FLAGS) hier.texi -o $@
unixtex.ftp: unixtex.texi
	$(makefinfo) $(one_info) $(MAKEINFO_FLAGS) unixtex.texi -o $@
doc: info dvi ps HIER BUGS INSTALL unixtex.ftp
!endif

!include <msvc/clean.mak>

extraclean::
	-@echo $(verbose) & ($(del) kpathsea*.html kpathsea*.pdf) 2>nul

distclean::
	-@$(del) paths.h texmf.cnf texmf.sed

!include <msvc/rdepend.mak>
!include "./depend.mak"

# Local Variables:
# mode: Makefile
# End: