##
# Makefile for type1.library
##

##
# Configurable Section
##

#
# Which CPU/FPU/mathlib combination?
#

# TetiSoft: scm.lib doesn't gain speed if FPU is available.
# So this lines are not used, but would work:
#
# MATHOPT   = MATH=STANDARD
# MATHLIB   = LIB:scm.lib

# TetiSoft: The IEEE Libraries work on all models and gain speed with
# coprocessor installed, but return no errors... This lines are used an work:
#
# MATHOPT   = MATH=IEEE
# MATHLIB   = LIB:scmieee.lib

# TetiSoft: The FFP Libraries work on all models, but don't gain speed with
# coprocessor installed, are less accurate than the IEEE libraries,
# and return no errors. This lines are not used, but would work:
#
# MATHOPT   = MATH=FFP
# MATHLIB   = LIB:scmffp.lib

# TetiSoft: scm881.lib works only with FPU, but is a bit faster than scmieee.lib.
# This lines are used and work:
#
# MATHOPT   = MATH=68881
# MATHLIB   = LIB:scm881.lib

# TetiSoft: The ReadMe for SAS/C 6.57 update states that scm040.lib is slower on a 040
# than scm881.lib, so this lines are not used, but would work:
#
# PROCESSOR = CPU=68040
# MATHOPT   = MATH=68881
# MATHLIB   = LIB:scm040.lib LIB:scm881.lib

# TetiSoft: The ReadMe for SAS/C 6.57 update states that code compiled with CPU=68060
# runs on 68020-68060 processors, so this lines are not used, but would work:
#
# PROCESSOR = CPU=68020
# PROCESSOR = CPU=68030
# PROCESSOR = CPU=68040

#####################################################################
# So, choose one of these groups, then delete t1.gst and call smake #
#####################################################################

#PROCESSOR = CPU=68000
#MATHOPT   = MATH=IEEE
#MATHLIB   = LIB:scmieee.lib
#TYPE1LIB  = type1.library.000

#PROCESSOR = CPU=68060
#MATHOPT   = MATH=IEEE
#MATHLIB   = LIB:scmieee.lib
#TYPE1LIB  = type1.library.020

PROCESSOR = CPU=68060
MATHOPT   = MATH=68881
MATHLIB   = LIB:scm881.lib
TYPE1LIB  = type1.library.020fpu


#
# Debugging/Optimization flags
# The first is to produce a library w/ debugging info, and w/o optimization.
#
#OPTIM = $(PROCESSOR) DEBUG=sf NOOPTIMIZE
#USERLFLAGS = SMALLCODE SMALLDATA 

# TetiSoft: Don't specify STRSECT=NEAR to verify that there are max 32 bytes
# (6 longs for lib bases in globals.c plus 2 longs for libinit) global non-const data.
# (In the meantime, the AGL array from typelist.h is also in data section,
# but it is const).
# We specify it to avoid some jmp's slink must insert since we have more than 32K code.
OPTIM = $(PROCESSOR) NODEBUG OPTIMIZE STRMERGE STRSECT=NEAR OPTTIME OPTSCHED OPTPEEP PARM=REGISTER
USERLFLAGS = SMALLCODE SMALLDATA ND


##
# Version stuff
##
VERLFLAGS = LIBVERSION 3 LIBREVISION 0


##
# Filenames
##
ASMSRCS = amisht1eexec.a fillrun.a
CSRCS = type1lib.c type1interface.c readfont.c afm.c globals.c \
	amishio.c amishmalloc.c amisht1funcs.c \
	arith.c curves.c fontfcn.c hints.c lines.c paths.c \
	regions.c scanfont.c spaces.c t1objects.c t1snap.c \
	token.c type1.c util.c

LIBOBJS = lib:libent.o lib:libinit.o
ASMOBJS = amisht1eexec.o fillrun.o
COBJS = type1lib.o type1interface.o readfont.o afm.o globals.o \
	amishio.o amishmalloc.o amisht1funcs.o \
	arith.o curves.o fontfcn.o hints.o lines.o paths.o \
	regions.o scanfont.o spaces.o t1objects.o t1snap.o \
	token.o type1.o util.o

SRCS = $(ASMSRCS) $(CSRCS)
OBJS = $(COBJS) $(ASMOBJS)
MFILE = type1.m
HDR   = t1.gst
FDFILE = type1_lib.fd


##
# Miscellaneous
##
LIBS  = $(MATHLIB) LIB:sc.lib # LIB:debug.lib LIB:small.lib
CFLAGS = NOSTACKCHECK NOCHKABORT NOICONS UTILLIB ERROR=a $(MATHOPT) $(DEBUG) $(OPTIM) # define DEBUG=0 define AMISHDEBUG=1
LFLAGS = LIBFD $(FDFILE) NOICONS MAP $(MFILE) XFHLS SWIDTH 16 PLAIN WITH LIB:utillib.with $(USERLFLAGS) $(VERLFLAGS)


##
# Rules
##
.c.o:
	sc $(CFLAGS) GST=$(HDR) $*

.a.o:
	asm -iINCLUDE: $*

$(TYPE1LIB): $(HDR) $(OBJS)
	sc $(CFLAGS) LIBCODE GST=$(HDR) globals.c # force update version string to currrent date
	slink $(LFLAGS) FROM $(LIBOBJS) $(OBJS) TO type1.library LIB $(LIBS)
	-delete $(TYPE1LIB) >NIL:
	rename type1.library $(TYPE1LIB)

$(HDR): global.h afm.h t1gst.c
	sc $(CFLAGS) NOOBJNAME MAKEGST=$(HDR) t1gst.c

readfont.o: readfont.c $(HDR)
	sc $(CFLAGS) $*

# TetiSoft: Contains external entry points, must be compiled with LIBCODE option
#
type1lib.o: type1lib.c $(HDR)
	sc $(CFLAGS) LIBCODE GST=$(HDR) $*

# TetiSoft: Contains external entry points, must be compiled with LIBCODE option
#
globals.o: globals.c $(HDR)
	sc $(CFLAGS) LIBCODE GST=$(HDR) $*

# TetiSoft: STRSECT=CODE, otherwise we exceed 32K limit
scanfont.o: scanfont.c $(HDR) encodings.h glyphlist.h
	sc $(CFLAGS) GST=$(HDR) STRSECT=CODE $*

clean:
	-delete $(OBJS) $(TYPE1LIB) $(HDR) $(MFILE)

install:
	-copy $(TYPE1LIB) libs:type1.library clone
	avail flush >NIL:
	avail flush >NIL:

distrib:
	copy $(TYPE1LIB) //Libs/ clone

##
# Dependencies
##

afm.o: afm.c $(HDR)
amishio.o: amishio.c $(HDR)
amishmalloc.o: amishmalloc.c $(HDR)
amisht1funcs.o: amisht1funcs.c $(HDR)
arith.o: arith.c $(HDR)
curves.o: curves.c $(HDR)
fontfcn.o: fontfcn.c $(HDR)
hints.o: hints.c $(HDR)
lines.o: lines.c $(HDR)
paths.o: paths.c $(HDR)
regions.o: regions.c $(HDR)
spaces.o: spaces.c $(HDR)
t1objects.o: t1objects.c $(HDR)
t1snap.o: t1snap.c $(HDR)
token.o: token.c $(HDR) digit.h tokst.h
type1.o: type1.c $(HDR)
type1interface.o: type1interface.c $(HDR)
util.o: util.c $(HDR)
