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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
diff --git a/ChangeLog b/ChangeLog
index 61edea1..c85a698 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2017-02-04 Werner Lemberg <wl@gnu.org>
+ 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 <wl@gnu.org>
+
* builds/unix/unix-def.in (freetype-config): Fix permissions.
2017-02-03 Werner Lemberg <wl@gnu.org>
diff --git a/builds/unix/freetype-config.in b/builds/unix/freetype-config.in
index 6c3e118..d20431b 100644
--- a/builds/unix/freetype-config.in
+++ b/builds/unix/freetype-config.in
@@ -12,11 +12,55 @@
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()
{
@@ -39,14 +83,17 @@ Options:
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 @@ while test $# -gt 0 ; do
echo_exec_prefix=yes
;;
--version)
- echo %ft_version%
- exit 0
+ echo_version=yes
+ break
;;
--ftversion)
echo_ft_version=yes
@@ -92,6 +139,9 @@ while test $# -gt 0 ; do
--static)
show_static=yes
;;
+ --help)
+ usage 0
+ ;;
*)
usage 1 1>&2
;;
@@ -99,12 +149,27 @@ while test $# -gt 0 ; do
shift
done
+
if test "$local_prefix" = "yes" ; then
if test "$exec_prefix_set" != "yes" ; then
exec_prefix=$prefix
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 @@ if test "$echo_exec_prefix" = "yes" ; then
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 @@ if test "$echo_ft_version" = "yes" ; then
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
diff --git a/docs/CHANGES b/docs/CHANGES
index 6ef2a9d..7112b56 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -47,6 +47,9 @@ CHANGES BETWEEN 2.7.1 and 2.7.2
. 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.
+
======================================================================
diff --git a/docs/freetype-config.1 b/docs/freetype-config.1
index 76082ec..d98400d 100644
--- a/docs/freetype-config.1
+++ b/docs/freetype-config.1
@@ -23,6 +23,14 @@ FreeType library version installed on the system, such as the
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 @@ Return the executable prefix value of the installed FreeType library
.
.TP
.B \-\-ftversion
-Return the FreeType version number.
+Return the FreeType version number, directly derived from file
+`freetype.h'.
.
.TP
.B \-\-version
@@ -72,32 +81,61 @@ Return compiler flags for compiling against the installed FreeType library.
.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
.