:: commit 7b0c430fb5c0022e6307222d10f1625b467075f8

mintsuki <mintsuki@protonmail.com> — 2022-01-21 01:24

parents: 65ef9561a5

build: Misc portability improvements

diff --git a/GNUmakefile.in b/GNUmakefile.in
index 8af02bb7..e882d19a 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -53,8 +53,11 @@ ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_CC) ; ), )
 override LIMINE_CC := $(CC)
 endif
 ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_LD) ; ), )
+override LIMINE_LD := ld.bfd
+ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_LD) ; ), )
 override LIMINE_LD := ld
 endif
+endif
 ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_AR) ; ), )
 override LIMINE_AR := ar
 endif
@@ -79,6 +82,16 @@ export LIMINE_OBJCOPY
 export LIMINE_OBJDUMP
 export LIMINE_READELF
 
+override USING_GNU_LD := $(shell $(LIMINE_LD) --version | grep Binutils >/dev/null && echo 1)
+ifeq ($(USING_GNU_LD), 0)
+$(error The specified LIMINE_LD linker ($(LIMINE_LD)) is not the GNU linker)
+endif
+
+override USING_GNU_OBJCOPY := $(shell $(LIMINE_OBJCOPY) --version | grep Binutils >/dev/null && echo 1)
+ifeq ($(USING_GNU_OBJCOPY), 0)
+$(error The specified LIMINE_OBJCOPY ($(LIMINE_OBJCOPY)) is not GNU objcopy)
+endif
+
 override USING_CLANG := $(shell $(LIMINE_CC) --version | grep clang >/dev/null && echo 1)
 export USING_CLANG
 
diff --git a/build-aux/make_toolchain.sh b/build-aux/make_toolchain.sh
index bce69753..fe8ac96b 100755
--- a/build-aux/make_toolchain.sh
+++ b/build-aux/make_toolchain.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/sh
 
 set -ex
 
@@ -6,7 +6,10 @@ TARGET=x86_64-elf
 BINUTILSVERSION=2.37
 GCCVERSION=11.2.0
 
-CFLAGS="-O2 -pipe"
+export CFLAGS="-O2 -pipe"
+
+unset CC
+unset CXX
 
 if [ "$(uname)" = "OpenBSD" ]; then
     # OpenBSD has an awfully ancient GCC which fails to build our toolchain.
diff --git a/stage23/gensyms.sh b/stage23/gensyms.sh
index 61a33aa1..797399a6 100755
--- a/stage23/gensyms.sh
+++ b/stage23/gensyms.sh
@@ -1,7 +1,9 @@
-#!/bin/sh
+#! /bin/sh
 
 set -e
 
+export LC_ALL=C
+
 TMP0=$(mktemp)
 
 cat >"$TMP0" <<EOF
diff --git a/version.sh b/version.sh
index a4e061d3..c8f6a7d0 100755
--- a/version.sh
+++ b/version.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/sh
 
 [ -f version ] || ( git describe --exact-match --tags $(git log -n1 --pretty='%h') 2>/dev/null || git log -n1 --pretty='%h' ) | xargs printf '%s'
 [ -f version ] && ( cat version 2>/dev/null ) | xargs printf '%s'
tab: 248 wrap: offon