SHELL = /bin/sh

include VERSION

.SUFFIXES: .o .lo .la .C

srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir= $(top_srcdir)
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@/gltt
oldincludedir = /usr/include

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
transform = @program_transform_name@

LIBTOOL = @LIBTOOL@

CXX = @CXX@
CXXFLAGS = -DNDEBUG @CXXFLAGS@
LDFLAGS = @LDFLAGS@
GL_INCLUDES = @GL_INCLUDES@
GL_LDFLAGS = @GL_LDFLAGS@
GL_BASELIBS=-l@GL_LIBNAME@GL -l@GL_LIBNAME@GLU

GLUT_INCLUDES = @GLUT_INCLUDES@
GLUT_LDFLAGS = @GLUT_LDFLAGS@

TTF_INCLUDES = @TTF_INCLUDES@
TTF_LDFLAGS = @TTF_LDFLAGS@

LIBSOCKET = @LIBSOCKET@
RANLIB = @RANLIB@
X_INCLUDES = @X_INCLUDES@
X_LDFLAGS = @X_LDFLAGS@

mkinstalldirs= $(SHELL) $(top_srcdir)/mkinstalldirs

DEPEND=depend

SRCS= FTEngine.C FTFace.C FTInstance.C FTGlyph.C \
 FTGlyphBitmap.C FTGlyphPixmap.C \
 FTFont.C FTBitmapFont.C FTPixmapFont.C \
 FTGlyphVectorizer.C \
 GLTTGlyphPolygonizer.C GLTTGlyphPolygonizerHandler.C \
 GLTTGlyphTriangulator.C \
 GLTTBitmapFont.C GLTTPixmapFont.C GLTTOutlineFont.C GLTTFont.C

OBJS=$(SRCS:.C=.o)
LOBJS=$(SRCS:.C=.lo)

DEMO_SRCS=BottomText.C hsv_to_rgb.C delays.C demo.C
DEMO_OBJS=$(DEMO_SRCS:.C=.o)

LOGO_SRCS=hsv_to_rgb.C delays.C logo.C
LOGO_OBJS=$(LOGO_SRCS:.C=.o)

BBOXDEMO_SRCS=bboxdemo.C
BBOXDEMO_OBJS=$(BBOXDEMO_SRCS:.C=.o)

DEMO=demo
LOGO=logo
BBOXDEMO=bboxdemo

DEMOS= $(DEMO) $(LOGO) $(BBOXDEMO)
DEMOS_SRCS= $(DEMO_SRCS) $(LOGO_SRCS) $(BBOXDEMO_SRCS)
DEMOS_OBJS=$(DEMOS_SRCS:.C=.o)

AR=ar

ALL_FLAGS=$(CXXFLAGS) $(GLUT_INCLUDES) $(GL_INCLUDES) $(TTF_INCLUDES) $(X_INCLUDES)

GLTT_LIB=libgltt.la
GL_LIBS=$(GLUT_LDFLAGS) -lglut $(GL_LDFLAGS) $(GL_BASELIBS)
X_LIBS=$(X_LDFLAGS) -lX11 -lXext -lXmu -lXt -lXi -lSM -lICE $(LIBSOCKET) -lm
TTF_LIBS=$(TTF_LDFLAGS) -lttf
ALL_LIBS=$(LDFLAGS) libgltt.la $(GL_LIBS) $(X_LIBS) $(TTF_LIBS)

TARGET = @GLTT_MAKE_TARGET@

all: $(TARGET)

lib_only: $(GLTT_LIB)

lib_and_demos: $(DEMOS)

.C.o:
	$(LIBTOOL) --mode=compile $(CXX) $(ALL_FLAGS) -c $*.C

.C.lo:
	$(LIBTOOL) --mode=compile $(CXX) $(ALL_FLAGS) -c $*.C

$(DEMO): $(GLTT_LIB) $(DEMO_OBJS)
	$(LIBTOOL) --mode=link $(CXX) -o $@ $(DEMO_OBJS) $(ALL_LIBS)

$(LOGO): $(GLTT_LIB) $(LOGO_OBJS)
	$(LIBTOOL) --mode=link $(CXX) -o $@ $(LOGO_OBJS) $(ALL_LIBS)

$(BBOXDEMO): $(GLTT_LIB) $(BBOXDEMO_OBJS)
	$(LIBTOOL) --mode=link $(CXX) -o $@ $(BBOXDEMO_OBJS) $(ALL_LIBS)

$(GLTT_LIB): $(LOBJS)
	$(LIBTOOL) --mode=link $(CXX) -o $@ \
            -rpath $(libdir) \
            -version-info $(VERSION_MAJOR):$(VERSION_MINOR):0 \
            $(LOBJS) $(TTF_LIBS)

dep: $(SRCS) $(DEMO_SRCS) $(LOGO_SRCS)
	$(CXX) -MM $(ALL_FLAGS) $(SRCS) $(DEMOS_SRCS) > $(DEPEND)

clean:
	rm -f *.o *.lo *.la *.a $(DEMOS) so_locations
	rm -rf .libs

distclean: clean
	rm -f config.log config.status config.cache Makefile config.h $(DEPEND)

install: $(GLTT_LIB)
	$(mkinstalldirs) $(libdir)
	$(LIBTOOL) --mode=install $(INSTALL) $(GLTT_LIB) $(libdir)/
	$(mkinstalldirs) $(includedir)
	$(INSTALL_DATA) FT*.h GLTT*.h $(includedir)/

install-demos: $(DEMOS)
	$(mkinstalldirs) $(bindir)
	$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(DEMOS) $(bindir)/

distrib:
	mkdistrib.sh

ifeq ($(DEPEND),$(wildcard $(DEPEND)))
include $(DEPEND)
endif
