
# This file should be configured before running `make'.
# Uncomment or change the values that are relevant for your OS.

# The preferred C compiler (by default use the OS-specific default value).
# For BSD/OS, FreeBSD, Linux (all flavors), NetBSD, OpenBSD the default
# compiler is GNU C. 
# (Note please the politically correct ordering by alphabet ! :-)
#
# Use GNU C even if it's not the default compiler
#
#CC=gcc
#
# Use the standard ANSI C compiler on HP-UX even if it's not default
#
#CC=c89
CC=cl
#
# The system-dependent flags for the C compiler
#
# Default
KPLIB=../kpathsea/kpathsealib.lib

YDEFS = -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE \
-D_CRT_OBSOLETE_NO_DEPRECATE -D_SECURE_SCL=0 -wd4819

CFLAGS_SYS= -MD -O2 -nologo -DWIN32=1 -DWINDOWS=1 $(YDEFS) -I. -I..

# For GNU C
#
#CFLAGS_SYS= -O2
#
# For GNU C with long options support library (Linux etc.)
#
#CFLAGS_SYS= -O2 -D_GNU_SOURCE
#
# For GNU C on HP-UX/PA-RISC 1.1
#
#CFLAGS_SYS= -O2 -Wa,-w
#
# For the standard ANSI C on HP-UX
#
#CFLAGS_SYS= +O2 -D_HPUX_SOURCE

#
# The system-dependent libraries
#
# Defalut (for the BSD-style OSes)

LIBS_SYS=

# For SystemV (such as SCO, UnixWare, Solaris, but _NOT_ Linux or HP-UX)
#
#LIBS_SYS= -lm -lsocket

#
# The flags for C compiler for the FreeType-2 library (disabled by default). 
# This WON'T BUILD with FT2-beta8, use the FreeType release 2.0.
# http://download.sourceforge.net/freetype/freetype-2.0.tar.gz

# To enable use of the FreeType-2 library
# (if the include and lib directory do not match your installation,
# modify them), also uncomment LIBS_FT
#
CFLAGS_FT = -DUSE_FREETYPE -I../../libs/freetype/include \
-I../../libs/freetype/include/freetype

# 
# The FreeType-2 library flags (disabled by default)

LIBS_FT=../../libs/freetype/objs/freetype.lib

# To enable use of the FreeType-2 library
# (if the include and lib directory do not match your installation,
# modify them), also uncomment LIBS_FT
#
#LIBS_FT= -L/usr/local/lib -lfreetype

#
# The flags for C compiler for the Autotrace library (disabled by default). 
# USE OF THIS FEATURE IS STRONGLY DISCOURAGED, THE BUILT-IN TRACING
# (AKA VECTORIZATION) PROVIDES MUCH BETTER RESULTS.
# The tested version is 0.29a (and the fonts produced with it are
# absolutely not usable).
# http://download.sourceforge.net/autotrace/autotrace-0.29.tar.gz

CFLAGS_AT= 

# To enable use of the Autotrace library
# (if the include and lib directory do not match your installation,
# modify them), also uncomment LIBS_AT
#
#CFLAGS_AT = -DUSE_AUTOTRACE -I/usr/local/include

# 
# The Autotrace library flags (disabled by default)

LIBS_AT=

# To enable use of the Autotrace library
# (if the include and lib directory do not match your installation,
# modify them), also uncomment CFLAGS_AT
#
#LIBS_AT= -L/usr/local/lib -lautotrace

#
# Preference of front-ends if multiple parsers match a file
# (by default the build-in front-end takes preference over FreeType)

CFLAGS_PREF=

# To prefer FreeType (if enabled):
#
#CFLAGS_PREF= -DPREFER_FREETYPE

# Uncomment the second line to not compile t1asm into ttf2pt1
CFLAGS_EXTT1ASM=
#CFLAGS_EXTT1ASM= -DEXTERNAL_T1ASM

CFLAGS= $(CFLAGS_SYS) $(CFLAGS_FT) $(CFLAGS_AT) $(CFLAGS_PREF)
LIBS= $(LIBS_SYS) $(LIBS_FT) $(LIBS_AT) $(KPLIB)

# Installation-related stuff
# 
# The base dir for installation and subdirs in it
INSTDIR = c:/usr/local
# for binaries
BINDIR = $(INSTDIR)/bin
# for binaries of little general interest
LIBXDIR = $(INSTDIR)/libexec/ttf2pt1
# for scripts, maps/encodings etc.
SHAREDIR = $(INSTDIR)/share/ttf2pt1
MANDIR = $(INSTDIR)/man

# owner and group of installed files
OWNER = root
GROUP = bin

# After you have configured the Makefile, comment out the following
# definition:
#warning: docs
#	@echo >&2
#	@echo "  You have to configure the Makefile before running make!" >&2
#	@echo "(or if you are lazy and hope that it will work as is run \`make all')">&2
#	@echo >&2

DOCS=CHANGES README FONTS FONTS.hpux encodings/README other/README \
	app/X11/README app/netscape/README

SUBDIRS = app encodings maps scripts other
TXTFILES = README* FONTS* CHANGES* COPYRIGHT

MANS1=ttf2pt1.1 ttf2pt1_convert.1 ttf2pt1_x2gs.1
MANS=$(MANS1) $(MANS5)

all: ttf2pt1.exe docs mans

docs: $(DOCS)

mans: $(MANS) 

clean::
	rm -f t1asm.exe ttf2pt1.exe *.obj *~

rpm: app/RPM/Makefile app/RPM/ttf2pt1.spec

ttf2pt1.1: README.html
	scripts/html2man . . <README.html

ttf2pt1_convert.1 ttf2pt1_x2gs.1: FONTS.html
	scripts/html2man . . <FONTS.html

app/RPM/Makefile: Makefile
	sed 's/^CFLAGS_SYS.*=.*$$/CFLAGS_SYS= -O2 -D_GNU_SOURCE/;/warning:/,/^$$/s/^/#/' <Makefile >app/RPM/Makefile

app/RPM/ttf2pt1.spec: app/RPM/ttf2pt1.spec.src version.h
	sed 's/^Version:.*/Version: '`grep TTF2PT1_VERSION version.h| cut -d\" -f2`'/' <app/RPM/ttf2pt1.spec.src  >$@

t1asm.exe: t1asm.c $(LIBS)
	$(CC) $(CFLAGS) -Fet1asm.exe -DSTANDALONE t1asm.c setargv.obj $(LIBS)

ttf2pt1.obj: ttf2pt1.c ttf.h pt1.h global.h version.h
	$(CC) $(CFLAGS) -c ttf2pt1.c

pt1.obj: pt1.c ttf.h pt1.h global.h
	$(CC) $(CFLAGS) -c pt1.c

ttf.obj: ttf.c ttf.h pt1.h global.h
	$(CC) $(CFLAGS) -c ttf.c

ft.obj: ft.c pt1.h global.h
	$(CC) $(CFLAGS) -c ft.c

bdf.obj: bdf.c pt1.h global.h
	$(CC) $(CFLAGS) -c bdf.c

bitmap.obj: bitmap.c pt1.h global.h
	$(CC) $(CFLAGS) -c bitmap.c

runt1asm.obj: runt1asm.c global.h
	$(CC) $(CFLAGS) $(CFLAGS_EXTT1ASM) -c runt1asm.c

ttf2pt1.exe:	ttf2pt1.obj pt1.obj runt1asm.obj ttf.obj ft.obj bdf.obj \
                bitmap.obj $(LIBS)
	$(CC) $(CFLAGS) -Fettf2pt1.exe ttf2pt1.obj pt1.obj runt1asm.obj \
           ttf.obj ft.obj bdf.obj bitmap.obj setargv.obj $(LIBS)

CHANGES: CHANGES.html
	scripts/unhtml <CHANGES.html >CHANGES

README: README.html
	scripts/unhtml <README.html >README

encodings/README: encodings/README.html
	scripts/unhtml <encodings/README.html >encodings/README

other/README: other/README.html
	scripts/unhtml <other/README.html >other/README

app/X11/README: app/X11/README.html
	scripts/unhtml <app/X11/README.html >app/X11/README

app/netscape/README: app/netscape/README.html
	scripts/unhtml <app/netscape/README.html >app/netscape/README

FONTS: FONTS.html
	scripts/unhtml <FONTS.html >FONTS

FONTS.hpux: FONTS.hpux.html
	scripts/unhtml <FONTS.hpux.html >FONTS.hpux

install: ttf2pt1.exe
	cp -p ttf2pt1.exe c:/usr/local/txdir/w32tex/bin/
	cp -p ttf2pt1.exe c:/usr/work/edrive/wk/dist/TTF2PT1/bin/

uninstall:
	rm -f $(BINDIR)/ttf2pt1 $(BINDIR)/ttf2pt1_convert $(BINDIR)/ttf2pt1_x2gs
	rm -rf $(LIBXDIR)
	rm -rf $(SHAREDIR)
	for i in $(MANS1); do { \
		rm -f $(MANDIR)/man1/$$i $(MANDIR)/man1/$$i.gz; \
	} done
	

# targets for automatic generation of releases and snapshots

snapshot:
	scripts/mkrel snapshot

release:
	scripts/mkrel release
