build: Misc improvements to makefiles

This commit is contained in:
mintsuki 2022-08-15 17:41:04 +02:00
parent 1e9ac0ac01
commit 5f1680acc1
3 changed files with 172 additions and 166 deletions

View File

@ -27,8 +27,8 @@ override BUILD_LIMINE_DEPLOY := @BUILD_LIMINE_DEPLOY@
WERROR ?= @WERROR@ WERROR ?= @WERROR@
export WERROR export WERROR
ifeq ($(origin CC), default) ifeq ($(origin CC),default)
CC := @CC@ CC := @CC@
endif endif
export CC export CC
@ -128,10 +128,10 @@ uninstall:
$(call MKESCAPE,$(BUILDDIR))/stage1.stamp: $(STAGE1_FILES) $(call MKESCAPE,$(BUILDDIR))/decompressor-build/decompressor.bin $(call MKESCAPE,$(BUILDDIR))/common-bios/stage2.bin.gz $(call MKESCAPE,$(BUILDDIR))/stage1.stamp: $(STAGE1_FILES) $(call MKESCAPE,$(BUILDDIR))/decompressor-build/decompressor.bin $(call MKESCAPE,$(BUILDDIR))/common-bios/stage2.bin.gz
$(MKDIR_P) '$(call SHESCAPE,$(BINDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BINDIR))'
cd '$(call SHESCAPE,$(SRCDIR))/stage1/hdd' && nasm bootsect.asm @WERROR@ -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-hdd.bin' cd '$(call SHESCAPE,$(SRCDIR))/stage1/hdd' && nasm bootsect.asm @WERROR@ -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-hdd.bin'
ifneq ($(BUILD_CD), no) ifneq ($(BUILD_CD),no)
cd '$(call SHESCAPE,$(SRCDIR))/stage1/cd' && nasm bootsect.asm @WERROR@ -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-cd.bin' cd '$(call SHESCAPE,$(SRCDIR))/stage1/cd' && nasm bootsect.asm @WERROR@ -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-cd.bin'
endif endif
ifneq ($(BUILD_PXE), no) ifneq ($(BUILD_PXE),no)
cd '$(call SHESCAPE,$(SRCDIR))/stage1/pxe' && nasm bootsect.asm @WERROR@ -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-pxe.bin' cd '$(call SHESCAPE,$(SRCDIR))/stage1/pxe' && nasm bootsect.asm @WERROR@ -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-pxe.bin'
endif endif
cp '$(call SHESCAPE,$(BUILDDIR))/common-bios/limine.sys' '$(call SHESCAPE,$(BINDIR))/' cp '$(call SHESCAPE,$(BUILDDIR))/common-bios/limine.sys' '$(call SHESCAPE,$(BINDIR))/'
@ -140,12 +140,12 @@ endif
.PHONY: limine-bios .PHONY: limine-bios
limine-bios: common-bios decompressor limine-bios: common-bios decompressor
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/stage1.stamp' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/stage1.stamp'
ifneq ($(BUILD_LIMINE_DEPLOY), no) ifneq ($(BUILD_LIMINE_DEPLOY),no)
$(MAKE) limine-deploy $(MAKE) limine-deploy
endif endif
$(call MKESCAPE,$(BINDIR))/limine-cd-efi.bin: $(if @BUILD_UEFI_IA32@, $(call MKESCAPE,$(BUILDDIR))/common-uefi-ia32/BOOTIA32.EFI) $(if @BUILD_UEFI_X86_64@, $(call MKESCAPE,$(BUILDDIR))/common-uefi-x86-64/BOOTX64.EFI) $(call MKESCAPE,$(BINDIR))/limine-cd-efi.bin: $(if @BUILD_UEFI_IA32@, $(call MKESCAPE,$(BUILDDIR))/common-uefi-ia32/BOOTIA32.EFI) $(if @BUILD_UEFI_X86_64@, $(call MKESCAPE,$(BUILDDIR))/common-uefi-x86-64/BOOTX64.EFI)
ifneq ($(BUILD_CD_EFI), no) ifneq ($(BUILD_CD_EFI),no)
$(MKDIR_P) '$(call SHESCAPE,$(BINDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BINDIR))'
rm -f '$(call SHESCAPE,$(BINDIR))/limine-cd-efi.bin' rm -f '$(call SHESCAPE,$(BINDIR))/limine-cd-efi.bin'
dd if=/dev/zero of='$(call SHESCAPE,$(BINDIR))/limine-cd-efi.bin' bs=512 count=2880 2>/dev/null dd if=/dev/zero of='$(call SHESCAPE,$(BINDIR))/limine-cd-efi.bin' bs=512 count=2880 2>/dev/null
@ -163,18 +163,24 @@ endif
limine-cd-efi: limine-cd-efi:
$(MAKE) '$(call SHESCAPE,$(BINDIR))/limine-cd-efi.bin' $(MAKE) '$(call SHESCAPE,$(BINDIR))/limine-cd-efi.bin'
.PHONY: limine-uefi-x86-64 $(call MKESCAPE,$(BINDIR))/BOOTX64.EFI: $(call MKESCAPE,$(BUILDDIR))/common-uefi-x86-64/BOOTX64.EFI
limine-uefi-x86-64: $(call MKESCAPE,$(SRCDIR))/limine-efi
$(MAKE) common-uefi-x86-64
$(MKDIR_P) '$(call SHESCAPE,$(BINDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BINDIR))'
cp '$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64/BOOTX64.EFI' '$(call SHESCAPE,$(BINDIR))/' cp '$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64/BOOTX64.EFI' '$(call SHESCAPE,$(BINDIR))/'
.PHONY: limine-uefi-ia32 .PHONY: limine-uefi-x86-64
limine-uefi-ia32: $(call MKESCAPE,$(SRCDIR))/limine-efi limine-uefi-x86-64:
$(MAKE) common-uefi-ia32 $(MAKE) common-uefi-x86-64
$(MAKE) '$(call SHESCAPE,$(BINDIR))/BOOTX64.EFI'
$(call MKESCAPE,$(BINDIR))/BOOTIA32.EFI: $(call MKESCAPE,$(BUILDDIR))/common-uefi-ia32/BOOTIA32.EFI
$(MKDIR_P) '$(call SHESCAPE,$(BINDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BINDIR))'
cp '$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32/BOOTIA32.EFI' '$(call SHESCAPE,$(BINDIR))/' cp '$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32/BOOTIA32.EFI' '$(call SHESCAPE,$(BINDIR))/'
.PHONY: limine-uefi-ia32
limine-uefi-ia32:
$(MAKE) common-uefi-ia32
$(MAKE) '$(call SHESCAPE,$(BINDIR))/BOOTIA32.EFI'
.PHONY: limine-bios-clean .PHONY: limine-bios-clean
limine-bios-clean: common-bios-clean decompressor-clean limine-bios-clean: common-bios-clean decompressor-clean

View File

@ -11,18 +11,18 @@ MKESCAPE = $(subst $(SPACE),\ ,$(1))
SHESCAPE = $(subst ','\'',$(1)) SHESCAPE = $(subst ','\'',$(1))
OBJESCAPE = $(subst .a ,.a' ',$(subst .o ,.o' ',$(call SHESCAPE,$(1)))) OBJESCAPE = $(subst .a ,.a' ',$(subst .o ,.o' ',$(call SHESCAPE,$(1))))
ifeq ($(call MKESCAPE,$(BUILDDIR)), ) ifeq ($(call MKESCAPE,$(BUILDDIR)),)
$(error BUILDDIR not specified) $(error BUILDDIR not specified)
endif endif
ifeq ($(TARGET), bios) ifeq ($(TARGET),bios)
override OBJCOPY_ARCH := elf32-i386 override OBJCOPY_ARCH := elf32-i386
else ifeq ($(TARGET), uefi-x86-64) else ifeq ($(TARGET),uefi-x86-64)
override OBJCOPY_ARCH := elf64-x86-64 override OBJCOPY_ARCH := elf64-x86-64
else ifeq ($(TARGET), uefi-ia32) else ifeq ($(TARGET),uefi-ia32)
override OBJCOPY_ARCH := elf32-i386 override OBJCOPY_ARCH := elf32-i386
else else
$(error Invalid target) $(error Invalid target)
endif endif
COM_OUTPUT ?= false COM_OUTPUT ?= false
@ -31,134 +31,134 @@ E9_OUTPUT ?= false
override S2CFLAGS := -Os override S2CFLAGS := -Os
override CROSS_CFLAGS += \ override CROSS_CFLAGS += \
-g \ -g \
$(WERROR) \ $(WERROR) \
-std=gnu11 \ -std=gnu11 \
-ffreestanding \ -ffreestanding \
-fno-stack-protector \ -fno-stack-protector \
-fno-stack-check \ -fno-stack-check \
-fno-omit-frame-pointer \ -fno-omit-frame-pointer \
-fno-strict-aliasing \ -fno-strict-aliasing \
-fno-lto \ -fno-lto \
-nostdinc \ -nostdinc \
-Wno-address-of-packed-member \ -Wno-address-of-packed-member \
-Wshadow \ -Wshadow \
-Wvla \ -Wvla \
-mno-80387 \ -mno-80387 \
-mno-mmx \ -mno-mmx \
-mno-sse \ -mno-sse \
-mno-sse2 \ -mno-sse2 \
-MMD \ -MMD \
-DCOM_OUTPUT=$(COM_OUTPUT) \ -DCOM_OUTPUT=$(COM_OUTPUT) \
-DE9_OUTPUT=$(E9_OUTPUT) \ -DE9_OUTPUT=$(E9_OUTPUT) \
-I../freestanding-headers \ -I../freestanding-headers \
-I'$(call SHESCAPE,$(BUILDDIR))/..' \ -I'$(call SHESCAPE,$(BUILDDIR))/..' \
-I. \ -I. \
-I.. \ -I.. \
-I'$(call SHESCAPE,$(BUILDDIR))/tinf' -I'$(call SHESCAPE,$(BUILDDIR))/tinf'
ifeq ($(TARGET), bios) ifeq ($(TARGET),bios)
override CROSS_CFLAGS += \ override CROSS_CFLAGS += \
-Dbios=1 \ -Dbios=1 \
-Duefi=0 \ -Duefi=0 \
-m32 \ -m32 \
-march=i686 \ -march=i686 \
-mtune=generic \ -mtune=generic \
-mabi=sysv \ -mabi=sysv \
-fno-pie \ -fno-pie \
-fno-pic -fno-pic
endif endif
ifeq ($(TARGET), uefi-x86-64) ifeq ($(TARGET),uefi-x86-64)
override CROSS_CFLAGS += \ override CROSS_CFLAGS += \
-Dbios=0 \ -Dbios=0 \
-Duefi=1 \ -Duefi=1 \
-m64 \ -m64 \
-march=x86-64 \ -march=x86-64 \
-mtune=generic \ -mtune=generic \
-mabi=sysv \ -mabi=sysv \
-DGNU_EFI_USE_MS_ABI \ -DGNU_EFI_USE_MS_ABI \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/x86_64' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/x86_64' \
-fpie \ -fpie \
-mno-red-zone -mno-red-zone
endif endif
ifeq ($(TARGET), uefi-ia32) ifeq ($(TARGET),uefi-ia32)
override CROSS_CFLAGS += \ override CROSS_CFLAGS += \
-Dbios=0 \ -Dbios=0 \
-Duefi=1 \ -Duefi=1 \
-m32 \ -m32 \
-march=i686 \ -march=i686 \
-mtune=generic \ -mtune=generic \
-mabi=sysv \ -mabi=sysv \
-DGNU_EFI_USE_MS_ABI \ -DGNU_EFI_USE_MS_ABI \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/ia32' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/ia32' \
-fpie -fpie
endif endif
override CROSS_LDFLAGS += \ override CROSS_LDFLAGS += \
-nostdlib \ -nostdlib \
-z max-page-size=0x1000 -z max-page-size=0x1000
ifeq ($(TARGET), bios) ifeq ($(TARGET),bios)
override CROSS_LDFLAGS += \ override CROSS_LDFLAGS += \
-melf_i386 \ -melf_i386 \
-static \ -static \
--build-id=sha1 --build-id=sha1
endif endif
ifeq ($(TARGET), uefi-x86-64) ifeq ($(TARGET),uefi-x86-64)
override CROSS_LDFLAGS += \ override CROSS_LDFLAGS += \
-melf_x86_64 \ -melf_x86_64 \
-static \ -static \
-pie \ -pie \
--no-dynamic-linker \ --no-dynamic-linker \
-ztext -ztext
endif endif
ifeq ($(TARGET), uefi-ia32) ifeq ($(TARGET),uefi-ia32)
override CROSS_LDFLAGS += \ override CROSS_LDFLAGS += \
-melf_i386 \ -melf_i386 \
-static \ -static \
-pie \ -pie \
--no-dynamic-linker \ --no-dynamic-linker \
-ztext -ztext
endif endif
.PHONY: all
override C_FILES := $(shell find ./ -type f -name '*.c') override C_FILES := $(shell find ./ -type f -name '*.c')
ifeq ($(TARGET), bios) ifeq ($(TARGET),bios)
override ASMX86_FILES := $(shell find ./ -type f -name '*.asm_x86') override ASMX86_FILES := $(shell find ./ -type f -name '*.asm_x86')
override ASM32_FILES := $(shell find ./ -type f -name '*.asm_ia32') override ASM32_FILES := $(shell find ./ -type f -name '*.asm_ia32')
override ASMB_FILES := $(shell find ./ -type f -name '*.asm_bios_ia32') override ASMB_FILES := $(shell find ./ -type f -name '*.asm_bios_ia32')
override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM32_FILES:.asm_ia32=.o) $(ASMB_FILES:.asm_bios_ia32=.o) $(ASMX86_FILES:.asm_x86=.o)) override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM32_FILES:.asm_ia32=.o) $(ASMB_FILES:.asm_bios_ia32=.o) $(ASMX86_FILES:.asm_x86=.o))
override OBJ_S2 := $(filter %.s2.o,$(OBJ)) override OBJ_S2 := $(filter %.s2.o,$(OBJ))
endif endif
ifeq ($(TARGET), uefi-x86-64) ifeq ($(TARGET),uefi-x86-64)
override ASMX86_FILES := $(shell find ./ -type f -name '*.asm_x86') override ASMX86_FILES := $(shell find ./ -type f -name '*.asm_x86')
override ASM64_FILES := $(shell find ./ -type f -name '*.asm_x86_64') override ASM64_FILES := $(shell find ./ -type f -name '*.asm_x86_64')
override ASM64U_FILES := $(shell find ./ -type f -name '*.asm_uefi_x86_64') override ASM64U_FILES := $(shell find ./ -type f -name '*.asm_uefi_x86_64')
override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM64_FILES:.asm_x86_64=.o) $(ASM64U_FILES:.asm_uefi_x86_64=.o) $(ASMX86_FILES:.asm_x86=.o)) override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM64_FILES:.asm_x86_64=.o) $(ASM64U_FILES:.asm_uefi_x86_64=.o) $(ASMX86_FILES:.asm_x86=.o))
endif endif
ifeq ($(TARGET), uefi-ia32) ifeq ($(TARGET),uefi-ia32)
override ASMX86_FILES := $(shell find ./ -type f -name '*.asm_x86') override ASMX86_FILES := $(shell find ./ -type f -name '*.asm_x86')
override ASM32_FILES := $(shell find ./ -type f -name '*.asm_ia32') override ASM32_FILES := $(shell find ./ -type f -name '*.asm_ia32')
override ASM32U_FILES := $(shell find ./ -type f -name '*.asm_uefi_ia32') override ASM32U_FILES := $(shell find ./ -type f -name '*.asm_uefi_ia32')
override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM32_FILES:.asm_ia32=.o) $(ASM32U_FILES:.asm_uefi_ia32=.o) $(ASMX86_FILES:.asm_x86=.o)) override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM32_FILES:.asm_ia32=.o) $(ASM32U_FILES:.asm_uefi_ia32=.o) $(ASMX86_FILES:.asm_x86=.o))
endif endif
override HEADER_DEPS := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.d)) override HEADER_DEPS := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.d))
ifeq ($(TARGET), bios) .PHONY: all
ifeq ($(TARGET),bios)
all: $(call MKESCAPE,$(BUILDDIR))/limine.sys $(call MKESCAPE,$(BUILDDIR))/stage2.bin.gz all: $(call MKESCAPE,$(BUILDDIR))/limine.sys $(call MKESCAPE,$(BUILDDIR))/stage2.bin.gz
else ifeq ($(TARGET), uefi-x86-64) else ifeq ($(TARGET),uefi-x86-64)
all: $(call MKESCAPE,$(BUILDDIR))/BOOTX64.EFI all: $(call MKESCAPE,$(BUILDDIR))/BOOTX64.EFI
else ifeq ($(TARGET), uefi-ia32) else ifeq ($(TARGET),uefi-ia32)
all: $(call MKESCAPE,$(BUILDDIR))/BOOTIA32.EFI all: $(call MKESCAPE,$(BUILDDIR))/BOOTIA32.EFI
endif endif
@ -180,7 +180,7 @@ $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o: $(call MKESCAPE,$(BUILDDIR))/tinf-
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)' $(CROSS_CC) $(CROSS_CFLAGS) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)'
ifeq ($(TARGET), bios) ifeq ($(TARGET),bios)
$(call MKESCAPE,$(BUILDDIR))/stage2.bin.gz: $(call MKESCAPE,$(BUILDDIR))/stage2.bin $(call MKESCAPE,$(BUILDDIR))/stage2.bin.gz: $(call MKESCAPE,$(BUILDDIR))/stage2.bin
gzip -n -9 < '$(call SHESCAPE,$<)' > '$(call SHESCAPE,$@)' gzip -n -9 < '$(call SHESCAPE,$<)' > '$(call SHESCAPE,$@)'
@ -249,7 +249,7 @@ $(call MKESCAPE,$(BUILDDIR))/limine-efi: ../limine-efi/*
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
cp -r ../limine-efi '$(call SHESCAPE,$(BUILDDIR))/' cp -r ../limine-efi '$(call SHESCAPE,$(BUILDDIR))/'
ifeq ($(TARGET), uefi-x86-64) ifeq ($(TARGET),uefi-x86-64)
$(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
@ -290,7 +290,7 @@ $(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi
endif endif
ifeq ($(TARGET), uefi-ia32) ifeq ($(TARGET),uefi-ia32)
$(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
@ -333,19 +333,19 @@ endif
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
ifeq ($(TARGET), uefi-x86-64) ifeq ($(TARGET),uefi-x86-64)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/limine-efi $(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/limine-efi
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(CROSS_CC) $(CROSS_CFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
endif endif
ifeq ($(TARGET), uefi-ia32) ifeq ($(TARGET),uefi-ia32)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/limine-efi $(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/limine-efi
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(CROSS_CC) $(CROSS_CFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
endif endif
ifeq ($(TARGET), bios) ifeq ($(TARGET),bios)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(CROSS_CC) $(CROSS_CFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
@ -353,7 +353,7 @@ endif
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
ifeq ($(TARGET), bios) ifeq ($(TARGET),bios)
$(call MKESCAPE,$(BUILDDIR))/%.s2.o: %.s2.c $(call MKESCAPE,$(BUILDDIR))/%.s2.o: %.s2.c
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(S2CFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(CROSS_CC) $(CROSS_CFLAGS) $(S2CFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
@ -361,7 +361,7 @@ endif
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
ifeq ($(TARGET), bios) ifeq ($(TARGET),bios)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_ia32 $(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(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,$@)'
@ -375,7 +375,7 @@ $(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86
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 endif
ifeq ($(TARGET), uefi-x86-64) ifeq ($(TARGET),uefi-x86-64)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86_64 $(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86_64
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(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,$@)'
@ -389,7 +389,7 @@ $(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86
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 endif
ifeq ($(TARGET), uefi-ia32) ifeq ($(TARGET),uefi-ia32)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_ia32 $(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(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,$@)'

View File

@ -8,45 +8,45 @@ MKESCAPE = $(subst $(SPACE),\ ,$(1))
SHESCAPE = $(subst ','\'',$(1)) SHESCAPE = $(subst ','\'',$(1))
OBJESCAPE = $(subst .a ,.a' ',$(subst .o ,.o' ',$(call SHESCAPE,$(1)))) OBJESCAPE = $(subst .a ,.a' ',$(subst .o ,.o' ',$(call SHESCAPE,$(1))))
ifeq ($(call MKESCAPE,$(BUILDDIR)), ) ifeq ($(call MKESCAPE,$(BUILDDIR)),)
$(error BUILDDIR not specified) $(error BUILDDIR not specified)
endif endif
override CROSS_CFLAGS += \ override CROSS_CFLAGS += \
$(WERROR) \ $(WERROR) \
-Os \ -Os \
-m32 \ -m32 \
-march=i686 \ -march=i686 \
-mtune=generic \ -mtune=generic \
-mabi=sysv \ -mabi=sysv \
-std=gnu11 \ -std=gnu11 \
-ffreestanding \ -ffreestanding \
-fno-stack-protector \ -fno-stack-protector \
-fno-stack-check \ -fno-stack-check \
-fno-strict-aliasing \ -fno-strict-aliasing \
-fno-lto \ -fno-lto \
-fno-pie \ -fno-pie \
-fno-pic \ -fno-pic \
-fomit-frame-pointer \ -fomit-frame-pointer \
-nostdinc \ -nostdinc \
-Wno-address-of-packed-member \ -Wno-address-of-packed-member \
-Wshadow \ -Wshadow \
-Wvla \ -Wvla \
-mno-80387 \ -mno-80387 \
-mno-mmx \ -mno-mmx \
-mno-sse \ -mno-sse \
-mno-sse2 \ -mno-sse2 \
-MMD \ -MMD \
-I../freestanding-headers \ -I../freestanding-headers \
-I. \ -I. \
-I'$(call SHESCAPE,$(BUILDDIR))/tinf' -I'$(call SHESCAPE,$(BUILDDIR))/tinf'
override CROSS_LDFLAGS += \ override CROSS_LDFLAGS += \
-melf_i386 \ -melf_i386 \
-nostdlib \ -nostdlib \
-z max-page-size=0x1000 \ -z max-page-size=0x1000 \
-static \ -static \
-Tlinker.ld -Tlinker.ld
override C_FILES := $(shell find ./ -type f -name '*.c') override C_FILES := $(shell find ./ -type f -name '*.c')
override ASM_FILES := $(shell find ./ -type f -name '*.asm') override ASM_FILES := $(shell find ./ -type f -name '*.asm')