From e3ab2e383aa0bb71b46d3ddc58966c6637949b48 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sun, 5 May 2002 10:57:06 +0000 Subject: [PATCH] FreeType 2 can now be built in an external directory with the configure script also. * builds/freetype.mk (INCLUDES): Add `OBJ_DIR'. * builds/unix/detect.mk (have_mk): New variable to test for external build. (unix-def.mk): Defined according to value of `have_mk'. * builds/unix/unix.mk (have_mk): New variable to test for external build. Select include paths for unix-def.mk and unix-cc.mk according to value of `have_mk'. * builds/unix/unix-def.in (OBJ_BUILD): New variable. (DISTCLEAN): Use it. * builds/unix/unix-cc.in (LIBTOOL): Define default value only if not yet defined. * builds/unix/install.mk (install): Use `OBJ_BUILD' for installing freetype-config. * configure: Don't depend on bash features. (ft2_dir, abs_curr_dir, abs_ft2_dir): New variables (code partially taken from Autoconf). Build a dummy Makefile if not building in source tree. * docs/INSTALL: Document it. --- ChangeLog | 28 +++++++++++++++++++++++++++ builds/freetype.mk | 2 +- builds/unix/detect.mk | 13 ++++++++++--- builds/unix/install.mk | 2 +- builds/unix/unix-cc.in | 4 +++- builds/unix/unix-def.in | 36 ++++++++++++++++++++--------------- builds/unix/unix.mk | 14 ++++++++++---- configure | 42 +++++++++++++++++++++++++++++++++++++++-- docs/INSTALL | 22 +++++++++++++++++---- 9 files changed, 132 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 949e8f1d2..e8bef62ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2002-05-05 Werner Lemberg + + FreeType 2 can now be built in an external directory with the + configure script also. + + * builds/freetype.mk (INCLUDES): Add `OBJ_DIR'. + + * builds/unix/detect.mk (have_mk): New variable to test for + external build. + (unix-def.mk): Defined according to value of `have_mk'. + * builds/unix/unix.mk (have_mk): New variable to test for + external build. + Select include paths for unix-def.mk and unix-cc.mk according + to value of `have_mk'. + * builds/unix/unix-def.in (OBJ_BUILD): New variable. + (DISTCLEAN): Use it. + * builds/unix/unix-cc.in (LIBTOOL): Define default value only + if not yet defined. + * builds/unix/install.mk (install): Use `OBJ_BUILD' for installing + freetype-config. + + * configure: Don't depend on bash features. + (ft2_dir, abs_curr_dir, abs_ft2_dir): New variables (code + partially taken from Autoconf). + Build a dummy Makefile if not building in source tree. + + * docs/INSTALL: Document it. + 2002-05-04 David Turner * src/truetype/ttgload.c (TT_Load_Glyph): Finally fixing the last diff --git a/builds/freetype.mk b/builds/freetype.mk index 62e42ea45..96473d85f 100644 --- a/builds/freetype.mk +++ b/builds/freetype.mk @@ -130,7 +130,7 @@ PROJECT_LIBRARY := $(LIB_)$(LIBRARY).$A # in the `freetype/builds/' directory, as these # files will override the default sources. # -INCLUDES := $(BUILD) $(TOP)$(SEP)include +INCLUDES := $(OBJ_DIR) $(BUILD) $(TOP)$(SEP)include INCLUDE_FLAGS = $(INCLUDES:%=$I%) diff --git a/builds/unix/detect.mk b/builds/unix/detect.mk index 6af635cfe..a6eb658d0 100644 --- a/builds/unix/detect.mk +++ b/builds/unix/detect.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2002 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -72,8 +72,15 @@ ifeq ($(PLATFORM),unix) setup: std_setup - unix-def.mk: $(TOP)/builds/unix/unix-def.in - cd builds/unix; ./configure $(CFG) + have_mk := $(strip $(wildcard $(OBJ_DIR)/Makefile)) + ifneq ($(have_mk),) + # we are building FT2 not in the src tree + unix-def.mk: $(TOP)/builds/unix/unix-def.in + $(TOP)/builds/unix/configure $(CFG) + else + unix-def.mk: $(TOP)/builds/unix/unix-def.in + cd builds/unix; ./configure $(CFG) + endif endif # test PLATFORM unix diff --git a/builds/unix/install.mk b/builds/unix/install.mk index 161ce06a5..add09b3e6 100644 --- a/builds/unix/install.mk +++ b/builds/unix/install.mk @@ -36,7 +36,7 @@ install: $(PROJECT_LIBRARY) $(INSTALL_DATA) $$P $(includedir)/freetype2/freetype/cache ; \ done $(INSTALL_DATA) $(BUILD)/ft2unix.h $(includedir)/ft2build.h - $(INSTALL_SCRIPT) -m 755 $(BUILD)/freetype-config \ + $(INSTALL_SCRIPT) -m 755 $(OBJ_BUILD)/freetype-config \ $(bindir)/freetype-config diff --git a/builds/unix/unix-cc.in b/builds/unix/unix-cc.in index 0e53a65b0..7a87396b7 100644 --- a/builds/unix/unix-cc.in +++ b/builds/unix/unix-cc.in @@ -3,7 +3,9 @@ CC := @CC@ -LIBTOOL := $(BUILD)/libtool +ifndef LIBTOOL + LIBTOOL := $(BUILD)/libtool +endif # The object file extension (for standard and static libraries). This can be diff --git a/builds/unix/unix-def.in b/builds/unix/unix-def.in index f7781bc50..6fcf06ea0 100644 --- a/builds/unix/unix-def.in +++ b/builds/unix/unix-def.in @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2002 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -18,12 +18,17 @@ ifndef TOP endif TOP := $(shell cd $(TOP); pwd) -DELETE := @RMF@ -DELDIR := @RMDIR@ -SEP := / -HOSTSEP := $(SEP) -BUILD := $(TOP)/builds/unix -PLATFORM := unix +DELETE := @RMF@ +DELDIR := @RMDIR@ +SEP := / +HOSTSEP := $(SEP) +BUILD := $(TOP)/builds/unix +PLATFORM := unix + +# this is used for `make distclean' and `make install' +ifndef OBJ_BUILD + OBJ_BUILD := $(BUILD) +endif # don't use `:=' here since the path stuff will be included after this file # @@ -35,14 +40,15 @@ INSTALL_PROGRAM := @INSTALL_PROGRAM@ INSTALL_SCRIPT := @INSTALL_SCRIPT@ MKINSTALLDIRS := $(BUILD)/mkinstalldirs -DISTCLEAN += $(BUILD)/config.cache \ - $(BUILD)/config.log \ - $(BUILD)/config.status \ - $(BUILD)/unix-def.mk \ - $(BUILD)/unix-cc.mk \ - $(BUILD)/ftconfig.h \ - $(BUILD)/freetype-config \ - $(LIBTOOL) +DISTCLEAN += $(OBJ_BUILD)/config.cache \ + $(OBJ_BUILD)/config.log \ + $(OBJ_BUILD)/config.status \ + $(OBJ_BUILD)/unix-def.mk \ + $(OBJ_BUILD)/unix-cc.mk \ + $(OBJ_BUILD)/ftconfig.h \ + $(OBJ_BUILD)/freetype-config \ + $(LIBTOOL) \ + $(OBJ_BUILD)/Makefile # Standard installation variables. diff --git a/builds/unix/unix.mk b/builds/unix/unix.mk index 5488d7baa..57d951a6a 100644 --- a/builds/unix/unix.mk +++ b/builds/unix/unix.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000 by +# Copyright 1996-2000, 2002 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -12,9 +12,15 @@ # indicate that you have read the license and understand and accept it # fully. - -include $(TOP)/builds/unix/unix-def.mk -include $(TOP)/builds/unix/unix-cc.mk +have_mk := $(strip $(wildcard $(TOP)/builds/unix/unix-def.mk)) +ifneq ($(have_mk),) + include $(TOP)/builds/unix/unix-def.mk + include $(TOP)/builds/unix/unix-cc.mk +else + # we are building FT2 not in the src tree + include $(OBJ_DIR)/unix-def.mk + include $(OBJ_DIR)/unix-cc.mk +endif ifdef BUILD_PROJECT diff --git a/configure b/configure index bd4c5231f..982a1df06 100644 --- a/configure +++ b/configure @@ -9,14 +9,52 @@ # install # -if [ "x$GNUMAKE" = x ]; then +if test "x$GNUMAKE" = x; then GNUMAKE=make fi -if [ `$GNUMAKE -v 2>/dev/null|grep -ic gnu` -eq 0 ]; then +if test -z "`$GNUMAKE -v 2>/dev/null | grep GNU`"; then echo "Sorry, GNU make is required to build FreeType2." >&2 echo "Please try \`GNUMAKE= $0'." >&2 exit 1 fi +# Uh, oh. This is taken from autoconf. They know what they are doing... + +if expr a : '\(a\)' >/dev/null 2>&1; then + ft_expr=expr +else + ft_expr=false +fi + +ft2_dir=`(dirname "$0") 2>/dev/null || +$ft_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + +abs_curr_dir=`pwd` +abs_ft2_dir=`cd "$ft2_dir" && pwd` + +# build a dummy Makefile if we are not building in the source tree + +if test "$abs_curr_dir" != "$abs_ft2_dir"; then + echo "OBJ_DIR=$abs_curr_dir" > Makefile + echo "TOP=$abs_ft2_dir" >> Makefile + echo "OBJ_BUILD=$abs_curr_dir" >> Makefile + echo "LIBTOOL=$abs_curr_dir/libtool" >> Makefile + echo "include $abs_ft2_dir/Makefile" >> Makefile +fi + +# call make + CFG="$@" $GNUMAKE setup unix + +# eof diff --git a/docs/INSTALL b/docs/INSTALL index 70caa8669..e959ed8d6 100644 --- a/docs/INSTALL +++ b/docs/INSTALL @@ -35,7 +35,6 @@ II. From the command line The second one is to use "GNU Make" (and NO OTHER MAKE TOOL). - 1. Building FT2 with "Jam" -------------------------- @@ -60,7 +59,6 @@ II. From the command line should become automatic on Unix systems. - 2. Building FT2 with "GNU Make" ------------------------------- @@ -119,8 +117,24 @@ II. From the command line - make setup lcc -> Win32-LCC -II. In your own environment (IDE) ---------------------------------- + If you want to build FreeType 2 in another directory, you must set + two environment variables, `OJB_DIR' and `TOP'. The former gives + the directory where the object files and the library should be + created (this directory must exist), the latter the top directory of + the FreeType 2 source tree. Example: + + OBJ_DIR=~/freetype2.compiled TOP=~/freetype2 \ + make -f$TOP/Makefile setup ansi + OBJ_DIR=~/freetype2.compiled TOP=~/freetype2 \ + make -f$TOP/Makefile + + On Unix boxes, calling `configure' from the build directory is + sufficient; it will build a small Makefile which calls the + FreeType 2 Makefile with the necessary parameters. + + +III. In your own environment (IDE) +---------------------------------- You need to add the directories "freetype2/include" to your include path when compiling the library.