diff --git a/GNUmakefile.in b/GNUmakefile.in index 7a1d23da..32dbd4e5 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -7,6 +7,8 @@ export SOURCE_DATE_EPOCH override SOURCE_DATE_EPOCH_TOUCH := @SOURCE_DATE_EPOCH_TOUCH@ override PACKAGE_TARNAME := @PACKAGE_TARNAME@ +override PACKAGE_VERSION := @PACKAGE_VERSION@ +override DIST_OUTPUT := $(PACKAGE_TARNAME)-$(PACKAGE_VERSION) prefix := @prefix@ exec_prefix := @exec_prefix@ @@ -87,8 +89,6 @@ export LDFLAGS_FOR_TARGET NASMFLAGS_FOR_TARGET := @NASMFLAGS_FOR_TARGET@ export NASMFLAGS_FOR_TARGET -override LIMINE_VERSION := @PACKAGE_VERSION@ - override STAGE1_FILES := $(shell find '$(call SHESCAPE,$(SRCDIR))/stage1' -type f -name '*.asm' | LC_ALL=C sort) .PHONY: all @@ -295,40 +295,40 @@ limine-uefi-loongarch64-clean: common-uefi-loongarch64-clean .PHONY: dist dist: - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)" - $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)" - cp -r '$(call SHESCAPE,$(SRCDIR))'/.git '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)"/ - cd '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)" && git checkout . - cd '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)" && ./bootstrap - 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)/freestnd-c-hdrs-0bsd/.git" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/nyu-efi/.git" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/nyu-efi/.gitignore" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/cc-runtime/.git" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/cc-runtime/.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)/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" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/README.md" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/autom4te.cache" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/test" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/test.mk" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/logo.png" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/screenshot.png" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/bochsrc" - echo "$(LIMINE_VERSION)" > '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/version" - cd '$(call SHESCAPE,$(BUILDDIR))' && tar -cf "limine-$(LIMINE_VERSION).tar" "limine-$(LIMINE_VERSION)" - cd '$(call SHESCAPE,$(BUILDDIR))' && gzip < "limine-$(LIMINE_VERSION).tar" > "limine-$(LIMINE_VERSION).tar.gz" - cd '$(call SHESCAPE,$(BUILDDIR))' && ( lzip < "limine-$(LIMINE_VERSION).tar" > "limine-$(LIMINE_VERSION).tar.lz" || rm -f "limine-$(LIMINE_VERSION).tar.lz" ) - cd '$(call SHESCAPE,$(BUILDDIR))' && ( bzip2 < "limine-$(LIMINE_VERSION).tar" > "limine-$(LIMINE_VERSION).tar.bz2" || rm -f "limine-$(LIMINE_VERSION).tar.bz2" ) - cd '$(call SHESCAPE,$(BUILDDIR))' && ( xz < "limine-$(LIMINE_VERSION).tar" > "limine-$(LIMINE_VERSION).tar.xz" || rm -f "limine-$(LIMINE_VERSION).tar.xz" ) - cd '$(call SHESCAPE,$(BUILDDIR))' && ( zstd < "limine-$(LIMINE_VERSION).tar" > "limine-$(LIMINE_VERSION).tar.zst" || rm -f "limine-$(LIMINE_VERSION).tar.zst" ) - cd '$(call SHESCAPE,$(BUILDDIR))' && rm "limine-$(LIMINE_VERSION).tar" - rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)" + $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)" + cp -r '$(call SHESCAPE,$(SRCDIR))'/.git '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)"/ + cd '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)" && git checkout . + cd '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)" && ./bootstrap + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/common/flanterm/.git" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/common/flanterm/.gitignore" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/freestnd-c-hdrs-0bsd/.git" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/nyu-efi/.git" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/nyu-efi/.gitignore" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/cc-runtime/.git" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/cc-runtime/.gitignore" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/dtc" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/tinf" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/common/lib/stb_image.h.nopatch" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/.git" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/.gitignore" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/.github" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/README.md" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/autom4te.cache" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/test" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/test.mk" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/logo.png" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/screenshot.png" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/bochsrc" + echo "$(PACKAGE_VERSION)" > '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)/version" + cd '$(call SHESCAPE,$(BUILDDIR))' && tar -cf "$(DIST_OUTPUT).tar" "$(DIST_OUTPUT)" + cd '$(call SHESCAPE,$(BUILDDIR))' && gzip < "$(DIST_OUTPUT).tar" > "$(DIST_OUTPUT).tar.gz" + cd '$(call SHESCAPE,$(BUILDDIR))' && ( lzip < "$(DIST_OUTPUT).tar" > "$(DIST_OUTPUT).tar.lz" || rm -f "$(DIST_OUTPUT).tar.lz" ) + cd '$(call SHESCAPE,$(BUILDDIR))' && ( bzip2 < "$(DIST_OUTPUT).tar" > "$(DIST_OUTPUT).tar.bz2" || rm -f "$(DIST_OUTPUT).tar.bz2" ) + cd '$(call SHESCAPE,$(BUILDDIR))' && ( xz < "$(DIST_OUTPUT).tar" > "$(DIST_OUTPUT).tar.xz" || rm -f "$(DIST_OUTPUT).tar.xz" ) + cd '$(call SHESCAPE,$(BUILDDIR))' && ( zstd < "$(DIST_OUTPUT).tar" > "$(DIST_OUTPUT).tar.zst" || rm -f "$(DIST_OUTPUT).tar.zst" ) + cd '$(call SHESCAPE,$(BUILDDIR))' && rm "$(DIST_OUTPUT).tar" + rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"$(DIST_OUTPUT)" .PHONY: distclean distclean: clean diff --git a/configure.ac b/configure.ac index 017e7901..8820d5e7 100644 --- a/configure.ac +++ b/configure.ac @@ -18,17 +18,39 @@ AC_SUBST([SOURCE_DATE_EPOCH_TOUCH]) AC_CANONICAL_HOST -AC_DEFUN([PROG_ABSPATH], [ - case "$$1" in - .*) $1="$(cd "$(dirname "$$1")" && pwd -P)/$(basename "$$1")" ;; - esac -]) +# Portably convert relative paths into absolute paths. +rel2abs() { + rel2abs_first=true + for i in $1; do + if test $rel2abs_first = true; then + case "$i" in + /*) + printf "%s" "$i" + ;; + */*) + if test -d "$(dirname "$i")"; then + printf "%s" "$(cd "$(dirname "$i")" && pwd -P)/$(basename "$i")" + else + printf "false" + fi + ;; + *) + printf "%s" "$i" + ;; + esac + rel2abs_first=false + else + printf " %s" "$i" + fi + done + printf "\n" +} test "x${CFLAGS+set}" = "x" && CFLAGS='-g -O2 -pipe' AC_LANG([C]) AC_PROG_CC -PROG_ABSPATH([CC]) +CC="$(rel2abs "$CC")" werror_state="no" AC_ARG_ENABLE([werror], @@ -41,46 +63,52 @@ else fi AC_PROG_MKDIR_P -PROG_ABSPATH([MKDIR_P]) +MKDIR_P="$(rel2abs "$MKDIR_P")" AC_PROG_INSTALL -PROG_ABSPATH([INSTALL]) +INSTALL="$(rel2abs "$INSTALL")" AC_PROG_SED -PROG_ABSPATH([SED]) +SED="$(rel2abs "$SED")" AC_PROG_GREP -PROG_ABSPATH([GREP]) +GREP="$(rel2abs "$GREP")" AC_PROG_AWK -PROG_ABSPATH([AWK]) +AWK="$(rel2abs "$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 -AC_ARG_VAR([STRIP], [strip command]) - -if ! test -z "$STRIP"; then - if test -x "$STRIP"; then - STRIP_USER_FOUND=yes +# $1 - UPPERCASEVAR, $2 - default program +AC_DEFUN([GET_PROG_FROM_TOOLCHAIN], [ + AC_ARG_VAR([$1], [$2 command @<:@default: $2@:>@]) + + if ! test -z "$$1"; then + first_elem="$(echo "$$1" | cut -f 1 -d " ")" + case "$first_elem" in + */*) + if test -f "$first_elem" && test -x "$first_elem"; then + $1_USER_FOUND=yes + fi + ;; + *) + AC_CHECK_PROG([$1_USER_FOUND], [$$1], [yes]) + ;; + esac + + if ! test "x$$1_USER_FOUND" = "xyes"; then + AC_MSG_ERROR([$2 not found, please install $2 before configuring]) + fi else - AC_CHECK_PROG([STRIP_USER_FOUND], [$STRIP], [yes]) - fi - - if ! test "x$STRIP_USER_FOUND" = "xyes"; then - AC_MSG_ERROR([$STRIP not found, please install $STRIP before configuring]) - fi -else - STRIP="$($CC -dumpmachine)"-strip - AC_CHECK_PROG([STRIP_FOUND], [$STRIP], [yes]) - if ! test "x$STRIP_FOUND" = "xyes"; then - STRIP=strip - AC_CHECK_PROG([STRIP_DEFAULT_FOUND], [$STRIP], [yes]) - if ! test "x$STRIP_DEFAULT_FOUND" = "xyes"; then - AC_MSG_ERROR([$STRIP not found, please install $STRIP before configuring]) + AC_CHECK_TOOL([$1], [$2], [:]) + if test "x$$1" = "x:"; then + AC_MSG_ERROR([$2 not found, please install $2 or set $1 to a valid command]) fi fi -fi -AC_SUBST([STRIP]) + $1="$(rel2abs "$$1")" +]) + +GET_PROG_FROM_TOOLCHAIN([STRIP], [strip]) AC_CHECK_HEADERS([stdint.h stddef.h stdbool.h limits.h inttypes.h stdio.h stdlib.h string.h], [], [AC_MSG_ERROR([required header not found])])