From 367e3333d7672e087d43c2e48107a2fb5470e628 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 14 Feb 2010 17:05:19 +0000 Subject: [PATCH 3/3] Add --with-system-include-path etc. Instead of hard-coding /usr/include, we now use the environment variable PKG_CONFIG_SYSTEM_INCLUDE_PATH, defaulting to the argument of ./configure --with-system-include-path, which in turn defaults to /usr/include. Similarly, PKG_CONFIG_SYSTEM_LIBRARY_PATH defaults to /usr/lib or /usr/lib:/usr/lib64 as appropriate. (As currently implemented, this causes a behaviour change on Win32 - the option -I/usr/include will now be filtered out.) The intended usage is for Debian to configure pkg-config with --with-system-include-path=/usr/include/$(DEB_HOST_GNU_TYPE):/usr/include and the corresponding library path, for multiarch support (). --- Makefile.am | 6 +++++- configure.in | 30 +++++++++++++++++++++++++----- pkg.c | 42 +++++++++++++++++++++++++++--------------- 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/Makefile.am b/Makefile.am index 95998a6..f3cf84e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,7 +17,11 @@ EXTRA_DIST = $(m4_DATA) $(man_MANS) README.win32 bin_PROGRAMS = pkg-config AM_CFLAGS=@WARN_CFLAGS@ -INCLUDES=-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" $(included_glib_includes) +INCLUDES= \ + -DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" \ + -DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"$(system_include_path)\"" \ + -DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"$(system_library_path)\"" \ + $(included_glib_includes) pkg_config_SOURCES= \ pkg.h \ diff --git a/configure.in b/configure.in index f7a424c..df43546 100644 --- a/configure.in +++ b/configure.in @@ -32,6 +32,31 @@ fi PKG_CONFIG_FIND_PC_PATH +AC_MSG_CHECKING([for --with-system-include-path]) +AC_ARG_WITH(system_include_path, + [ --with-system-include-path Avoid -I flags that add the given directories ], + [ system_include_path="$withval" ], + [ system_include_path="/usr/include" ]) + AC_MSG_RESULT([$system_include_path]) + AC_SUBST([system_include_path]) + +AC_MSG_CHECKING([for --with-system-library-path]) +AC_ARG_WITH(system_library_path, + [ --with-system-library-path Avoid -L flags that add the given directories ], + [ system_library_path="$withval" ], + [ +case "$libdir" in +*lib64) + system_library_path="/usr/lib64:/usr/lib" + ;; +*) + system_library_path="/usr/lib" + ;; +esac +]) + AC_MSG_RESULT([$system_library_path]) + AC_SUBST([system_library_path]) + # # Code taken from gtk+-2.0's configure.in. # @@ -90,11 +115,6 @@ case "$host" in esac AC_MSG_RESULT([$native_win32]) -case "$libdir" in -*lib64) AC_DEFINE(PREFER_LIB64,1,[Define if your native architecture defines libdir to be $prefix/lib64 instead of $prefix/lib.]) ;; -*) : ;; -esac - if test x$native_win32 = xyes; then # On Win32, use the normal installed GLib. Yes, this is a circular # dependency. But then, only experienced hackers that presumably can diff --git a/pkg.c b/pkg.c index 66d10f6..d5602fa 100644 --- a/pkg.c +++ b/pkg.c @@ -757,7 +757,7 @@ verify_package (Package *pkg) GSList *conflicts_iter; GSList *system_dir_iter = NULL; int count; - const gchar *c_include_path; + const gchar *search_path; /* Be sure we have the required fields */ @@ -869,20 +869,26 @@ verify_package (Package *pkg) /* We make a list of system directories that gcc expects so we can remove * them. */ -#ifndef G_OS_WIN32 - system_directories = g_slist_append (NULL, g_strdup ("/usr/include")); -#endif - c_include_path = g_getenv ("C_INCLUDE_PATH"); - if (c_include_path != NULL) + search_path = g_getenv ("PKG_CONFIG_SYSTEM_INCLUDE_PATH"); + + if (search_path == NULL) { - system_directories = add_env_variable_to_list (system_directories, c_include_path); + search_path = PKG_CONFIG_SYSTEM_INCLUDE_PATH; } - - c_include_path = g_getenv ("CPLUS_INCLUDE_PATH"); - if (c_include_path != NULL) + + system_directories = add_env_variable_to_list (system_directories, search_path); + + search_path = g_getenv ("C_INCLUDE_PATH"); + if (search_path != NULL) + { + system_directories = add_env_variable_to_list (system_directories, search_path); + } + + search_path = g_getenv ("CPLUS_INCLUDE_PATH"); + if (search_path != NULL) { - system_directories = add_env_variable_to_list (system_directories, c_include_path); + system_directories = add_env_variable_to_list (system_directories, search_path); } count = 0; @@ -935,11 +941,17 @@ verify_package (Package *pkg) g_slist_foreach (system_directories, (GFunc) g_free, NULL); g_slist_free (system_directories); + system_directories = NULL; + + search_path = g_getenv ("PKG_CONFIG_SYSTEM_LIBRARY_PATH"); + + if (search_path == NULL) + { + search_path = PKG_CONFIG_SYSTEM_LIBRARY_PATH; + } + + system_directories = add_env_variable_to_list (system_directories, search_path); - system_directories = g_slist_prepend (NULL, "/usr/lib"); -#ifdef PREFER_LIB64 - system_directories = g_slist_prepend (system_directories, "/usr/lib64"); -#endif count = 0; iter = pkg->L_libs; while (iter != NULL) -- 1.7.4.1