build: Improve toolchain detection
This commit is contained in:
parent
dc3de36c7e
commit
53a2dbefdf
@ -72,8 +72,9 @@ The toolchain's build process depends on the following packages: `GNU make`,
|
||||
|
||||
Building the toolchain can be accomplished by running:
|
||||
```bash
|
||||
./make_toolchain.sh
|
||||
TARGET=<target architecture> ./make_toolchain.sh
|
||||
```
|
||||
where `<target architecture>` is something like `i686` or `x86_64`.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
|
@ -25,18 +25,6 @@ else
|
||||
$(error Invalid target)
|
||||
endif
|
||||
|
||||
ifeq ($(USING_CLANG), 1)
|
||||
ifeq ($(TARGET), bios)
|
||||
override LIMINE_CC += --target=i686-elf
|
||||
endif
|
||||
ifeq ($(TARGET), uefi-x86-64)
|
||||
override LIMINE_CC += --target=x86_64-elf
|
||||
endif
|
||||
ifeq ($(TARGET), uefi-ia32)
|
||||
override LIMINE_CC += --target=i686-elf
|
||||
endif
|
||||
endif
|
||||
|
||||
COM_OUTPUT ?= false
|
||||
E9_OUTPUT ?= false
|
||||
|
||||
|
12
configure.ac
12
configure.ac
@ -66,8 +66,8 @@ else
|
||||
(
|
||||
mkdir -p "$BUILDDIR/toolchain-files"
|
||||
cd "$BUILDDIR/toolchain-files"
|
||||
ARCHITECTURE=i686 "$SRCDIR/toolchain-detect/configure" || exit 1
|
||||
)
|
||||
ARCHITECTURE=i686 "$SRCDIR/toolchain-detect/configure"
|
||||
) || exit 1
|
||||
BUILD_BIOS="limine-bios"
|
||||
fi
|
||||
|
||||
@ -109,8 +109,8 @@ else
|
||||
(
|
||||
mkdir -p "$BUILDDIR/toolchain-files"
|
||||
cd "$BUILDDIR/toolchain-files"
|
||||
ARCHITECTURE=i686 "$SRCDIR/toolchain-detect/configure" || exit 1
|
||||
)
|
||||
ARCHITECTURE=i686 "$SRCDIR/toolchain-detect/configure"
|
||||
) || exit 1
|
||||
BUILD_UEFI_IA32="limine-uefi-ia32"
|
||||
fi
|
||||
|
||||
@ -128,8 +128,8 @@ else
|
||||
(
|
||||
mkdir -p "$BUILDDIR/toolchain-files"
|
||||
cd "$BUILDDIR/toolchain-files"
|
||||
ARCHITECTURE=x86_64 "$SRCDIR/toolchain-detect/configure" || exit 1
|
||||
)
|
||||
ARCHITECTURE=x86_64 "$SRCDIR/toolchain-detect/configure"
|
||||
) || exit 1
|
||||
BUILD_UEFI_X86_64="limine-uefi-x86-64"
|
||||
fi
|
||||
|
||||
|
@ -12,10 +12,6 @@ ifeq ($(call MKESCAPE,$(BUILDDIR)), )
|
||||
$(error BUILDDIR not specified)
|
||||
endif
|
||||
|
||||
ifeq ($(USING_CLANG), 1)
|
||||
override LIMINE_CC += --target=i686-elf
|
||||
endif
|
||||
|
||||
override INTERNAL_CFLAGS := \
|
||||
$(WERROR) \
|
||||
-m32 \
|
||||
@ -87,7 +83,3 @@ $(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied
|
||||
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm
|
||||
mkdir -p "$$(dirname '$(call SHESCAPE,$@)')"
|
||||
nasm '$(call SHESCAPE,$<)' -f elf32 -o '$(call SHESCAPE,$@)'
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf '$(call SHESCAPE,$(BUILDDIR))'
|
||||
|
@ -12,6 +12,8 @@ AC_PROG_GREP
|
||||
|
||||
if test "x$TOOLCHAIN" = "x"; then
|
||||
TOOLCHAIN=$ARCHITECTURE-elf
|
||||
else
|
||||
ENFORCE_TOOLCHAIN=yes
|
||||
fi
|
||||
|
||||
AC_SUBST(TOOLCHAIN, $TOOLCHAIN)
|
||||
@ -33,6 +35,9 @@ else
|
||||
fi
|
||||
AC_CHECK_PROG([LIMINE_CC_1], [$LIMINE_CC], [yes])
|
||||
if ! test "x$LIMINE_CC_1" = "xyes"; then
|
||||
if test "x$ENFORCE_TOOLCHAIN" = "xyes"; then
|
||||
CC_ERROR_MSG
|
||||
fi
|
||||
LIMINE_CC="$TOOLCHAIN-cc"
|
||||
AC_CHECK_PROG([LIMINE_CC_2], [$LIMINE_CC], [yes])
|
||||
if ! test "x$LIMINE_CC_2" = "xyes"; then
|
||||
@ -59,13 +64,22 @@ if ! $LIMINE_CC --version >/dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
if $LIMINE_CC --version | $GREP clang >/dev/null 2>&1; then
|
||||
AC_SUBST(USING_CLANG, 1)
|
||||
LIMINE_CC="$LIMINE_CC --target=$ARCHITECTURE-elf"
|
||||
elif $LIMINE_CC --version | $GREP 'Free Software Foundation' >/dev/null 2>&1; then
|
||||
AC_SUBST(USING_CLANG, 0)
|
||||
true
|
||||
else
|
||||
CC_ERROR_MSG
|
||||
fi
|
||||
|
||||
if ! $LIMINE_CC -dumpmachine >/dev/null 2>&1; then
|
||||
CC_ERROR_MSG
|
||||
fi
|
||||
|
||||
CC_MACHINE="$($LIMINE_CC -dumpmachine | dd bs=${#ARCHITECTURE} count=1 2>/dev/null)"
|
||||
if ! test "x$CC_MACHINE" = "x$ARCHITECTURE"; then
|
||||
CC_ERROR_MSG
|
||||
fi
|
||||
|
||||
AC_DEFUN([GET_BINUTILS_PROG], [
|
||||
if ! test "x$LIMINE_$1" = "x"; then
|
||||
AC_CHECK_PROG([LIMINE_$1_0], [$LIMINE_$1], [yes])
|
||||
@ -80,6 +94,9 @@ AC_DEFUN([GET_BINUTILS_PROG], [
|
||||
fi
|
||||
AC_CHECK_PROG([LIMINE_$1_1], [$LIMINE_$1], [yes])
|
||||
if ! test "x$LIMINE_$1_1" = "xyes"; then
|
||||
if test "x$ENFORCE_TOOLCHAIN" = "xyes"; then
|
||||
AC_MSG_ERROR([LIMINE_$1 ($LIMINE_$1) not found])
|
||||
fi
|
||||
if test '$2' = 'ld'; then
|
||||
LIMINE_$1='ld.lld'
|
||||
else
|
||||
|
@ -1,5 +1,3 @@
|
||||
override USING_CLANG := @USING_CLANG@
|
||||
export USING_CLANG
|
||||
override TOOLCHAIN := @TOOLCHAIN@
|
||||
export TOOLCHAIN
|
||||
override LIMINE_CC := @LIMINE_CC@
|
||||
|
Loading…
Reference in New Issue
Block a user