# Makefile for ttf2pk -- loyer@enst.fr, wl@gnu.org
#
# This Makefile assumes that you've already built and installed
# the FreeType library.

VPATH = @srcdir@
srcdir = @srcdir@

RM = @RM@
RMF = @RM@ -f
RMDIR = @RMDIR@

INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@

CC = @CC@
CPP = @CPP@

LIBTOOL = ../../libtool
MKINSTALLDIRS = $(srcdir)/../../mkinstalldirs

include MakeSub

CFLAGS = @CFLAGS@ @XX_CFLAGS@
CPPFLAGS = @CPPFLAGS@ @DEFS@
FT_CFLAGS = $(CFLAGS) $(CPPFLAGS)
LDFLAGS = @LDFLAGS@ @LIBS@
LIBDIR = ../../lib

SRC = $(srcdir)/case.c     \
      $(srcdir)/errormsg.c \
      $(srcdir)/filesrch.c \
      $(srcdir)/ligkern.c  \
      $(srcdir)/newobj.c   \
      $(srcdir)/parse.c    \
      $(srcdir)/pklib.c    \
      $(srcdir)/subfont.c  \
      $(srcdir)/texenc.c   \
      $(srcdir)/tfmaux.c   \
      $(srcdir)/ttf2pk.c   \
      $(srcdir)/ttf2tfm.c  \
      $(srcdir)/ttfaux.c   \
      $(srcdir)/ttfenc.c   \
      $(srcdir)/ttflib.c   \
      $(srcdir)/vplaux.c

ttf2pkobjs = errormsg.o filesrch.o ligkern.o newobj.o parse.o pklib.o \
             subfont.o texenc.o ttf2pk.o ttfenc.o ttflib.o
ttf2tfmobjs = case.o errormsg.o filesrch.o ligkern.o newobj.o parse.o \
              subfont.o texenc.o tfmaux.o ttf2tfm.o ttfaux.o ttfenc.o \
              vplaux.o


.c.o:
	$(CC) -c $(FT_CFLAGS) $<


PROGRAMS = ttf2pk ttf2tfm

default all: $(PROGRAMS)

ttf2pk: $(ttf2pkobjs) $(LIBDIR)/libttf.la
	$(LIBTOOL) --mode=link $(CC) $(FT_CFLAGS) -o ttf2pk $(ttf2pkobjs) \
                                     $(LIBDIR)/libttf.la $(LDFLAGS)

ttf2tfm: $(ttf2tfmobjs) $(LIBDIR)/libttf.la
	$(LIBTOOL) --mode=link $(CC) $(FT_CFLAGS) -o ttf2tfm $(ttf2tfmobjs) \
                                     $(LIBDIR)/libttf.la $(LDFLAGS)

install: $(PROGRAMS)
	$(MKINSTALLDIRS) $(bindir) $(mandir)/man1
	for P in $(PROGRAMS) ; do \
          $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$P $(bindir)/$$P ; \
          $(INSTALL_DATA) $(srcdir)/$$P.1 $(mandir)/man1 ; \
        done

uninstall:
	-for P in $(PROGRAMS) ; do \
          $(LIBTOOL) --mode=uninstall $(RM) $(bindir)/$$P ; \
          $(RMF) $(mandir)/man1/$$P.1 ; \
        done

clean: do_clean

distclean: do_clean
	-$(RMF) dep.end $(PROGRAMS)
	-$(RMF) *~ *.orig core *.core
	-$(RMF) config.cache config.log config.status Makefile MakeSub
	-$(RMF) .libs/*
	-$(RMDIR) .libs

do_clean:
	-$(RMF) *.o


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 $(SRC) ; do \
          $(CPP) $(CPPFLAGS) $$file | \
           sed -n -e 's|^# [1-9][0-9]* "\([^/].*\.h\)".*|\1|p' \
                  -e 's|^# [1-9][0-9]* "\($(srcdir)/.*\.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

# Dependencies generated by make depend: PUT NO STUFF BELOW
