shithub: freetype+ttf2subf

Download patch

ref: 93ebcbd0acec39ea697cd4c5af96710c990a66f6
parent: e962a914fdee0e442c3a3da8650edf0c04f1dae4
author: Werner Lemberg <[email protected]>
date: Mon Mar 3 02:13:45 EST 2014

Rewrite library option handling in `configure'; improve `freetype-config'.

o Introduce `auto' value for `--with-XXX' library options; this is
  now the default.

o First use `pkg-config' for library detection, then fall back to
  other tests.

* builds/unix/configure.raw (--with-zlib, --with-bzip2, --with-png,
--with-harfbuzz): Rewrite.
Use new `xxx_reqpriv', `xxx_libpriv', and `xxx_libstaticconf'
variables to collect data for `freetype2.pc' and `freetype-config'.
(FT2_EXTRA_LIBS): Renamed to ...
(ft2_extra_libs): This since it gets no longer substituted.
(REQUIRES_PRIVATE, LIBS_PRIVATE, LIBS_CONFIG, LIBSSTATIC_CONFIG):
New output variables, replacing `XXX_PKG' and `LIBXXX'.
Add notice at the end of `configure' showing the library
configuration.

* builds/unix/freetype-config.in (--static): New command line
option.
(libs): Updated.
(staticlibs): New variable, to be used if `--static' is given.
* builds/doc/freetype-config.1: Document `--static'.

* builds/unix/freetype2.in, builds/unix/unix-def.in: Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2014-03-03  Werner Lemberg  <[email protected]>
+
+	Rewrite library option handling in `configure'.
+
+	o Introduce `auto' value for `--with-XXX' library options; this is
+	  now the default.
+
+	o First use `pkg-config' for library detection, then fall back to
+	  other tests.
+
+	* builds/unix/configure.raw (--with-zlib, --with-bzip2, --with-png,
+	--with-harfbuzz): Rewrite.
+	Use new `xxx_reqpriv', `xxx_libpriv', and `xxx_libstaticconf'
+	variables to collect data for `freetype2.pc' and `freetype-config'.
+	(FT2_EXTRA_LIBS): Renamed to ...
+	(ft2_extra_libs): This since it gets no longer substituted.
+	(REQUIRES_PRIVATE, LIBS_PRIVATE, LIBS_CONFIG, LIBSSTATIC_CONFIG):
+	New output variables, replacing `XXX_PKG' and `LIBXXX'.
+	Add notice at the end of `configure' showing the library
+	configuration.
+
+	* builds/unix/freetype-config.in (--static): New command line
+	option.
+	(libs): Updated.
+	(staticlibs): New variable, to be used if `--static' is given.
+	* builds/doc/freetype-config.1: Document `--static'.
+
+	* builds/unix/freetype2.in, builds/unix/unix-def.in: Updated.
+
 2014-03-01  Werner Lemberg  <[email protected]>
 
 	Avoid `long long' warnings with older gcc compilers.
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -36,7 +36,9 @@
 
 PKG_PROG_PKG_CONFIG([0.24])
 
+LT_INIT(win32-dll)
 
+
 # checks for native programs to generate building tool
 
 if test ${cross_compiling} = yes; then
@@ -287,97 +289,217 @@
 AC_SUBST([XX_ANSIFLAGS])
 
 
+# All library tests below try `pkg-config' first.  If that fails, a function
+# from the library is tested in the traditional autoconf way (zlib, bzip2),
+# or a config script is called (libpng).
+#
+# The `xxx_reqpriv' variables are for the `Requires.private' field in
+# `freetype2.pc'.  The `xxx_libpriv' variables are for the `Libs.private'
+# field in `freetype2.pc' if pkg-config doesn't find a proper .pc file.
+#
+# The `xxx_libstaticconf' variables are for the `freetype-config' script.
+#
+# Note that a call to PKG_CHECK_MODULES(XXX, ...) sets and creates the
+# output variables `XXX_CFLAGS' and `XXX_LIBS'.  In case one or both are set
+# for a library by the user, no entry for this library is added to
+# `Requires.private'.  Instead, it gets added to `Libs.private'
+
+
 # check for system zlib
 
-# don't quote AS_HELP_STRING!
 AC_ARG_WITH([zlib],
-  AS_HELP_STRING([--without-zlib],
-                 [use internal zlib instead of system-wide]))
-if test x$with_zlib != xno && test -z "$LIBZ"; then
-  AC_CHECK_LIB([z],
-               [gzsetparams],
-               [AC_CHECK_HEADER([zlib.h], [LIBZ='-lz'])])
-fi
-if test x$with_zlib != xno && test -n "$LIBZ"; then
-  SYSTEM_ZLIB=yes
-fi
+  [AS_HELP_STRING([--with-zlib=@<:@yes|no|auto@:>@],
+                  [use system zlib instead of internal library @<:@default=auto@:>@])],
+  [], [with_zlib=auto])
 
+have_zlib=no
+if test x"$with_zlib" = xyes -o x"$with_zlib" = xauto; then
+  zlib_pkg="zlib"
+  have_zlib_pkg=no
 
-# All library tests below use `pkg-config'.  The `XXX_PKG' variables are for
-# the `Requires.private' field in `freetype2.pc'; we use the `HAVE_PKG' flag
-# to insert commas between the entries.
-HAVE_PKG=no
+  if test x"$ZLIB_CFLAGS" = x -a x"$ZLIB_LIBS" = x; then
+    PKG_CHECK_EXISTS([$zlib_pkg], [have_zlib_pkg=yes])
+  fi
+  PKG_CHECK_MODULES([ZLIB], [$zlib_pkg],
+                    [have_zlib="yes (pkg-config)"], [:])
 
+  if test $have_zlib_pkg = yes; then
+    # we have zlib.pc
+    zlib_reqpriv="$zlib_pkg"
+    zlib_libpriv=
+    zlib_libstaticconf=`$PKG_CONFIG --static --libs "$zlib_pkg"`
+  else
+    zlib_reqpriv=
 
+    if test "$have_zlib" != no; then
+      # ZLIB_CFLAGS and ZLIB_LIBS are set by the user
+      zlib_libpriv="$ZLIB_LIBS"
+      zlib_libstaticconf="$ZLIB_LIBS"
+      have_zlib="yes (ZLIB_CFLAGS and ZLIB_LIBS)"
+    else
+      # fall back to standard autoconf test
+      AC_CHECK_LIB([z],
+                   [gzsetparams],
+                   [AC_CHECK_HEADER([zlib.h],
+                                    [have_zlib="yes (autoconf test)"
+                                     zlib_libpriv="-lz"
+                                     zlib_libstaticconf="$zlib_libpriv"
+                                     ZLIB_LIBS="$zlib_libpriv"])])
+    fi
+  fi
+fi
+
+if test x"$with_zlib" = xyes -a "$have_zlib" = no; then
+  AC_MSG_ERROR([external zlib support requested but library not found])
+fi
+
+
 # check for system libbz2
 
-HAVE_LIBBZIP2=no
-# don't quote AS_HELP_STRING!
 AC_ARG_WITH([bzip2],
-  AS_HELP_STRING([--without-bzip2],
-                 [do not support bzip2 compressed fonts]))
-if test x$with_bzip2 != xno; then
-  BZIP2_PKG="bzip2"
-  # as a side effect, this call sets and creates output variables
-  # BZIP2_CFLAGS and BZIP2_LIBS
-  PKG_CHECK_MODULES([BZIP2], [$BZIP2_PKG])
-  LIBBZIP2=`$PKG_CONFIG --libs-only-l "$BZIP2_PKG"`
-  HAVE_LIBBZIP2=yes
-  AC_MSG_RESULT([$BZIP2_LIBS])
-  if test $HAVE_PKG = no; then
-    HAVE_PKG=yes
+  [AS_HELP_STRING([--with-bzip2=@<:@yes|no|auto@:>@],
+                  [support bzip2 compressed fonts @<:@default=auto@:>@])],
+  [], [with_bzip2=auto])
+
+have_bzip2=no
+if test x"$with_bzip2" = xyes -o x"$with_bzip2" = xauto; then
+  bzip2_pkg="bzip2"
+  have_bzip2_pkg=no
+
+  if test x"$BZIP2_CFLAGS" = x -a x"$BZIP2_LIBS" = x; then
+    PKG_CHECK_EXISTS([$bzip2_pkg], [have_bzip2_pkg=yes])
+  fi
+  PKG_CHECK_MODULES([BZIP2], [$bzip2_pkg],
+                    [have_bzip2="yes (pkg-config)"], [:])
+
+  if test $have_bzip2_pkg = yes; then
+    # we have bzip2.pc
+    bzip2_reqpriv="$bzip2_pkg"
+    bzip2_libpriv=
+    bzip2_libstaticconf=`$PKG_CONFIG --static --libs "$bzip2_pkg"`
   else
-    BZIP2_PKG=", $BZIP2_PKG"
+    bzip2_reqpriv=
+
+    if test "$have_bzip2" != no; then
+      # BZIP2_CFLAGS and BZIP2_LIBS are set by the user
+      bzip2_libpriv="$BZIP2_LIBS"
+      bzip2_libstaticconf="$BZIP2_LIBS"
+      have_bzip2="yes (BZIP2_CFLAGS and BZIP2_LIBS)"
+    else
+      # fall back to standard autoconf test
+      AC_CHECK_LIB([bz2],
+                   [BZ2_bzDecompress],
+                   [AC_CHECK_HEADER([bzlib.h],
+                                    [have_bzip2="yes (autoconf test)"
+                                     bzip2_libpriv="-lbz2"
+                                     bzip2_libstaticconf="$bzip2_libpriv"
+                                     BZIP2_LIBS="$bzip2_libpriv"])])
+    fi
   fi
 fi
 
+if test x"$with_bzip2" = xyes -a "$have_bzip2" = no; then
+  AC_MSG_ERROR([bzip2 support requested but library not found])
+fi
 
+
 # check for system libpng
 
-HAVE_LIBPNG=no
-# don't quote AS_HELP_STRING!
 AC_ARG_WITH([png],
-  AS_HELP_STRING([--without-png],
-                 [do not support png compressed OpenType embedded bitmaps]))
-if test x$with_png != xno; then
-  LIBPNG_PKG="libpng"
-  # as a side effect, this call sets and creates output variables
-  # LIBPNG_CFLAGS and LIBPNG_LIBS
-  PKG_CHECK_MODULES([LIBPNG], [$LIBPNG_PKG])
-  LIBPNG=`$PKG_CONFIG --libs-only-l "$LIBPNG_PKG"`
-  HAVE_LIBPNG=yes
-  AC_MSG_RESULT([$LIBPNG_LIBS])
-  if test $HAVE_PKG = no; then
-    HAVE_PKG=yes
+  [AS_HELP_STRING([--with-png=@<:@yes|no|auto@:>@],
+                  [support png compressed OpenType embedded bitmaps @<:@default=auto@:>@])],
+  [], [with_png=auto])
+
+have_libpng=no
+if test x"$with_png" = xyes -o x"$with_png" = xauto; then
+  libpng_pkg="libpng"
+  have_libpng_pkg=no
+
+  if test x"$LIBPNG_CFLAGS" = x -a x"$LIBPNG_LIBS" = x; then
+    PKG_CHECK_EXISTS([$libpng_pkg], [have_libpng_pkg=yes])
+  fi
+  PKG_CHECK_MODULES([LIBPNG], [$libpng_pkg],
+                    [have_libpng="yes (pkg-config)"], [:])
+
+  if test $have_libpng_pkg = yes; then
+    # we have libpng.pc
+    libpng_reqpriv="$libpng_pkg"
+    libpng_libpriv=
+    libpng_libstaticconf=`$PKG_CONFIG --static --libs "$libpng_pkg"`
   else
-    LIBPNG_PKG=", $LIBPNG_PKG"
+    libpng_reqpriv=
+
+    if test "$have_libpng" != no; then
+      # LIBPNG_CFLAGS and LIBPNG_LIBS are set by the user
+      libpng_libpriv="$LIBPNG_LIBS"
+      libpng_libstaticconf="$LIBPNG_LIBS"
+      have_libpng="yes (LIBPNG_CFLAGS and LIBPNG_LIBS)"
+    else
+      # fall back to config script.
+      AC_MSG_CHECKING([for libpng-config])
+      if which libpng-config > /dev/null; then
+        LIBPNG_CFLAGS=`libpng-config --cflags`
+        LIBPNG_LIBS=`libpng-config --ldflags`
+        libpng_libpriv=`libpng-config --static --ldflags`
+        libpng_libstaticconf="$libpng_libpriv"
+        have_libpng="yes (libpng-config)"
+        AC_MSG_RESULT([yes])
+      else
+        AC_MSG_RESULT([no])
+      fi
+    fi
   fi
 fi
 
+if test x"$with_png" = xyes -a "$have_libpng" = no; then
+  AC_MSG_ERROR([libpng support requested but library not found])
+fi
 
+
 # check for system libharfbuzz
 
-HAVE_HARFBUZZ=no
-# don't quote AS_HELP_STRING!
 AC_ARG_WITH([harfbuzz],
-  AS_HELP_STRING([--without-harfbuzz],
-                 [do not use improved auto-hinting of OpenType fonts]))
-if test x$with_harfbuzz != xno; then
-  HARFBUZZ_PKG="harfbuzz >= 0.9.19"
-  # as a side effect, this call sets and creates output variables
-  # HARFBUZZ_CFLAGS and HARFBUZZ_LIBS
-  PKG_CHECK_MODULES([HARFBUZZ], [$HARFBUZZ_PKG])
-  LIBHARFBUZZ=`$PKG_CONFIG --libs-only-l "$HARFBUZZ_PKG"`
-  HAVE_LIBHARFBUZZ=yes
-  AC_MSG_RESULT([$HARFBUZZ_LIBS])
-  if test $HAVE_PKG = no; then
-    HAVE_PKG=yes
+  [AS_HELP_STRING([--with-harfbuzz=@<:@yes|no|auto@:>@],
+                  [improve auto-hinting of OpenType fonts @<:@default=auto@:>@])],
+  [], [with_harfbuzz=auto])
+
+have_harfbuzz=no
+if test x"$with_harfbuzz" = xyes -o x"$with_harfbuzz" = xauto; then
+  harfbuzz_pkg="harfbuzz >= 0.9.19"
+  have_harfbuzz_pkg=no
+
+  if test x"$HARFBUZZ_CFLAGS" = x -a x"$HARFBUZZ_LIBS" = x; then
+    PKG_CHECK_EXISTS([$harfbuzz_pkg], [have_harfbuzz_pkg=yes])
+  fi
+  PKG_CHECK_MODULES([HARFBUZZ], [$harfbuzz_pkg],
+                    [have_harfbuzz="yes (pkg-config)"], [:])
+
+  if test $have_harfbuzz_pkg = yes; then
+    # we have harfbuzz.pc
+    harfbuzz_reqpriv="$harfbuzz_pkg"
+    harfbuzz_libpriv=
+    harfbuzz_libstaticconf=`$PKG_CONFIG --static --libs "$harfbuzz_pkg"`
   else
-    HARFBUZZ_PKG=", $HARFBUZZ_PKG"
+    harfbuzz_reqpriv=
+
+    if test "$have_harfbuzz" != no; then
+      # HARFBUZZ_CFLAGS and HARFBUZZ_LIBS are set by the user
+      harfbuzz_libpriv="$HARFBUZZ_LIBS"
+      harfbuzz_libstaticconf="$HARFBUZZ_LIBS"
+      have_harfbuzz="yes (HARFBUZZ_CFLAGS and HARFBUZZ_LIBS)"
+    else
+      # since HarfBuzz is quite a new library we don't fall back to a
+      # different test; additionally, it has too many dependencies
+      :
+    fi
   fi
 fi
 
+if test x"$with_harfbuzz" = xyes -a "$have_harfbuzz" = no; then
+  AC_MSG_ERROR([harfbuzz support requested but library not found])
+fi
 
+
 # Some options handling SDKs/archs in CFLAGS should be copied
 # to LDFLAGS. Apple TechNote 2137 recommends to include these
 # options in CFLAGS but not in LDFLAGS.
@@ -426,7 +548,6 @@
 
 ftmac_c="" # src/base/ftmac.c should not be included in makefiles by default
 
-# don't quote AS_HELP_STRING!
 AC_ARG_WITH([old-mac-fonts],
   AS_HELP_STRING([--with-old-mac-fonts],
                  [allow Mac resource-based fonts to be used]))
@@ -433,8 +554,8 @@
 if test x$with_old_mac_fonts = xyes; then
   orig_LDFLAGS="${LDFLAGS}"
   AC_MSG_CHECKING([CoreServices & ApplicationServices of Mac OS X])
-  FT2_EXTRA_LIBS="-Wl,-framework,CoreServices -Wl,-framework,ApplicationServices"
-  LDFLAGS="$LDFLAGS $FT2_EXTRA_LIBS"
+  ft2_extra_libs="-Wl,-framework,CoreServices -Wl,-framework,ApplicationServices"
+  LDFLAGS="$LDFLAGS $ft2_extra_libs"
   AC_LINK_IFELSE([
     AC_LANG_PROGRAM([
 
@@ -520,7 +641,7 @@
         CFLAGS="$CFLAGS -DHAVE_TYPE_RESOURCE_INDEX=0"
        ])],
     [AC_MSG_RESULT([not found])
-     FT2_EXTRA_LIBS=""
+     ft2_extra_libs=""
      LDFLAGS="${orig_LDFLAGS}"
      CFLAGS="$CFLAGS -DDARWIN_NO_CARBON"])
 else
@@ -740,7 +861,6 @@
 
 # Whether to use AppleTypeService since Mac OS X.
 
-# don't quote AS_HELP_STRING!
 AC_ARG_WITH([ats],
   AS_HELP_STRING([--with-ats],
                  [use AppleTypeService, if available (default=yes)]))
@@ -791,41 +911,91 @@
 esac
 
 
-AC_SUBST([ftmac_c])
-AC_SUBST([LIBZ])
-AC_SUBST([LIBBZIP2])
-AC_SUBST([LIBPNG])
-AC_SUBST([LIBHARFBUZZ])
-AC_SUBST([FT2_EXTRA_LIBS])
-AC_SUBST([SYSTEM_ZLIB])
+# entries in Requires.private are separated by commas;
+REQUIRES_PRIVATE="$zlib_reqpriv,     \
+                  $bzip2_reqpriv,    \
+                  $libpng_reqpriv,   \
+                  $harfbuzz_reqpriv"
+# beautify
+REQUIRES_PRIVATE=`echo "$REQUIRES_PRIVATE" \
+                  | sed -e 's/^  *//'      \
+                        -e 's/  *$//'      \
+                        -e 's/, */,/g'     \
+                        -e 's/,,*/,/g'     \
+                        -e 's/^,*//'       \
+                        -e 's/,*$//'       \
+                        -e 's/,/, /g'`
 
-AC_SUBST([BZIP2_PKG])
-AC_SUBST([LIBPNG_PKG])
-AC_SUBST([HARFBUZZ_PKG])
+LIBS_PRIVATE="$zlib_libpriv     \
+              $bzip2_libpriv    \
+              $libpng_libpriv   \
+              $harfbuzz_libpriv \
+              $ft2_extra_libs"
+# beautify
+LIBS_PRIVATE=`echo "$LIBS_PRIVATE"  \
+              | sed -e 's/^  *//'   \
+                    -e 's/  *$//'   \
+                    -e 's/  */ /g'`
 
-LT_INIT(win32-dll)
+LIBS_CONFIG="-lfreetype      \
+             $ZLIB_LIBS      \
+             $BZIP2_LIBS     \
+             $LIBPNG_LIBS    \
+             $HARFBUZZ_LIBS  \
+             $ft2_extra_libs"
+# remove -L/usr/lib and -L/usr/lib64 since `freetype-config' adds them later
+# on if necessary; also beautify
+LIBS_CONFIG=`echo "$LIBS_CONFIG"                \
+             | sed -e 's|-L */usr/lib64/* | |g' \
+                   -e 's|-L */usr/lib/* | |g'   \
+                   -e 's/^  *//'                \
+                   -e 's/  *$//'                \
+                   -e 's/  */ /g'`
 
+LIBSSTATIC_CONFIG="-lfreetype              \
+                   $zlib_libstaticconf     \
+                   $bzip2_libstaticconf    \
+                   $libpng_libstaticconf   \
+                   $harfbuzz_libstaticconf \
+                   $ft2_extra_libs"
+# remove -L/usr/lib and -L/usr/lib64 since `freetype-config' adds them later
+# on if necessary; also beautify
+LIBSSTATIC_CONFIG=`echo "$LIBSSTATIC_CONFIG"          \
+                   | sed -e 's|-L */usr/lib64/* | |g' \
+                         -e 's|-L */usr/lib/* | |g'   \
+                         -e 's/^  *//'                \
+                         -e 's/  *$//'                \
+                         -e 's/  */ /g'`
+
+
+AC_SUBST([ftmac_c])
+AC_SUBST([REQUIRES_PRIVATE])
+AC_SUBST([LIBS_PRIVATE])
+AC_SUBST([LIBS_CONFIG])
+AC_SUBST([LIBSSTATIC_CONFIG])
+
 AC_SUBST([hardcode_libdir_flag_spec])
 AC_SUBST([wl])
 AC_SUBST([build_libtool_libs])
 
+
 # changing LDFLAGS value should only be done after
 # lt_cv_prog_compiler_static_works test
 
-if test x$SYSTEM_ZLIB = xyes; then
-  CFLAGS="$CFLAGS -DFT_CONFIG_OPTION_SYSTEM_ZLIB"
-  LDFLAGS="$LDFLAGS $LIBZ"
+if test "$have_zlib" != no; then
+  CFLAGS="$CFLAGS $ZLIB_CFLAGS -DFT_CONFIG_OPTION_SYSTEM_ZLIB"
+  LDFLAGS="$LDFLAGS $ZLIB_LIBS"
 fi
 
-if test x$HAVE_LIBBZIP2 = xyes; then
-  CFLAGS="$CFLAGS $LIBBZIP2_CFLAGS -DFT_CONFIG_OPTION_USE_BZIP2"
-  LDFLAGS="$LDFLAGS $LIBBZIP2_LIBS"
+if test "$have_bzip2" != no; then
+  CFLAGS="$CFLAGS $BZIP2_CFLAGS -DFT_CONFIG_OPTION_USE_BZIP2"
+  LDFLAGS="$LDFLAGS $BZIP2_LIBS"
 fi
-if test x$HAVE_LIBPNG = xyes; then
+if test x"$have_libpng" != no; then
   CFLAGS="$CFLAGS $LIBPNG_CFLAGS -DFT_CONFIG_OPTION_USE_PNG"
   LDFLAGS="$LDFLAGS $LIBPNG_LIBS"
 fi
-if test x$HAVE_LIBHARFBUZZ = xyes; then
+if test x"$have_harfbuzz" != no; then
   CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS -DFT_CONFIG_OPTION_USE_HARFBUZZ"
   LDFLAGS="$LDFLAGS $HARFBUZZ_LIBS"
 fi
@@ -854,5 +1024,14 @@
 # AC_CONFIG_FILES([../../Jamfile:../../Jamfile.in])
 
 AC_OUTPUT
+
+AC_MSG_NOTICE([
+
+Library configuration:
+  external zlib: $have_zlib
+  bzip2:         $have_bzip2
+  libpng:        $have_libpng
+  harfbuzz:      $have_harfbuzz
+])
 
 # end of configure.raw
--- a/builds/unix/freetype-config.in
+++ b/builds/unix/freetype-config.in
@@ -38,6 +38,8 @@
   --libtool              display library name for linking with libtool
   --cflags               display flags for compiling with the FreeType
                          library
+  --static               make command line options display flags
+                         for static linking
 EOF
   exit $1
 }
@@ -88,6 +90,9 @@
   --libtool)
     echo_libtool=yes
     ;;
+  --static)
+    show_static=yes
+    ;;
   *)
     usage 1 1>&2
     ;;
@@ -137,7 +142,11 @@
 fi
 
 if test "$echo_libs" = "yes" ; then
-  libs="-lfreetype %LIBZ% %LIBBZIP2% %LIBPNG% %LIBHARFBUZZ% %FT2_EXTRA_LIBS%"
+  libs="%LIBS_CONFIG%"
+  staticlibs="%LIBSSTATIC_CONFIG%"
+  if test "$show_static" = "yes" ; then
+    libs="$staticlibs"
+  fi
   if test "${SYSROOT}$libdir" != "/usr/lib"  &&
      test "${SYSROOT}$libdir" != "/usr/lib64"; then
     echo -L${SYSROOT}$libdir $libs
--- a/builds/unix/freetype2.in
+++ b/builds/unix/freetype2.in
@@ -8,7 +8,7 @@
 Description: A free, high-quality, and portable font engine.
 Version: %ft_version%
 Requires:
-Requires.private: %BZIP2_PKG%%LIBPNG_PKG%%HARFBUZZ_PKG%
+Requires.private: %REQUIRES_PRIVATE%
 Libs: -L${libdir} -lfreetype
-Libs.private: %LIBZ% %FT2_EXTRA_LIBS%
+Libs.private: %LIBS_PRIVATE%
 Cflags: -I${includedir}
--- a/builds/unix/unix-def.in
+++ b/builds/unix/unix-def.in
@@ -62,16 +62,12 @@
 
 # Variables needed for `freetype-config' and `freetype.pc'.
 #
-FT2_EXTRA_LIBS     := @FT2_EXTRA_LIBS@
-LIBZ               := @LIBZ@
-LIBBZIP2           := @LIBBZIP2@
-LIBPNG             := @LIBPNG@
-LIBHARFBUZZ        := @LIBHARFBUZZ@
+REQUIRES_PRIVATE   := @REQUIRES_PRIVATE@
+LIBS_PRIVATE       := @LIBS_PRIVATE@
+LIBS_CONFIG        := @LIBS_CONFIG@
+LIBSSTATIC_CONFIG  := @LIBSSTATIC_CONFIG@
 build_libtool_libs := @build_libtool_libs@
 ft_version         := @ft_version@
-BZIP2_PKG          := @BZIP2_PKG@
-LIBPNG_PKG         := @LIBPNG_PKG@
-HARFBUZZ_PKG       := @HARFBUZZ_PKG@
 
 # The directory where all library files are placed.
 #
@@ -106,18 +102,15 @@
 
 $(OBJ_BUILD)/freetype-config: $(TOP_DIR)/builds/unix/freetype-config.in
 	rm -f $@ [email protected]
-	sed -e 's|%FT2_EXTRA_LIBS%|$(FT2_EXTRA_LIBS)|' \
-	    -e 's|%LIBZ%|$(LIBZ)|' \
-	    -e 's|%LIBBZIP2%|$(LIBBZIP2)|' \
-	    -e 's|%LIBPNG%|$(LIBPNG)|' \
-	    -e 's|%LIBHARFBUZZ%|$(LIBHARFBUZZ)|' \
+	sed -e 's|%LIBS_CONFIG%|$(LIBS_CONFIG)|'               \
+	    -e 's|%LIBSSTATIC_CONFIG%|$(LIBSSTATIC_CONFIG)|'   \
 	    -e 's|%build_libtool_libs%|$(build_libtool_libs)|' \
-	    -e 's|%exec_prefix%|$(exec_prefix)|' \
-	    -e 's|%ft_version%|$(ft_version)|' \
-	    -e 's|%includedir%|$(includedir)|' \
-	    -e 's|%libdir%|$(libdir)|' \
-	    -e 's|%prefix%|$(prefix)|' \
-	    $< \
+	    -e 's|%exec_prefix%|$(exec_prefix)|'               \
+	    -e 's|%ft_version%|$(ft_version)|'                 \
+	    -e 's|%includedir%|$(includedir)|'                 \
+	    -e 's|%libdir%|$(libdir)|'                         \
+	    -e 's|%prefix%|$(prefix)|'                         \
+	    $<                                                 \
 	    > [email protected]
 	chmod +x [email protected]
 	chmod a-w [email protected]
@@ -125,18 +118,15 @@
 
 $(OBJ_BUILD)/freetype2.pc: $(TOP_DIR)/builds/unix/freetype2.in
 	rm -f $@ [email protected]
-	sed -e 's|%FT2_EXTRA_LIBS%|$(FT2_EXTRA_LIBS)|' \
-	    -e 's|%LIBZ%|$(LIBZ)|' \
-	    -e 's|%BZIP2_PKG%|$(BZIP2_PKG)|' \
-	    -e 's|%LIBPNG_PKG%|$(LIBPNG_PKG)|' \
-	    -e 's|%HARFBUZZ_PKG%|$(HARFBUZZ_PKG)|' \
+	sed -e 's|%REQUIRES_PRIVATE%|$(REQUIRES_PRIVATE)|'     \
+	    -e 's|%LIBS_PRIVATE%|$(LIBS_PRIVATE)|'             \
 	    -e 's|%build_libtool_libs%|$(build_libtool_libs)|' \
-	    -e 's|%exec_prefix%|$(exec_prefix)|' \
-	    -e 's|%ft_version%|$(ft_version)|' \
-	    -e 's|%includedir%|$(includedir)|' \
-	    -e 's|%libdir%|$(libdir)|' \
-	    -e 's|%prefix%|$(prefix)|' \
-	    $< \
+	    -e 's|%exec_prefix%|$(exec_prefix)|'               \
+	    -e 's|%ft_version%|$(ft_version)|'                 \
+	    -e 's|%includedir%|$(includedir)|'                 \
+	    -e 's|%libdir%|$(libdir)|'                         \
+	    -e 's|%prefix%|$(prefix)|'                         \
+	    $<                                                 \
 	    > [email protected]
 	chmod a-w [email protected]
 	mv [email protected] $@
--- a/docs/freetype-config.1
+++ b/docs/freetype-config.1
@@ -68,6 +68,10 @@
 .B \-\-cflags
 Return compiler flags for compiling against the installed FreeType library.
 .
+.TP
+.B \-\-static
+Make command line options display flags for static linking.
+.
 .
 .SS Path override options
 .