shithub: freetype+ttf2subf

Download patch

ref: 1c513fbb8872bfac5631964963b6a751169a1ce6
parent: 790428905df6d91ee186156be4df462f3550fc96
author: Werner Lemberg <[email protected]>
date: Sat Feb 4 15:30:40 EST 2017

Make `freetype-config' a wrapper of `pkg-config' if possible.

Based on ideas taken from

  http://pkgs.fedoraproject.org/cgit/rpms/freetype.git/tree/freetype-multilib.patch
  http://pkgs.fedoraproject.org/cgit/rpms/freetype.git/tree/freetype-2.5.3-freetype-config-prefix.patch

* builds/unix/freetype-config.in: Rewritten.  Use `pkg-config' to
set output variables if program is available.

* docs/CHANGES, docs/freetype-config.1: Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2017-02-04  Werner Lemberg  <[email protected]>
 
+	Make `freetype-config' a wrapper of `pkg-config' if possible.
+
+	Based on ideas taken from
+
+	  http://pkgs.fedoraproject.org/cgit/rpms/freetype.git/tree/freetype-multilib.patch
+	  http://pkgs.fedoraproject.org/cgit/rpms/freetype.git/tree/freetype-2.5.3-freetype-config-prefix.patch
+
+	* builds/unix/freetype-config.in: Rewritten.  Use `pkg-config' to
+	set output variables if program is available.
+
+	* docs/CHANGES, docs/freetype-config.1: Updated.
+
+2017-02-04  Werner Lemberg  <[email protected]>
+
 	* builds/unix/unix-def.in (freetype-config): Fix permissions.
 
 2017-02-03  Werner Lemberg  <[email protected]>
--- a/builds/unix/freetype-config.in
+++ b/builds/unix/freetype-config.in
@@ -12,12 +12,56 @@
 LC_ALL=C
 export LC_ALL
 
-prefix="%prefix%"
-exec_prefix="%exec_prefix%"
-exec_prefix_set="no"
-includedir="%includedir%"
-libdir="%libdir%"
 
+# if `pkg-config' is available, use values from `freetype.pc'
+pkg-config --version >/dev/null 2>&1
+if test $? -eq 0 ; then
+  # note that option `--variable' is not affected by the
+  # PKG_CONFIG_SYSROOT_DIR environment variable
+  if test "x$SYSROOT" != "x" ; then
+    PKG_CONFIG_SYSROOT_DIR="$SYSROOT"
+    export PKG_CONFIG_SYSROOT_DIR
+  fi
+
+  prefix=`pkg-config --variable prefix freetype2`
+  exec_prefix=`pkg-config --variable exec_prefix freetype2`
+
+  includedir=`pkg-config --variable includedir freetype2`
+  libdir=`pkg-config --variable libdir freetype2`
+
+  version=`pkg-config --modversion freetype2`
+
+  cflags=`pkg-config --cflags freetype2`
+  dynamic_libs=`pkg-config --libs freetype2`
+  static_libs=`pkg-config --static --libs freetype2`
+else
+  prefix="%prefix%"
+  exec_prefix="%exec_prefix%"
+
+  includedir="%includedir%"
+  libdir="%libdir%"
+
+  version=%ft_version%
+
+  cflags="-I${SYSROOT}$includedir/freetype2"
+  dynamic_libs="-lfreetype"
+  static_libs="%LIBSSTATIC_CONFIG%"
+  if test "${SYSROOT}$libdir" != "/usr/lib"   &&
+     test "${SYSROOT}$libdir" != "/usr/lib64" ; then
+    libs_L="-L${SYSROOT}$libdir"
+  fi
+fi
+
+orig_prefix=$prefix
+orig_exec_prefix=$exec_prefix
+
+orig_includedir=$includedir
+orig_libdir=$libdir
+
+include_suffix=`echo $includedir | sed "s|$prefix||"`
+lib_suffix=`echo $libdir | sed "s|$exec_prefix||"`
+
+
 usage()
 {
   cat <<EOF
@@ -39,14 +83,17 @@
                          library
   --static               make command line options display flags
                          for static linking
+  --help                 display this help and exit
 EOF
   exit $1
 }
 
+
 if test $# -eq 0 ; then
   usage 1 1>&2
 fi
 
+
 while test $# -gt 0 ; do
   case "$1" in
   -*=*)
@@ -74,8 +121,8 @@
     echo_exec_prefix=yes
     ;;
   --version)
-    echo %ft_version%
-    exit 0
+    echo_version=yes
+    break
     ;;
   --ftversion)
     echo_ft_version=yes
@@ -92,6 +139,9 @@
   --static)
     show_static=yes
     ;;
+  --help)
+    usage 0
+    ;;
   *)
     usage 1 1>&2
     ;;
@@ -99,6 +149,7 @@
   shift
 done
 
+
 if test "$local_prefix" = "yes" ; then
   if test "$exec_prefix_set" != "yes" ; then
     exec_prefix=$prefix
@@ -105,6 +156,20 @@
   fi
 fi
 
+if test "$local_prefix" = "yes" ; then
+  includedir=${prefix}${include_suffix}
+  if test "$exec_prefix_set" = "yes" ; then
+    libdir=${exec_prefix}${lib_suffix}
+  else
+    libdir=${prefix}${lib_suffix}
+  fi
+fi
+
+
+if test "$echo_version" = "yes" ; then
+  echo $version
+fi
+
 if test "$echo_prefix" = "yes" ; then
   echo ${SYSROOT}$prefix
 fi
@@ -113,15 +178,6 @@
   echo ${SYSROOT}$exec_prefix
 fi
 
-if test "$exec_prefix_set" = "yes" ; then
-  libdir=$exec_prefix/lib
-else
-  if test "$local_prefix" = "yes" ; then
-    includedir=$prefix/include
-    libdir=$prefix/lib
-  fi
-fi
-
 if test "$echo_ft_version" = "yes" ; then
   major=`grep define ${SYSROOT}$includedir/freetype2/freetype/freetype.h \
          | grep FREETYPE_MAJOR \
@@ -136,26 +192,20 @@
 fi
 
 if test "$echo_cflags" = "yes" ; then
-  echo -I${SYSROOT}$includedir/freetype2
+  echo $cflags | sed "s|$orig_includedir/freetype2|$includedir/freetype2|"
 fi
 
 if test "$echo_libs" = "yes" ; then
-  libs="-lfreetype"
-  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
+    libs="$libs_L $static_libs"
   else
-    echo $libs
+    libs="$libs_L $dynamic_libs"
   fi
+  echo $libs | sed "s|$orig_libdir|$libdir|"
 fi
 
 if test "$echo_libtool" = "yes" ; then
-  convlib="libfreetype.la"
-  echo ${SYSROOT}$libdir/$convlib
+  echo ${SYSROOT}$libdir/libfreetype.la
 fi
 
 # EOF
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -47,6 +47,9 @@
       . Language, encoding, and name IDs have been updated to OpenType
         version 1.8.1.
 
+    - The `freetype-config' script is now a wrapper of `pkg-config' if
+      this program is available in the path.
+
 
 ======================================================================
 
--- a/docs/freetype-config.1
+++ b/docs/freetype-config.1
@@ -23,6 +23,14 @@
 installation (directory path) prefix or the FreeType version number.
 .
 .PP
+If
+.BR pkg-config (1)
+is found in the path,
+.B freetype-config
+acts as a wrapper for
+.BR pkg-config .
+.
+.PP
 This program is part of the FreeType package.
 .
 .
@@ -50,7 +58,8 @@
 .
 .TP
 .B \-\-ftversion
-Return the FreeType version number.
+Return the FreeType version number, directly derived from file
+`freetype.h'.
 .
 .TP
 .B \-\-version
@@ -72,31 +81,60 @@
 .B \-\-static
 Make command line options display flags for static linking.
 .
+.TP
+.B \-\-help
+Show help and exit.
 .
+.
 .SS Path override options
 .
 These affect any selected output option, except the libtool version
-returned by `--version'.
+returned by
+.BR \-\-version .
 .
 .TP
 .BI \-\-prefix= PREFIX
-Override `--prefix' value with
+Override
+.B \-\-prefix
+value with
 .IR PREFIX .
 .
+This also sets
+.BI \-\-exec-prefix= PREFIX
+if option
+.B \-\-exec-prefix
+is not explicitly given.
+.
 .TP
 .BI \-\-exec-prefix= EPREFIX
-Override `--exec-prefix' value with
+Override
+.B \-\-exec-prefix
+value with
 .IR EPREFIX .
 .
 .
 .SH BUGS
 In case the libraries FreeType links to are located in non-standard
-directories, the output from option
+directories, and
+.BR pkg-config (1)
+is not available, the output from option
 .B \-\-libs
 might be incomplete.
+.
 It is thus recommended to use the
 .BR pkg-config (1)
 interface instead, which is able to correctly resolve all dependencies.
+.
+.PP
+Setting
+.B \-\-exec-prefix
+(either explicitly or implicitly) might return incorrect results if
+combined with option
+.BR \-\-static .
+.
+The same problem can occur if you set the
+.B SYSROOT
+environment variable.
 .
 .
 .SH AUTHOR