# This file is part of the FreeType project.
#
# test/arch/unix/Makefile.in

ARCH = arch/unix

top_builddir=..

VPATH = @srcdir@/../..
srcdir = @srcdir@/../..

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

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@

CC = @CC@
CPP = @CPP@

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

include $(top_builddir)/MakeSub

FT_LIBDIR = $(srcdir)/../lib
INCDIRS = -I. -I$(srcdir) -I$(top_builddir) \
          -I$(FT_LIBDIR) -I$(FT_LIBDIR)/extend

CFLAGS = @CFLAGS@ @X_CFLAGS@ @XX_CFLAGS@
CPPFLAGS = @CPPFLAGS@
FT_CFLAGS = $(INCDIRS) $(CFLAGS) $(CPPFLAGS) -DX11 -DLOCALEDIR='"@LOCALEDIR@"'

FT_LIBS = @X_LIBS@ @X_PRE_LIBS@ @X_EXTRA_LIBS@ @LIBS@

SRC = $(srcdir)/arabic.c           \
      $(srcdir)/common.c           \
      $(srcdir)/ftdump.c           \
      $(srcdir)/fterror.c          \
      $(srcdir)/ftlint.c           \
      $(srcdir)/ftmetric.c         \
      $(srcdir)/ftsbit.c           \
      $(srcdir)/ftstring.c         \
      $(srcdir)/ftstrpnm.c         \
      $(srcdir)/fttimer.c          \
      $(srcdir)/ftview.c           \
      $(srcdir)/ftzoom.c           \
      $(srcdir)/ftstrtto.c         \
      $(srcdir)/gmain.c            \
      $(srcdir)/$(ARCH)/gwin_x11.c

DISPOBJS = common.o gmain.o display.o gwin_x11.o blitter.o

PROGRAMS = ftview fttimer ftlint ftdump ftzoom ftsbit \
           ftstring ftstrpnm fterror ftmetric ftstrtto

# set this variable to nil if you don't need to use Electric-Fence
EFENCE =
#EFENCE = -lefence


# variables used to compile either with libtool or not
#
PROCESS = $(LIBTOOL) --mode=link  $(CC) $(FT_CFLAGS)
#PROCESS = $(CC) $(FT_CFLAGS)

LIBTTF = $(top_builddir)/lib/libttf.la
#LIBTTF =$(top_builddir)/lib/libttf.a

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


all: $(PROGRAMS)


gwin_x11.o: $(srcdir)/$(ARCH)/gwin_x11.c
	$(CC) -c $(FT_CFLAGS) $(srcdir)/$(ARCH)/gwin_x11.c

ftzoom: ftzoom.o $(DISPOBJS) $(LIBTTF)
	$(PROCESS) -o ftzoom ftzoom.o $(DISPOBJS) \
          $(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11

fttimer: fttimer.o $(DISPOBJS) $(LIBTTF)
	$(PROCESS) -o fttimer fttimer.o $(DISPOBJS) \
          $(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11

ftview: ftview.o $(DISPOBJS) $(LIBTTF)
	$(PROCESS) -o ftview ftview.o $(DISPOBJS) \
          $(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11

ftlint: ftlint.o common.o $(LIBTTF)
	$(PROCESS) -o ftlint ftlint.o common.o \
          $(EFENCE) $(LIBTTF) $(FT_LIBS)

ftdump: ftdump.o common.o $(LIBTTF)
	$(PROCESS) -o ftdump ftdump.o common.o \
          $(EFENCE) $(LIBTTF) $(FT_LIBS)

ftmetric: ftmetric.o common.o $(LIBTTF)
	$(PROCESS) -o ftmetric ftmetric.o common.o \
          $(EFENCE) $(LIBTTF) $(FT_LIBS)

ftsbit: ftsbit.o common.o $(LIBTTF)
	$(PROCESS) -o ftsbit ftsbit.o common.o \
          $(EFENCE) $(LIBTTF)

ftstring: ftstring.o $(DISPOBJS) $(LIBTTF)
	$(PROCESS) -o ftstring ftstring.o $(DISPOBJS) \
          $(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11

# ftstrpnm does not need any extra libraries
ftstrpnm: ftstrpnm.o common.o $(LIBTTF)
	$(PROCESS) -o ftstrpnm ftstrpnm.o common.o \
          $(EFENCE) $(LIBTTF)

fterror: fterror.o common.o $(LIBTTF)
	$(PROCESS) -o fterror fterror.o common.o \
          $(EFENCE) $(LIBTTF) $(FT_LIBS)

ftstrtto: ftstrtto.o $(DISPOBJS) arabic.o $(LIBTTF)
	$(PROCESS) -o ftstrtto ftstrtto.o $(DISPOBJS) arabic.o \
          $(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11


install: $(PROGRAMS)
	$(MKINSTALLDIRS) $(bindir)
	for P in $(PROGRAMS) ; do \
          $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$P $(bindir)/$$P ; \
        done

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

clean: do_clean

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

do_clean:
	-$(RMF) *.o

depend:
	(echo '/^#.* PUT NO STUFF BELOW/,$$d' ; echo w ; echo q) | \
         ed - $(ARCH)/Makefile
	echo '# Dependencies generated by make depend: PUT NO STUFF BELOW' \
          >> $(ARCH)/Makefile
	for file in $(SRC) ; do \
          $(CPP) $(CPPFLAGS) $(INCDIRS) $$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 }' >> $(ARCH)/Makefile

# Dependencies generated by make depend: PUT NO STUFF BELOW
