1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00
RetroArch/qb/qb.comp.sh

137 lines
2.6 KiB
Bash
Raw Normal View History

2011-06-25 15:11:18 +00:00
. qb/config.comp.sh
2010-12-30 01:52:02 +00:00
TEMP_C=.tmp.c
TEMP_CXX=.tmp.cxx
TEMP_EXE=.tmp
2019-02-08 20:28:15 +00:00
CC="${CC:-}"
CXX="${CXX:-}"
PKG_CONF_PATH="${PKG_CONF_PATH:-}"
WINDRES="${WINDRES:-}"
2010-12-30 01:52:02 +00:00
# Checking for working C compiler
2015-06-16 23:40:25 +00:00
cat << EOF > "$TEMP_C"
2012-06-12 20:16:16 +00:00
#include <stdio.h>
int main(void) { puts("Hai world!"); return 0; }
EOF
2015-06-16 23:40:25 +00:00
2020-01-13 17:17:00 +00:00
# test_compiler:
# Check that the compiler exists in the $PATH and works
# $1 = compiler
# $2 = temporary build file
test_compiler ()
{
compiler=
for comp in $(printf %s "$1"); do
if ! next "$comp"; then
compiler="${compiler} $(exists "${comp}")" ||
return 1
fi
done
$(printf %s "$1") -o "$TEMP_EXE" "$2" >/dev/null 2>&1 || return 1
compiler="${compiler# }"
return 0
}
printf %s 'Checking for suitable working C compiler ... '
2015-06-16 23:40:25 +00:00
cc_works=0
add_opt CC no
2020-01-13 17:17:00 +00:00
2015-06-16 23:40:25 +00:00
if [ "$CC" ]; then
2020-01-13 17:17:00 +00:00
if test_compiler "$CC" "$TEMP_C"; then
cc_works=1
fi
2015-06-16 23:40:25 +00:00
else
2017-11-21 16:42:48 +00:00
for cc in gcc cc clang; do
2020-01-13 17:17:00 +00:00
if test_compiler "${CROSS_COMPILE}${cc}" "$TEMP_C"; then
CC="$compiler"
cc_works=1
break
2017-11-21 16:42:48 +00:00
fi
2015-06-16 23:40:25 +00:00
done
fi
2017-11-21 16:42:48 +00:00
rm -f -- "$TEMP_C" "$TEMP_EXE"
2015-06-16 23:40:25 +00:00
cc_status='does not work'
2015-06-17 17:31:20 +00:00
if [ "$cc_works" = '1' ]; then
2015-06-16 23:40:25 +00:00
cc_status='works'
HAVE_CC='yes'
2015-06-17 13:21:55 +00:00
elif [ -z "$CC" ]; then
2015-06-16 23:40:25 +00:00
cc_status='not found'
fi
printf %s\\n "$CC $cc_status"
2015-06-16 23:40:25 +00:00
2015-06-17 17:31:20 +00:00
if [ "$cc_works" = '0' ] && [ "$USE_LANG_C" = 'yes' ]; then
die 1 'Error: Cannot proceed without a working C compiler.'
2010-12-30 01:52:02 +00:00
fi
2012-06-12 20:16:16 +00:00
# Checking for working C++
2015-06-16 23:40:25 +00:00
cat << EOF > "$TEMP_CXX"
2012-06-12 20:16:16 +00:00
#include <iostream>
int main() { std::cout << "Hai guise" << std::endl; return 0; }
EOF
2015-06-16 23:40:25 +00:00
printf %s 'Checking for suitable working C++ compiler ... '
2015-06-16 23:40:25 +00:00
cxx_works=0
add_opt CXX no
2020-01-13 17:17:00 +00:00
2015-06-16 23:40:25 +00:00
if [ "$CXX" ]; then
2020-01-13 17:17:00 +00:00
if test_compiler "$CXX" "$TEMP_CXX"; then
cxx_works=1
fi
2015-06-16 23:40:25 +00:00
else
2017-11-21 16:42:48 +00:00
for cxx in g++ c++ clang++; do
2020-01-13 17:17:00 +00:00
if test_compiler "${CROSS_COMPILE}${cxx}" "$TEMP_CXX"; then
CXX="$compiler"
cxx_works=1
break
2017-11-21 16:42:48 +00:00
fi
2015-06-16 23:40:25 +00:00
done
fi
2017-11-21 16:42:48 +00:00
rm -f -- "$TEMP_CXX" "$TEMP_EXE"
2015-06-16 23:40:25 +00:00
cxx_status='does not work'
2015-06-16 23:45:35 +00:00
if [ "$cxx_works" = '1' ]; then
2015-06-16 23:40:25 +00:00
cxx_status='works'
HAVE_CXX='yes'
2015-06-17 13:21:55 +00:00
elif [ -z "$CXX" ]; then
2015-06-16 23:40:25 +00:00
cxx_status='not found'
fi
printf %s\\n "$CXX $cxx_status"
2015-06-16 23:40:25 +00:00
2015-06-16 23:45:35 +00:00
if [ "$cxx_works" = '0' ] && [ "$USE_LANG_CXX" = 'yes' ]; then
die : 'Warning: A working C++ compiler was not found, C++ features will be disabled.'
2010-12-30 01:52:02 +00:00
fi
2014-09-14 20:49:51 +00:00
if [ "$OS" = "Win32" ]; then
2019-11-01 16:00:35 +00:00
printf %s 'Checking for windres ... '
WINDRES="${WINDRES:-$(exists "${CROSS_COMPILE}windres" || :)}"
printf %s\\n "${WINDRES:=none}"
if [ "$WINDRES" = none ]; then
die 1 'Error: Cannot proceed without windres.'
2014-09-14 20:49:51 +00:00
fi
fi
printf %s 'Checking for pkg-config ... '
PKG_CONF_PATH="${PKG_CONF_PATH:-$(exists "${CROSS_COMPILE}pkgconf" ||
exists "${CROSS_COMPILE}pkg-config" || :)}"
2015-04-19 13:56:57 +00:00
printf %s\\n "${PKG_CONF_PATH:=none}"
2015-04-19 13:56:57 +00:00
if [ "$PKG_CONF_PATH" = "none" ]; then
die : 'Warning: pkg-config not found, package checks will fail.'
2015-04-19 13:56:57 +00:00
fi