forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathqb.comp.sh
136 lines (106 loc) · 2.65 KB
/
qb.comp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
. qb/config.comp.sh
TEMP_C=.tmp.c
TEMP_CXX=.tmp.cxx
TEMP_EXE=.tmp
CC="${CC:-}"
CXX="${CXX:-}"
PKG_CONF_PATH="${PKG_CONF_PATH:-}"
WINDRES="${WINDRES:-}"
# Checking for working C compiler
cat << EOF > "$TEMP_C"
#include <stdio.h>
int main(void) { puts("Hai world!"); return 0; }
EOF
# 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 ... '
cc_works=0
add_opt CC no
if [ "$CC" ]; then
if test_compiler "$CC" "$TEMP_C"; then
cc_works=1
fi
else
for cc in gcc cc clang; do
if test_compiler "${CROSS_COMPILE}${cc}" "$TEMP_C"; then
CC="$compiler"
cc_works=1
break
fi
done
fi
rm -f -- "$TEMP_C" "$TEMP_EXE"
cc_status='does not work'
if [ "$cc_works" = '1' ]; then
cc_status='works'
HAVE_CC='yes'
elif [ -z "$CC" ]; then
cc_status='not found'
fi
printf %s\\n "$CC $cc_status"
if [ "$cc_works" = '0' ] && [ "$USE_LANG_C" = 'yes' ]; then
die 1 'Error: Cannot proceed without a working C compiler.'
fi
# Checking for working C++
cat << EOF > "$TEMP_CXX"
#include <iostream>
int main() { std::cout << "Hai guise" << std::endl; return 0; }
EOF
printf %s 'Checking for suitable working C++ compiler ... '
cxx_works=0
add_opt CXX no
if [ "$CXX" ]; then
if test_compiler "$CXX" "$TEMP_CXX"; then
cxx_works=1
fi
else
for cxx in g++ c++ clang++; do
if test_compiler "${CROSS_COMPILE}${cxx}" "$TEMP_CXX"; then
CXX="$compiler"
cxx_works=1
break
fi
done
fi
rm -f -- "$TEMP_CXX" "$TEMP_EXE"
cxx_status='does not work'
if [ "$cxx_works" = '1' ]; then
cxx_status='works'
HAVE_CXX='yes'
elif [ -z "$CXX" ]; then
cxx_status='not found'
fi
printf %s\\n "$CXX $cxx_status"
if [ "$cxx_works" = '0' ] && [ "$USE_LANG_CXX" = 'yes' ]; then
die : 'Warning: A working C++ compiler was not found, C++ features will be disabled.'
fi
if [ "$OS" = "Win32" ]; then
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.'
fi
fi
printf %s 'Checking for pkg-config ... '
PKG_CONF_PATH="${PKG_CONF_PATH:-$(exists "${CROSS_COMPILE}pkgconf" ||
exists "${CROSS_COMPILE}pkg-config" || :)}"
printf %s\\n "${PKG_CONF_PATH:=none}"
if [ "$PKG_CONF_PATH" = "none" ]; then
die : 'Warning: pkg-config not found, package checks will fail.'
fi