# Makefile for ctex/lib (C-TeX library routines)
#

# DEST is where to install the library for programs outside the Raster Toolkit.
# RI is the include directory for RLE files.
# TI is the include directory for C-TeX stuff
DEST = ../../../lib
RI = ../../include
TI = ../h

# Alas, -R makes ALL initialised variables read-only, and we cannot
# use it on font files; hence, FCFLAGS.
IFLAGS= -I$(TI)
CFLAGS=	-O -R $(IFLAGS) $(DFLAGS)
FCFLAGS=-O $(IFLAGS) $(DFLAGS)

# System V make pays attention to the SHELL environment variable. Override it.
SHELL = /bin/sh

# Lint option for creating a lint library
# 4.3bsd:
LINTLIBOPT= -C$(LIBABBR)
# HPUX (and other SYS V?):
# LINTLIBOPT= -o $(LIBABBR)

# This will be overridden by ../Makefile, but just in case...
CONFFILE=/usr/local/lib/tex/fontdesc

# 4.1BSD Vax:
#ASSRC=	bcopy.s bzero.s
#ASOBJ=	bcopy.o bzero.o
#MISCC=
#MISCO=

# 4.2BSD Vax:
#ASSRC=
#ASOBJ=
#MISCC=
#MISCO=

# 4.2BSD Sun:
#ASSRC=
#ASOBJ=
#MISCC=
#MISCO=

# 4.2BSD Pyramid:
#ASSRC=
#ASOBJ=
#MISCC=
#MISCO=

# 4.3BSD Vax:
ASSRC=
ASOBJ=
MISCC=
MISCO=

# all
CSRC=	conv.c dviclass.c error.c findpost.c fio.c font.c font_subr.c \
	gfclass.c gripes.c magfactor.c rotate.c scaletfm.c scanpost.c \
	search.c seek.c split.c strsave.c tfm.c ${MISCC}
COBJ=	conv.o dviclass.o error.o findpost.o fio.o font.o font_subr.o \
	gfclass.o gripes.o magfactor.o rotate.o scaletfm.o scanpost.o \
	search.o seek.o split.o strsave.o tfm.o ${MISCO}
FSRC=	gffont.c pkfont.c pxlfont.c tfmfont.c
FOBJ=	gffont.o pkfont.o pxlfont.o tfmfont.o

SRC=	$(MISCC) $(CSRC) $(FSRC)
OBJS=	${COBJ} ${ASOBJ} ${FOBJ}

LIBABBR= ib
LIBNAME= lib.a

default: all

all: buildlib

# Just rebuild the object files
objs: $(OBJS)

# Rebuild the library from all the .o files.
buildlib: $(OBJS)
	-rm $(LIBNAME)
	ar rc $(LIBNAME)
	ar q $(LIBNAME) $(OBJS)
	ranlib $(LIBNAME)
	touch buildlib

# no installation is necessary; this entry is just for standardisation
install: buildlib
# Clean up installed stuff and binaries
pristine: clean
# nothing installed, nothing to do

clean:
	rm -f *.o $(LIBNAME)
	-rm -f *.ln
	-rm -f buildlib install lintlib

# Lint actions:
#
# lintall - run lint on all the source files
# lint1 - run line on one source file
# llib-lrle.ln - build machine readable form of lint library for
# use in linting programs that use the library
#
lintall:
	lint $(DFLAGS) $(IFLAGS) $(SRC)

lint1:
	lint $(DFLAGS) $(IFLAGS) -u $(LINTF) llib-l$(LIBABBR).ln

lintlib llib-l$(LIBABBR).ln: llib-l$(LIBABBR)
	lint $(LINTLIBOPT) $(DFLAGS) $(IFLAGS) $(SRC)
	touch lintlib

makefile:
depend:

# font.o needs to know where to find the font description file
font.o:
	${CC} ${CFLAGS} -c -DCONFFILE=\"${CONFFILE}\" font.c

# special rules for font objects
${FOBJ}:
	${CC} ${FCFLAGS} -c $*.c

# Assume everything depends on all .h files.  I wish make depend worked
# everywhere
$(OBJS): $(TI)/*.h

# DO NOT DELETE THIS LINE -- make depend uses it

# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
