# Makefile for kpathsea --kb@mail.tug.org.  Public domain.
# edited by A. Kakuto for W32
#
version = 6.2.3

prefix = c:/usr/local
exec_prefix = ${prefix}

bindir = ${exec_prefix}/bin

scriptdir = $(bindir)

libdir = ${exec_prefix}/lib

datadir = ${prefix}/share

includedir = ${prefix}/include

infodir = ${prefix}/info

manext = 1
mandir = ${prefix}/man/man$(manext)

texmf = c:/usr/local/share/texmf

vartexfonts = c:/var/tex/fonts

texinputdir = $(texmf)/tex
mfinputdir = $(texmf)/metafont
mpinputdir = $(texmf)/metapost
mftinputdir = $(texmf)/mft

dvips_plain_macrodir = $(texinputdir)/plain/dvips
dvilj_latex2e_macrodir = $(texinputdir)/latex/dvilj

web2cdir = $(texmf)/web2c

fontdir = $(texmf)/fonts

fmtdir = $(web2cdir)
basedir = $(fmtdir)
memdir = $(fmtdir)

texpooldir = $(web2cdir)
mfpooldir = $(texpooldir)
mppooldir = $(texpooldir)

fontnamedir = $(texmf)/fontname

dvipsdir = $(texmf)/dvips

psheaderdir = $(dvipsdir)

default_texsizes = 300:600

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)'

SHELL = sh
MAKE=make
top_srcdir = .
srcdir = .
#
# for W32TeX
#
XDEFS = -DWIN32=1 -DMAKE_KPSE_DLL=1
XDEFS2 = -DWIN32=1
#
#
#

YDEFS = -D_CRT_SECURE_NO_DEPRECATE -DEXEEXT='".exe"'

CC = cl
CFLAGS = -nologo -W3 -favor:blend -MD -O2 $(XCFLAGS)
CPPFLAGS =  $(XCPPFLAGS)
DEFS = -DHAVE_CONFIG_H $(XDEFS) $(YDEFS)
DEFS2 = -DHAVE_CONFIG_H $(XDEFS2) $(YDEFS)

LIBTOOL =

ALL_CPPFLAGS = $(DEFS) -I. -I$(srcdir) -I$(kpathsea_parent) \
  -I$(kpathsea_srcdir_parent) $(prog_cflags) $(CPPFLAGS)
ALL_CPPFLAGS2 = $(DEFS2) -I. -I$(srcdir) -I$(kpathsea_parent) \
  -I$(kpathsea_srcdir_parent) $(prog_cflags) $(CPPFLAGS)
ALL_CFLAGS = $(ALL_CPPFLAGS) $(CFLAGS) -c
ALL_CFLAGS2 = $(ALL_CPPFLAGS2) $(CFLAGS) -c
compile = $(CC) $(ALL_CFLAGS)
compile2 = $(CC) $(ALL_CFLAGS2)

.SUFFIXES:
.SUFFIXES: .c .obj # in case the suffix list has been cleared, e.g., by web2c
.c.obj:
	$(compile) $<

INSTALL = cp
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = $(INSTALL_PROGRAM)
INSTALL_DATA = ${INSTALL}
INSTALL_LIBTOOL_LIBS = INSTALL_DATA='$(INSTALL_DATA)' $(LIBTOOL) install-lib
INSTALL_LIBTOOL_PROG = INSTALL_PROGRAM='$(INSTALL_PROGRAM)' $(LIBTOOL) install-prog

# Creating hard links.
LN = ln

kpathsea_parent = ..
kpathsea_dir = $(kpathsea_parent)/kpathsea
kpathsea_srcdir_parent = $(top_srcdir)/..
kpathsea_srcdir = $(kpathsea_srcdir_parent)/kpathsea
kpathsea = $(kpathsea_dir)/kpathsealibw64.lib

AR = lib
ARFLAGS = -out:
RANLIB =

LDFLAGS =  $(XLDFLAGS)

SYSLIBS = user32.lib advapi32.lib shell32.lib

LOADLIBES = $(proglib) $(kpathsea) $(LIBS) $(XLOADLIBES)

CCLD = $(CC)
link_command = $(CCLD) -Fe$@ $(LDFLAGS) 

kpathsea_link = $(link_command)

install_headers = *.h $(srcdir)/*.h

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

liblobjs =
malloc =

library = kpathsealibw64.lib

KPATHSEA_CC = "$(CC)"

default all: kpsewhich.exe kpsestat.exe kpseaccess.exe \
             kpsereadlink.exe kpathsea.h

tex-make.exe: tex-make.c
	cl $(CFLAGS) -I.. -DWIN32=1 -DTEST -Od -Zi tex-make.c $(LOADLIBES)

kpsewhich.exe: $(kpathsea) kpsewhich.obj
	$(kpathsea_link) kpsewhich.obj $(LOADLIBES) -link /MANIFEST
	mt -manifest $@.manifest -outputresource:$@";"1

xdirtest.exe: $(kpathsea) xdirtest.obj
	$(kpathsea_link) xdirtest.obj $(LOADLIBES)

kpsewhich.obj: kpsewhich.c
	$(compile2) kpsewhich.c

xdirtest.obj: xdirtest.c
	$(compile2) xdirtest.c

kpsestat.exe: kpsestat.obj
	$(link_command) kpsestat.obj $(LOADLIBES) -link /MANIFEST
	mt -manifest $@.manifest -outputresource:$@";"1

kpsestat.obj: kpsestat.c
	$(compile2) kpsestat.c

kpseaccess.exe: access.obj
	$(link_command) access.obj $(LOADLIBES) -link /MANIFEST
	mt -manifest $@.manifest -outputresource:$@";"1

access.obj: access.c
	$(compile2) access.c

kpsereadlink.exe: readlink.obj
	$(link_command) readlink.obj $(LOADLIBES) -link /MANIFEST
	mt -manifest $@.manifest -outputresource:$@";"1

readlink.obj: readlink.c
	$(compile2) readlink.c

$(kpathsea): $(objects)
	link -DLL -out:kpathsealibw64.dll $(objects) $(SYSLIBS) /MANIFEST
	mt -manifest kpathsealibw64.dll.manifest -outputresource:kpathsealibw64.dll";"2

kpseinclude_HEADERS = $(special_headers) $(normal_headers)

# Headers treated specially when building kpathsea.h
#
special_headers = \
	config.h \
	knj.h \
	mingw32.h \
	win32lib.h

normal_headers = \
	absolute.h \
	c-ctype.h \
	c-dir.h \
	c-errno.h \
	c-fopen.h \
	c-limits.h \
	c-memstr.h \
	c-minmax.h \
	c-namemx.h \
	c-pathch.h \
	c-pathmx.h \
	c-proto.h \
	c-stat.h \
	c-std.h \
	c-unistd.h \
	cnf.h \
	concatn.h \
	debug.h \
	expand.h \
	getopt.h \
	hash.h \
	lib.h \
	line.h \
	magstep.h \
	pathsearch.h \
	proginit.h \
	progname.h \
	readable.h \
	str-list.h \
	str-llist.h \
	systypes.h \
	tex-file.h \
	tex-glyph.h \
	tex-hush.h \
	tex-make.h \
	types.h \
	variable.h \
	version.h

noinst_HEADERS = \
	db.h \
	default.h \
	fn.h \
	fontmap.h \
	tilde.h \
	xopendir.h \
	xstat.h

kpathsea.h: paths.h
	rm -f $@
	echo '/* This is a generated file */' >$@
	echo '/* collecting all public kpathsea headers. */' >>$@
	for f in config.h c-auto.h paths.h $(normal_headers); do \
	  echo "#include <kpathsea/$$f>" >>$@; \
	done

check: kpsewhich.exe
	./kpsewhich -expand-var '$$TEXMF'

# clean.mk -- cleaning.

clean::
	rm -f *.exe *.obj *.lib *.dll *.exp *~

install:
	echo Do nothing.

# End of clean.mk.
.NOEXPORT:

include depend.mk
