summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2013-04-10 17:59:35 -0700
committerDan Nicholson <dbn.lists@gmail.com>2013-05-17 05:13:14 -0700
commit409ee76ce1ba3372f34ca4d14b629bd8ad8347e1 (patch)
treebf92d1d51cb3cb4544d3229ac336c409fa863c9e
parent636e804ded087d01378cf69598e237700f9376eb (diff)
downloadpkg-config-409ee76ce1ba3372f34ca4d14b629bd8ad8347e1.tar.gz
Allow more control of redefined prefix behavior
Currently the native Win32 builds default to redefining the prefix variable in .pc files based on their installation paths. This behavior is not always desired when pkg-config is being used in a traditional fixed path environment (e.g., /mingw like /usr). Allow the default to be set via configure switch --enable/disable-define-prefix, and allow it to be set both ways at runtime through the --[dont-]define-prefix pkg-config option.
-rw-r--r--configure.ac13
-rw-r--r--main.c10
-rw-r--r--parse.c6
-rw-r--r--pkg-config.119
-rw-r--r--pkg.h6
5 files changed, 40 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac
index 94666a4..4eeaa82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,6 +161,19 @@ if test "$cross_compiling" = yes && test "$native_win32" = yes; then
test "x$WINE" != x && TESTS_PKG_CONFIG='${WINE} '"$TESTS_PKG_CONFIG"
fi
+dnl On Windows, the prefix variable in .pc files can be redfined at
+dnl runtime. Allow the default behavior to be controlled.
+AC_MSG_CHECKING([if prefix should be redefined at runtime])
+AC_ARG_ENABLE([define_prefix],
+ [AS_HELP_STRING([--enable-define-prefix],
+ [redefine prefix in .pc files @<:@default=yes on Win32@:>@])],
+ [],
+ [enable_define_prefix=$native_win32])
+AC_MSG_RESULT([$enable_define_prefix])
+AC_DEFINE_UNQUOTED([ENABLE_DEFINE_PREFIX],
+ [`test "x$enable_define_prefix" = xyes && echo TRUE || echo FALSE`],
+ [Define ${prefix} in .pc files at runtime])
+
dnl
dnl Find glib or use internal copy. Required version is 2.16 for
dnl g_win32_get_package_installation_directory_of_module().
diff --git a/main.c b/main.c
index c937efc..f76ac87 100644
--- a/main.c
+++ b/main.c
@@ -462,9 +462,13 @@ static const GOptionEntry options_table[] = {
&output_opt_cb, "print which packages the package requires for static "
"linking", NULL },
#ifdef G_OS_WIN32
- { "dont-define-prefix", 0, 0, G_OPTION_ARG_NONE, &dont_define_prefix,
- "don't try to override the value of prefix for each .pc file found with "
- "a guesstimated value based on the location of the .pc file", NULL },
+ { "define-prefix", 0, 0, G_OPTION_ARG_NONE, &define_prefix,
+ "try to override the value of prefix for each .pc file found with a "
+ "guesstimated value based on the location of the .pc file", NULL },
+ { "dont-define-prefix", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE,
+ &define_prefix, "don't try to override the value of prefix for each .pc "
+ "file found with a guesstimated value based on the location of the .pc "
+ "file", NULL },
{ "prefix-variable", 0, 0, G_OPTION_ARG_STRING, &prefix_variable,
"set the name of the variable that pkg-config automatically sets",
"PREFIX" },
diff --git a/parse.c b/parse.c
index 3b549f8..4e0857d 100644
--- a/parse.c
+++ b/parse.c
@@ -35,7 +35,7 @@
#include <sys/types.h>
#ifdef G_OS_WIN32
-gboolean dont_define_prefix = FALSE;
+gboolean define_prefix = ENABLE_DEFINE_PREFIX;
char *prefix_variable = "prefix";
gboolean msvc_syntax = FALSE;
#endif
@@ -968,7 +968,7 @@ parse_line (Package *pkg, const char *untrimmed, const char *path,
pkg->vars = g_hash_table_new (g_str_hash, g_str_equal);
#ifdef G_OS_WIN32
- if (!dont_define_prefix && strcmp (tag, prefix_variable) == 0)
+ if (define_prefix && strcmp (tag, prefix_variable) == 0)
{
/* This is the prefix variable. Try to guesstimate a value for it
* for this package from the location of the .pc file.
@@ -1025,7 +1025,7 @@ parse_line (Package *pkg, const char *untrimmed, const char *path,
goto cleanup;
}
}
- else if (!dont_define_prefix &&
+ else if (define_prefix &&
orig_prefix != NULL &&
strncmp (p, orig_prefix, strlen (orig_prefix)) == 0 &&
G_IS_DIR_SEPARATOR (p[strlen (orig_prefix)]))
diff --git a/pkg-config.1 b/pkg-config.1
index c5d87d3..201b473 100644
--- a/pkg-config.1
+++ b/pkg-config.1
@@ -208,14 +208,23 @@ prints \fIfoo.lib\fP. Note that the --libs output consists of flags
for the linker, and should be placed on the cl command line after a
/link switch.
.TP
+.I "--define-prefix"
+.TQ
.I "--dont-define-prefix"
-This option is available only on Windows. It prevents \fIpkg-config\fP
-from automatically trying to override the value of the variable
-"prefix" in each .pc file.
+These options are available only on Windows. They control whether
+.I pkg-config
+overrides the value of the variable "prefix" in each .pc file. With
+\-\-define-prefix,
+.I pkg-config
+uses the installed location of the .pc file to determine the
+prefix. \-\-dont-define-prefix prevents this behavior. The default is
+usually \-\-define-prefix.
.TP
.I "--prefix-variable=PREFIX"
-Also this option is available only on Windows. It sets the name of the
-variable that \fIpkg-config\fP automatically sets as described above.
+This option is available only on Windows. It sets the name of the
+variable that
+.I pkg-config
+overrides instead of "prefix" when using the \-\-define-prefix feature.
.TP
.I "--static"
Output libraries suitable for static linking. That means including
diff --git a/pkg.h b/pkg.h
index 96943a1..74687dc 100644
--- a/pkg.h
+++ b/pkg.h
@@ -134,9 +134,9 @@ extern char *pcsysrootdir;
extern char *pkg_config_pc_path;
#ifdef G_OS_WIN32
-/* If TRUE, do not automatically define "prefix" while
- * parsing each .pc file */
-extern gboolean dont_define_prefix;
+/* If TRUE, define "prefix" in .pc files at runtime. */
+extern gboolean define_prefix;
+
/* The name of the variable that acts as prefix, unless it is "prefix" */
extern char *prefix_variable;