Correct default paths on W32

LRN lrn1986 at gmail.com
Sat Mar 30 11:52:22 PDT 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 30.03.2013 21:52, LRN wrote:
> (2) has some build-time implications. For example, you'll need to 
> reconfigure pkg-config to build with different paths (with current 
> system you can just pass different stuff via command line), and 
> variables (such as ${libdir}) will also expand during configure,
> not at the moment of compiler invocation.
> 
After tinkering with the code i've realized that ${libdir} should not
be expanded at all, in fact. It is passed like that all the way to the
source code, and used as-is.

Anyway, here's a patch. Tell me what you think of it.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJRVzRlAAoJEOs4Jb6SI2Cw5SsH/1EhyI527880qd9Wjz5UDQnd
hHxi1NnQUgBBLbx8ubVQ/8a7LhvaV0rnRIO3u/GzD6KDdiQyd6r8HUEkzFd5b2EO
z6QpE/hsMjyBejsHJLtMiANwe7NyT53XdfYwoQcE30li0qtIw0UeUL2JQVVsa2VS
45Ef+RSs5TGK709rjXQ0xvEOatDU3Q0Kag3FMpN5IW7SBqCcqx6B0gSpb/GY14cQ
5DhhFyZAdeaFCUJK1bVE1CjgmSLBkzE381ET2gYUOeAlXotpudZ9PZ2yLnmzYZC7
HL4RJAzE58QgOELCwJC9aesFHO8JOdLTpF/MBR5/SyhF5rvvltwtfTmjx68UMnI=
=JQaM
-----END PGP SIGNATURE-----
-------------- next part --------------
From bf4b39e618c29f0e51c40960a05a3366d2abad92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1?=
 =?UTF-8?q?=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986 at gmail.com>
Date: Sat, 30 Mar 2013 22:49:44 +0400
Subject: [PATCH] Define default paths at configuration time, pass via
 config.h

---
 Makefile.am  | 13 -------------
 configure.ac | 41 ++++++++++++++++++++++++-----------------
 2 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 41e48e8..b808aa4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,19 +9,6 @@ endif
 SUBDIRS = $(GLIB_SUBDIR) . check
 DIST_SUBDIRS = $(SUBDIRS)
 
-# Escape paths properly on windows
-if NATIVE_WIN32
-AM_CPPFLAGS = \
-	-DPKG_CONFIG_PC_PATH="\"$(subst /,\/,$(pc_path))\"" \
-	-DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"$(subst /,\/,$(system_include_path))\"" \
-	-DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"$(subst /,\/,$(system_library_path))\""
-else
-AM_CPPFLAGS = \
-	-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" \
-	-DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"$(system_include_path)\"" \
-	-DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"$(system_library_path)\""
-endif
-
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	$(GCOV_CFLAGS) \
diff --git a/configure.ac b/configure.ac
index 2b33371..b80fcd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,22 @@ AC_ARG_VAR([TESTS_SHELL], [Path to a POSIX shell to be used for testing])
 conf_path="$PATH:`getconf PATH 2>/dev/null`"
 AC_PATH_PROGS([TESTS_SHELL], [bash ksh sh], [$CONFIG_SHELL], [$conf_path])
 
+AC_MSG_CHECKING([for Win32])
+case "$build" in
+  *-*-mingw*)
+    native_win32=yes
+    pathseparator=";"
+    defaultprefix=/mingw
+  ;;
+  *)
+    native_win32=no
+    pathseparator=":"
+    defaultprefix=/usr
+  ;;
+esac
+AC_MSG_RESULT([$native_win32])
+AM_CONDITIONAL(NATIVE_WIN32, [test "x$native_win32" = xyes])
+
 dnl
 dnl Default pkg-config search path
 dnl
@@ -44,12 +60,13 @@ AC_ARG_WITH([pc_path],
 # This is slightly wrong, but hopefully causes less confusion than
 # people being unable to find their .pc files in the standard location.
 if test "${prefix}" = "NONE"; then
-	pc_path='${libdir}/pkgconfig:${datadir}/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig'
+	pc_path="\${libdir}/pkgconfig${pathseparator}\${datadir}/pkgconfig${pathseparator}${defaultprefix}/lib/pkgconfig${pathseparator}${defaultprefix}/share/pkgconfig"
 else
-	pc_path='${libdir}/pkgconfig:${datadir}/pkgconfig'
+	pc_path="\${libdir}/pkgconfig${pathseparator}\${datadir}/pkgconfig"
 fi
 ])
 AC_MSG_RESULT([$pc_path])
+AC_DEFINE_UNQUOTED([PKG_CONFIG_PC_PATH], ["$pc_path"], [Default location of .pc files])
 AC_SUBST([pc_path])
 
 dnl
@@ -60,8 +77,9 @@ AC_ARG_WITH([system_include_path],
   [AS_HELP_STRING([--with-system-include-path],
     [avoid -I flags from the given path])],
   [system_include_path="$withval"],
-  [system_include_path="/usr/include"])
+  [system_include_path="${defaultprefix}/include"])
 AC_MSG_RESULT([$system_include_path])
+AC_DEFINE_UNQUOTED([PKG_CONFIG_SYSTEM_INCLUDE_PATH], ["$system_include_path"], [Default location of headers])
 AC_SUBST([system_include_path])
 
 dnl
@@ -76,14 +94,15 @@ AC_ARG_WITH([system_library_path],
 pc_lib_sfx=`echo "$libdir" | sed 's:.*/lib::'`
 case "$pc_lib_sfx" in
 */*|"")
-  system_library_path="/usr/lib:/lib"
+  system_library_path="${defaultprefix}/lib${pathseparator}/lib"
   ;;
 *)
-  system_library_path="/usr/lib$pc_lib_sfx:/lib$pc_lib_sfx:/usr/lib:/lib"
+  system_library_path="${defaultprefix}/lib$pc_lib_sfx${pathseparator}/lib$pc_lib_sfx${pathseparator}${defaultprefix}/lib${pathseparator}/lib"
   ;;
 esac
 ])
 AC_MSG_RESULT([$system_library_path])
+AC_DEFINE_UNQUOTED([PKG_CONFIG_SYSTEM_LIBRARY_PATH], ["$system_library_path"], [Default location of libraries])
 AC_SUBST([system_library_path])
 
 dnl Code taken from gtk+-2.0's configure.in.
@@ -137,18 +156,6 @@ if test "${GCC}" = "yes" && test "${ac_env_CFLAGS_set}" != "set"; then
 fi
 AC_SUBST(WARN_CFLAGS)
 
-AC_MSG_CHECKING([for Win32])
-case "$build" in
-  *-*-mingw*)
-    native_win32=yes
-  ;;
-  *)
-    native_win32=no
-  ;;
-esac
-AC_MSG_RESULT([$native_win32])
-AM_CONDITIONAL(NATIVE_WIN32, [test "x$native_win32" = xyes])
-
 dnl
 dnl Find glib or use internal copy. Required version is 2.16 for
 dnl g_win32_get_package_installation_directory_of_module().
-- 
1.7.11


More information about the pkg-config mailing list