mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2026-02-04 04:50:32 +01:00
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 (<http://bugs.debian.org/482884>). Based on work by Colin Walters <walters@verbum.org>
This commit is contained in:
parent
57d6c40d7a
commit
01005bbbd0
3 changed files with 86 additions and 35 deletions
|
|
@ -21,7 +21,11 @@ EXTRA_DIST = $(m4_DATA) $(man_MANS) README.win32
|
|||
bin_PROGRAMS = pkg-config
|
||||
AM_CFLAGS=@WARN_CFLAGS@
|
||||
|
||||
INCLUDES=-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" @GLIB_CFLAGS@ \
|
||||
INCLUDES= \
|
||||
-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" \
|
||||
-DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"$(system_include_path)\"" \
|
||||
-DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"$(system_library_path)\"" \
|
||||
@GLIB_CFLAGS@ \
|
||||
$(popt_includes)
|
||||
|
||||
pkg_config_SOURCES= \
|
||||
|
|
|
|||
30
configure.ac
30
configure.ac
|
|
@ -34,6 +34,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.
|
||||
#
|
||||
|
|
@ -92,11 +117,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$GLIB_CFLAGS" = "x" && test "x$GLIB_LIBS" = "x"; then
|
||||
AC_CHECK_PROGS([PKG_CONFIG], [pkg-config], [])
|
||||
if test -n $PKG_CONFIG && $PKG_CONFIG --exists glib-2.0; then
|
||||
|
|
|
|||
85
pkg.c
85
pkg.c
|
|
@ -744,7 +744,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 */
|
||||
|
||||
|
|
@ -856,20 +856,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, c_include_path);
|
||||
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, search_path);
|
||||
}
|
||||
|
||||
count = 0;
|
||||
|
|
@ -922,31 +928,52 @@ verify_package (Package *pkg)
|
|||
g_slist_foreach (system_directories, (GFunc) g_free, NULL);
|
||||
g_slist_free (system_directories);
|
||||
|
||||
#ifdef PREFER_LIB64
|
||||
#define SYSTEM_LIBDIR "/usr/lib64"
|
||||
#else
|
||||
#define SYSTEM_LIBDIR "/usr/lib"
|
||||
#endif
|
||||
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);
|
||||
|
||||
count = 0;
|
||||
iter = pkg->L_libs;
|
||||
while (iter != NULL)
|
||||
{
|
||||
if (strcmp (iter->data, "-L" SYSTEM_LIBDIR) == 0 ||
|
||||
strcmp (iter->data, "-L " SYSTEM_LIBDIR) == 0)
|
||||
{
|
||||
debug_spew ("Package %s has -L" SYSTEM_LIBDIR " in Libs\n",
|
||||
pkg->name);
|
||||
if (g_getenv ("PKG_CONFIG_ALLOW_SYSTEM_LIBS") == NULL)
|
||||
{
|
||||
iter->data = NULL;
|
||||
++count;
|
||||
debug_spew ("Removing -L" SYSTEM_LIBDIR " from libs for %s\n", pkg->key);
|
||||
}
|
||||
}
|
||||
GSList *system_dir_iter = system_directories;
|
||||
|
||||
while (system_dir_iter != NULL)
|
||||
{
|
||||
gboolean is_system = FALSE;
|
||||
const char *linker_arg = iter->data;
|
||||
const char *system_libpath = system_dir_iter->data;
|
||||
|
||||
if (strncmp (linker_arg, "-L ", 3) == 0 &&
|
||||
strcmp (linker_arg + 3, system_libpath) == 0)
|
||||
is_system = TRUE;
|
||||
else if (strncmp (linker_arg, "-L", 2) == 0 &&
|
||||
strcmp (linker_arg + 2, system_libpath) == 0)
|
||||
is_system = TRUE;
|
||||
if (is_system)
|
||||
{
|
||||
debug_spew ("Package %s has -L %s in Libs\n",
|
||||
pkg->name, system_libpath);
|
||||
if (g_getenv ("PKG_CONFIG_ALLOW_SYSTEM_LIBS") == NULL)
|
||||
{
|
||||
iter->data = NULL;
|
||||
++count;
|
||||
debug_spew ("Removing -L %s from libs for %s\n", system_libpath, pkg->key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
system_dir_iter = system_dir_iter->next;
|
||||
}
|
||||
iter = iter->next;
|
||||
}
|
||||
#undef SYSTEM_LIBDIR
|
||||
g_slist_free (system_directories);
|
||||
|
||||
while (count)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue