ref: bfe872dad159882ddbc6e5409403b7b3f94c9b27
parent: 82a07e93789aefc149df7b91fa01a90835530328
author: Suzuki, Toshiya (鈴木俊哉) <[email protected]>
date: Sat Oct 14 09:08:05 EDT 2006
* preliminary autoconf-based cross-building support
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2006-10-14 suzuki toshiya <[email protected]>
+
+ * docs/INSTALL.CROSS: New document file for cross-building.
+
+ * builds/unix/configure.raw: Preliminary cross-building support.
+ Find native C compiler and pass it by CC_BUILD, and
+ find suffix for native executable and pass it by EXEEXT_BUILD.
+ Also suffix for target executable is passed by EXEEXT.
+
+ * builds/unix/unix-cc.in: CCraw_build and E_BUILD are introduced
+ to build apinames which runs on building system. They are set by
+ CC_BUILD and EXEEXT_BUILD.
+
+ * builds/exports.mk: Change the extension for apinames from the
+ suffix for target (E) to that for building host (E_BUILD).
+
2006-10-12 Werner Lemberg <[email protected]>
* docs/INSTALL.UNX, docs/UPGRADE.UNX: Renamed to...
--- a/builds/exports.mk
+++ b/builds/exports.mk
@@ -48,7 +48,7 @@
# Note that $(APINAMES_OPTIONS) is empty, except for Windows compilers.
#
APINAMES_SRC := $(TOP_DIR)/src/tools/apinames.c
- APINAMES_EXE := $(OBJ_DIR)/apinames$E
+ APINAMES_EXE := $(OBJ_DIR)/apinames$(E_BUILD)
$(APINAMES_EXE): $(APINAMES_SRC)
$(CCexe) $(TE)$@ $<
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -25,6 +25,8 @@
# checks for system type
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
AC_CANONICAL_TARGET
@@ -32,6 +34,42 @@
AC_PROG_CC
AC_PROG_CPP
+AC_SUBST(EXEEXT)
+
+
+# checks for native programs to generate building tool
+
+if test ${cross_compiling} = yes; then
+ AC_CHECK_PROG(CC_BUILD, ${build}-gcc, ${build-gcc})
+ test -z "${CC_BUILD}" && AC_CHECK_PROG(CC_BUILD, gcc, gcc)
+ test -z "${CC_BUILD}" && AC_CHECK_PROG(CC_BUILD, cc, cc, , , /usr/ucb/cc)
+ test -z "${CC_BUILD}" && AC_MSG_ERROR([cannot find native C compiler])
+
+ AC_MSG_CHECKING([for suffix of native executables])
+ rm -f a.* b.* a_out.exe conftest.*
+ echo > conftest.c "int main() { return 0;}"
+ ${CC_BUILD} conftest.c || AC_MSG_ERROR([native C compiler is not working])
+ rm -f conftest.c
+ if test -x a.out -o -x b.out -o -x conftest; then
+ EXEEXT_BUILD=""
+ elif test -x a_out.exe -o -x conftest.exe; then
+ EXEEXT_BUILD=".exe"
+ elif test -x conftest.* ; then
+ EXEEXT_BUILD=`echo conftest.* | sed -n '1s/^.*\.//g'`
+ fi
+ AC_MSG_RESULT($EXEEXT_BUILD)
+else
+ CC_BUILD=${CC}
+ EXEEXT_BUILD=${EXEEXT}
+fi
+
+
+if test ! -z ${EXEEXT_BUILD}; then
+ EXEEXT_BUILD=."${EXEEXT_BUILD}"
+fi
+AC_SUBST(CC_BUILD)
+AC_SUBST(EXEEXT_BUILD)
+
# get compiler flags right
--- a/builds/unix/unix-cc.in
+++ b/builds/unix/unix-cc.in
@@ -25,6 +25,12 @@
SO := o
+# The executable file extension. Although most Unix platform use no extension,
+# we copy the extension detected by autoconf, useful for cross building on
+# Unix system for non-Unix system.
+#
+E := @EXEEXT@
+
# The library file extension (for standard and static libraries). This can
# be .a, .lib, etc., depending on the platform.
#
@@ -88,10 +94,12 @@
LDFLAGS := @LDFLAGS@
-# export symbols (XXX: HOW TO DEAL WITH CROSS COMPILATION ?)
+# export symbols
#
+CCraw_build := @CC_BUILD@ # native CC of building system
+E_BUILD := @EXEEXT_BUILD@ # extension for exexutable on building system
EXPORTS_LIST := $(OBJ_DIR)/ftexport.sym
-CCexe := $(CCraw) # used to compile "apinames" only
+CCexe := $(CCraw_build) # used to compile "apinames" only
# Library linking
--- /dev/null
+++ b/docs/INSTALL.CROSS
@@ -1,0 +1,135 @@
+This document contains instructions on how to cross-build the FreeType
+library on Unix systems, for example, building binaries for Linux/MIPS
+on FreeBSD/i386. Before reading this document, please consult
+INSTALL.UNIX for required tools and the basic self-building procedure.
+
+
+ 1. Required Tools
+ -----------------
+
+ For self-building the FreeType library on a Unix system, GNU Make
+ 3.78.1 or newer is required. INSTALL.UNIX contains hints how to
+ check the installed `make'.
+
+ The GNU C compiler to cross-build the target system is required.
+ At present, using non-GNU cross compiler is not tested. The cross
+ compiler is expected to be installed with a system prefix. For
+ example, if your building system is FreeBSD/i386 and the target
+ system is Linux/MIPS, the cross compiler should be installed with
+ the name `mips-ip22-linuxelf-gcc'.
+
+ A C compiler for a self-build is required also, to build a tool
+ that is executed during the building procedure. Non-GNU self
+ compilers are acceptable, but such a setup is not tested yet.
+
+
+ 2. Configuration
+ ----------------
+
+ 2.1. Building and target system
+
+ To configure for cross-build, the options `--host=<system>' and
+ `--build=<system>' must be passed to configure. For example, if
+ your building system is FreeBSD/i386 and the target system is
+ Linux/MIPS, say
+
+ ./configure \
+ --build=i386-unknown-freebsd \
+ --host=mips-ip22-linuxelf \
+ [other options]
+
+ It should be noted that `--host=<system>' specifies the system
+ where the built binaries will be executed, not the system where
+ the build actually happens. Older versions of GNU autoconf use
+ the option pair `--host=' and `--target='. This is broken and
+ doesn't work. Similarly, an explicit CC specification like
+
+ env CC=mips-ip22-linux-gcc ./configure
+
+ or
+
+ env CC=/usr/local/mips-ip22-linux/bin/gcc ./configure
+
+ doesn't work either; such a configuration confuses the
+ `configure' script while trying to find the cross and native C
+ compilers.
+
+
+ 2.2. The prefix to install FreeType2
+
+ Setting `--prefix=<prefix>' properly is important. The prefix
+ to install FreeType2 is written into the freetype-config script
+ and freetype2.pc configuration file.
+
+ If the built FreeType 2 library is used as a part of the
+ cross-building system, the prefix is expected to be different
+ from the self-building system. For example, configuration with
+ `--prefix=/usr/local' installs binaries into the system wide
+ `/usr/local' directory which then can't be executed. This
+ causes confusion in configuration of all applications which use
+ FreeType2. Instead, use a prefix to install the cross-build
+ into a separate system tree, for example,
+ `--prefix=/usr/local/mips-ip22-linux/'.
+
+ On the other hand, if the built FreeType2 is used as a part of
+ the target system, the prefix to install should reflect the file
+ system structure of the target system.
+
+
+ 3. Building command
+ -------------------
+
+ If the configuration finishes successfuly, invoking GNU make builds
+ FreeType2. Just say
+
+ make
+
+ or
+
+ gmake
+
+ depending on the name the GNU make binary actually has.
+
+
+ 4. Installation
+ ---------------
+
+ Saying
+
+ make install
+
+ as usual to install FreeType2 into the directory tree specified by
+ the argument of the `--prefix' option.
+
+ As noted in section 2.2, FreeType2 is sometimes configured to be
+ installed into the system directory of the target system, and
+ should not be installed in the cross-building system. In such
+ cases, the make variable `DESTDIR' is useful to change the root
+ directory in the installation. For example, after
+
+ make DESTDIR=/mnt/target_system_root/ install
+
+ the built FreeType2 library files are installed into the directory
+ `/mnt/target_system_root/<prefix_in_configure>/lib'.
+
+
+ 5. TODO
+ -------
+
+ Cross building between Cygwin (or MSys) and Unix must be tested.
+
+
+----------------------------------------------------------------------
+
+Copyright 2006 by suzuki toshiya
+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.
+
+
+--- end of INSTALL.CROSS ---