mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2026-05-14 11:48:10 +02:00
Make the --define-prefix feature available on all platforms
Allowing pkg-config to override the prefix variable in .pc files is a useful feature for making packages relocatable. There's nothing Windows specific about it. Freedesktop #63602 (https://bugs.freedesktop.org/show_bug.cgi?id=63602)
This commit is contained in:
parent
755639aac0
commit
43c1e0e4af
4 changed files with 27 additions and 30 deletions
2
main.c
2
main.c
|
|
@ -461,7 +461,6 @@ static const GOptionEntry options_table[] = {
|
|||
{ "print-requires-private", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
||||
&output_opt_cb, "print which packages the package requires for static "
|
||||
"linking", NULL },
|
||||
#ifdef G_OS_WIN32
|
||||
{ "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 },
|
||||
|
|
@ -472,6 +471,7 @@ static const GOptionEntry options_table[] = {
|
|||
{ "prefix-variable", 0, 0, G_OPTION_ARG_STRING, &prefix_variable,
|
||||
"set the name of the variable that pkg-config automatically sets",
|
||||
"PREFIX" },
|
||||
#ifdef G_OS_WIN32
|
||||
{ "msvc-syntax", 0, 0, G_OPTION_ARG_NONE, &msvc_syntax,
|
||||
"output -l and -L flags for the Microsoft compiler (cl)", NULL },
|
||||
#endif
|
||||
|
|
|
|||
5
parse.c
5
parse.c
|
|
@ -34,9 +34,10 @@
|
|||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
gboolean define_prefix = ENABLE_DEFINE_PREFIX;
|
||||
char *prefix_variable = "prefix";
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
gboolean msvc_syntax = FALSE;
|
||||
#endif
|
||||
|
||||
|
|
@ -943,7 +944,6 @@ parse_line (Package *pkg, const char *untrimmed, const char *path,
|
|||
if (pkg->vars == NULL)
|
||||
pkg->vars = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
if (define_prefix && strcmp (tag, prefix_variable) == 0)
|
||||
{
|
||||
/* This is the prefix variable. Try to guesstimate a value for it
|
||||
|
|
@ -1006,7 +1006,6 @@ parse_line (Package *pkg, const char *untrimmed, const char *path,
|
|||
p + strlen (pkg->orig_prefix), NULL);
|
||||
g_free (oldstr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_hash_table_lookup (pkg->vars, tag))
|
||||
{
|
||||
|
|
|
|||
46
pkg-config.1
46
pkg-config.1
|
|
@ -211,20 +211,37 @@ for the linker, and should be placed on the cl command line after a
|
|||
.I "--define-prefix"
|
||||
.TQ
|
||||
.I "--dont-define-prefix"
|
||||
These options are available only on Windows. They control whether
|
||||
These options control whether
|
||||
.I pkg-config
|
||||
overrides the value of the variable "prefix" in each .pc file. With
|
||||
\-\-define-prefix,
|
||||
overrides the value of the variable
|
||||
.I 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.
|
||||
|
||||
When this feature is enabled and a .pc file is found in a directory named
|
||||
.IR pkgconfig ,
|
||||
the prefix for that package is assumed to be the grandparent of the
|
||||
directory where the file was found, and the
|
||||
.I prefix
|
||||
variable is overridden for that file accordingly.
|
||||
|
||||
If the value of a variable in a .pc file begins with the original,
|
||||
non-overridden, value of the
|
||||
.I prefix
|
||||
variable, then the overridden value of
|
||||
.I prefix
|
||||
is used instead. This allows the feature to work even when the variables
|
||||
have been expanded in the .pc file.
|
||||
.TP
|
||||
.I "--prefix-variable=PREFIX"
|
||||
This option is available only on Windows. It sets the name of the
|
||||
variable that
|
||||
Set the name of the variable that
|
||||
.I pkg-config
|
||||
overrides instead of "prefix" when using the \-\-define-prefix feature.
|
||||
overrides instead of
|
||||
.I prefix
|
||||
when using the \-\-define-prefix feature.
|
||||
.TP
|
||||
.I "--static"
|
||||
Output libraries suitable for static linking. That means including
|
||||
|
|
@ -317,23 +334,6 @@ and
|
|||
.IR share\epkgconfig .
|
||||
This can be augmented or replaced using the standard environment
|
||||
variables described above.
|
||||
|
||||
If a .pc file is found in a directory named
|
||||
.IR pkgconfig ,
|
||||
the prefix for that package is assumed to be the grandparent of the
|
||||
directory where the file was found, and the
|
||||
.I prefix
|
||||
variable is overridden for that file accordingly.
|
||||
|
||||
If the value of a variable in a .pc file begins with the original,
|
||||
non-overridden, value of the
|
||||
.I prefix
|
||||
variable, then the overridden value of
|
||||
.I prefix
|
||||
is used instead. This allows the feature to work even when the variables
|
||||
have been expanded in the .pc file.
|
||||
|
||||
See the \-\-dont-define-prefix option for disabling this feature.
|
||||
.\"
|
||||
.SH AUTOCONF MACROS
|
||||
.TP
|
||||
|
|
|
|||
4
pkg.h
4
pkg.h
|
|
@ -85,9 +85,7 @@ struct _Package
|
|||
int libs_num; /* Number of times the "Libs" header has been seen */
|
||||
int libs_private_num; /* Number of times the "Libs.private" header has been seen */
|
||||
gboolean in_requires_chain; /* package is in current Requires chain */
|
||||
#ifdef G_OS_WIN32
|
||||
char *orig_prefix; /* original prefix value before redefinition */
|
||||
#endif
|
||||
};
|
||||
|
||||
Package *get_package (const char *name);
|
||||
|
|
@ -136,13 +134,13 @@ extern char *pcsysrootdir;
|
|||
*/
|
||||
extern char *pkg_config_pc_path;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* 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;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* If TRUE, output flags in MSVC syntax. */
|
||||
extern gboolean msvc_syntax;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue