build: Run toolchain-detect at configure time

This commit is contained in:
mintsuki 2022-06-18 03:03:06 +02:00
parent 5b181e10a3
commit 7eac8416e7
4 changed files with 32 additions and 29 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/bin
/build
/toolchain
/toolchain-files
/limine-efi
/freestanding_headers
/ovmf*

View File

@ -203,7 +203,7 @@ dist:
.PHONY: distclean
distclean: clean
rm -rf toolchain ovmf* config.log config.status GNUmakefile config.h
rm -rf toolchain ovmf* config.log config.status GNUmakefile config.h toolchain-files
.PHONY: maintainer-clean
maintainer-clean: distclean
@ -212,11 +212,8 @@ maintainer-clean: distclean
.PHONY: common-uefi-x86-64
common-uefi-x86-64:
mkdir -p '$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64'
cd '$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64' && \
TARGET=uefi-x86-64 '$(call SHESCAPE,$(SRCDIR))'/toolchain-detect/configure
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64/toolchain.mk' \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/x86_64-toolchain.mk' \
TARGET=uefi-x86-64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64'
@ -226,11 +223,8 @@ common-uefi-x86-64-clean:
.PHONY: common-uefi-ia32
common-uefi-ia32:
mkdir -p '$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32'
cd '$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32' && \
TARGET=uefi-ia32 '$(call SHESCAPE,$(SRCDIR))'/toolchain-detect/configure
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32/toolchain.mk' \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/i686-toolchain.mk' \
TARGET=uefi-ia32 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32'
@ -240,11 +234,8 @@ common-uefi-ia32-clean:
.PHONY: common-bios
common-bios:
mkdir -p '$(call SHESCAPE,$(BUILDDIR))/common-bios'
cd '$(call SHESCAPE,$(BUILDDIR))/common-bios' && \
TARGET=bios '$(call SHESCAPE,$(SRCDIR))'/toolchain-detect/configure
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/common-bios/toolchain.mk' \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/i686-toolchain.mk' \
TARGET=bios \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-bios'
@ -254,11 +245,8 @@ common-bios-clean:
.PHONY: decompressor
decompressor:
mkdir -p '$(call SHESCAPE,$(BUILDDIR))/decompressor-build'
cd '$(call SHESCAPE,$(BUILDDIR))/decompressor-build' && \
TARGET=bios '$(call SHESCAPE,$(SRCDIR))'/toolchain-detect/configure
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/decompressor' all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/common-bios/toolchain.mk' \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/i686-toolchain.mk' \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/decompressor-build'
.PHONY: decompressor-clean

View File

@ -13,6 +13,8 @@ AC_SUBST(SRCDIR, [$SRCDIR])
AC_SUBST(BUILDDIR, [$BUILDDIR])
AC_SUBST(PATH, [$PATH])
rm -rf "$BUILDDIR/toolchain-files"
test "x$CFLAGS" = "x" && CFLAGS='-g -O2 -pipe -Wall -Wextra'
AC_PROG_CC
@ -61,6 +63,11 @@ AC_ARG_ENABLE([bios],
if test "x$BUILD_BIOS" = "xno"; then
BUILD_BIOS=""
else
(
mkdir -p "$BUILDDIR/toolchain-files"
cd "$BUILDDIR/toolchain-files"
ARCHITECTURE=i686 "$SRCDIR/toolchain-detect/configure" || exit 1
)
BUILD_BIOS="limine-bios"
fi
@ -99,6 +106,11 @@ AC_ARG_ENABLE([uefi-ia32],
if test "x$BUILD_UEFI_IA32" = "xno"; then
BUILD_UEFI_IA32=""
else
(
mkdir -p "$BUILDDIR/toolchain-files"
cd "$BUILDDIR/toolchain-files"
ARCHITECTURE=i686 "$SRCDIR/toolchain-detect/configure" || exit 1
)
BUILD_UEFI_IA32="limine-uefi-ia32"
fi
@ -113,6 +125,11 @@ AC_ARG_ENABLE([uefi-x86-64],
if test "x$BUILD_UEFI_X86_64" = "xno"; then
BUILD_UEFI_X86_64=""
else
(
mkdir -p "$BUILDDIR/toolchain-files"
cd "$BUILDDIR/toolchain-files"
ARCHITECTURE=x86_64 "$SRCDIR/toolchain-detect/configure" || exit 1
)
BUILD_UEFI_X86_64="limine-uefi-x86-64"
fi

View File

@ -2,21 +2,18 @@ AC_INIT([Limine], m4_esyscmd([../version.sh]), [https://github.com/limine-bootlo
AC_PREREQ(2.69)
case "$TARGET" in
uefi-x86-64)
ARCHITECTURE=x86_64
;;
uefi-ia32|bios)
ARCHITECTURE=i686
;;
*)
AC_MSG_ERROR([invalid target])
;;
esac
BUILDDIR="$(pwd -P)"
if test -f "$BUILDDIR/$ARCHITECTURE-toolchain.mk"; then
exit 0
fi
AC_PROG_GREP
if test "x$TOOLCHAIN" = "x"; then
TOOLCHAIN=$ARCHITECTURE-elf
fi
AC_SUBST(TOOLCHAIN, $TOOLCHAIN)
AC_DEFUN([CC_ERROR_MSG], [
@ -108,5 +105,5 @@ GET_BINUTILS_PROG(OBJCOPY, objcopy, objcopy)
GET_BINUTILS_PROG(OBJDUMP, objdump, objdump)
GET_BINUTILS_PROG(READELF, readelf, readelf)
AC_CONFIG_FILES(toolchain.mk)
AC_CONFIG_FILES([$ARCHITECTURE-toolchain.mk:toolchain.mk.in])
AC_OUTPUT