Skip to content

Commit

Permalink
build: Misc improvements wrt variable passing
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsuki committed Nov 27, 2024
1 parent e287c9d commit 375360f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 49 deletions.
60 changes: 32 additions & 28 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ $(call MKESCAPE,$(BINDIR))/limine-bios-hdd.h: $(call MKESCAPE,$(BINDIR))/limine-
$(MKDIR_P) '$(call SHESCAPE,$(BINDIR))'
cd '$(call SHESCAPE,$(BINDIR))' && '$(call SHESCAPE,$(SRCDIR))/host/hgen.sh' >limine-bios-hdd.h

override LIMINE_NO_BIOS :=
ifneq ($(BUILD_BIOS),limine-bios)
override LIMINE_NO_BIOS := -DLIMINE_NO_BIOS
endif
Expand All @@ -113,7 +114,10 @@ $(call MKESCAPE,$(BINDIR))/limine: $(call MKESCAPE,$(BINDIR))/Makefile $(call MK
$(MAKE) -C '$(call SHESCAPE,$(BINDIR))' limine \
CC="$(CC)" \
CFLAGS="$(CFLAGS)" \
CPPFLAGS='$(CPPFLAGS) $(LIMINE_NO_BIOS) -DLIMINE_DATADIR=\"$(call SHESCAPE,$(datarootdir))/limine\"'
CPPFLAGS='$(CPPFLAGS) $(LIMINE_NO_BIOS) -DLIMINE_DATADIR=\"$(call SHESCAPE,$(datarootdir))/limine\"' \
LDFLAGS="$(LDFLAGS)" \
LIBS="$(LIBS)" \
WERROR_FLAG="$(WERROR_FLAG)"

$(call MKESCAPE,$(BINDIR))/Makefile: $(call MKESCAPE,$(SRCDIR))/host/host.mk $(call MKESCAPE,$(SRCDIR))/host/.gitignore
mkdir -p '$(call SHESCAPE,$(BINDIR))'
Expand Down Expand Up @@ -336,75 +340,75 @@ maintainer-clean: distclean

.PHONY: common-uefi-x86-64
common-uefi-x86-64:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk' \
TARGET=uefi-x86-64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64'
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk' \
TARGET=uefi-x86-64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64' \
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk

.PHONY: common-uefi-x86-64-clean
common-uefi-x86-64-clean:
rm -rf '$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64'

.PHONY: common-uefi-aarch64
common-uefi-aarch64:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-aarch64-toolchain.mk' \
TARGET=uefi-aarch64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-aarch64'
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-aarch64-toolchain.mk' \
TARGET=uefi-aarch64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-aarch64' \
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk

.PHONY: common-uefi-aarch64-clean
common-uefi-aarch64-clean:
rm -rf '$(call SHESCAPE,$(BUILDDIR))/common-uefi-aarch64'

.PHONY: common-uefi-riscv64
common-uefi-riscv64:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-riscv64-toolchain.mk' \
TARGET=uefi-riscv64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-riscv64'
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-riscv64-toolchain.mk' \
TARGET=uefi-riscv64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-riscv64' \
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk

.PHONY: common-uefi-riscv64-clean
common-uefi-riscv64-clean:
rm -rf '$(call SHESCAPE,$(BUILDDIR))/common-uefi-riscv64'

.PHONY: common-uefi-loongarch64
common-uefi-loongarch64:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-loongarch64-toolchain.mk' \
TARGET=uefi-loongarch64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-loongarch64'
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-loongarch64-toolchain.mk' \
TARGET=uefi-loongarch64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-loongarch64' \
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk

.PHONY: common-uefi-loongarch64-clean
common-uefi-loongarch64-clean:
rm -rf '$(call SHESCAPE,$(BUILDDIR))/common-uefi-loongarch64'

.PHONY: common-uefi-ia32
common-uefi-ia32:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-i686-toolchain.mk' \
TARGET=uefi-ia32 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32'
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-i686-toolchain.mk' \
TARGET=uefi-ia32 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32' \
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk

.PHONY: common-uefi-ia32-clean
common-uefi-ia32-clean:
rm -rf '$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32'

.PHONY: common-bios
common-bios:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/bios-i686-toolchain.mk' \
TARGET=bios \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-bios'
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/bios-i686-toolchain.mk' \
TARGET=bios \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-bios' \
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' -f common.mk

.PHONY: common-bios-clean
common-bios-clean:
rm -rf '$(call SHESCAPE,$(BUILDDIR))/common-bios'

.PHONY: decompressor
decompressor:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/decompressor' -f decompressor.mk all \
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/bios-i686-toolchain.mk' \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/decompressor-build'
TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/bios-i686-toolchain.mk' \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/decompressor-build' \
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/decompressor' -f decompressor.mk

.PHONY: decompressor-clean
decompressor-clean:
Expand Down
7 changes: 0 additions & 7 deletions common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ export OBJDUMP_FOR_TARGET
export OBJCOPY_FOR_TARGET
export READELF_FOR_TARGET

TARGET :=
BUILDDIR :=

override SRCDIR := $(shell pwd -P)

override SPACE := $(subst ,, )
Expand All @@ -20,10 +17,6 @@ override MKESCAPE = $(subst $(SPACE),\ ,$(1))
override SHESCAPE = $(subst ','\'',$(1))
override OBJESCAPE = $(subst .a ,.a' ',$(subst .o ,.o' ',$(call SHESCAPE,$(1))))

ifeq ($(call MKESCAPE,$(BUILDDIR)),)
$(error BUILDDIR not specified)
endif

COM_OUTPUT := false
E9_OUTPUT := false

Expand Down
12 changes: 0 additions & 12 deletions decompressor/decompressor.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ MAKEFLAGS += -rR
.SUFFIXES:

include $(TOOLCHAIN_FILE)
export AR_FOR_TARGET
export CC_FOR_TARGET
export LD_FOR_TARGET
export OBJDUMP_FOR_TARGET
export OBJCOPY_FOR_TARGET
export READELF_FOR_TARGET

BUILDDIR :=

override SRCDIR := $(shell pwd -P)

Expand All @@ -19,10 +11,6 @@ override MKESCAPE = $(subst $(SPACE),\ ,$(1))
override SHESCAPE = $(subst ','\'',$(1))
override OBJESCAPE = $(subst .a ,.a' ',$(subst .o ,.o' ',$(call SHESCAPE,$(1))))

ifeq ($(call MKESCAPE,$(BUILDDIR)),)
$(error BUILDDIR not specified)
endif

override CFLAGS_FOR_TARGET += \
-Os \
-Wall \
Expand Down
9 changes: 7 additions & 2 deletions host/host.mk
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
SHELL = /bin/sh

CC = cc
CFLAGS = -g -O2 -pipe
CPPFLAGS =
LDFLAGS =
LIBS =

WERROR_FLAG =

STRIP = strip
INSTALL = ./install-sh

PREFIX = /usr/local

CFLAGS = -g -O2 -pipe

.PHONY: all
all: limine

Expand Down

0 comments on commit 375360f

Please sign in to comment.