build: Misc improvements
This commit is contained in:
parent
d7b8c3cf8a
commit
9332a9f4e1
|
@ -70,7 +70,7 @@ export LIMINE_OBJDUMP
|
||||||
LIMINE_READELF ?= @LIMINE_READELF@
|
LIMINE_READELF ?= @LIMINE_READELF@
|
||||||
export LIMINE_READELF
|
export LIMINE_READELF
|
||||||
|
|
||||||
override USING_CLANG := $(shell PATH='$(call SHESCAPE,$(PATH))' $(LIMINE_CC) --version | grep clang >/dev/null && echo 1)
|
override USING_CLANG := @using_clang@
|
||||||
export USING_CLANG
|
export USING_CLANG
|
||||||
|
|
||||||
override STAGE1_FILES := $(shell find '$(call SHESCAPE,$(SRCDIR))/stage1' -type f -name '*.asm')
|
override STAGE1_FILES := $(shell find '$(call SHESCAPE,$(SRCDIR))/stage1' -type f -name '*.asm')
|
||||||
|
@ -141,7 +141,7 @@ limine-bios: stage23-bios decompressor
|
||||||
.PHONY: limine-eltorito-efi
|
.PHONY: limine-eltorito-efi
|
||||||
limine-eltorito-efi:
|
limine-eltorito-efi:
|
||||||
mkdir -p '$(call SHESCAPE,$(BINDIR))'
|
mkdir -p '$(call SHESCAPE,$(BINDIR))'
|
||||||
dd if=/dev/zero of='$(call SHESCAPE,$(BINDIR))/limine-eltorito-efi.bin' bs=512 count=2880
|
dd if=/dev/zero of='$(call SHESCAPE,$(BINDIR))/limine-eltorito-efi.bin' bs=512 count=2880 2>/dev/null
|
||||||
( mformat -i '$(call SHESCAPE,$(BINDIR))/limine-eltorito-efi.bin' -f 1440 :: && \
|
( mformat -i '$(call SHESCAPE,$(BINDIR))/limine-eltorito-efi.bin' -f 1440 :: && \
|
||||||
mmd -D s -i '$(call SHESCAPE,$(BINDIR))/limine-eltorito-efi.bin' ::/EFI && \
|
mmd -D s -i '$(call SHESCAPE,$(BINDIR))/limine-eltorito-efi.bin' ::/EFI && \
|
||||||
mmd -D s -i '$(call SHESCAPE,$(BINDIR))/limine-eltorito-efi.bin' ::/EFI/BOOT && \
|
mmd -D s -i '$(call SHESCAPE,$(BINDIR))/limine-eltorito-efi.bin' ::/EFI/BOOT && \
|
||||||
|
|
|
@ -73,7 +73,7 @@ This step can take a long time, but it will ensure that the toolchain will work
|
||||||
with Limine. If on an x86_64 host, with GCC or Clang installed, it is possible
|
with Limine. If on an x86_64 host, with GCC or Clang installed, it is possible
|
||||||
that the host toolchain will suffice. You can skip to the next paragraph in order
|
that the host toolchain will suffice. You can skip to the next paragraph in order
|
||||||
to use the system's toolchain instead. If that fails, you can still come back here
|
to use the system's toolchain instead. If that fails, you can still come back here
|
||||||
later (remember to re-run `./configure` after building the toolchain).
|
later (remember to `make clean` and re-run `./configure` after building the toolchain).
|
||||||
|
|
||||||
The toolchain's build process depends on the following packages: `GNU make`, `GNU tar`,
|
The toolchain's build process depends on the following packages: `GNU make`, `GNU tar`,
|
||||||
`curl`, `gzip`, `bzip2`, `gcc/clang`, `g++/clang++`.
|
`curl`, `gzip`, `bzip2`, `gcc/clang`, `g++/clang++`.
|
||||||
|
|
|
@ -9,15 +9,13 @@ test -z "$srcdir" && srcdir=.
|
||||||
|
|
||||||
cd "$srcdir"
|
cd "$srcdir"
|
||||||
|
|
||||||
build_aux="build-aux"
|
|
||||||
|
|
||||||
[ -d stivale ] || git clone https://github.com/stivale/stivale.git
|
[ -d stivale ] || git clone https://github.com/stivale/stivale.git
|
||||||
[ -d reduced-gnu-efi ] || git clone https://github.com/limine-bootloader/reduced-gnu-efi.git
|
[ -d reduced-gnu-efi ] || git clone https://github.com/limine-bootloader/reduced-gnu-efi.git
|
||||||
|
|
||||||
automake_libdir="$(automake --print-libdir)"
|
automake_libdir="$(automake --print-libdir)"
|
||||||
|
|
||||||
mkdir -p build-aux
|
mkdir -p build-aux
|
||||||
cp "${automake_libdir}/install-sh" "${build_aux}"
|
cp "${automake_libdir}/install-sh" build-aux
|
||||||
|
|
||||||
autoconf
|
autoconf
|
||||||
|
|
||||||
|
|
44
configure.ac
44
configure.ac
|
@ -54,6 +54,10 @@ test "x$TOOLCHAIN" = "x" && TOOLCHAIN='limine'
|
||||||
|
|
||||||
AC_ARG_VAR(LIMINE_CC, [C compiler command for Limine [default: $TOOLCHAIN-gcc]])
|
AC_ARG_VAR(LIMINE_CC, [C compiler command for Limine [default: $TOOLCHAIN-gcc]])
|
||||||
|
|
||||||
|
AC_DEFUN([CC_ERROR_MSG], [
|
||||||
|
AC_MSG_ERROR([no suitable LIMINE_CC found, run $srcdir/make_toolchain.sh or install x86_64 GCC/Clang])
|
||||||
|
])
|
||||||
|
|
||||||
if ! test "x$LIMINE_CC" = "x"; then
|
if ! test "x$LIMINE_CC" = "x"; then
|
||||||
AC_CHECK_PROG([LIMINE_CC_0], [$LIMINE_CC], [yes])
|
AC_CHECK_PROG([LIMINE_CC_0], [$LIMINE_CC], [yes])
|
||||||
if ! test "x$LIMINE_CC_0" = "xyes"; then
|
if ! test "x$LIMINE_CC_0" = "xyes"; then
|
||||||
|
@ -66,15 +70,31 @@ else
|
||||||
LIMINE_CC="$CC"
|
LIMINE_CC="$CC"
|
||||||
AC_CHECK_PROG([LIMINE_CC_2], [$LIMINE_CC], [yes])
|
AC_CHECK_PROG([LIMINE_CC_2], [$LIMINE_CC], [yes])
|
||||||
if ! test "x$LIMINE_CC_2" = "xyes"; then
|
if ! test "x$LIMINE_CC_2" = "xyes"; then
|
||||||
AC_MSG_ERROR([no suitable LIMINE_CC found, run $srcdir/make_toolchain.sh or install x86_64 GCC/Clang])
|
CC_ERROR_MSG
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! $LIMINE_CC --version >/dev/null 2>&1; then
|
||||||
|
CC_ERROR_MSG
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $LIMINE_CC --version | grep clang >/dev/null 2>&1; then
|
||||||
|
AC_SUBST(using_clang, 1)
|
||||||
|
elif $LIMINE_CC --version | grep 'Free Software Foundation' >/dev/null 2>&1; then
|
||||||
|
AC_SUBST(using_clang, 0)
|
||||||
|
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=6 count=1 2>/dev/null)"
|
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" = "xx86_64"; then
|
||||||
if ! test "x$CC_MACHINE" = "xamd64-"; then
|
if ! test "x$CC_MACHINE" = "xamd64-"; then
|
||||||
AC_MSG_ERROR([no suitable LIMINE_CC found, run $srcdir/make_toolchain.sh or install x86_64 GCC/Clang])
|
CC_ERROR_MSG
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -83,19 +103,19 @@ AC_DEFUN([GET_BINUTILS_PROG], [
|
||||||
|
|
||||||
if ! test "x$LIMINE_$1" = "x"; then
|
if ! test "x$LIMINE_$1" = "x"; then
|
||||||
AC_CHECK_PROG([LIMINE_$1_0], [$LIMINE_$1], [yes])
|
AC_CHECK_PROG([LIMINE_$1_0], [$LIMINE_$1], [yes])
|
||||||
if ! test "x$LIMINE_$1_0" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null; then
|
if ! test "x$LIMINE_$1_0" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null 2>&1; then
|
||||||
AC_MSG_ERROR([LIMINE_$1 ($LIMINE_$1) is not a suitable $3])
|
AC_MSG_ERROR([LIMINE_$1 ($LIMINE_$1) is not a suitable $3])
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
LIMINE_$1="$TOOLCHAIN-$2"
|
LIMINE_$1="$TOOLCHAIN-$2"
|
||||||
AC_CHECK_PROG([LIMINE_$1_1], [$LIMINE_$1], [yes])
|
AC_CHECK_PROG([LIMINE_$1_1], [$LIMINE_$1], [yes])
|
||||||
if ! test "x$LIMINE_$1_1" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null; then
|
if ! test "x$LIMINE_$1_1" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null 2>&1; then
|
||||||
LIMINE_$1='g$2'
|
LIMINE_$1='g$2'
|
||||||
AC_CHECK_PROG([LIMINE_$1_2], [$LIMINE_$1], [yes])
|
AC_CHECK_PROG([LIMINE_$1_2], [$LIMINE_$1], [yes])
|
||||||
if ! test "x$LIMINE_$1_2" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null; then
|
if ! test "x$LIMINE_$1_2" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null 2>&1; then
|
||||||
LIMINE_$1='$2'
|
LIMINE_$1='$2'
|
||||||
AC_CHECK_PROG([LIMINE_$1_3], [$LIMINE_$1], [yes])
|
AC_CHECK_PROG([LIMINE_$1_3], [$LIMINE_$1], [yes])
|
||||||
if ! test "x$LIMINE_$1_3" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null; then
|
if ! test "x$LIMINE_$1_3" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null 2>&1; then
|
||||||
AC_MSG_ERROR([no suitable LIMINE_$1 found, run $srcdir/make_toolchain.sh or install GNU binutils])
|
AC_MSG_ERROR([no suitable LIMINE_$1 found, run $srcdir/make_toolchain.sh or install GNU binutils])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -103,12 +123,12 @@ AC_DEFUN([GET_BINUTILS_PROG], [
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
GET_BINUTILS_PROG(LD, ld, Linker)
|
GET_BINUTILS_PROG(LD, ld, linker)
|
||||||
GET_BINUTILS_PROG(AR, ar, Archiver)
|
GET_BINUTILS_PROG(AR, ar, archiver)
|
||||||
GET_BINUTILS_PROG(AS, as, Assembler)
|
GET_BINUTILS_PROG(AS, as, assembler)
|
||||||
GET_BINUTILS_PROG(OBJCOPY, objcopy, Objcopy)
|
GET_BINUTILS_PROG(OBJCOPY, objcopy, objcopy)
|
||||||
GET_BINUTILS_PROG(OBJDUMP, objdump, Objdump)
|
GET_BINUTILS_PROG(OBJDUMP, objdump, objdump)
|
||||||
GET_BINUTILS_PROG(READELF, readelf, Readelf)
|
GET_BINUTILS_PROG(READELF, readelf, readelf)
|
||||||
|
|
||||||
AC_ARG_VAR(LIMINE_CFLAGS, [C flags for Limine [default: -O3 -pipe -Wall -Wextra]])
|
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'
|
test "x$LIMINE_CFLAGS" = "x" && LIMINE_CFLAGS='-O3 -pipe -Wall -Wextra'
|
||||||
|
|
|
@ -213,7 +213,7 @@ $(call MKESCAPE,$(BUILDDIR))/stage2.bin.gz: $(call MKESCAPE,$(BUILDDIR))/stage2.
|
||||||
gzip -n -9 < '$(call SHESCAPE,$<)' > '$(call SHESCAPE,$@)'
|
gzip -n -9 < '$(call SHESCAPE,$<)' > '$(call SHESCAPE,$@)'
|
||||||
|
|
||||||
$(call MKESCAPE,$(BUILDDIR))/stage2.bin: $(call MKESCAPE,$(BUILDDIR))/limine.sys
|
$(call MKESCAPE,$(BUILDDIR))/stage2.bin: $(call MKESCAPE,$(BUILDDIR))/limine.sys
|
||||||
dd if='$(call SHESCAPE,$<)' bs=$$(( 0x$$("$(LIMINE_READELF)" -S '$(call SHESCAPE,$(BUILDDIR))/limine.elf' | grep .stage3.text | sed 's/^.*] //' | awk '{print $$3}' | sed 's/^0*//') - 0x8000 )) count=1 of='$(call SHESCAPE,$@)'
|
dd if='$(call SHESCAPE,$<)' bs=$$(( 0x$$("$(LIMINE_READELF)" -S '$(call SHESCAPE,$(BUILDDIR))/limine.elf' | $(GREP) .stage3.text | $(SED) 's/^.*] //' | $(AWK) '{print $$3}' | $(SED) 's/^0*//') - 0x8000 )) count=1 of='$(call SHESCAPE,$@)' 2>/dev/null
|
||||||
|
|
||||||
$(call MKESCAPE,$(BUILDDIR))/stage2.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf
|
$(call MKESCAPE,$(BUILDDIR))/stage2.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf
|
||||||
cd '$(call SHESCAPE,$(BUILDDIR))' && \
|
cd '$(call SHESCAPE,$(BUILDDIR))' && \
|
||||||
|
|
Loading…
Reference in New Issue