From 986e4ebb03aef2ecd67c4dcc49306707ef9f68b0 Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Thu, 14 Jul 2005 13:06:42 +0000 Subject: [PATCH] 2005-04-01 Tollef Fog Heen Author: tfheen Date: 2005-04-01 21:46:07 GMT 2005-04-01 Tollef Fog Heen * configure.in: Try to detect whether this architecture supports inter-library dependencies. If so, we default to assuming that this support is used and link to the minimal set of libraries rather than traversing the full depends set. * main.c (main): Only recurse if we want a static library list or if this architecture doesn't support inter-library dependencies. This will probably expose bugs for libraries which declare dependencies in their .pc files but don't actually link against each other. * pkg.c (packages_get_all_libs): Add recurse option (packages_get_L_libs): Add recurse option (package_get_L_libs): Add recurse option (packages_get_l_libs): Add recurse option (package_get_l_libs): Add recurse option * pkg.h: Update prototypes to handle the recurse option. --- ChangeLog | 21 +++++++++++++++++ configure.in | 34 ++++++++++++++++++++++++++- main.c | 9 ++++--- pkg.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++------ pkg.h | 10 ++++---- 5 files changed, 124 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4341a6b..38daf78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2005-04-01 Tollef Fog Heen + + * configure.in: Try to detect whether this architecture supports + inter-library dependencies. If so, we default to assuming that + this support is used and link to the minimal set of libraries + rather than traversing the full depends set. + + * main.c (main): Only recurse if we want a static library list or + if this architecture doesn't support inter-library dependencies. + This will probably expose bugs for libraries which declare + dependencies in their .pc files but don't actually link against + each other. + + * pkg.c (packages_get_all_libs): Add recurse option + (packages_get_L_libs): Add recurse option + (package_get_L_libs): Add recurse option + (packages_get_l_libs): Add recurse option + (package_get_l_libs): Add recurse option + + * pkg.h: Update prototypes to handle the recurse option. + 2005-03-29 Tollef Fog Heen * check/check-cflags, check/check-define-variable, diff --git a/configure.in b/configure.in index 3010b8f..d0baabd 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ AC_INIT(pkg-config.1) -AM_INIT_AUTOMAKE(pkgconfig, 0.16.0) +AM_INIT_AUTOMAKE(pkgconfig, 0.16.1) AM_MAINTAINER_MODE AM_CONFIG_HEADER(config.h) @@ -24,6 +24,38 @@ dnl AC_DEFINE_UNQUOTED(PKG_CONFIG_PC_PATH,["$pc_path"],[Default search path for PKG_CONFIG_FIND_PC_PATH +# +# Code taken from gtk+-2.0's configure.in. +# +# This causes pkg-config to only list direct dependencies on platforms +# which support inter-library dependencies. +# + +AC_ARG_ENABLE(indirect-deps, + [AC_HELP_STRING([--enable-indirect-deps=@<:@yes/no/auto@:>@], + [list both direct and indirect dependencies. [default=auto]])],, + [enable_indirect_deps=auto]) + +AC_MSG_CHECKING([Whether to list both direct and indirect dependencies]) +case $enable_indirect_deps in + auto) + deplib_check_method=`(./libtool --config; echo eval echo \\$deplib_check_method) | sh` + if test "X$deplib_check_method" = Xnone || test "x$enable_static" = xyes ; then + enable_indirect_deps=yes + else + enable_indirect_deps=no + fi + ;; + yes|no) + ;; + *) AC_MSG_ERROR([Value given to --enable-indirect-deps must be one of yes, no +or auto]) + ;; +esac +AC_MSG_RESULT($enable_explicit_deps) + +AC_DEFINE_UNQUOTED(ENABLE_INDIRECT_DEPS, `test $enable_indirect_deps = yes; echo $?`, [Indirect shared library dependencies enabled]) + AC_MSG_CHECKING([for Win32]) case "$host" in *-*-mingw*) diff --git a/main.c b/main.c index 2ede2c4..11ca830 100644 --- a/main.c +++ b/main.c @@ -182,6 +182,7 @@ main (int argc, char **argv) int want_I_cflags = 0; int want_other_cflags = 0; int want_list = 0; + int want_static_lib_list = ENABLE_INDIRECT_DEPS; int result; int want_uninstalled = 0; char *variable_name = NULL; @@ -215,6 +216,8 @@ main (int argc, char **argv) "require given version of pkg-config", "VERSION" }, { "libs", 0, POPT_ARG_NONE, &want_libs, 0, "output all linker flags" }, + { "static", 0, POPT_ARG_NONE, &want_static_lib_list, 0, + "output linker flags for static linking" }, { "libs-only-l", 0, POPT_ARG_NONE, &want_l_libs, 0, "output -l flags" }, { "libs-only-other", 0, POPT_ARG_NONE, &want_other_libs, 0, @@ -591,14 +594,14 @@ main (int argc, char **argv) if (want_l_libs) { - char *str = packages_get_l_libs (packages); + char *str = packages_get_l_libs (packages, want_static_lib_list); printf ("%s ", str); g_free (str); need_newline = TRUE; } else if (want_L_libs) { - char *str = packages_get_L_libs (packages); + char *str = packages_get_L_libs (packages, want_static_lib_list); printf ("%s ", str); g_free (str); need_newline = TRUE; @@ -612,7 +615,7 @@ main (int argc, char **argv) } else if (want_libs) { - char *str = packages_get_all_libs (packages); + char *str = packages_get_all_libs (packages, want_static_lib_list); printf ("%s ", str); g_free (str); need_newline = TRUE; diff --git a/pkg.c b/pkg.c index 6bcaceb..7f430f6 100644 --- a/pkg.c +++ b/pkg.c @@ -998,8 +998,10 @@ get_multi_merged_from_back (GSList *pkgs, GetListFunc func, gboolean in_path_ord } char * -package_get_l_libs (Package *pkg) +package_get_l_libs (Package *pkg, gboolean recurse) { + if (!recurse) + return string_list_to_string (get_l_libs(pkg)); /* We don't want these in search path order, rather in dependency * order, so static linking works. */ @@ -1010,14 +1012,41 @@ package_get_l_libs (Package *pkg) } char * -packages_get_l_libs (GSList *pkgs) +packages_get_l_libs (GSList *pkgs, gboolean recurse) { + if (!recurse) { + GSList *tmp; + GSList *list; + GSList *dups_list = NULL; + char *retval; + + tmp = pkgs; + while (tmp != NULL) + { + dups_list = g_slist_concat (dups_list, get_l_libs(tmp->data)); + tmp = tmp->next; + } + + list = string_list_strip_duplicates_from_back (dups_list); + g_slist_free (dups_list); + + retval = string_list_to_string (list); + + g_slist_free (list); + + return retval; + + } + return get_multi_merged_from_back (pkgs, get_l_libs, FALSE); } char * -package_get_L_libs (Package *pkg) +package_get_L_libs (Package *pkg, gboolean recurse) { + if (!recurse) + return string_list_to_string (get_L_libs(pkg)); + /* We want these in search path order so the -L flags don't override PKG_CONFIG_PATH */ if (pkg->L_libs_merged == NULL) pkg->L_libs_merged = get_merged (pkg, get_L_libs, TRUE); @@ -1026,8 +1055,31 @@ package_get_L_libs (Package *pkg) } char * -packages_get_L_libs (GSList *pkgs) +packages_get_L_libs (GSList *pkgs, gboolean recurse) { + if (!recurse) { + GSList *tmp; + GSList *list; + GSList *dups_list = NULL; + char *retval; + + tmp = pkgs; + while (tmp != NULL) + { + dups_list = g_slist_concat (dups_list, get_L_libs(tmp->data)); + tmp = tmp->next; + } + + list = string_list_strip_duplicates_from_back (dups_list); + g_slist_free (dups_list); + + retval = string_list_to_string (list); + + g_slist_free (list); + + return retval; + } + return get_multi_merged (pkgs, get_L_libs, TRUE); } @@ -1047,7 +1099,7 @@ packages_get_other_libs (GSList *pkgs) } char * -packages_get_all_libs (GSList *pkgs) +packages_get_all_libs (GSList *pkgs, gboolean recurse) { char *l_libs; char *L_libs; @@ -1058,8 +1110,8 @@ packages_get_all_libs (GSList *pkgs) str = g_string_new (""); other_libs = packages_get_other_libs (pkgs); - L_libs = packages_get_L_libs (pkgs); - l_libs = packages_get_l_libs (pkgs); + L_libs = packages_get_L_libs (pkgs, recurse); + l_libs = packages_get_l_libs (pkgs, recurse); if (other_libs) g_string_append (str, other_libs); diff --git a/pkg.h b/pkg.h index a63aa3f..b5f73df 100644 --- a/pkg.h +++ b/pkg.h @@ -75,13 +75,13 @@ struct _Package }; Package *get_package (const char *name); -char * package_get_l_libs (Package *pkg); -char * packages_get_l_libs (GSList *pkgs); -char * package_get_L_libs (Package *pkg); -char * packages_get_L_libs (GSList *pkgs); +char * package_get_l_libs (Package *pkg, gboolean recurse); +char * packages_get_l_libs (GSList *pkgs, gboolean recurse); +char * package_get_L_libs (Package *pkg, gboolean recurse); +char * packages_get_L_libs (GSList *pkgs, gboolean recurse); char * package_get_other_libs (Package *pkg); char * packages_get_other_libs (GSList *pkgs); -char * packages_get_all_libs (GSList *pkgs); +char * packages_get_all_libs (GSList *pkgs, gboolean recurse); char * package_get_I_cflags (Package *pkg); char * packages_get_I_cflags (GSList *pkgs); char * package_get_other_cflags (Package *pkg); -- 2.39.5