Commit f41070fef0d9b3844c9f75714c637a8265739784

Werner Lemberg 2014-03-27T17:38:23

Fix Savannah bug #38235. Work around a bug in pkg-config version 0.28 and earlier: If a variable value gets surrounded by doublequotes (in particular values for the `prefix' variable), the prefix override mechanism fails. * builds/unix/freetype2.in: Don't use doublequotes. * builds/unix/unix-def.in (freetype.pc): Escape spaces in directory names with backslashes.

diff --git a/ChangeLog b/ChangeLog
index 0874f93..d903984 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2014-03-27  Werner Lemberg  <wl@gnu.org>
+
+	Fix Savannah bug #38235.
+
+	Work around a bug in pkg-config version 0.28 and earlier: If a
+	variable value gets surrounded by doublequotes (in particular values
+	for the `prefix' variable), the prefix override mechanism fails.
+
+	* builds/unix/freetype2.in: Don't use doublequotes.
+	* builds/unix/unix-def.in (freetype.pc): Escape spaces in directory
+	names with backslashes.
+
 2014-03-24  Werner Lemberg  <wl@gnu.org>
 
 	Fix Savannah bug #41946.
diff --git a/builds/unix/freetype2.in b/builds/unix/freetype2.in
index 6e7fb10..a488d96 100644
--- a/builds/unix/freetype2.in
+++ b/builds/unix/freetype2.in
@@ -1,7 +1,7 @@
-prefix="%prefix%"
-exec_prefix="%exec_prefix%"
-libdir="%libdir%"
-includedir="%includedir%/freetype2"
+prefix=%prefix%
+exec_prefix=%exec_prefix%
+libdir=%libdir%
+includedir=%includedir%/freetype2
 
 Name: FreeType 2
 URL: http://freetype.org
diff --git a/builds/unix/unix-def.in b/builds/unix/unix-def.in
index 6a4eef6..4c06a05 100644
--- a/builds/unix/unix-def.in
+++ b/builds/unix/unix-def.in
@@ -114,16 +114,29 @@ $(OBJ_BUILD)/freetype-config: $(TOP_DIR)/builds/unix/freetype-config.in
 	chmod a-w $@.tmp
 	mv $@.tmp $@
 
+# To support directory names with spaces (as might easily happen on Windows
+# platforms), the right solution would be to surround the pkg-variables in
+# `freetype2.pc' with double quotes.  However, doing so ironically disables
+# the prefix override mechanism especially written for Windows.  This is a
+# bug in pkg-config version 0.28 and earlier.
+#
+# For this reason, we escape spaces with backslashes.
+
+exec_prefix_x := $(subst $(space),\\$(space),$(exec_prefix))
+includedir_x  := $(subst $(space),\\$(space),$(includedir))
+libdir_x      := $(subst $(space),\\$(space),$(libdir))
+prefix_x      := $(subst $(space),\\$(space),$(prefix))
+
 $(OBJ_BUILD)/freetype2.pc: $(TOP_DIR)/builds/unix/freetype2.in
 	rm -f $@ $@.tmp
 	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|%exec_prefix%|$(exec_prefix_x)|'             \
 	    -e 's|%ft_version%|$(ft_version)|'                 \
-	    -e 's|%includedir%|$(includedir)|'                 \
-	    -e 's|%libdir%|$(libdir)|'                         \
-	    -e 's|%prefix%|$(prefix)|'                         \
+	    -e 's|%includedir%|$(includedir_x)|'               \
+	    -e 's|%libdir%|$(libdir_x)|'                       \
+	    -e 's|%prefix%|$(prefix_x)|'                       \
 	    $<                                                 \
 	    > $@.tmp
 	chmod a-w $@.tmp