#  Makefile.in for VFlib
#  by Hirotsugu Kakugawa (h.kakugwa@computer.org)

makedefault: default 
include ../make-sub

#-------------------------------------------------
LIBTOOL = ../libtool
VFLIB   = libVFlib3.la
VFLIB_H = VFlib-3_7.h

PROGRAMS       = vflserver vfltest vflpp vfldisol vfldrvs vflbanner 
UTIL_PROGRAMS  = vflmkvfl vflmktex vflmkgf vflmkpk vflmktfm vflmkvf vflmkt1 \
		 vflmkpcf vflmkttf vflmkekan vflmkajt vflmkjpc
SHELL_PROGRAMS = vflmkfdb vflmkcaptex
DBG_PROGRAMS   = vflservers vfldisols dvg-ccv dbg-bml dbg-sexp test-gen 

ALL_PROGRAMS   = $(PROGRAMS) $(UTIL_PROGRAMS)


CORE_SRCS = VFlib.c  defaults.c  cache.c  vflibcap.c  raster.c  \
	    bitmap.c  bmlist.c  metric.c  drv_ini.c \
	    bm2ol.c  fsearch.c  fileman.c  params.c  \
	    image.c  sexp.c  ccv.c  path.c  str.c  mem.c
CORE_OBJS = VFlib.lo defaults.lo cache.lo vflibcap.lo raster.lo \
	    bitmap.lo bmlist.lo metric.lo drv_ini.lo \
	    bm2ol.lo fsearch.lo fileman.lo params.lo \
	    image.lo sexp.lo ccv.lo path.lo str.lo mem.lo

DRV_SRCS =  drv_bdf.c bdf.c drv_pcf.c pcf.c drv_hbf.c hbf.c \
	    drv_zeit.c zeit.c drv_jg.c jg.c drv_ekan.c \
	    drv_ttf.c  drv_otf.c drv_t1.c \
	    texfonts.c \
	    drv_gf.c gf.c drv_pk.c pk.c drv_tfm.c tfm.c drv_vf.c drv_jtex.c \
	    drv_comic.c  drv_try.c  drv_mojikmap.c
DRV_OBJS =  @bdf_objs@ @pcf_objs@ @hbf_objs@ \
	    @zeit_objs@ @jg_objs@ @ekan_objs@ \
	    @ttf_objs@ @otf_objs@ @type1_objs@ \
	    @texfonts_objs@ \
	    @gf_objs@ @pk_objs@ @tfm_objs@ @vf_objs@ @jtex_objs@ \
	    @comic_objs@ @try_objs@ @mojikmap_objs@

SRCS = $(CORE_SRCS) $(DRV_SRCS) 
OBJS = $(CORE_OBJS) $(DRV_OBJS)  


#-------------------------------------------------
all default:
	$(MAKE) $(VFLIB) $(ALL_PROGRAMS)  

$(VFLIB): $(OBJS) $(VFLIB_EXTRA_OBJS)
	$(LIBTOOL) --mode=link \
		$(CC) -o $(VFLIB) $(OBJS) \
		  -version-info @version_info@ -rpath $(libdir) $(EXT_LIBRARY)

$(VFLIBJ): $(OBJS) $(VFLIB_EXTRA_OBJS) ../java/VFlib3J.lo
	$(LIBTOOL) --mode=link \
		$(CC) -o $(VFLIBJ) $(OBJS) ../java/VFlib3J.lo \
		  -version-info @version_info@ -rpath $(libdir) $(EXT_LIBRARY)

.SUFFIXES: .c .lo .o
.c.lo:
	$(LIBTOOL) --mode=compile  $(CC) $(VFCFLAGS) -c $<
.c.o:
	$(CC) $(VFCFLAGS) -c $<

$(PROGRAMS): $(VFLIB)

drv_ttf.lo: drv_ttf.c ttfx.h ttf.h
	$(LIBTOOL) --mode=compile  $(CC) $(VFCFLAGS) \
		@freetype_includedir@ -c drv_ttf.c
drv_otf.lo: drv_otf.c otf.h
	$(LIBTOOL) --mode=compile  $(CC) $(VFCFLAGS) \
		@opentype_includedir@ -c drv_otf.c
drv_t1.lo: drv_t1.c t1.h
	$(LIBTOOL) --mode=compile  $(CC) $(VFCFLAGS) \
		@t1lib_includedir@ -c drv_t1.c
fsearch.lo: fsearch.c fsearch.h 
	$(LIBTOOL) --mode=compile  $(CC) $(VFCFLAGS) \
		@kpathsea_includedir@ -c fsearch.c

drv_pcf.c:	drv_bdf.c
	@-$(RM) drv_pcf.c
	@echo "/* CAUTION! NEVER EDIT THIS FILE */"                >  drv_pcf.c
	@sed 's/bdf/pcf/g' drv_bdf.c | sed 's/BDF/PCF/g'           >> drv_pcf.c
	@echo "drv_pcf.c is created"
drv_hbf.c:	drv_bdf.c
	@-$(RM) drv_hbf.c
	@echo "/* CAUTION! NEVER EDIT THIS FILE */"                >  drv_hbf.c
	@sed 's/bdf/hbf/g' drv_bdf.c | sed 's/BDF/HBF/g'           >> drv_hbf.c
	@echo "drv_hbf.c is created"
drv_jg.c:	drv_zeit.c
	@-$(RM) drv_jg.c
	@echo "/* CAUTION! NEVER EDIT THIS FILE */"                >  drv_jg.c
	@sed 's/zeit/jg/g' drv_zeit.c | sed 's/ZEIT/JG/g'          >> drv_jg.c
	@echo "drv_jg.c is created"
drv_pk.c:	drv_gf.c
	@-$(RM) drv_pk.c
	@echo "/* CAUTION! NEVER EDIT THIS FILE */"                >  drv_pk.c
	@sed 's/gf/pk/g' drv_gf.c | sed 's/GF/PK/g'                >> drv_pk.c
	@echo "drv_pk.c is created"

vflpaths.h: ../configure.in ../config.status
	@-$(RM) vflpaths.tmp
	@echo "/* NEVER EDIT THIS! This file is automatically generated */" \
	  >  vflpaths.tmp
	@(echo '#define DEFAULT_VFLIBCAP'      \"$(default_vflibcap)\"; \
	  echo '#define DIR_RUNTIME_SITE_LIB'  \"$(runtimesitedir)\"; \
	  echo '#define DIR_RUNTIME_LIB'       \"$(runtimedir)\"; \
	  echo '#define DIR_CCV'          \"$(runtimedir)/${subdir_ccv}\"; \
	  echo '#define DIR_T1'           \"$(runtimedir)/${subdir_t1enc}\"; \
	  echo '#define DIR_ASCII_JTEX'   \"$(runtimedir)/${subdir_ascii_jtex}\"; \
	  echo '#define DIR_INSTALL_BIN'  \"$(bindir)\"; \
	  echo '#define DIR_INSTALL_LIB'  \"$(libdir)\"; \
	  echo '#define VFLSERVER_PATH'   \"$(bindir)/vflserver\"; \
	 ) >> vflpaths.tmp
	@if cmp -s vflpaths.tmp vflpaths.h 2>/dev/null; then \
		echo "vflpaths.h is unchanged"; \
		rm -f vflpaths.tmp; \
	else 	echo "vflpaths.h is created"; \
		rm -f vflpaths.h; mv -f vflpaths.tmp vflpaths.h;   fi

COMM_HDRS1= config.h $(VFLIB_H) VFsys.h mem.h sexp.h vflibcap.h \
            cache.h consts.h 
COMM_HDRS2= config.h $(VFLIB_H) VFsys.h mem.h sexp.h vflibcap.h str.h

VFlib.lo:     $(COMM_HDRS1) vflpaths.h metric.h str.h
defaults.lo:  $(COMM_HDRS2) fsearch.h
vflibcap.lo:  $(COMM_HDRS2) vflpaths.h 
cache.lo:     $(COMM_HDRS2) cache.h 
fsearch.lo:   $(COMM_HDRS2) vflpaths.h fsearch.h
fileman.lo:   $(COMM_HDRS2) vflpaths.h consts.h 
raster.lo:    $(COMM_HDRS2) consts.h 
bm2ol.lo:     $(COMM_HDRS2) consts.h 
bitmap.lo:    $(COMM_HDRS2) consts.h 
bmlist.lo:    $(COMM_HDRS2) bmlist.h
str.lo:       $(COMM_HDRS2) 
path.lo:      $(COMM_HDRS2) vflpaths.h path.h 
sexp.lo:      $(COMM_HDRS2) 
mem.lo:       $(COMM_HDRS2) 
params.lo:    $(COMM_HDRS2) vflpaths.h params.h 
ccv.lo:       $(COMM_HDRS2) vflpaths.h vflpaths.h ccv.h 
drv_ini.lo:   $(COMM_HDRS2) with.h
drv_bdf.lo:   $(COMM_HDRS1) bdf.h bdf.c
drv_pcf.lo:   $(COMM_HDRS1) pcf.h pcf.c
drv_hbf.lo:   $(COMM_HDRS1) hbf.h hbf.c 
drv_zeit.lo:  $(COMM_HDRS1) zeit.c zeit.h
drv_jg.lo:    $(COMM_HDRS1) jg.c jg.h
drv_ttf.lo:   $(COMM_HDRS1) ttfx.h ttf.h 
drv_otf.lo:   $(COMM_HDRS1) otf.h 
drv_gf.lo:    $(COMM_HDRS1) texfonts.h gf.c gf.h tfm.h
drv_pk.lo:    $(COMM_HDRS1) texfonts.h pk.c pk.h tfm.h
drv_vf.lo:    $(COMM_HDRS1) texfonts.h vf.c vf.h tfm.h
drv_tfm.lo:   $(COMM_HDRS1) texfonts.h tfm.h 
tfm.lo:       $(COMM_HDRS1) texfonts.h tfm.h
jfmbi.lo:     $(COMM_HDRS1) jfmbi.h
drv_jtex.lo:  $(COMM_HDRS1) vflpaths.h texfonts.h jtex.h 
texfonts.lo:  $(COMM_HDRS1) texfonts.h with.h tfm.h 
drv_comic.lo: $(COMM_HDRS1) comic.h
drv_try.lo:   $(COMM_HDRS1) try.h
drv_mojikmap.lo: $(COMM_HDRS1) mojikmap.h
drv_ekan.lo:  $(COMM_HDRS1) ekan.h


#-------------------------------------------------
vflserver.o: vflserver.c $(VFLIB_H)
	$(CC) $(VFCFLAGS) -c vflserver.c
vflserver: vflserver.o $(VFLIB)
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflserver vflserver.o $(VFLIB)

vfltest.o: vfltest.c $(VFLIB_H)
vfltest: vfltest.o $(VFLIB)
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vfltest vfltest.o $(VFLIB)

vfldisol.o: vfldisol.c $(VFLIB_H)
vfldisol: vfldisol.o $(VFLIB)
	$(LIBTOOL) --mode=link \
		$(CC) $(VFCFLAGS) -o vfldisol vfldisol.o $(VFLIB)

vflpp.o: vflpp.c $(VFLIB_H)
vflpp: vflpp.o $(VFLIB)
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflpp vflpp.o $(VFLIB)

vflbanner.o: vflbanner.c $(VFLIB_H)
vflbanner: vflbanner.o $(VFLIB)
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflbanner vflbanner.o $(VFLIB)

vfldrvs.o: vfldrvs.c $(VFLIB_H)
vfldrvs: vfldrvs.o $(VFLIB)
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vfldrvs vfldrvs.o $(VFLIB)

vflmkvfl.o: vflmkvfl.c $(VFLIB_H) vflmklib.h vflibcap.h fsearch.h
	$(CC) $(VFCFLAGS) @kpathsea_includedir@ -c vflmkvfl.c
vflmkvfl: vflmkvfl.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkvfl vflmkvfl.o vflmklib.o \
			@kpathsea_libdir@ @kpathsea_lib@
vflmktex.o: vflmktex.c $(VFLIB_H) vflmklib.h vflibcap.h fsearch.h
	$(CC) $(VFCFLAGS) @kpathsea_includedir@ -c vflmktex.c
vflmktex: vflmktex.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmktex vflmktex.o vflmklib.o \
			@kpathsea_libdir@ @kpathsea_lib@
vflmkgf.o: vflmkgf.c $(VFLIB_H) vflmklib.h vflibcap.h gf.h fsearch.h
	$(CC) $(VFCFLAGS) @kpathsea_includedir@ -c vflmkgf.c
vflmkgf: vflmkgf.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkgf vflmkgf.o vflmklib.o \
			@kpathsea_libdir@ @kpathsea_lib@
vflmkpk.c: vflmkgf.c
	cat vflmkgf.c | sed 's/gf/pk/g' | sed 's/GF/PK/g' > vflmkpk.c
vflmkpk.o: vflmkpk.c $(VFLIB_H) vflmklib.h vflibcap.h pk.h fsearch.h
	$(CC) $(VFCFLAGS) @kpathsea_includedir@ -c vflmkpk.c
vflmkpk: vflmkpk.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkpk vflmkpk.o vflmklib.o  \
			@kpathsea_libdir@ @kpathsea_lib@
vflmktfm.o: vflmktfm.c $(VFLIB_H) vflmklib.h vflibcap.h tfm.h fsearch.h
	$(CC) $(VFCFLAGS) @kpathsea_includedir@ -c vflmktfm.c
vflmktfm: vflmktfm.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmktfm vflmktfm.o vflmklib.o \
			@kpathsea_libdir@ @kpathsea_lib@
vflmkvf.o: vflmkvf.c $(VFLIB_H) vflmklib.h vflibcap.h vf.h fsearch.h
	$(CC) $(VFCFLAGS) @kpathsea_includedir@ -c vflmkvf.c
vflmkvf: vflmkvf.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkvf vflmkvf.o vflmklib.o \
			@kpathsea_libdir@ @kpathsea_lib@
vflmkt1.o: vflmkt1.c $(VFLIB_H) vflmklib.h vflibcap.h t1.h fsearch.h
	$(CC) $(VFCFLAGS) @kpathsea_includedir@ -c vflmkt1.c
vflmkt1: vflmkt1.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkt1 vflmkt1.o vflmklib.o \
		      @kpathsea_libdir@ @kpathsea_lib@
vflmkpcf.o: vflmkpcf.c $(VFLIB_H) vflmklib.h vflibcap.h pcf.h fsearch.h
	$(CC) $(VFCFLAGS) -c vflmkpcf.c
vflmkpcf: vflmkpcf.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkpcf vflmkpcf.o vflmklib.o \
		      @kpathsea_libdir@ @kpathsea_lib@
vflmkttf.o: vflmkttf.c $(VFLIB_H) vflmklib.h vflibcap.h ttfx.h ttf.h fsearch.h
	$(CC) $(VFCFLAGS) -c vflmkttf.c
vflmkttf: vflmkttf.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkttf vflmkttf.o vflmklib.o \
		      @kpathsea_libdir@ @kpathsea_lib@
vflmkekan.o: vflmkekan.c $(VFLIB_H) vflmklib.h vflibcap.h ekan.h fsearch.h
	$(CC) $(VFCFLAGS) -c vflmkekan.c
vflmkekan: vflmkekan.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkekan vflmkekan.o vflmklib.o \
		      @kpathsea_libdir@ @kpathsea_lib@
vflmkajt.o: vflmkajt.c $(VFLIB_H) vflmklib.h vflibcap.h jtex.h fsearch.h
	$(CC) $(VFCFLAGS) -c vflmkajt.c
vflmkajt: vflmkajt.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkajt vflmkajt.o vflmklib.o \
		      @kpathsea_libdir@ @kpathsea_lib@
vflmkjpc.o: vflmkjpc.c $(VFLIB_H) vflmklib.h vflibcap.h comic.h 
	$(CC) $(VFCFLAGS) -c vflmkjpc.c
vflmkjpc: vflmkjpc.o vflmklib.o
	$(LIBTOOL) --mode=link  \
		$(CC) $(VFCFLAGS) -o vflmkjpc vflmkjpc.o vflmklib.o \
		      @kpathsea_libdir@ @kpathsea_lib@
vflmklib.o: vflmklib.c $(VFLIB_H) vflmklib.h vflibcap.h fsearch.h
	$(CC) $(VFCFLAGS) @kpathsea_includedir@ -c vflmklib.c


test-gen.o: test-gen.c
test-gen: test-gen.o
	$(LIBTOOL) --mode=link $(CC) $(VFCFLAGS) -o test-gen test-gen.o 

#-------------------------------------------------
install:  $(PROGRAMS) $(VFLIB)
	@if [ ! -d $(libdir) ] ; then \
	  ../recmkdir $(libdir); \
	fi
	@echo "Installing VFlib library..."
	@$(LIBTOOL) --mode=install \
	  ../$(INSTALL) $(VFLIB) $(libdir)
	@if [ ! -d $(bindir) ] ; then \
	  ../recmkdir $(bindir); \
	fi
	@for P in $(PROGRAMS) $(SHELL_PROGRAMS) $(UTIL_PROGRAMS) ; do \
	  $(LIBTOOL) --mode=install \
	    ../$(INSTALL_PROGRAM) $$P $(bindir); done
	@if [ ! -d $(includedir) ] ; then \
	  ../recmkdir $(includedir); \
	fi
	@../$(INSTALL_DATA) $(VFLIB_H) $(includedir)/$(VFLIB_H)

uninstall:
	for P in $(PROGRAMS) $(SHELL_PROGRAMS) $(UTIL_PROGRAMS) ; do \
	  $(LIBTOOL) --mode=uninstall $(RM) $(bindir)/$$P; done; 
	$(LIBTOOL) --mode=uninstall $(RM) $(libdir)/$(VFLIB)
	$(RM) $(includedir)/$(VFLIB_H)

clean::
	-$(RM) $(ALL_PROGRAMS) $(VFLIB) $(DBG_PROGRAMS) *.tmp
	-$(RM) dbg-ccv.c dbg-sexp.c
distclean:: clean 
	-$(RM) config.h with.h Makefile \
		vflpaths.h $(VFLIB_H) \
		drv_pcf.c drv_hbf.c test-olr.c test-bm1.c test-bm2.c \
		dbg-ccv.c dbg

wc:
	wc *.c *.h
WC:
	wc *.c *.h *.in

#-------------------------------------------------
# for debugging purpose...
vflservers: vflserver.o $(VFLIB)
	$(LIBTOOL) --mode=link \
		$(CC) -o vflservers -static vflserver.o $(VFLIB) 
vfldisols: vfldisol.o $(VFLIB)
	$(LIBTOOL) --mode=link \
		$(CC) -o vfldisols -static vfldisol.o $(VFLIB)
dbg-ccv.o: ccv.c $(VFLIB)
	$(CC) $(VFCFLAGS) -DDEBUG -o dbg-ccv.o -c ccv.c 
dbg-ccv: dbg-ccv.o $(VFLIB)
	$(LIBTOOL) --mode=link \
		$(CC) $(VFCFLAGS) -o dbg-ccv dbg-ccv.o $(VFLIB)
dbg-bml.o: dbg-bml.c $(VFLIB)
	$(CC) $(VFCFLAGS) -c dbg-bml.c 
dbg-bml: dbg-bml.o $(VFLIB)
	$(LIBTOOL) --mode=link \
		$(CC) $(VFCFLAGS) -o dbg-bml dbg-bml.o $(VFLIB)
dbg-sexp.o: sexp.c $(VFLIB)
	$(CC) $(VFCFLAGS) -DDEBUG -o dbg-sexp.o -c sexp.c 
dbg-sexp: dbg-sexp.o $(CORE_OBJS)
	$(LIBTOOL) --mode=link \
		$(CC) $(VFCFLAGS) -o dbg-sexp dbg-sexp.o $(CORE_OBJS)
dbg_ml.o: sexp.c $(VFLIB)
	$(CC) $(VFCFLAGS) -DDEBUG -o dbg_ml.o -c dbg_ml.c 
dbg_ml: dbg_ml.o $(CORE_OBJS)
	$(LIBTOOL) --mode=link \
		$(CC) $(VFCFLAGS) -o dbg_ml dbg_ml.o $(VFLIB)

dbg.o: dbg.c __dbg.tmp
	$(CC) $(VFCFLAGS) -c dbg.c
dbg: dbg.o $(VFLIB)
	$(LIBTOOL) --mode=link  \
		$(CC) -o dbg -static dbg.o $(VFLIB)

#-------------------------------------------------
#EOF
