build: Minor misc fixes

This commit is contained in:
mintsuki 2022-01-29 17:23:41 +01:00
parent 9fc8ec0ce3
commit ac865be1a1
3 changed files with 18 additions and 10 deletions

View File

@ -30,6 +30,8 @@ CC := @CC@
endif
export CC
HOST_CC ?= @HOST_CC@
INSTALL ?= @INSTALL@
export INSTALL
@ -53,18 +55,17 @@ LIMINE_READELF ?= @LIMINE_READELF@
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 := gld
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 := /usr/local/bin/ld
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_LD) ; ), )
override LIMINE_LD := ld
endif
endif
endif
endif
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_AR) ; ), )
override LIMINE_AR := gar
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_AR) ; ), )
@ -74,6 +75,7 @@ override LIMINE_AR := ar
endif
endif
endif
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_AS) ; ), )
override LIMINE_AS := gas
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_AS) ; ), )
@ -83,6 +85,7 @@ override LIMINE_AS := as
endif
endif
endif
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_OBJCOPY) ; ), )
override LIMINE_OBJCOPY := gobjcopy
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_OBJCOPY) ; ), )
@ -92,6 +95,7 @@ override LIMINE_OBJCOPY := objcopy
endif
endif
endif
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_OBJDUMP) ; ), )
override LIMINE_OBJDUMP := gobjdump
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_OBJDUMP) ; ), )
@ -101,6 +105,7 @@ override LIMINE_OBJDUMP := objdump
endif
endif
endif
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_READELF) ; ), )
override LIMINE_READELF := greadelf
ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(LIMINE_READELF) ; ), )
@ -200,7 +205,7 @@ all: limine-uefi limine-bios
$(call MKESCAPE,$(BUILDDIR))/hgen: $(call MKESCAPE,$(SRCDIR))/limine-install/hgen.c
mkdir -p '$(call SHESCAPE,$(BUILDDIR))'
$(CC) $(CFLAGS) -std=c11 '$(call SHESCAPE,$(SRCDIR))/limine-install/hgen.c' -o '$(call SHESCAPE,$(BUILDDIR))/hgen'
$(HOST_CC) $(CFLAGS) -std=c11 '$(call SHESCAPE,$(SRCDIR))/limine-install/hgen.c' -o '$(call SHESCAPE,$(BUILDDIR))/hgen'
.PHONY: limine-hdd.h
limine-hdd.h: $(call MKESCAPE,$(BINDIR))/limine-hdd.h

View File

@ -19,6 +19,9 @@ fi
AC_PROG_CC
AC_PROG_INSTALL
AC_ARG_VAR(HOST_CC, [C compiler for the build host [$(CC)]])
test "x$HOST_CC" = "x" && HOST_CC='$(CC)'
AC_ARG_VAR(TOOLCHAIN, [Alternative toolchain prefix [limine]])
test "x$TOOLCHAIN" = "x" && TOOLCHAIN='limine'

View File

@ -364,31 +364,31 @@ endif
ifeq ($(TARGET), bios)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm32
mkdir -p "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g -Werror -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asmb
mkdir -p "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g -Werror -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
endif
ifeq ($(TARGET), uefi64)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm64
mkdir -p "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g -Werror -f elf64 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf64 -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm64u
mkdir -p "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g -Werror -f elf64 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf64 -o '$(call SHESCAPE,$@)'
endif
ifeq ($(TARGET), uefi32)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm32
mkdir -p "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g -Werror -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm32u
mkdir -p "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g -Werror -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
endif
clean: