:: limine / configure.ac 9.5 KB raw

1
AC_INIT([Limine], [m4_esyscmd([./version.sh])], [https://github.com/Limine-Bootloader/Limine/issues], [limine], [https://limine-bootloader.org/])
2
3
AC_PREREQ([2.69])
4
5
AC_CONFIG_AUX_DIR([build-aux])
6
AC_CONFIG_MACRO_DIRS([m4])
7
8
SRCDIR="$(cd "$srcdir" && pwd -P)"
9
BUILDDIR="$(pwd -P)"
10
11
AC_SUBST([SRCDIR])
12
AC_SUBST([BUILDDIR])
13
14
. "$SRCDIR"/timestamps
15
16
AC_SUBST([REGEN_DATE])
17
AC_SUBST([SOURCE_DATE_EPOCH])
18
AC_SUBST([SOURCE_DATE_EPOCH_TOUCH])
19
20
AC_CANONICAL_HOST
21
AC_CANONICAL_BUILD
22
23
# Portably convert relative paths into absolute paths.
24
rel2abs() {
25
    rel2abs_first=true
26
    for i in $1; do
27
        if test $rel2abs_first = true; then
28
            case "$i" in
29
                /*)
30
                    printf "%s" "$i"
31
                    ;;
32
                */*)
33
                    if test -d "$(dirname "$i")"; then
34
                        printf "%s" "$(cd "$(dirname "$i")" && pwd -P)/$(basename "$i")"
35
                    else
36
                        printf "false"
37
                    fi
38
                    ;;
39
                *)
40
                    printf "%s" "$i"
41
                    ;;
42
            esac
43
            rel2abs_first=false
44
        else
45
            printf " %s" "$i"
46
        fi
47
    done
48
    printf "\n"
49
}
50
51
test "x${CFLAGS+set}" = "x" && CFLAGS='-g -O2 -pipe'
52
53
AC_LANG([C])
54
AC_PROG_CC
55
CC="$(rel2abs "$CC")"
56
57
AX_PROG_CC_FOR_BUILD
58
CC_FOR_BUILD="$(rel2abs "$CC_FOR_BUILD")"
59
60
werror_state="no"
61
AC_ARG_ENABLE([werror],
62
    [AS_HELP_STRING([--enable-werror], [treat warnings as errors])],
63
    [werror_state="$enableval"])
64
if test "$werror_state" = "yes"; then
65
    AC_SUBST([WERROR_FLAG], [-Werror])
66
else
67
    AC_SUBST([WERROR_FLAG], [-Wno-error])
68
fi
69
70
AC_PROG_MKDIR_P
71
MKDIR_P="$(rel2abs "$MKDIR_P")"
72
AC_PROG_INSTALL
73
INSTALL="$(rel2abs "$INSTALL")"
74
AC_PROG_SED
75
SED="$(rel2abs "$SED")"
76
AC_PROG_GREP
77
GREP="$(rel2abs "$GREP")"
78
AC_PROG_AWK
79
AWK="$(rel2abs "$AWK")"
80
81
AC_CHECK_PROG([FIND_FOUND], [find], [yes])
82
if ! test "x$FIND_FOUND" = "xyes"; then
83
    AC_MSG_ERROR([find not found, please install find before configuring])
84
fi
85
86
# $1 - UPPERCASEVAR, $2 - default command, $3 - 'tool' if toolchain, $4 - 'no-err' to ignore errors
87
AC_DEFUN([GET_PROG], [
88
    if test "x${$1+set}" = "xset"; then
89
        first_elem="$(rel2abs $(echo "$$1" | cut -f 1 -d " "))"
90
        case "$first_elem" in
91
            /*)
92
                AC_MSG_CHECKING([for $first_elem])
93
                if test -f "$first_elem" && test -x "$first_elem"; then
94
                    $1="$(rel2abs "$$1")"
95
                    $1_FOUND=yes
96
                else
97
                    $1_FOUND=no
98
                fi
99
                AC_MSG_RESULT([$$1_FOUND])
100
                ;;
101
            *)
102
                AC_CHECK_PROG([$1_FOUND], [$first_elem], [yes])
103
                ;;
104
        esac
105
    else
106
        if ! test -z "$2"; then
107
            if test "x$3" = "xtool"; then
108
                AC_CHECK_TOOL([$1_FOUND], [$2], [no])
109
                if ! test "x$$1_FOUND" = "xno"; then
110
                    $1="$(rel2abs "$$1_FOUND")"
111
                    $1_FOUND=yes
112
                fi
113
            else
114
                first_elem="$(rel2abs $(echo "$2" | cut -f 1 -d " "))"
115
                AC_CHECK_PROG([$1_FOUND], [$first_elem], [yes])
116
                if test "x$$1_FOUND" = "xyes"; then
117
                    $1="$(rel2abs "$2")"
118
                fi
119
            fi
120
        else
121
            $1_FOUND=no
122
        fi
123
    fi
124
125
    if ! test "x$$1_FOUND" = "xyes"; then
126
        if test "x$4" = "xno-err"; then
127
            AC_MSG_WARN([$first_elem invalid, set $1 to a valid program])
128
        else
129
            AC_MSG_ERROR([$first_elem invalid, set $1 to a valid program])
130
        fi
131
    fi
132
])
133
134
AC_ARG_VAR([STRIP], [strip command])
135
GET_PROG([STRIP], [strip], [tool])
136
137
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],
138
    [], [AC_MSG_ERROR([required header not found])])
139
140
AC_ARG_VAR([TOOLCHAIN_FOR_TARGET], [alternative toolchain prefix for Limine])
141
142
AC_ARG_VAR([CC_FOR_TARGET], [C compiler command for Limine])
143
if test "x${CC_FOR_TARGET+set}" = "x"; then
144
    if test "x${TOOLCHAIN_FOR_TARGET+set}" = "x"; then
145
        CC_FOR_TARGET="clang"
146
    else
147
        CC_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}gcc"
148
    fi
149
fi
150
AC_ARG_VAR([LD_FOR_TARGET], [linker command for Limine])
151
if test "x${LD_FOR_TARGET+set}" = "x"; then
152
    if test "x${TOOLCHAIN_FOR_TARGET+set}" = "x"; then
153
        LD_FOR_TARGET="ld.lld"
154
    else
155
        LD_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}ld"
156
    fi
157
fi
158
159
test "x${TOOLCHAIN_FOR_TARGET+set}" = "x" && TOOLCHAIN_FOR_TARGET=llvm-
160
161
AC_ARG_VAR([OBJCOPY_FOR_TARGET], [objcopy command for Limine])
162
test "x${OBJCOPY_FOR_TARGET+set}" = "x" && OBJCOPY_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}objcopy"
163
AC_ARG_VAR([OBJDUMP_FOR_TARGET], [objdump command for Limine])
164
test "x${OBJDUMP_FOR_TARGET+set}" = "x" && OBJDUMP_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}objdump"
165
AC_ARG_VAR([READELF_FOR_TARGET], [readelf command for Limine])
166
test "x${READELF_FOR_TARGET+set}" = "x" && READELF_FOR_TARGET="${TOOLCHAIN_FOR_TARGET}readelf"
167
168
GET_PROG([CC_FOR_TARGET])
169
GET_PROG([LD_FOR_TARGET])
170
GET_PROG([OBJCOPY_FOR_TARGET])
171
GET_PROG([OBJDUMP_FOR_TARGET])
172
GET_PROG([READELF_FOR_TARGET])
173
174
BUILD_ALL="no"
175
176
AC_ARG_ENABLE([all],
177
    [AS_HELP_STRING([--enable-all], [enable ALL ports and targets])],
178
    [BUILD_ALL="$enableval"])
179
180
BUILD_BIOS_CD="$BUILD_ALL"
181
182
AC_ARG_ENABLE([bios-cd],
183
    [AS_HELP_STRING([--enable-bios-cd], [enable building the x86 BIOS CD image])],
184
    [BUILD_BIOS_CD="$enableval"])
185
186
AC_SUBST([BUILD_BIOS_CD])
187
188
BUILD_BIOS_PXE="$BUILD_ALL"
189
190
AC_ARG_ENABLE([bios-pxe],
191
    [AS_HELP_STRING([--enable-bios-pxe], [enable building the x86 BIOS PXE image])],
192
    [BUILD_BIOS_PXE="$enableval"])
193
194
AC_SUBST([BUILD_BIOS_PXE])
195
196
BUILD_BIOS="$BUILD_ALL"
197
198
AC_ARG_ENABLE([bios],
199
    [AS_HELP_STRING([--enable-bios], [enable building the x86 BIOS port])],
200
    [BUILD_BIOS="$enableval"])
201
202
if test "x$BUILD_BIOS" = "xno"; then
203
    if test "x$BUILD_BIOS_CD" = "xyes"; then
204
        BUILD_BIOS="yes"
205
    fi
206
    if test "x$BUILD_BIOS_PXE" = "xyes"; then
207
        BUILD_BIOS="yes"
208
    fi
209
fi
210
211
if test "x$BUILD_BIOS" = "xno"; then
212
    BUILD_BIOS=""
213
else
214
    BUILD_BIOS="limine-bios"
215
    NEED_NASM=yes
216
fi
217
218
AC_SUBST([BUILD_BIOS])
219
220
BUILD_UEFI_IA32="$BUILD_ALL"
221
222
AC_ARG_ENABLE([uefi-ia32],
223
    [AS_HELP_STRING([--enable-uefi-ia32], [enable building the IA-32 UEFI port])],
224
    [BUILD_UEFI_IA32="$enableval"])
225
226
if test "x$BUILD_UEFI_IA32" = "xno"; then
227
    BUILD_UEFI_IA32=""
228
else
229
    BUILD_UEFI_IA32="limine-uefi-ia32"
230
    NEED_NASM=yes
231
fi
232
233
AC_SUBST([BUILD_UEFI_IA32])
234
235
BUILD_UEFI_X86_64="$BUILD_ALL"
236
237
AC_ARG_ENABLE([uefi-x86-64],
238
    [AS_HELP_STRING([--enable-uefi-x86-64], [enable building the x86-64 UEFI port])],
239
    [BUILD_UEFI_X86_64="$enableval"])
240
241
if test "x$BUILD_UEFI_X86_64" = "xno"; then
242
    BUILD_UEFI_X86_64=""
243
else
244
    BUILD_UEFI_X86_64="limine-uefi-x86-64"
245
    NEED_NASM=yes
246
fi
247
248
AC_SUBST([BUILD_UEFI_X86_64])
249
250
BUILD_UEFI_AARCH64="$BUILD_ALL"
251
252
AC_ARG_ENABLE([uefi-aarch64],
253
    [AS_HELP_STRING([--enable-uefi-aarch64], [enable building the aarch64 UEFI port])],
254
    [BUILD_UEFI_AARCH64="$enableval"])
255
256
if test "x$BUILD_UEFI_AARCH64" = "xno"; then
257
    BUILD_UEFI_AARCH64=""
258
else
259
    BUILD_UEFI_AARCH64="limine-uefi-aarch64"
260
fi
261
262
AC_SUBST([BUILD_UEFI_AARCH64])
263
264
BUILD_UEFI_RISCV64="$BUILD_ALL"
265
266
AC_ARG_ENABLE([uefi-riscv64],
267
    [AS_HELP_STRING([--enable-uefi-riscv64], [enable building the riscv64 UEFI port])],
268
    [BUILD_UEFI_RISCV64="$enableval"])
269
270
if test "x$BUILD_UEFI_RISCV64" = "xno"; then
271
    BUILD_UEFI_RISCV64=""
272
else
273
    BUILD_UEFI_RISCV64="limine-uefi-riscv64"
274
fi
275
276
AC_SUBST([BUILD_UEFI_RISCV64])
277
278
BUILD_UEFI_LOONGARCH64="$BUILD_ALL"
279
280
AC_ARG_ENABLE([uefi-loongarch64],
281
    [AS_HELP_STRING([--enable-uefi-loongarch64], [enable building the loongarch64 UEFI port])],
282
    [BUILD_UEFI_LOONGARCH64="$enableval"])
283
284
if test "x$BUILD_UEFI_LOONGARCH64" = "xno"; then
285
    BUILD_UEFI_LOONGARCH64=""
286
else
287
    BUILD_UEFI_LOONGARCH64="limine-uefi-loongarch64"
288
fi
289
290
AC_SUBST([BUILD_UEFI_LOONGARCH64])
291
292
BUILD_UEFI_CD="$BUILD_ALL"
293
294
AC_ARG_ENABLE([uefi-cd],
295
    [AS_HELP_STRING([--enable-uefi-cd], [enable building limine-uefi-cd.bin])],
296
    [BUILD_UEFI_CD="$enableval"])
297
298
if ! test "x$BUILD_UEFI_CD" = "xno"; then
299
    AC_CHECK_PROG([MTOOLS_FOUND], [mcopy], [yes])
300
    if ! test "x$MTOOLS_FOUND" = "xyes"; then
301
        if test "x$BUILD_UEFI_CD" = "xyes"; then
302
            AC_MSG_ERROR([mtools not found, install mtools to build limine-uefi-cd.bin])
303
        fi
304
        AC_MSG_WARN([mtools not found, install mtools to build limine-uefi-cd.bin])
305
        BUILD_UEFI_CD="no"
306
    fi
307
fi
308
309
AC_SUBST([BUILD_UEFI_CD])
310
311
if test "x$NEED_NASM" = "xyes"; then
312
    AC_CHECK_PROG([NASM_FOUND], [nasm], [yes])
313
    if ! test "x$NASM_FOUND" = "xyes"; then
314
        AC_MSG_ERROR([nasm not found, please install nasm before configuring])
315
    fi
316
fi
317
318
319
BORROWED_CFLAGS=""
320
for cflag in $CFLAGS; do
321
    case $cflag in
322
        -O*|-pipe|-g|-f*-prefix-map*)
323
            BORROWED_CFLAGS="$BORROWED_CFLAGS $cflag"
324
            ;;
325
    esac
326
done
327
328
AC_ARG_VAR([CFLAGS_FOR_TARGET], [C flags for Limine])
329
test "x${CFLAGS_FOR_TARGET+set}" = "x" && CFLAGS_FOR_TARGET="$BORROWED_CFLAGS"
330
331
AC_ARG_VAR([CPPFLAGS_FOR_TARGET], [C preprocessor flags for Limine])
332
test "x${CPPFLAGS_FOR_TARGET+set}" = "x" && CPPFLAGS_FOR_TARGET=""
333
334
AC_ARG_VAR([LDFLAGS_FOR_TARGET], [linker flags for Limine])
335
test "x${LDFLAGS_FOR_TARGET+set}" = "x" && LDFLAGS_FOR_TARGET=""
336
337
AC_ARG_VAR([NASMFLAGS_FOR_TARGET], [nasm flags for Limine])
338
test "x${NASMFLAGS_FOR_TARGET+set}" = "x" && NASMFLAGS_FOR_TARGET="-g"
339
340
LIMINE_COPYRIGHT=$($GREP Copyright "$SRCDIR/COPYING")
341
AC_SUBST([LIMINE_COPYRIGHT])
342
343
AC_PREFIX_DEFAULT([/usr/local])
344
345
AC_CONFIG_FILES([man/man1/limine.1 GNUmakefile config.h])
346
AC_OUTPUT
tab: 248 wrap: offon