2022-02-11 22:46:57 +03:00
|
|
|
AC_INIT([Limine], m4_esyscmd([./version.sh]), [https://github.com/limine-bootloader/limine/issues], [limine], [https://limine-bootloader.org/])
|
2022-01-16 08:09:36 +03:00
|
|
|
|
|
|
|
AC_PREREQ(2.69)
|
|
|
|
|
2022-01-31 13:46:19 +03:00
|
|
|
AC_CONFIG_AUX_DIR([build-aux])
|
|
|
|
|
2022-02-11 22:46:57 +03:00
|
|
|
SRCDIR="$(cd "$srcdir" && pwd -P)"
|
|
|
|
BUILDDIR="$(pwd -P)"
|
|
|
|
PATH="$BUILDDIR/toolchain/bin$PATH_SEPARATOR$SRCDIR/toolchain/bin$PATH_SEPARATOR/usr/local/bin$PATH_SEPARATOR$PATH"
|
2022-01-31 13:46:19 +03:00
|
|
|
export PATH
|
2022-01-16 08:09:36 +03:00
|
|
|
|
2022-02-11 22:46:57 +03:00
|
|
|
AC_SUBST(SRCDIR, [$SRCDIR])
|
|
|
|
AC_SUBST(BUILDDIR, [$BUILDDIR])
|
|
|
|
AC_SUBST(PATH, [$PATH])
|
|
|
|
|
2022-01-28 12:23:26 +03:00
|
|
|
test "x$CFLAGS" = "x" && CFLAGS='-g -O2 -pipe -Wall -Wextra'
|
2022-01-31 13:46:19 +03:00
|
|
|
AC_PROG_CC
|
2022-01-28 12:23:26 +03:00
|
|
|
|
|
|
|
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
|
2022-02-11 22:46:57 +03:00
|
|
|
AC_SUBST(WERROR, [-Werror])
|
2022-01-28 12:23:26 +03:00
|
|
|
CFLAGS="$CFLAGS -Werror"
|
|
|
|
fi
|
|
|
|
|
2022-01-22 05:46:48 +03:00
|
|
|
AC_PROG_INSTALL
|
2022-02-01 10:04:55 +03:00
|
|
|
AC_PROG_GREP
|
|
|
|
AC_PROG_SED
|
|
|
|
AC_PROG_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
|
2022-01-16 08:09:36 +03:00
|
|
|
|
2022-01-31 13:46:19 +03:00
|
|
|
AC_CHECK_PROG([NASM_FOUND], [nasm], [yes])
|
|
|
|
if ! test "x$NASM_FOUND" = "xyes"; then
|
2022-02-01 10:04:55 +03:00
|
|
|
AC_MSG_ERROR([nasm not found, please install nasm before configuring])
|
|
|
|
fi
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-02-08 17:43:21 +03:00
|
|
|
BUILD_ELTORITO_EFI="default"
|
2022-02-08 17:35:54 +03:00
|
|
|
|
|
|
|
AC_ARG_ENABLE([eltorito-efi],
|
|
|
|
AS_HELP_STRING([--disable-eltorito-efi], [disable limine-eltorito-efi.bin build]),
|
|
|
|
BUILD_ELTORITO_EFI="$enableval")
|
|
|
|
|
2022-02-08 17:43:21 +03:00
|
|
|
if ! test "x$BUILD_ELTORITO_EFI" = "xno"; then
|
|
|
|
AC_CHECK_PROG([MTOOLS_FOUND], [mcopy], [yes])
|
|
|
|
if ! test "x$MTOOLS_FOUND" = "xyes"; then
|
|
|
|
if test "x$BUILD_ELTORITO_EFI" = "xyes"; then
|
|
|
|
AC_MSG_ERROR([mtools not found, install mtools to build limine-eltorito-efi.bin])
|
|
|
|
fi
|
|
|
|
AC_MSG_WARN([mtools not found, install mtools to build limine-eltorito-efi.bin])
|
|
|
|
BUILD_ELTORITO_EFI="no"
|
|
|
|
fi
|
2022-02-08 17:35:54 +03:00
|
|
|
fi
|
|
|
|
|
2022-02-11 22:46:57 +03:00
|
|
|
AC_SUBST(BUILD_ELTORITO_EFI, [$BUILD_ELTORITO_EFI])
|
2022-01-31 13:46:19 +03:00
|
|
|
|
|
|
|
AC_ARG_VAR(TOOLCHAIN, [Alternative toolchain prefix [default: limine]])
|
2022-01-17 00:41:37 +03:00
|
|
|
test "x$TOOLCHAIN" = "x" && TOOLCHAIN='limine'
|
|
|
|
|
2022-01-31 13:46:19 +03:00
|
|
|
AC_ARG_VAR(LIMINE_CC, [C compiler command for Limine [default: $TOOLCHAIN-gcc]])
|
2022-02-01 10:04:55 +03:00
|
|
|
|
2022-02-02 18:24:13 +03:00
|
|
|
AC_DEFUN([CC_ERROR_MSG], [
|
|
|
|
AC_MSG_ERROR([no suitable LIMINE_CC found, run $srcdir/make_toolchain.sh or install x86_64 GCC/Clang])
|
|
|
|
])
|
|
|
|
|
2022-02-01 10:04:55 +03:00
|
|
|
if ! test "x$LIMINE_CC" = "x"; then
|
|
|
|
AC_CHECK_PROG([LIMINE_CC_0], [$LIMINE_CC], [yes])
|
|
|
|
if ! test "x$LIMINE_CC_0" = "xyes"; then
|
|
|
|
AC_MSG_ERROR([LIMINE_CC ($LIMINE_CC) not found])
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
LIMINE_CC="$TOOLCHAIN-gcc"
|
|
|
|
AC_CHECK_PROG([LIMINE_CC_1], [$LIMINE_CC], [yes])
|
|
|
|
if ! test "x$LIMINE_CC_1" = "xyes"; then
|
|
|
|
LIMINE_CC="$CC"
|
|
|
|
AC_CHECK_PROG([LIMINE_CC_2], [$LIMINE_CC], [yes])
|
|
|
|
if ! test "x$LIMINE_CC_2" = "xyes"; then
|
2022-02-02 18:24:13 +03:00
|
|
|
CC_ERROR_MSG
|
2022-02-01 10:04:55 +03:00
|
|
|
fi
|
2022-01-31 13:46:19 +03:00
|
|
|
fi
|
|
|
|
fi
|
2022-01-17 02:20:59 +03:00
|
|
|
|
2022-02-02 18:24:13 +03:00
|
|
|
if ! $LIMINE_CC --version >/dev/null 2>&1; then
|
|
|
|
CC_ERROR_MSG
|
|
|
|
fi
|
|
|
|
|
2022-02-03 13:35:54 +03:00
|
|
|
if $LIMINE_CC --version | $GREP clang >/dev/null 2>&1; then
|
2022-02-11 22:46:57 +03:00
|
|
|
AC_SUBST(USING_CLANG, 1)
|
2022-02-03 13:35:54 +03:00
|
|
|
elif $LIMINE_CC --version | $GREP 'Free Software Foundation' >/dev/null 2>&1; then
|
2022-02-11 22:46:57 +03:00
|
|
|
AC_SUBST(USING_CLANG, 0)
|
2022-02-02 18:24:13 +03:00
|
|
|
else
|
|
|
|
CC_ERROR_MSG
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! $LIMINE_CC -dumpmachine >/dev/null 2>&1; then
|
|
|
|
CC_ERROR_MSG
|
|
|
|
fi
|
|
|
|
|
2022-01-31 13:46:19 +03:00
|
|
|
CC_MACHINE="$($LIMINE_CC -dumpmachine | dd bs=6 count=1 2>/dev/null)"
|
|
|
|
if ! test "x$CC_MACHINE" = "xx86_64"; then
|
|
|
|
if ! test "x$CC_MACHINE" = "xamd64-"; then
|
2022-02-02 18:24:13 +03:00
|
|
|
CC_ERROR_MSG
|
2022-01-31 13:46:19 +03:00
|
|
|
fi
|
|
|
|
fi
|
2022-01-16 08:09:36 +03:00
|
|
|
|
2022-02-01 10:04:55 +03:00
|
|
|
AC_DEFUN([GET_BINUTILS_PROG], [
|
|
|
|
AC_ARG_VAR(LIMINE_$1, [$3 command for Limine [default: $TOOLCHAIN-$2]])
|
|
|
|
|
|
|
|
if ! test "x$LIMINE_$1" = "x"; then
|
|
|
|
AC_CHECK_PROG([LIMINE_$1_0], [$LIMINE_$1], [yes])
|
2022-02-03 13:35:54 +03:00
|
|
|
if ! test "x$LIMINE_$1_0" = "xyes" || ! $LIMINE_$1 --version | $GREP 'Free Software Foundation' >/dev/null 2>&1; then
|
2022-02-01 10:04:55 +03:00
|
|
|
AC_MSG_ERROR([LIMINE_$1 ($LIMINE_$1) is not a suitable $3])
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
LIMINE_$1="$TOOLCHAIN-$2"
|
|
|
|
AC_CHECK_PROG([LIMINE_$1_1], [$LIMINE_$1], [yes])
|
2022-02-03 13:35:54 +03:00
|
|
|
if ! test "x$LIMINE_$1_1" = "xyes" || ! $LIMINE_$1 --version | $GREP 'Free Software Foundation' >/dev/null 2>&1; then
|
2022-02-01 10:04:55 +03:00
|
|
|
LIMINE_$1='g$2'
|
|
|
|
AC_CHECK_PROG([LIMINE_$1_2], [$LIMINE_$1], [yes])
|
2022-02-03 13:35:54 +03:00
|
|
|
if ! test "x$LIMINE_$1_2" = "xyes" || ! $LIMINE_$1 --version | $GREP 'Free Software Foundation' >/dev/null 2>&1; then
|
2022-02-01 10:04:55 +03:00
|
|
|
LIMINE_$1='$2'
|
|
|
|
AC_CHECK_PROG([LIMINE_$1_3], [$LIMINE_$1], [yes])
|
2022-02-03 13:35:54 +03:00
|
|
|
if ! test "x$LIMINE_$1_3" = "xyes" || ! $LIMINE_$1 --version | $GREP 'Free Software Foundation' >/dev/null 2>&1; then
|
2022-02-01 10:04:55 +03:00
|
|
|
AC_MSG_ERROR([no suitable LIMINE_$1 found, run $srcdir/make_toolchain.sh or install GNU binutils])
|
2022-01-31 13:46:19 +03:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2022-02-02 18:24:13 +03:00
|
|
|
GET_BINUTILS_PROG(LD, ld, linker)
|
|
|
|
GET_BINUTILS_PROG(AR, ar, archiver)
|
|
|
|
GET_BINUTILS_PROG(AS, as, assembler)
|
|
|
|
GET_BINUTILS_PROG(OBJCOPY, objcopy, objcopy)
|
|
|
|
GET_BINUTILS_PROG(OBJDUMP, objdump, objdump)
|
|
|
|
GET_BINUTILS_PROG(READELF, readelf, readelf)
|
2022-02-01 10:04:55 +03:00
|
|
|
|
|
|
|
AC_ARG_VAR(LIMINE_CFLAGS, [C flags for Limine [default: -O3 -pipe -Wall -Wextra]])
|
|
|
|
test "x$LIMINE_CFLAGS" = "x" && LIMINE_CFLAGS='-O3 -pipe -Wall -Wextra'
|
|
|
|
|
|
|
|
AC_ARG_VAR(LIMINE_LDFLAGS, [Linker flags for Limine [default: ]])
|
|
|
|
test "x$LIMINE_LDFLAGS" = "x" && LIMINE_LDFLAGS=' '
|
2022-01-16 08:09:36 +03:00
|
|
|
|
|
|
|
AC_PREFIX_DEFAULT(/usr/local)
|
|
|
|
|
|
|
|
AC_CONFIG_FILES(GNUmakefile)
|
|
|
|
AC_OUTPUT
|