build: Misc portability improvements

This commit is contained in:
mintsuki 2022-01-21 02:24:36 +01:00
parent 65ef9561a5
commit 7b0c430fb5
4 changed files with 22 additions and 4 deletions

View File

@ -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

View File

@ -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.

View File

@ -1,7 +1,9 @@
#!/bin/sh
#! /bin/sh
set -e
export LC_ALL=C
TMP0=$(mktemp)
cat >"$TMP0" <<EOF

View File

@ -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'