#
# FreeType 2 configuration rules templates for Unix + configure
#


# Copyright 1996-2000 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.


ifndef TOP
  TOP := .
endif

DELETE        := @RMF@
DELDIR        := @RMDIR@
SEP           := /
HOSTSEP       := $(SEP)
BUILD         := $(TOP)/builds/unix
PLATFORM      := unix
CC            := @CC@

INSTALL       := @INSTALL@
INSTALL_DATA  := @INSTALL_DATA@
MKINSTALLDIRS := $(BUILD)/mkinstalldirs

LIBTOOL       := $(BUILD)/libtool


# don't use `:=' here since the path stuff will be included after this file
#
FTSYS_SRC = @FTSYS_SRC@

DISTCLEAN += $(BUILD)/config.cache  \
             $(BUILD)/config.log    \
             $(BUILD)/config.status \
             $(BUILD)/unix.mk       \
             $(BUILD)/ftconfig.h    \
             $(LIBTOOL)


# Standard installation variables.
#
prefix       := @prefix@
exec_prefix  := @exec_prefix@
libdir       := @libdir@
bindir       := @bindir@
includedir   := @includedir@

version_info := @version_info@


# The directory where all object files are placed.
#
# Note that this is not $(TOP)/obj!
# This lets you build the library in your own directory with something like
#
#   set TOP=.../path/to/freetype2/top/dir...
#   mkdir obj
#   make -f $TOP/Makefile setup [options]
#   make -f $TOP/Makefile
#
OBJ_DIR := obj


# The directory where all library files are placed.
#
# By default, this is the same as $(OBJ_DIR), however, this can be changed
# to suit particular needs.
#
LIB_DIR := $(OBJ_DIR)


# The object file extension (for standard and static libraries).  This can be
# .o, .tco, .obj, etc., depending on the platform.
#
O  := lo
SO := o

# The library file extension (for standard and static libraries).  This can
# be .a, .lib, etc., depending on the platform.
#
A  := la
SA := a


# The name of the final library file.  Note that the DOS-specific Makefile
# uses a shorter (8.3) name.
#
LIBRARY := libfreetype


# Path inclusion flag.  Some compilers use a different flag than `-I' to
# specify an additional include path.  Examples are `/i=' or `-J'.
#
I := -I


# C flag used to define a macro before the compilation of a given source
# object.  Usually is `-D' like in `-DDEBUG'.
#
D := -D


# The link flag used to specify a given library file on link.  Note that
# this is only used to compile the demo programs, not the library itself.
#
L := -l


# Target flag.
#
T := -o # Don't remove this comment line!  We need the space after `-o'.


# C flags
#
#   These should concern: debug output, optimization & warnings.
#
#   Use the ANSIFLAGS variable to define the compiler flags used to enfore
#   ANSI compliance.
#
CFLAGS := -c @XX_CFLAGS@ @CFLAGS@

# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
#
ANSIFLAGS := @XX_ANSIFLAGS@

# C compiler to use -- we use libtool!
#
#
CCraw := $(CC)
CC    := $(LIBTOOL) --mode=compile $(CCraw)

# Linker flags.
#
LDFLAGS := @LDFLAGS@


ifdef BUILD_FREETYPE

  # Now include the main sub-makefile.  It contains all the rules used to
  # build the library with the previous variables defined.
  #
  include $(TOP)/builds/freetype.mk


  # The cleanup targets.
  #
  clean_freetype: clean_freetype_unix
  distclean_freetype: distclean_freetype_unix


  # Unix installation and deinstallation targets.
  install: $(FT_LIBRARY)
	  $(MKINSTALLDIRS) $(libdir)                       \
                           $(includedir)/freetype/config   \
                           $(includedir)/freetype/internal
	  $(LIBTOOL) --mode=install $(INSTALL) $(FT_LIBRARY) $(libdir)
	  -for P in $(PUBLIC_H) ; do                     \
            $(INSTALL_DATA) $$P $(includedir)/freetype ; \
          done
	  -for P in $(BASE_H) ; do                                \
            $(INSTALL_DATA) $$P $(includedir)/freetype/internal ; \
          done
	  -for P in $(CONFIG_H) ; do                            \
            $(INSTALL_DATA) $$P $(includedir)/freetype/config ; \
          done

  uninstall:
	  -$(LIBTOOL) --mode=uninstall $(RM) $(libdir)/$(LIBRARY).$A
	  -$(DELETE) $(includedir)/freetype/config/*
	  -$(DELDIR) $(includedir)/freetype/config
	  -$(DELETE) $(includedir)/freetype/internal/*
	  -$(DELDIR) $(includedir)/freetype/internal
	  -$(DELETE) $(includedir)/freetype/*
	  -$(DELDIR) $(includedir)/freetype


  # Unix cleaning and distclean rules.
  #
  clean_freetype_unix:
	  -$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S)
	  -$(DELETE) $(subst $O,$(SO),$(BASE_OBJECTS) $(OBJ_M) $(OBJ_S)) \
                     $(CLEAN)

  distclean_freetype_unix: clean_freetype_unix
	  -$(DELETE) $(FT_LIBRARY)
	  -$(DELETE) $(OBJ_DIR)/.libs/*
	  -$(DELDIR) $(OBJ_DIR)/.libs
	  -$(DELETE) *.orig *~ core *.core $(DISTCLEAN)


  # Librarian to use to build the library
  #
  FT_LIBRARIAN := $(LIBTOOL) --mode=link $(CCraw)


  # This final rule is used to link all object files into a single library.
  # It is part of the system-specific sub-Makefile because not all
  # librarians accept a simple syntax like
  #
  #   librarian library_file {list of object files}
  #
  $(FT_LIBRARY): $(OBJECTS_LIST)
	  $(FT_LIBRARIAN) -o $@ $(OBJECTS_LIST) \
                          -rpath $(libdir) -version-info $(version_info)

endif

# EOF
