#
# Makefile for VFlib version 2
#    by H.Kakugawa
#
#
# Copyright (C) 1993,1994,1995,1996 Hirotsugu KAKUGAWA. All rights reserved.
#
# VFlib is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
# to anyone for the consequences of using it or for whether it serves any
# particular purpose or works at all, unless he says so in writing.  Refer
# to the GNU General Public License for full details.
#
# Everyone is granted permission to copy, modify and redistribute
# VFlib, but only under the conditions described in the GNU
# General Public License.  A copy of this license is supposed to have been
# given to you along with VFlib so you can know your rights and
# responsibilities.  It should be in a file named COPYING.  Among other
# things, the copyright notice and this notice must be preserved on all
# copies. 
#

#-------------------------
### VFlib configurations
#-------------------------

# Maximum of open files
    OPENFILES = -DMAX_OPEN_FONT_FILES=6

# SONY FSlib
#     USEFSLIB = -DUSE_SONY_FONT
#   SONY_FSLIB = -L/usr/sony/lib -lFSlib

# VFontcap file
        VFCAP = -DDEFAULT_VFCAP=\"/usr/local/TeX/lib/vfontcap\"

# OS and Machine dependent compiling options
#  Define __MSDOS__ (e.g., CCOPT=-D__MSDOS__) if you compile VFlib on MS-DOS
#  Define SYSV if you do not have bzero() etc.

       CCOPT = # -DSYSV
       LDOPT = # -Bstatic

#-------------------------
# Compilers, compiling options, etc.
#-------------------------
        CC = cc
    CFLAGS = $(CCOPT) $(DEBUGOPT) -O

   LDFLAGS = $(LDOPT)
  SYS_LIBS = -lm
        LN = ln -s
       ARC = ar rc
        CP = cp
        RM = rm
    RANLIB = ranlib
     LATEX = latex
    DVI2PS = dvi2ps

#-------------------------
# Installation Directories
#-------------------------
INSTALL_LIBDIR=/usr/local/lib
INSTALL_INCDIR=/usr/local/include
INSTALL_BINDIR=/usr/local/etc



#-------------------------------------------
#  YOU DO NOT HAVE TO EDIT FOLLOWING LINES
#-------------------------------------------

#  DEBUGOPT = -DDYNAMIC_OPEN_CLOSE_DEBUG
      LIBS = $(SONY_FSLIB) $(SYS_LIBS)


# for the HBF API
#ifdef __MSDOS__
FS=msdos
#else
FS=unix
#endif

default:
	make libVFlib.a ttindex bdfindex fwindex
all:
	make libVFlib.a ttindex bdfindex fwindex

install:
	-$(RM) -f $(INSTALL_LIBDIR)/VFlib.a $(INSTALL_LIBDIR)/libVFlib.a
	$(CP) VFlib.a $(INSTALL_LIBDIR)/VFlib.a
	-$(RANLIB) $(INSTALL_LIBDIR)/VFlib.a
	$(LN) $(INSTALL_LIBDIR)/VFlib.a $(INSTALL_LIBDIR)/libVFlib.a
	$(CP) VF.h $(INSTALL_INCDIR)/VF.h
	$(CP) ttindex $(INSTALL_BINDIR)/ttindex
	$(CP) bdfindex $(INSTALL_BINDIR)/bdfindex

clean:
	-$(RM) -rf VFlib.a libVFlib.a ttindex bdfindex bdfjpindex *.o core
veryclean:
	-$(RM) -rf VFlib.a libVFlib.a ttindex bdfindex bdfjpindex\
	           *.o core *~ \#tz* 


# Font drivers
DRV_OBJ=  VF_Sony.o VF_Zeit.o VF_Jg.o VF_TT.o VF_Bdf.o VF_Hbf.o hbf.o \
	  VF_Comp.o VF_BitOp.o VF_FNTWV.o VF_Comp2.o VF_Null.o


# VFlib
libVFlib.a:	VFlib.o VFenc.o VFEtable.o VFcap.o fn2ent.o fman.o $(DRV_OBJ)
	$(ARC) libVFlib.a  VFlib.o VFenc.o VFEtable.o VFcap.o \
	                   fn2ent.o fman.o $(DRV_OBJ)
	-$(RANLIB) libVFlib.a
	$(CP) libVFlib.a VFlib.a
	-$(RANLIB) VFlib.a

# VFlib
VFlib.o:  	VFlib.c
	$(CC) $(CFLAGS) $(USEFSLIB)  -c VFlib.c

# font capability database 
VFcap.o:	VFcap.c
	$(CC) $(CFLAGS) $(VFCAP) -c VFcap.c

# handling of font encodings
VFenc.o:	VFenc.c
	$(CC) $(CFLAGS) -c VFenc.c

# font encoding and character set tables
VFEtable.o:	VFEtable.c
	$(CC) $(CFLAGS) -c VFEtable.c

# conv font name to font entry name
fn2ent.o:	fn2ent.c
	$(CC) $(CFLAGS)  -c fn2ent.c

# dynamic file stream manager
fman.o:		fman.c
	$(CC) $(CFLAGS) $(OPENFILES) -c fman.c

# Sony Font driver
VF_Sony.o:  	VF_Sony.c
	$(CC) $(CFLAGS) $(USEFSLIB) -c VF_Sony.c
# Zeit Syotai-Club Font driver
VF_Zeit.o:  	VF_Zeit.c
	$(CC) $(CFLAGS)  -c VF_Zeit.c
# Zeit JG Font driver
VF_Jg.o:  	VF_Jg.c
	$(CC) $(CFLAGS)  -c VF_Jg.c
# TrueType Driver
VF_TT.o:  	VF_TT.c
	$(CC) $(CFLAGS)  -c VF_TT.c
# BDF Driver
VF_Bdf.o:  	VF_Bdf.c
	$(CC) $(CFLAGS)  -c VF_Bdf.c
# HBF Driver
VF_Hbf.o:	VF_Hbf.c
	$(CC) $(CFLAGS) -D$(FS) -c VF_Hbf.c
hbf.o:	hbf.c
	$(CC) $(CFLAGS) -D$(FS) -DNO_STRDUP -c hbf.c
# Composite font driver
VF_Comp.o:  	VF_Comp.c
	$(CC) $(CFLAGS)  -c VF_Comp.c
# Bit-Operated font driver
VF_BitOp.o:  	VF_BitOp.c
	$(CC) $(CFLAGS)  -c VF_BitOp.c
# Null font driver
VF_Null.o:  	VF_Null.c
	$(CC) $(CFLAGS)  -c VF_Null.c

# Index generator for TrueType font
ttindex:	ttindex.c 
	$(CC) $(CFLAGS) -o ttindex ttindex.c

# Index generator for BDF font
bdfindex.o:	bdfindex.c
	$(CC) $(CFLAGS) -c bdfindex.c
bdfindex:	bdfindex.o libVFlib.a
	$(CC) $(CFLAGS) -o bdfindex bdfindex.o -L./ -lVFlib $(LIBS) -lc

# Index generator for BDF font 
#   - A subset of bdfindex. This can be used only for Japanese.
bdfjpindex:	bdfjpindex.c 
	$(CC) $(CFLAGS) -o bdfjpindex bdfjpindex.c 

# Index generator for FontWave font
fwindex:        fwindex.c fwindex.h
	$(CC) $(CFLAGS) -o fwindex fwindex.c

# Ross Paterson (rap@doc.ic.ac.uk) wrote this ingenious part.
depend:
	(echo '/^#.* PUT NO STUFF BELOW/,$$d'; echo w; echo q) \
		| ed - Makefile
	echo '# Dependencies generated by make depend: PUT NO STUFF BELOW' \
		>> Makefile
	for file in *.c; \
	do $(CC) $(CPPFLAGS) -E $$file \
		| sed -n 's|^# [1-9][0-9]* "\([^/].*\.h\)".*|\1|p' \
		| sed -e 's|/\./|.|g' -e "s/^/`basename $$file .c`.o: /"; \
	done \
	| sort -u \
	| awk '{ if (LINE == 1) { line = last = $$1 } \
		 else if ($$1 != last) { print line; line = last = $$1 } \
		 line = line " " $$2 } \
		 END { print line }' \
	>> Makefile
	echo "#EOF" >>Makefile

# Dependencies generated by make depend: PUT NO STUFF BELOW

VFEtable.o: VFenc.h
VF_Bdf.o: VF.h VFcap.h VFenc.h _VF.h bdf.h config.h
VF_BitOp.o: VF.h VFcap.h _VF.h config.h
VF_Comp.o: VF.h VFcap.h _VF.h config.h
VF_Hbf.o: VF.h VFcap.h VFenc.h _VF.h config.h hbf.h
VF_Jg.o: VF.h VFcap.h _VF.h config.h
VF_Null.o: VF.h VFcap.h _VF.h config.h
VF_Sony.o: VF.h VFcap.h _VF.h config.h
VF_TT.o: VF.h VFcap.h _VF.h config.h
VF_Zeit.o: VF.h VFcap.h _VF.h config.h
VFcap.o: VFcap.h config.h
VFenc.o: VF.h VFenc.h _VF.h config.h
VFlib.o: VF.h VFcap.h _VF.h config.h
bdfindex.o: VFenc.h bdf.h
fman.o: VF.h _VF.h config.h
fn2ent.o: VF.h
hbf.o: hbf.h
ttindex.o: ttindex.h
#EOF
