From fcb804effea60a9b7af3b40fdad5c49eda8fd6c9 Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Thu, 14 Jul 2005 13:05:17 +0000 Subject: [PATCH] 2002-09-06 Havoc Pennington Author: hp Date: 2002-09-06 20:00:08 GMT 2002-09-06 Havoc Pennington * parse.c, pkg.c: handle other_libs other_cflags same as -l/-L/-I flags, so we pull in from dependent packages. Closes #85244, #90706, #89851 --- ChangeLog | 6 +++++ README | 5 +++- parse.c | 28 +++++++--------------- pkg.c | 72 +++++++++++++++++-------------------------------------- pkg.h | 4 ++-- 5 files changed, 42 insertions(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88778d7..dc3882d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-09-06 Havoc Pennington + + * parse.c, pkg.c: handle other_libs other_cflags same + as -l/-L/-I flags, so we pull in from dependent packages. + Closes #85244, #90706, #89851 + 2002-03-27 Havoc Pennington * pkg.c (verify_package): fix a typo diff --git a/README b/README index 4e9cf22..6efa507 100644 --- a/README +++ b/README @@ -1,7 +1,10 @@ pkg-config is a script to make putting together all the build flags when compiling/linking a lot easier. -to use it, do something like the following in your configure.in +Report bugs at http://bugzilla.gnome.org (pkg-config is in no way +gnome-specific but gnome.org was a convenient bug tracker). + +To use pkg-config, do something like the following in your configure.in PKG_CHECK_MODULES(GNOME, gtk > 1.2.8 gnomeui >= 1.2.0) AC_SUBST(GNOME_CFLAGS) diff --git a/parse.c b/parse.c index d1a66b4..4cd32ee 100644 --- a/parse.c +++ b/parse.c @@ -587,7 +587,6 @@ parse_libs (Package *pkg, const char *str, const char *path) /* Strip out -l and -L flags, put them in a separate list. */ char *trimmed; - GString *other; char **argv = NULL; int argc; int result; @@ -620,8 +619,6 @@ parse_libs (Package *pkg, const char *str, const char *path) exit (1); } - - other = g_string_new (""); i = 0; while (i < argc) @@ -675,9 +672,9 @@ parse_libs (Package *pkg, const char *str, const char *path) } else { - g_string_append_c (other, ' '); - g_string_append (other, arg); - g_string_append_c (other, ' '); + if (*arg != '\0') + pkg->other_libs = g_slist_prepend (pkg->other_libs, + g_strdup (arg)); } g_free (arg); @@ -688,12 +685,9 @@ parse_libs (Package *pkg, const char *str, const char *path) g_free (argv); g_free (trimmed); - pkg->other_libs = other->str; - - g_string_free (other, FALSE); - pkg->l_libs = g_slist_reverse (pkg->l_libs); pkg->L_libs = g_slist_reverse (pkg->L_libs); + pkg->other_libs = g_slist_reverse (pkg->other_libs); } static void @@ -702,7 +696,6 @@ parse_cflags (Package *pkg, const char *str, const char *path) /* Strip out -I flags, put them in a separate list. */ char *trimmed; - GString *other; char **argv = NULL; int argc; int result; @@ -726,8 +719,6 @@ parse_cflags (Package *pkg, const char *str, const char *path) exit (1); } - - other = g_string_new (""); i = 0; while (i < argc) @@ -761,9 +752,9 @@ parse_cflags (Package *pkg, const char *str, const char *path) } else { - if (other->len > 0) - g_string_append (other, " "); - g_string_append (other, arg); + if (*arg != '\0') + pkg->other_cflags = g_slist_prepend (pkg->other_cflags, + g_strdup (arg)); } g_free (arg); @@ -774,11 +765,8 @@ parse_cflags (Package *pkg, const char *str, const char *path) g_free (argv); g_free (trimmed); - pkg->other_cflags = other->str; - - g_string_free (other, FALSE); - pkg->I_cflags = g_slist_reverse (pkg->I_cflags); + pkg->other_cflags = g_slist_reverse (pkg->other_cflags); } static void diff --git a/pkg.c b/pkg.c index 41279bf..499f320 100644 --- a/pkg.c +++ b/pkg.c @@ -438,12 +438,24 @@ get_L_libs (Package *pkg) return pkg->L_libs; } +static GSList* +get_other_libs (Package *pkg) +{ + return pkg->other_libs; +} + static GSList * get_I_cflags (Package *pkg) { return pkg->I_cflags; } +static GSList * +get_other_cflags (Package *pkg) +{ + return pkg->other_cflags; +} + static GSList * get_conflicts (Package *pkg) { @@ -917,36 +929,16 @@ packages_get_L_libs (GSList *pkgs) char * package_get_other_libs (Package *pkg) { - return g_strdup (pkg->other_libs); + if (pkg->other_libs_merged == NULL) + pkg->other_libs_merged = get_merged (pkg, get_other_libs, TRUE); + + return pkg->other_libs_merged; } char * packages_get_other_libs (GSList *pkgs) { - GSList *tmp; - GString *str; - char *retval; - - str = g_string_new (""); - - tmp = pkgs; - while (tmp != NULL) - { - Package *pkg = tmp->data; - - if (pkg->other_libs) - { - g_string_append (str, pkg->other_libs); - g_string_append (str, " "); - } - - tmp = g_slist_next (tmp); - } - - retval = str->str; - g_string_free (str, FALSE); - - return retval; + return get_multi_merged (pkgs, get_other_libs, TRUE); } char * @@ -1004,36 +996,16 @@ packages_get_I_cflags (GSList *pkgs) char * package_get_other_cflags (Package *pkg) { - return g_strdup (pkg->other_cflags); + if (pkg->other_cflags_merged == NULL) + pkg->other_cflags_merged = get_merged (pkg, get_other_cflags, TRUE); + + return pkg->other_cflags_merged; } char * packages_get_other_cflags (GSList *pkgs) { - GSList *tmp; - GString *str; - char *retval; - - str = g_string_new (""); - - tmp = pkgs; - while (tmp != NULL) - { - Package *pkg = tmp->data; - - if (pkg->other_cflags) - { - g_string_append (str, pkg->other_cflags); - g_string_append (str, " "); - } - - tmp = g_slist_next (tmp); - } - - retval = str->str; - g_string_free (str, FALSE); - - return retval; + return get_multi_merged (pkgs, get_other_cflags, TRUE); } char * diff --git a/pkg.h b/pkg.h index bbb293a..2ab9f56 100644 --- a/pkg.h +++ b/pkg.h @@ -60,11 +60,11 @@ struct _Package char *l_libs_merged; GSList *L_libs; char *L_libs_merged; - char *other_libs; + GSList *other_libs; char *other_libs_merged; GSList *I_cflags; char *I_cflags_merged; - char *other_cflags; + GSList *other_cflags; char *other_cflags_merged; GHashTable *vars; GHashTable *required_versions; /* hash from name to RequiredVersion */ -- 2.39.5