#
# Makefile for bibtex8.exe and bibtexu.exe
#

programs = bibtex8.exe bibtexu.exe

default: all
all: $(programs)

ICUROOT = ../../libs/icu-src
ICU_INCLUDES = -I$(ICUROOT)/source/common \
-I$(ICUROOT)/source/i18n \
-I$(ICUROOT)/source/io

INCLUDES8 = -I. -I.. -I../kpathsea
INCLUDESU = -I. -I.. -I../kpathsea $(ICU_INCLUDES)

CPPFLAGS8 = -DWIN32=1 -DKPATHSEA=1 -DSUPPORT_8BIT=1 -DHAVE_CONFIG_H=1 \
-D_CRT_SECURE_NO_DEPRECATE=1 -DNO_KPSE_DLL=1 -J

CPPFLAGSU = -DWIN32=1 -DKPATHSEA=1 -DUTF_8=1 -DHAVE_CONFIG_H=1 \
-D_CRT_SECURE_NO_DEPRECATE=1 -DNO_KPSE_DLL=1 -J \
-DICUFORXeTeX=1

CFLAGSU = -nologo -wd4819 -O2 -MT -DTRACE=1 $(CPPFLAGSU) $(INCLUDESU)

CFLAGS8 = -nologo -O2 -MT -DTRACE=1 $(CPPFLAGS8) $(INCLUDES8)

#CFLAGSU = -nologo -Od -Zi -MT $(CPPFLAGSU) $(INCLUDESU)

#CFLAGS8 = -nologo -Od -Zi -MT $(CPPFLAGS8) $(INCLUDES8)


#
# objects for bibtex8
#
OBJS8 = bibtex-1.obj bibtex-2.obj bibtex-3.obj \
bibtex-4.obj bibtex.obj utils.obj

#
# objects for bibtexu
#
OBJSU = bibtex-1u.obj bibtex-2u.obj bibtex-3u.obj \
bibtex-4u.obj bibtexu.obj utilsu.obj

kpathsea=../kpathsea/libkpathsea.lib
LOADLIBES=$(kpathsea) user32.lib AdvAPI32.lib shell32.lib

ICU_LIBS=$(ICUROOT)/lib/icudt.lib \
$(ICUROOT)/lib/icuucommon.lib \
$(ICUROOT)/lib/icuinternational.lib

LOADLIBESU = $(kpathsea) $(ICU_LIBS) user32.lib AdvAPI32.lib shell32.lib

bibtex8.exe: $(OBJS8) $(kpathsea)
	cl -Fe$@ $(OBJS8) setargv.obj $(LOADLIBES)

bibtexu.exe: $(OBJSU) $(kpathsea) $(ICU_LIBS)
	cl -Fe$@ $(OBJSU) setargv.obj $(LOADLIBESU)

bibtex-1.obj: bibtex-1.c
	cl $(CFLAGS8) -c -Fo$@ $<

bibtex-2.obj: bibtex-2.c
	cl $(CFLAGS8) -c -Fo$@ $<

bibtex-3.obj: bibtex-3.c
	cl $(CFLAGS8) -c -Fo$@ $<

bibtex-4.obj: bibtex-4.c
	cl $(CFLAGS8) -c -Fo$@ $<

bibtex.obj: bibtex.c
	cl $(CFLAGS8) -c -Fo$@ $<

utils.obj: utils.c
	cl $(CFLAGS8) -c -Fo$@ $<

bibtex-1u.obj: bibtex-1.c
	cl $(CFLAGSU) -c -Fo$@ $<

bibtex-2u.obj: bibtex-2.c
	cl $(CFLAGSU) -c -Fo$@ $<

bibtex-3u.obj: bibtex-3.c
	cl $(CFLAGSU) -c -Fo$@ $<

bibtex-4u.obj: bibtex-4.c
	cl $(CFLAGSU) -c -Fo$@ $<

bibtexu.obj: bibtex.c
	cl $(CFLAGSU) -c -Fo$@ $<

utilsu.obj: utils.c
	cl $(CFLAGSU) -c -Fo$@ $<


install: $(programs)
	cp -p $(programs) c:/usr/local/txdir/w32tex/bin/
	cp -p bibtex8.exe c:/usr/work/edrive/wk/dist/WEB2CBIN/bin/
	cp -p bibtexu.exe c:/usr/work/edrive/wk/dist/XETEX/bin/

clean:
	rm *.obj *.exe *~
