-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathconfigure.ac
More file actions
348 lines (279 loc) · 9.58 KB
/
configure.ac
File metadata and controls
348 lines (279 loc) · 9.58 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
AC_INIT([Limine], [m4_esyscmd([./version.sh])], [https://codeberg.org/Limine/Limine/issues], [limine], [https://limine-bootloader.org/])
AC_PREREQ([2.69])
AC_CONFIG_AUX_DIR([build-aux])
SRCDIR="$(cd "$srcdir" && pwd -P)"
BUILDDIR="$(pwd -P)"
AC_SUBST([SRCDIR])
AC_SUBST([BUILDDIR])
. "$SRCDIR"/timestamps
AC_SUBST([REGEN_DATE])
AC_SUBST([SOURCE_DATE_EPOCH])
AC_SUBST([SOURCE_DATE_EPOCH_TOUCH])
AC_CANONICAL_HOST
# Portably convert relative paths into absolute paths.
rel2abs() {
rel2abs_first=true
for i in $1; do
if test $rel2abs_first = true; then
case "$i" in
/*)
printf "%s" "$i"
;;
*/*)
if test -d "$(dirname "$i")"; then
printf "%s" "$(cd "$(dirname "$i")" && pwd -P)/$(basename "$i")"
else
printf "false"
fi
;;
*)
printf "%s" "$i"
;;
esac
rel2abs_first=false
else
printf " %s" "$i"
fi
done
printf "\n"
}
test "x${CFLAGS+set}" = "x" && CFLAGS='-g -O2 -pipe'
AC_LANG([C])
AC_PROG_CC
CC="$(rel2abs "$CC")"
werror_state="no"
AC_ARG_ENABLE([werror],
[AS_HELP_STRING([--enable-werror], [treat warnings as errors])],
[werror_state="$enableval"])
if test "$werror_state" = "yes"; then
AC_SUBST([WERROR_FLAG], [-Werror])
else
AC_SUBST([WERROR_FLAG], [-Wno-error])
fi
AC_PROG_MKDIR_P
MKDIR_P="$(rel2abs "$MKDIR_P")"
AC_PROG_INSTALL
INSTALL="$(rel2abs "$INSTALL")"
AC_PROG_SED
SED="$(rel2abs "$SED")"
AC_PROG_GREP
GREP="$(rel2abs "$GREP")"
AC_PROG_AWK
AWK="$(rel2abs "$AWK")"
AC_CHECK_PROG([FIND_FOUND], [find], [yes])
if ! test "x$FIND_FOUND" = "xyes"; then
AC_MSG_ERROR([find not found, please install find before configuring])
fi
# $1 - UPPERCASEVAR, $2 - default command, $3 - 'tool' if toolchain, $4 - 'no-err' to ignore errors
AC_DEFUN([GET_PROG], [
if test "x${$1+set}" = "xset"; then
first_elem="$(rel2abs $(echo "$$1" | cut -f 1 -d " "))"
case "$first_elem" in
/*)
AC_MSG_CHECKING([for $first_elem])
if test -f "$first_elem" && test -x "$first_elem"; then
$1="$(rel2abs "$$1")"
$1_FOUND=yes
else
$1_FOUND=no
fi
AC_MSG_RESULT([$$1_FOUND])
;;
*)
AC_CHECK_PROG([$1_FOUND], [$first_elem], [yes])
;;
esac
else
if ! test -z "$2"; then
if test "x$3" = "xtool"; then
AC_CHECK_TOOL([$1_FOUND], [$2], [no])
if ! test "x$$1_FOUND" = "xno"; then
$1="$(rel2abs "$$1_FOUND")"
$1_FOUND=yes
fi
else
first_elem="$(rel2abs $(echo "$2" | cut -f 1 -d " "))"
AC_CHECK_PROG([$1_FOUND], [$first_elem], [yes])
if test "x$$1_FOUND" = "xyes"; then
$1="$(rel2abs "$2")"
fi
fi
else
$1_FOUND=no
fi
fi
if ! test "x$$1_FOUND" = "xyes"; then
if test "x$4" = "xno-err"; then
AC_MSG_WARN([$first_elem invalid, set $1 to a valid program])
else
AC_MSG_ERROR([$first_elem invalid, set $1 to a valid program])
fi
fi
])
AC_ARG_VAR([STRIP], [strip command])
GET_PROG([STRIP], [strip], [tool])
AC_CHECK_HEADERS([stdio.h stdlib.h stdint.h stddef.h stdbool.h stdarg.h string.h errno.h inttypes.h limits.h time.h],
[], [AC_MSG_ERROR([required header not found])])
AC_ARG_VAR([TOOLCHAIN_FOR_TARGET], [alternative toolchain prefix for Limine])
AC_ARG_VAR([CC_FOR_TARGET], [C compiler command for Limine])
if test "x${CC_FOR_TARGET+set}" = "x"; then
if test "x${TOOLCHAIN_FOR_TARGET+set}" = "x"; then
CC_FOR_TARGET="clang"
else
CC_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}gcc"
fi
fi
AC_ARG_VAR([LD_FOR_TARGET], [linker command for Limine])
if test "x${LD_FOR_TARGET+set}" = "x"; then
if test "x${TOOLCHAIN_FOR_TARGET+set}" = "x"; then
LD_FOR_TARGET="ld.lld"
else
LD_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}ld"
fi
fi
test "x${TOOLCHAIN_FOR_TARGET+set}" = "x" && TOOLCHAIN_FOR_TARGET=llvm-
AC_ARG_VAR([OBJCOPY_FOR_TARGET], [objcopy command for Limine])
test "x${OBJCOPY_FOR_TARGET+set}" = "x" && OBJCOPY_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}objcopy"
AC_ARG_VAR([OBJDUMP_FOR_TARGET], [objdump command for Limine])
test "x${OBJDUMP_FOR_TARGET+set}" = "x" && OBJDUMP_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}objdump"
AC_ARG_VAR([READELF_FOR_TARGET], [readelf command for Limine])
test "x${READELF_FOR_TARGET+set}" = "x" && READELF_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}readelf"
GET_PROG([CC_FOR_TARGET])
GET_PROG([LD_FOR_TARGET])
GET_PROG([OBJCOPY_FOR_TARGET])
GET_PROG([OBJDUMP_FOR_TARGET])
GET_PROG([READELF_FOR_TARGET])
BUILD_ALL="no"
AC_ARG_ENABLE([all],
[AS_HELP_STRING([--enable-all], [enable ALL ports and targets])],
[BUILD_ALL="$enableval"])
BUILD_BIOS_CD="$BUILD_ALL"
AC_ARG_ENABLE([bios-cd],
[AS_HELP_STRING([--enable-bios-cd], [enable building the x86 BIOS CD image])],
[BUILD_BIOS_CD="$enableval"])
AC_SUBST([BUILD_BIOS_CD])
BUILD_BIOS_PXE="$BUILD_ALL"
AC_ARG_ENABLE([bios-pxe],
[AS_HELP_STRING([--enable-bios-pxe], [enable building the x86 BIOS PXE image])],
[BUILD_BIOS_PXE="$enableval"])
AC_SUBST([BUILD_BIOS_PXE])
BUILD_BIOS="$BUILD_ALL"
AC_ARG_ENABLE([bios],
[AS_HELP_STRING([--enable-bios], [enable building the x86 BIOS port])],
[BUILD_BIOS="$enableval"])
if test "x$BUILD_BIOS" = "xno"; then
if test "x$BUILD_BIOS_CD" = "xyes"; then
BUILD_BIOS="yes"
fi
if test "x$BUILD_BIOS_PXE" = "xyes"; then
BUILD_BIOS="yes"
fi
fi
if test "x$BUILD_BIOS" = "xno"; then
BUILD_BIOS=""
else
BUILD_BIOS="limine-bios"
NEED_NASM=yes
NEED_GZIP=yes
fi
AC_SUBST([BUILD_BIOS])
BUILD_UEFI_IA32="$BUILD_ALL"
AC_ARG_ENABLE([uefi-ia32],
[AS_HELP_STRING([--enable-uefi-ia32], [enable building the IA-32 UEFI port])],
[BUILD_UEFI_IA32="$enableval"])
if test "x$BUILD_UEFI_IA32" = "xno"; then
BUILD_UEFI_IA32=""
else
BUILD_UEFI_IA32="limine-uefi-ia32"
NEED_NASM=yes
fi
AC_SUBST([BUILD_UEFI_IA32])
BUILD_UEFI_X86_64="$BUILD_ALL"
AC_ARG_ENABLE([uefi-x86-64],
[AS_HELP_STRING([--enable-uefi-x86-64], [enable building the x86-64 UEFI port])],
[BUILD_UEFI_X86_64="$enableval"])
if test "x$BUILD_UEFI_X86_64" = "xno"; then
BUILD_UEFI_X86_64=""
else
BUILD_UEFI_X86_64="limine-uefi-x86-64"
NEED_NASM=yes
fi
AC_SUBST([BUILD_UEFI_X86_64])
BUILD_UEFI_AARCH64="$BUILD_ALL"
AC_ARG_ENABLE([uefi-aarch64],
[AS_HELP_STRING([--enable-uefi-aarch64], [enable building the aarch64 UEFI port])],
[BUILD_UEFI_AARCH64="$enableval"])
if test "x$BUILD_UEFI_AARCH64" = "xno"; then
BUILD_UEFI_AARCH64=""
else
BUILD_UEFI_AARCH64="limine-uefi-aarch64"
fi
AC_SUBST([BUILD_UEFI_AARCH64])
BUILD_UEFI_RISCV64="$BUILD_ALL"
AC_ARG_ENABLE([uefi-riscv64],
[AS_HELP_STRING([--enable-uefi-riscv64], [enable building the riscv64 UEFI port])],
[BUILD_UEFI_RISCV64="$enableval"])
if test "x$BUILD_UEFI_RISCV64" = "xno"; then
BUILD_UEFI_RISCV64=""
else
BUILD_UEFI_RISCV64="limine-uefi-riscv64"
fi
AC_SUBST([BUILD_UEFI_RISCV64])
BUILD_UEFI_LOONGARCH64="$BUILD_ALL"
AC_ARG_ENABLE([uefi-loongarch64],
[AS_HELP_STRING([--enable-uefi-loongarch64], [enable building the loongarch64 UEFI port])],
[BUILD_UEFI_LOONGARCH64="$enableval"])
if test "x$BUILD_UEFI_LOONGARCH64" = "xno"; then
BUILD_UEFI_LOONGARCH64=""
else
BUILD_UEFI_LOONGARCH64="limine-uefi-loongarch64"
fi
AC_SUBST([BUILD_UEFI_LOONGARCH64])
BUILD_UEFI_CD="$BUILD_ALL"
AC_ARG_ENABLE([uefi-cd],
[AS_HELP_STRING([--enable-uefi-cd], [enable building limine-uefi-cd.bin])],
[BUILD_UEFI_CD="$enableval"])
if ! test "x$BUILD_UEFI_CD" = "xno"; then
AC_CHECK_PROG([MTOOLS_FOUND], [mcopy], [yes])
if ! test "x$MTOOLS_FOUND" = "xyes"; then
if test "x$BUILD_UEFI_CD" = "xyes"; then
AC_MSG_ERROR([mtools not found, install mtools to build limine-uefi-cd.bin])
fi
AC_MSG_WARN([mtools not found, install mtools to build limine-uefi-cd.bin])
BUILD_UEFI_CD="no"
fi
fi
AC_SUBST([BUILD_UEFI_CD])
if test "x$NEED_NASM" = "xyes"; then
AC_CHECK_PROG([NASM_FOUND], [nasm], [yes])
if ! test "x$NASM_FOUND" = "xyes"; then
AC_MSG_ERROR([nasm not found, please install nasm before configuring])
fi
fi
if test "x$NEED_GZIP" = "xyes"; then
AC_CHECK_PROG([GZIP_FOUND], [gzip], [yes])
if ! test "x$GZIP_FOUND" = "xyes"; then
AC_MSG_ERROR([gzip not found, please install gzip before configuring])
fi
fi
BORROWED_CFLAGS=""
for cflag in $CFLAGS; do
case $cflag in
-O*|-pipe|-g|-f*-prefix-map*)
BORROWED_CFLAGS="$BORROWED_CFLAGS $cflag"
;;
esac
done
AC_ARG_VAR([CFLAGS_FOR_TARGET], [C flags for Limine])
test "x${CFLAGS_FOR_TARGET+set}" = "x" && CFLAGS_FOR_TARGET="$BORROWED_CFLAGS"
AC_ARG_VAR([CPPFLAGS_FOR_TARGET], [C preprocessor flags for Limine])
test "x${CPPFLAGS_FOR_TARGET+set}" = "x" && CPPFLAGS_FOR_TARGET=""
AC_ARG_VAR([LDFLAGS_FOR_TARGET], [linker flags for Limine])
test "x${LDFLAGS_FOR_TARGET+set}" = "x" && LDFLAGS_FOR_TARGET=""
AC_ARG_VAR([NASMFLAGS_FOR_TARGET], [nasm flags for Limine])
test "x${NASMFLAGS_FOR_TARGET+set}" = "x" && NASMFLAGS_FOR_TARGET="-g"
LIMINE_COPYRIGHT=$($GREP Copyright "$SRCDIR/COPYING")
AC_SUBST([LIMINE_COPYRIGHT])
AC_PREFIX_DEFAULT([/usr/local])
AC_CONFIG_FILES([man/man1/limine.1 GNUmakefile config.h])
AC_OUTPUT