-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·217 lines (200 loc) · 5.56 KB
/
configure
File metadata and controls
executable file
·217 lines (200 loc) · 5.56 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/usr/bin/env bash
# Check for rustc
printf "Checking for rustc..."
if [ -n "$RC" ] && command -v $RC &> /dev/null
then
echo "$RC"
elif [ -n "$RUSTC" ] && command -v $RUSTC &> /dev/null
then
echo "$RC"
RC=$RUSTC
elif ! command -v rustc &> /dev/null
then
echo "not found"
echo "rustc not found. Please install it to continue."
exit 1
else
RC=rustc
echo "rustc"
fi
# Check for cargo
printf "Checking for cargo..."
if [ -n "$CARGO" ] && command -v $CARGO &> /dev/null
then
echo "$CARGO"
elif ! command -v cargo &> /dev/null
then
echo "not found"
echo "cargo not found. Please install it to continue."
exit 1
else
CARGO=cargo
echo "cargo"
fi
# Check for make
printf "Checking for make..."
if ! command -v make &> /dev/null
then
echo "not found"
echo "make not found. Please install it to continue."
exit 1
else
echo "found"
fi
# Check for a C compiler
printf "Checking for C compiler..."
if [ -n "$CC" ] && command -v $CC &> /dev/null
then
echo "$CC"
elif command -v gcc &> /dev/null
then
CC=gcc
echo "gcc"
elif command -v clang &> /dev/null
then
CC=clang
echo "clang"
elif command -v cc &> /dev/null
then
CC=cc
echo "cc"
else
echo "not found"
echo "No C compiler found. Please install gcc, clang, or some C compiler to continue."
exit 1
fi
mkdir -p /tmp/e10b5eccac1ecb4e8706e3898719b197a1e9d10d65e860192d38155cb31233ea-configure
cd /tmp/e10b5eccac1ecb4e8706e3898719b197a1e9d10d65e860192d38155cb31233ea-configure
for header in stdio.h stdlib.h math.h; do
printf "Checking for $header..."
echo "#include <$header>" > test.c
echo "int main() { return 0; }" >> test.c
if $CC -c test.c -o test.o 2>/dev/null; then
echo "found"
else
echo "not found"
echo "Header file $header not found. Please ensure it is installed and in your include path."
exit 1
fi
rm -f test.c test.o
done
cd - > /dev/null 2>&1
rm -rf /tmp/e10b5eccac1ecb4e8706e3898719b197a1e9d10d65e860192d38155cb31233ea-configure
# Check for ar
printf "Checking for ar..."
if command -v ar &> /dev/null
then
echo "found"
else
echo "not found"
echo "ar not found. Please install it to continue. It usually comes with the binutils package."
exit 1
fi
printf "Checking if libmysolvers should be included..."
if [ "$INCLUDE_LIBMYSOLVERS" = "FALSE" ]; then
echo "no"
elif [ "$INCLUDE_LIBMYSOLVERS" = "TRUE" ]; then
echo "yes"
else
echo "no"
INCLUDE_LIBMYSOLVERS="FALSE"
fi
# Check for prefix
printf "Checking for prefix..."
if printf '%s\n' "$@" | grep -q -- "^--prefix="; then
prefix_arg=$(printf '%s\n' "$@" | grep -m1 '^--prefix=')
prefix_path="${prefix_arg#--prefix=}"
PREFIX=$prefix_path
echo "$PREFIX"
else
PREFIX="/usr/local"
echo "$PREFIX"
fi
# Check whether to build GUI
# printf "Checking if GUI should be built..."
# if printf '%s\n' "$@" | grep -q -- "^--enable-gui$"; then
# echo "yes"
# BUILD_GUI="TRUE"
# else
# echo "no"
# BUILD_GUI="FALSE"
# fi
# Check for python
# if [ "$BUILD_GUI" = "TRUE" ]; then
# printf "Checking for python..."
# if command -v python &> /dev/null || command -v python3 &> /dev/null
# then
# echo "found"
# else
# echo "not found"
# echo "python not found. Please install it to continue."
# exit 1
# fi
# printf "Checking for tkinter..."
# if python -c "import tkinter" &> /dev/null || python3 -c "import tkinter" &> /dev/null
# then
# echo "found"
# else
# echo "not found"
# echo "tkinter not found. Please install it to continue."
# exit 1
# fi
# printf "Checking for python-is-python3 or similar..."
# if command -v python &> /dev/null
# then
# echo "found"
# else
# echo "not found"
# echo "The 'python' command is not found. Please install a package like 'python-is-python3' that links the 'python' command to 'python3', or create a similar alias."
# exit 1
# fi
# else
# echo "Skipping python and tkinter checks since GUI is not being built."
# fi
# Checking for realpath
# printf "Checking for realpath..."
# if command -v realpath &> /dev/null
# then
# echo "found"
# else
# echo "not found"
# echo "realpath not found. Please install it to continue."
# exit 1
# fi
# Check OS type in order to determine proper sed
# Detect OS and set sed -i syntax
if [[ "$OSTYPE" == "darwin"* ]]; then
SED_INPLACE=("sed" "-i" "")
else
SED_INPLACE=("sed" "-i")
fi
# Patching Makefile
echo "Executing depfiles commands..."
cp Makefile.in Makefile
"${SED_INPLACE[@]}" "s#@CC@#$CC#g" Makefile
"${SED_INPLACE[@]}" "s#@PREFIX@#$PREFIX#g" Makefile
"${SED_INPLACE[@]}" "s#@CARGO@#$CARGO#g" Makefile
"${SED_INPLACE[@]}" "s#@RC@#$RC#g" Makefile
"${SED_INPLACE[@]}" "s#@INCLUDE_LIBMYSOLVERS@#$INCLUDE_LIBMYSOLVERS#g" Makefile
"${SED_INPLACE[@]}" "s#@BUILD_GUI@#$BUILD_GUI#g" Makefile
rm -rf /tmp/e10b5eccac1ecb4e8706e3898719b197a1e9d10d65e860192d38155cb31233ea
# Setting up
export CC="$CC"
# if [ "$BUILD_GUI" = "TRUE" ]; then
# echo "Setting up aliases..."
# rm -rf build
# mkdir -p build/bin
# if command -v python3 &> /dev/null; then
# echo '#!/usr/bin/env bash
# python3 "$@"' > build/bin/python
# chmod +x build/bin/python
# BUILD_BIN=$(cd build/bin && pwd)
# if ! command -v python &> /dev/null; then
# printf "Adding $BUILD_BIN to PATH..."
# export PATH=$BUILD_BIN:$PATH
# echo "done"
# fi
# fi
# fi
touch .configured
echo "Configuration complete. Run 'make' to build."