This is a potential security issue.
The problem is that config.h and config.mk are populated with
all variables prefixed with 'HAVE_' from the user's environment.
Example:
$ HAVE_FOO=yes ./configure
$ grep FOO config.mk
HAVE_FOO = 1
$ grep FOO config.h
#define HAVE_FOO 1
After this commit these files will only use variables set by
qb configure process and not from the user's environment. This
issue could result in hard to diagnose undefined behavior or
maybe worse?
The user should experience no change in behavior, but
developers should be more careful about setting 'HAVE_'
variables manually.
Unless the FOO variable is used by check_enabled ($2 only),
check_platform, check_lib, check_pkgconf, check_header,
check_macro or check_switch functions it should be set at
least once by the new add_opt function. The first argument
should be 'FOO' which matches the HAVE_FOO variable and the
second argument should contain 'auto', 'no' or 'yes'.
Example:
add_opt FOO yes
When in doubt its safe to use add_opt. This will also fix a
few potential issues where configure arguments used by the
user are ignored.
When the second argument is not set the FOO variable will only
be used to populate config.h and config.mk with its current
value. This should only be done in qb/qb.libs.sh in functions
that set 'HAVE_' variables.
This extends the check_platform function to support checking more
than one OS for each feature.
This also adds the match helper function to qb.init.sh to compare
one variable against a list of variables.
This extends the check_enabled function to be able to check more than
one feature. In the case of RPNG it depends on either the builtin or
system zlib, but if the system zlib was not available while the builtin
zlib was it would still be disabled erroneously.
Now it will only be disabled if both the system and builtin zlib are
disabled.
This allows enabling and disabling features for platforms
more robustly.
Fixes https://github.com/libretro/RetroArch/issues/8777
v2: Fix D3D configure checks.
v3: Cleanup.
v4: Update Makefile.msvc and Makefile.win
This fixes issues where if both check_header and check_lib are used
it would set HAVE_FOO=yes and then result in a configure failure
when check_lib failed. This was also implemented for the other functions
to avoid similar issues.
This fixes a few subtle problems with passing CFLAGS and CXXFLAGS as
environment variables for configure.
First it will now only add these variables to config.mk when they are
actually set. If they are unset then the default optimizations in the
Makefile are set. This avoids passing more than one conflicting
optimization level to the compiler.
Next all CFLAGS are added to CXXFLAGS to avoid issues with forgetting to
set both CFLAGS and CXXFLAGS. This results in the cxx compiler getting
passed several redundant optimization levels when both the CFLAGS and
CXXFLAGS environment variabls are used. Now these uses of CFLAGS in
Makefile.common are set to DEF_FLAGS. This allows adding $(DEF_FLAGS)
to the CXXFLAGS variable without adding redundant flags from CFLAGS.
v2: Update other build files.
This uses safer quoting and removes an unneeded use of printf.
Fixes the following shellcheck warning.
In qb/qb.libs.sh line 143:
if [ $3 ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.
v2: Remove redundant conditional.
This does the following.
1. Fixes checking if the CXX compiler works on platforms other than windows.
2. Turns the error when the CXX compiler is missing or doesn't work into a warning.
3. Adds HAVE_CC and HAVE_CXX.
4. Only adds CC and CXX to config.mk when HAVE_CC or HAVE_CXX are true.
5. Disables Qt companion, Vulkan, CXX_BUILD and NEED_CXX_LINKER if HAVE_CXX is false.
6. Explicitly errors when the CXX compiler is broken or missing and Qt or vulkan support is enabled.
7. No longer explicitly links with the CXX compiler on windows since this should no longer be needed.
This also adds the function `check_enabled` to `qb/qb.lib.sh` which
can be used to dynamically disable any libraries that require C++
support.
This allows a user to use --datarootdir=PATH to configure the
share directory used for pixmaps, desktop files, man pages and assets.
By default this will be '/usr/local/share'. Assets and man page install
paths can still be configured with:
--with-man_dir=PATH
and
--with-assets_dir=PATH
Some operating systems like Haiku use unconventional install paths
and this should allow them to configure their build correctly.
Haiku really should use the configure flags provided, that is why they exists.
In this case.
./configure \
--global-config-dir=$PREFIX/settings
--with-assets_dir=$PREFIX/data
--with-mand_dir=$PREFIX/documentation/man
Changing the defaults just makes the script more complicated for no good reason.
This accomplishes two things for the fallback path without pkg-config.
1. If --disable-foo is passed to configure it will explicitly skip
check_val. This has the benefit of reducing checks in
qb/config.libs.sh which are easy to break due to human error.
2. When a fallback path exists and --enable-foo is passed to configure,
but fails due to the missing -lfoo check_val will now bail and print
a configure error. However --enable-foo will still be ignored if
there is no fallback path and pkg-config is not installed.
One issue with this is that if pkg-config is installed and the package
foo is not, it will still check if -lfoo works. As not all pkg-config
implemenations can be trusted to work even if they exist this seems
unavoidable.