diff --git a/.gitignore b/.gitignore index 073aeafb..a9c925ed 100644 --- a/.gitignore +++ b/.gitignore @@ -29,13 +29,13 @@ /freestanding-headers /common/flanterm /common/libfdt +/common/lib/stb_image.h.nopatch /common/lib/stb_image.h /common/cc-runtime /decompressor/tinf /decompressor/cc-runtime /dtc /tinf -/stb /ovmf* /bochsout.txt /bx_enh_dbg.ini diff --git a/GNUmakefile.in b/GNUmakefile.in index 9ba87343..07971667 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -309,14 +309,13 @@ dist: rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/common/flanterm/.git" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/common/flanterm/.gitignore" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/freestanding-headers/.git" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/build-aux/freestanding-toolchain/.git" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/common/cc-runtime/.git" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/decompressor/cc-runtime/.git" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/limine-efi/.git" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/limine-efi/.gitignore" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/dtc" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/tinf" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/stb" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/common/lib/stb_image.h.nopatch" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/.git" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/.gitignore" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/.github" @@ -343,7 +342,7 @@ distclean: clean .PHONY: maintainer-clean maintainer-clean: distclean - cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf common/flanterm common/libfdt common/lib/stb_image.h decompressor/tinf tinf stb dtc freestanding-headers common/cc-runtime decompressor/cc-runtime limine-efi configure timestamps build-aux *'~' autom4te.cache aclocal.m4 *.tar* + cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf common/flanterm common/libfdt common/lib/stb_image.h.nopatch common/lib/stb_image.h decompressor/tinf tinf dtc freestanding-headers common/cc-runtime decompressor/cc-runtime limine-efi configure timestamps build-aux *'~' autom4te.cache aclocal.m4 *.tar* .PHONY: common-uefi-x86-64 common-uefi-x86-64: diff --git a/bootstrap b/bootstrap index c30ab3f5..a309776e 100755 --- a/bootstrap +++ b/bootstrap @@ -10,15 +10,6 @@ test -z "$srcdir" && srcdir=. cd "$srcdir" -FREESTANDING_TOOLCHAIN_COMMIT_HASH=18a5e52483344e117d45738c9afb2b34792cbced -FREESTANDING_HEADERS_COMMIT_HASH=dd3abd2d7147efc4170dff478d3b7730bed14147 -CC_RUNTIME_COMMIT_HASH=aa5854cebb4a5a561f35252cdda741919fc9c3f6 -LIMINE_EFI_COMMIT_HASH=d8257094947b0edefe9fa4dcb15255235e3c5193 -TINF_COMMIT_HASH=57ffa1f1d5e3dde19011b2127bd26d01689b694b -FLANTERM_COMMIT_HASH=ef07a10cc38b34aa003d17be97a9f3542e275069 -STB_COMMIT_HASH=013ac3beddff3dbffafd5177e7972067cd2b5083 -DTC_COMMIT_HASH=039a99414e778332d8f9c04cbd3072e1dcc62798 - AUXFILES="config.guess config.sub install-sh" clone_repo_commit() { @@ -40,33 +31,87 @@ clone_repo_commit() { fi } -if ! test -f version; then - clone_repo_commit https://github.com/osdev0/freestanding-toolchain.git build-aux/freestanding-toolchain $FREESTANDING_TOOLCHAIN_COMMIT_HASH - clone_repo_commit https://github.com/osdev0/freestanding-headers.git freestanding-headers $FREESTANDING_HEADERS_COMMIT_HASH +download_by_hash() { + DOWNLOAD_COMMAND="curl -Lo" + if ! command -v $DOWNLOAD_COMMAND >/dev/null 2>&1; then + DOWNLOAD_COMMAND="wget -O" + if ! command -v $DOWNLOAD_COMMAND >/dev/null 2>&1; then + echo "error: Neither curl nor wget found" + exit 1 + fi + fi + SHA256_COMMAND="sha256sum" + if ! command -v $SHA256_COMMAND >/dev/null 2>&1; then + SHA256_COMMAND="sha256" + if ! command -v $SHA256_COMMAND >/dev/null 2>&1; then + echo "error: Cannot find sha256(sum) command" + exit 1 + fi + fi + if ! test -f $2 || ! $SHA256_COMMAND $2 | grep $3 >/dev/null 2>&1; then + rm -f $2 + mkdir -p $2 && rm -rf $2 + $DOWNLOAD_COMMAND $2 $1 + if ! $SHA256_COMMAND $2 | grep $3 >/dev/null 2>&1; then + echo "error: Cannot download file '$2' by hash" + exit 1 + fi + fi +} - clone_repo_commit https://github.com/osdev0/cc-runtime.git decompressor/cc-runtime $CC_RUNTIME_COMMIT_HASH +if ! test -f version; then + clone_repo_commit \ + https://github.com/osdev0/freestanding-headers.git \ + freestanding-headers \ + dd3abd2d7147efc4170dff478d3b7730bed14147 + + clone_repo_commit \ + https://github.com/osdev0/cc-runtime.git \ + decompressor/cc-runtime \ + aa5854cebb4a5a561f35252cdda741919fc9c3f6 rm -rf common/cc-runtime cp -rp decompressor/cc-runtime common/ for f in common/cc-runtime/*.c; do mv "$f" "$(echo "$f" | sed 's/\.c/.s2.c/g')" done - clone_repo_commit https://github.com/limine-bootloader/limine-efi.git limine-efi $LIMINE_EFI_COMMIT_HASH + download_by_hash \ + https://github.com/osdev0/freestanding-toolchain/raw/18a5e52483344e117d45738c9afb2b34792cbced/freestanding-toolchain \ + build-aux/freestanding-toolchain \ + b5b66c4e94d463116e549b10e78fb96cdb97530cc165f9b5babe31a97a78e90c + chmod +x build-aux/freestanding-toolchain - clone_repo_commit https://github.com/jibsen/tinf.git tinf $TINF_COMMIT_HASH + clone_repo_commit \ + https://github.com/limine-bootloader/limine-efi.git \ + limine-efi \ + d8257094947b0edefe9fa4dcb15255235e3c5193 + + clone_repo_commit \ + https://github.com/jibsen/tinf.git \ + tinf \ + 57ffa1f1d5e3dde19011b2127bd26d01689b694b mkdir -p decompressor/tinf cp tinf/src/tinf.h tinf/src/tinflate.c tinf/src/tinfgzip.c decompressor/tinf/ patch -p0 < decompressor/tinf.patch rm -f tinf/src/tinf.h.orig tinf/src/tinflate.c.orig tinf/src/tinfgzip.c.orig - clone_repo_commit https://github.com/mintsuki/flanterm.git common/flanterm $FLANTERM_COMMIT_HASH + clone_repo_commit \ + https://github.com/mintsuki/flanterm.git \ + common/flanterm \ + ef07a10cc38b34aa003d17be97a9f3542e275069 - clone_repo_commit https://github.com/nothings/stb.git stb $STB_COMMIT_HASH - cp stb/stb_image.h common/lib/ + download_by_hash \ + https://github.com/nothings/stb/raw/f7f20f39fe4f206c6f19e26ebfef7b261ee59ee4/stb_image.h \ + common/lib/stb_image.h.nopatch \ + 594c2fe35d49488b4382dbfaec8f98366defca819d916ac95becf3e75f4200b3 + cp common/lib/stb_image.h.nopatch common/lib/stb_image.h patch -p0 < common/stb_image.patch rm -f common/lib/stb_image.h.orig - clone_repo_commit https://git.kernel.org/pub/scm/utils/dtc/dtc.git dtc $DTC_COMMIT_HASH + clone_repo_commit \ + https://git.kernel.org/pub/scm/utils/dtc/dtc.git \ + dtc \ + 039a99414e778332d8f9c04cbd3072e1dcc62798 rm -rf common/libfdt cp -rp dtc/libfdt common/ find common/libfdt/ -type f -not -name '*.c' -not -name '*.h' -delete diff --git a/configure.ac b/configure.ac index b34e1b5e..300d2009 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,7 @@ AC_DEFUN([PROG_ABSPATH], [ esac ]) -test "${CFLAGS-unset}" = "unset" && CFLAGS='-g -O2 -pipe' +test "x${CFLAGS+set}" = "x" && CFLAGS='-g -O2 -pipe' AC_LANG([C]) AC_PROG_CC @@ -174,7 +174,7 @@ else FREESTANDING_OBJDUMP="$OBJDUMP_FOR_TARGET" \ WANT_FREESTANDING_READELF=yes \ FREESTANDING_READELF="$READELF_FOR_TARGET" \ - "$SRCDIR/build-aux/freestanding-toolchain/freestanding-toolchain" 2>"toolchain-files/bios-i686-toolchain.mk" || exit 1 + "$SRCDIR/build-aux/freestanding-toolchain" 2>"toolchain-files/bios-i686-toolchain.mk" || exit 1 BUILD_BIOS="limine-bios" NEED_NASM=yes NEED_GZIP=yes @@ -204,7 +204,7 @@ else FREESTANDING_OBJCOPY="$OBJCOPY_FOR_TARGET" \ WANT_FREESTANDING_OBJDUMP=yes \ FREESTANDING_OBJDUMP="$OBJDUMP_FOR_TARGET" \ - "$SRCDIR/build-aux/freestanding-toolchain/freestanding-toolchain" 2>"toolchain-files/uefi-i686-toolchain.mk" || exit 1 + "$SRCDIR/build-aux/freestanding-toolchain" 2>"toolchain-files/uefi-i686-toolchain.mk" || exit 1 BUILD_UEFI_IA32="limine-uefi-ia32" NEED_NASM=yes fi @@ -233,7 +233,7 @@ else FREESTANDING_OBJCOPY="$OBJCOPY_FOR_TARGET" \ WANT_FREESTANDING_OBJDUMP=yes \ FREESTANDING_OBJDUMP="$OBJDUMP_FOR_TARGET" \ - "$SRCDIR/build-aux/freestanding-toolchain/freestanding-toolchain" 2>"toolchain-files/uefi-x86_64-toolchain.mk" || exit 1 + "$SRCDIR/build-aux/freestanding-toolchain" 2>"toolchain-files/uefi-x86_64-toolchain.mk" || exit 1 BUILD_UEFI_X86_64="limine-uefi-x86-64" NEED_NASM=yes fi @@ -262,7 +262,7 @@ else FREESTANDING_OBJCOPY="$OBJCOPY_FOR_TARGET" \ WANT_FREESTANDING_OBJDUMP=yes \ FREESTANDING_OBJDUMP="$OBJDUMP_FOR_TARGET" \ - "$SRCDIR/build-aux/freestanding-toolchain/freestanding-toolchain" 2>"toolchain-files/uefi-aarch64-toolchain.mk" || exit 1 + "$SRCDIR/build-aux/freestanding-toolchain" 2>"toolchain-files/uefi-aarch64-toolchain.mk" || exit 1 BUILD_UEFI_AARCH64="limine-uefi-aarch64" fi @@ -290,7 +290,7 @@ else FREESTANDING_OBJCOPY="$OBJCOPY_FOR_TARGET" \ WANT_FREESTANDING_OBJDUMP=yes \ FREESTANDING_OBJDUMP="$OBJDUMP_FOR_TARGET" \ - "$SRCDIR/build-aux/freestanding-toolchain/freestanding-toolchain" 2>"toolchain-files/uefi-riscv64-toolchain.mk" || exit 1 + "$SRCDIR/build-aux/freestanding-toolchain" 2>"toolchain-files/uefi-riscv64-toolchain.mk" || exit 1 BUILD_UEFI_RISCV64="limine-uefi-riscv64" fi @@ -332,23 +332,23 @@ fi BORROWED_CFLAGS="" for cflag in $CFLAGS; do case $cflag in - -O*|-pipe|-g|-ffile-prefix-map*) + -O*|-pipe|-g|-f*-prefix-map*) BORROWED_CFLAGS="$BORROWED_CFLAGS $cflag" ;; esac done AC_ARG_VAR([CFLAGS_FOR_TARGET], [C flags for Limine]) -test "${CFLAGS_FOR_TARGET-unset}" = "unset" && CFLAGS_FOR_TARGET="$BORROWED_CFLAGS" +test "x${CFLAGS_FOR_TARGET+set}" = "x" && CFLAGS_FOR_TARGET="$BORROWED_CFLAGS" AC_ARG_VAR([CPPFLAGS_FOR_TARGET], [C preprocessor flags for Limine]) -test "${CPPFLAGS_FOR_TARGET-unset}" = "unset" && CPPFLAGS_FOR_TARGET="" +test "x${CPPFLAGS_FOR_TARGET+set}" = "x" && CPPFLAGS_FOR_TARGET="" AC_ARG_VAR([LDFLAGS_FOR_TARGET], [linker flags for Limine]) -test "${LDFLAGS_FOR_TARGET-unset}" = "unset" && LDFLAGS_FOR_TARGET="" +test "x${LDFLAGS_FOR_TARGET+set}" = "x" && LDFLAGS_FOR_TARGET="" AC_ARG_VAR([NASMFLAGS_FOR_TARGET], [nasm flags for Limine]) -test "${NASMFLAGS_FOR_TARGET-unset}" = "unset" && NASMFLAGS_FOR_TARGET="-F dwarf -g" +test "x${NASMFLAGS_FOR_TARGET+set}" = "x" && NASMFLAGS_FOR_TARGET="-F dwarf -g" LIMINE_COPYRIGHT=$($GREP Copyright "$SRCDIR/COPYING") AC_SUBST([LIMINE_COPYRIGHT]) diff --git a/version.sh b/version.sh index 511ebe3d..fe6d4b35 100755 --- a/version.sh +++ b/version.sh @@ -8,12 +8,12 @@ test -z "$srcdir" && srcdir=. cd "$srcdir" -if [ -f version ]; then +if test -f version; then printf '%s' "$(cat version)" exit 0 fi -if ! [ -d .git ] || ! git log -n1 --pretty='%h' >/dev/null 2>&1; then +if ! test -d .git || ! git log -n1 --pretty='%h' >/dev/null 2>&1; then printf 'UNVERSIONED' exit 0 fi