diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-07-10 23:20:03 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-07-10 23:20:03 +0800 |
| commit | 48ef95c24e9ac3d11200b61af617a01b10b507d1 (patch) | |
| tree | 57f0e26ab98e795b19839b6eece98ca58a4b702d /scripts | |
| parent | b9ff206e6bd3f4d67851263a6f2acb5f575cf3b0 (diff) | |
| download | lume-48ef95c24e9ac3d11200b61af617a01b10b507d1.tar.gz lume-48ef95c24e9ac3d11200b61af617a01b10b507d1.tar.xz | |
build: introduce declarative non-recursive build graph
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Kbuild.include | 136 | ||||
| -rw-r--r-- | scripts/Kconfig.mk | 89 | ||||
| -rw-r--r-- | scripts/build/Build.mk | 10 | ||||
| -rwxr-xr-x | scripts/build/archive.sh | 10 | ||||
| -rwxr-xr-x | scripts/build/check-kernel-elf.sh | 47 | ||||
| -rw-r--r-- | scripts/build/environments/host.mk | 8 | ||||
| -rw-r--r-- | scripts/build/environments/kernel.mk | 28 | ||||
| -rw-r--r-- | scripts/build/environments/phys.mk | 12 | ||||
| -rwxr-xr-x | scripts/build/generate-asm-offsets.sh | 25 | ||||
| -rwxr-xr-x | scripts/build/generate-autoconf.sh | 29 | ||||
| -rwxr-xr-x | scripts/build/generate-initramfs.sh | 12 | ||||
| -rwxr-xr-x | scripts/build/link-kernel.sh | 10 | ||||
| -rwxr-xr-x | scripts/build/probe-toolchain.sh | 48 | ||||
| -rwxr-xr-x | scripts/build/run-if-changed.sh | 45 | ||||
| -rw-r--r-- | scripts/build/targets.mk | 81 | ||||
| -rw-r--r-- | scripts/build/tests/host_library.cc | 8 | ||||
| -rw-r--r-- | scripts/build/tests/host_test.cc | 7 | ||||
| -rw-r--r-- | scripts/build/tests/phys_library.cc | 5 | ||||
| -rw-r--r-- | scripts/build/toolchain.mk | 103 | ||||
| -rwxr-xr-x | scripts/build/write-compdb.py | 26 | ||||
| -rwxr-xr-x | scripts/gen_initramfs.sh | 2 |
21 files changed, 634 insertions, 107 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 76466bd..7ccc03d 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -9,14 +9,7 @@ # - Q / KBUILD_VERBOSE : `make V=1` shows full commands, # default V=0 prints a one-line summary # - $(call cmd,<name>) : echo a quiet summary, then run cmd_<name> -# - $(call if_changed,<name>) : currently a thin alias for $(cmd) — -# no .cmd-file hashing yet (Linux's full -# if_changed uses fixdep to detect both -# recipe-text and header changes; LumeOS -# relies on `-MMD -MP` for headers and -# on `make clean` for flag changes). -# - $(call kbuild-objs,...) : translate Kbuild-style `obj-y := foo.o` -# entries into SRCS_C / SRCS_CC. +# - $(call if_changed,<name>) : rebuild when inputs or the command change. # # Naming convention adopted from Linux: each command has both a # `quiet_cmd_<name>` (single-line summary) and a `cmd_<name>` (full @@ -49,11 +42,11 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) cmd = @$(echo-cmd) $(cmd_$(1)) -# if_changed currently degenerates to `cmd` — full Linux semantics -# require tracking the command-line via per-target .<file>.cmd files -# and comparing on every rebuild, which needs fixdep. Until LumeOS -# grows that infrastructure, `make clean` after editing CFLAGS suffices. -if_changed = $(cmd) +# Record a checksum of the exact argv next to each output. FORCE makes Make +# reconsider the action; run-if-changed executes it only for a changed input or +# command signature. +if_changed = @scripts/build/run-if-changed.sh \ + $(dir $@).$(notdir $@).cmd $@ '$($(quiet)cmd_$(1))' $^ -- $(cmd_$(1)) # --- Standard quiet_cmd_* / cmd_* templates --------------------------- # @@ -61,21 +54,99 @@ if_changed = $(cmd) # name via $(call cmd,<name>). Add new pairs here as new recipe shapes # show up (e.g., cmd_lz / cmd_gz / cmd_zstd for compressed Image targets). - quiet_cmd_cc_o_c = CC $< - cmd_cc_o_c = $(CC) $(CFLAGS_LIBC) -c $< -o $@ + quiet_cmd_cc_o_c = CC $(PRIVATE_SOURCE) + cmd_cc_o_c = $(CC) $(CFLAGS_LIBC) $(PRIVATE_INCLUDES) $(PRIVATE_DEFINES) $(PRIVATE_CFLAGS) -c $(PRIVATE_SOURCE) -o $@ - quiet_cmd_cxx_o_cc = CXX $< - cmd_cxx_o_cc = $(CXX) $(CXXFLAGS) -c $< -o $@ + quiet_cmd_cxx_o_cc = CXX $(PRIVATE_SOURCE) + cmd_cxx_o_cc = $(CXX) $(CXXFLAGS) $(PRIVATE_INCLUDES) $(PRIVATE_DEFINES) $(PRIVATE_CXXFLAGS) -c $(PRIVATE_SOURCE) -o $@ - quiet_cmd_as_o_S = AS $< - cmd_as_o_S = $(CC) $(ASFLAGS) -c $< -o $@ + quiet_cmd_as_o_S = AS $(PRIVATE_SOURCE) + cmd_as_o_S = $(CC) $(ASFLAGS) $(PRIVATE_INCLUDES) $(PRIVATE_DEFINES) $(PRIVATE_ASFLAGS) -c $(PRIVATE_SOURCE) -o $@ quiet_cmd_cc_s_c = CC -S $< - cmd_cc_s_c = $(CC) $(CFLAGS_LIBC) -S $< -o $@ + cmd_cc_s_c = $(CC) $(CFLAGS_LIBC) -S $(PRIVATE_SOURCE) -o $@ + + quiet_cmd_gen_asm_offsets = GEN $@ + cmd_gen_asm_offsets = scripts/build/generate-asm-offsets.sh $@ \ + $(ASM_OFFSETS_S) $(ASM_OFFSETS_SED) $(ASM_OFFSETS_C) + + quiet_cmd_autoconf = GEN $@ + cmd_autoconf = scripts/build/generate-autoconf.sh $@ \ + CONFIG_NR_CPUS $(CONFIG_NR_CPUS) value \ + CONFIG_HZ $(CONFIG_HZ) value \ + CONFIG_NR_PRIORITIES $(CONFIG_NR_PRIORITIES) value \ + CONFIG_DEFAULT_PRIORITY $(CONFIG_DEFAULT_PRIORITY) value \ + CONFIG_IDLE_PRIORITY $(CONFIG_IDLE_PRIORITY) value \ + CONFIG_DEFAULT_TIMESLICE $(CONFIG_DEFAULT_TIMESLICE) value \ + CONFIG_PAGE_SIZE $(CONFIG_PAGE_SIZE) value \ + CONFIG_MAX_ORDER $(CONFIG_MAX_ORDER) value \ + CONFIG_KERNEL_STACK_SIZE $(CONFIG_KERNEL_STACK_SIZE) value \ + CONFIG_KASLR $(CONFIG_KASLR) bool \ + CONFIG_KASLR_POLICY_ID $(CONFIG_KASLR_POLICY_ID) value \ + CONFIG_KASLR_LOG_LEVEL $(CONFIG_KASLR_LOG_LEVEL) value \ + CONFIG_STACK_CANARY $(CONFIG_STACK_CANARY) bool \ + CONFIG_DEBUG $(CONFIG_DEBUG) bool \ + CONFIG_DEBUG_LOCKS $(CONFIG_DEBUG_LOCKS) bool \ + CONFIG_SELFTEST $(CONFIG_SELFTEST) bool \ + CONFIG_KLOG $(CONFIG_KLOG) bool \ + CONFIG_KERNEL_COMPRESSED $(CONFIG_KERNEL_COMPRESSED) bool + + quiet_cmd_linker_script = LDS $@ + cmd_linker_script = $(CC) -E -P -x c $(INCLUDES) $(PRIVATE_SOURCE) -o $@ + + quiet_cmd_initramfs = INITRAMFS $(INITRAMFS_SOURCE) + cmd_initramfs = scripts/build/generate-initramfs.sh $(GEN_INIT_CPIO) \ + ./scripts/gen_initramfs.sh $@ \ + $(CONFIG_INITRAMFS_ROOT_UID) $(CONFIG_INITRAMFS_ROOT_GID) \ + $(INITRAMFS_SOURCE) + + quiet_cmd_initramfs_obj = AS $@ (initramfs) + cmd_initramfs_obj = $(CC) $(ASFLAGS) \ + -DINITRAMFS_IMAGE='"$(INITRAMFS_CPIO)"' \ + -c $(PRIVATE_SOURCE) -o $@ quiet_cmd_objcopy_bin = OBJCOPY $@ cmd_objcopy_bin = $(OBJCOPY) -O binary $< $@ + quiet_cmd_archive = AR $@ + cmd_archive = scripts/build/archive.sh $@ $(AR) $(PRIVATE_ARCHIVE_OBJECTS) + + quiet_cmd_host_tool = HOSTCC $@ + cmd_host_tool = $(HOSTCC) $(HOSTCFLAGS) $(PRIVATE_HOST_CFLAGS) \ + -o $@ $(PRIVATE_HOST_SOURCE) + + quiet_cmd_host_cc_o_c = HOSTCC $(PRIVATE_SOURCE) + cmd_host_cc_o_c = $(HOSTCC) $(HOSTCFLAGS) -MMD -MP -c $(PRIVATE_SOURCE) -o $@ + + quiet_cmd_host_cxx_o_cc = HOSTCXX $(PRIVATE_SOURCE) + cmd_host_cxx_o_cc = $(HOSTCXX) $(HOSTCXXFLAGS) -MMD -MP -c $(PRIVATE_SOURCE) -o $@ + + quiet_cmd_host_archive = HOSTAR $@ + cmd_host_archive = scripts/build/archive.sh $@ $(HOSTAR) $(PRIVATE_ARCHIVE_OBJECTS) + + quiet_cmd_host_link = HOSTLD $@ + cmd_host_link = $(HOSTCXX) $(HOSTCXXFLAGS) -o $@ \ + $(PRIVATE_HOST_OBJECTS) $(PRIVATE_HOST_LIBS) + + quiet_cmd_toolchain_probe = PROBE toolchain + cmd_toolchain_probe = scripts/build/probe-toolchain.sh $@ \ + $(CC) $(CXX) $(LD) $(COMPILER_FAMILY) $(TARGET_TRIPLE) \ + '$(GCC_TOOLCHAIN)' '$(GCC_SYSROOT)' + + quiet_cmd_phys_cc_o_c = PHYSCC $(PRIVATE_SOURCE) + cmd_phys_cc_o_c = $(CC) $(PHYS_CFLAGS) -MMD -MP -c $(PRIVATE_SOURCE) -o $@ + + quiet_cmd_phys_cxx_o_cc = PHYSCXX $(PRIVATE_SOURCE) + cmd_phys_cxx_o_cc = $(CXX) $(PHYS_CXXFLAGS) -MMD -MP -c $(PRIVATE_SOURCE) -o $@ + + quiet_cmd_phys_as_o_S = PHYSAS $(PRIVATE_SOURCE) + cmd_phys_as_o_S = $(CC) $(PHYS_ASFLAGS) -MMD -MP -c $(PRIVATE_SOURCE) -o $@ + + quiet_cmd_link_vmlume = LD $@ + cmd_link_vmlume = scripts/build/link-kernel.sh $@ $(SIZE) \ + $(LD) $(LDFLAGS) -T $(LINKER_SCRIPT) -o $@ \ + $(KERNEL_LINK_INPUTS) $(INITRAMFS_OBJ) + # Objcopy with custom flags via per-target OBJCOPYFLAGS variable — # used by the .pi.o post-processing rule (--prefix-symbols=__pi_ etc.). quiet_cmd_objcopy = OBJCOPY $@ @@ -83,28 +154,3 @@ if_changed = $(cmd) quiet_cmd_ld_kernel = LD $@ cmd_ld_kernel = $(LD) $(LDFLAGS) -T $(LINKER_SCRIPT) -o $@ $^ - -# --- kbuild-objs: obj-y -> SRCS_C / SRCS_CC --------------------------- -# -# Usage from a subdir Makefile (e.g. arch/riscv/kernel/pi/Makefile): -# -# obj-dir := arch/riscv/kernel/pi -# obj-y := fdt_early.pi.o cmdline_early.pi.o archrandom_early.pi.o -# $(eval $(call kbuild-objs,$(obj-dir),$(obj-y:.pi.o=.o))) -# -# For each <name>.o entry, looks up <dir>/<name>.cc first, then -# <dir>/<name>.c, and appends to SRCS_CC / SRCS_C respectively. -# Pure .pi.o entries should be passed through `:.pi.o=.o` first by the -# caller so the .pi suffix doesn't confuse the source-file lookup. - -define _kbuild-find-src -$(if $(wildcard $(1)/$(basename $(2)).cc),\ - $(eval SRCS_CC += $(1)/$(basename $(2)).cc),\ - $(if $(wildcard $(1)/$(basename $(2)).c),\ - $(eval SRCS_C += $(1)/$(basename $(2)).c),\ - $(error kbuild-objs: no $(1)/$(basename $(2)).{c,cc} for obj $(2)))) -endef - -define kbuild-objs -$(foreach _obj,$(2),$(call _kbuild-find-src,$(1),$(_obj))) -endef diff --git a/scripts/Kconfig.mk b/scripts/Kconfig.mk index 2bdc934..3db7a2f 100644 --- a/scripts/Kconfig.mk +++ b/scripts/Kconfig.mk @@ -6,15 +6,15 @@ # This file is the heart of the LumeOS build-time configuration system. # It mirrors the role of Linux's Kconfig + auto.conf pipeline: # -# 1. Developer edits `.config` (or copies from arch/$(ARCH)/defconfig) -# 2. This file reads `.config`, applies defaults for anything missing, +# 1. Developer edits `$(O)/.config` (or runs `make O=... defconfig`) +# 2. This file reads that configuration and applies missing defaults, # validates constraints, and exports two things: # a) KCPPFLAGS — a set of -DCONFIG_xxx=value flags for the compiler # b) $(BUILD)/generated/autoconf.h — the same values as C #defines # # Design Principles (matching Linux conventions): -# - Every CONFIG_ symbol has a default defined HERE, so a bare `make` -# with no .config still builds a sane kernel. +# - Every CONFIG_ symbol has a default defined HERE, so an empty output +# directory still builds a sane kernel. # - Boolean options use 'y' / 'n'. Numeric options are plain integers. # - The generated autoconf.h uses the exact same names so that # `#ifdef CONFIG_DEBUG` works identically in Makefile and C. @@ -23,7 +23,8 @@ # ------------------------------------------------------------------ # §1 Read user configuration (if it exists) # ------------------------------------------------------------------ --include .config +KCONFIG_CONFIG ?= $(BUILD)/.config +-include $(KCONFIG_CONFIG) # ------------------------------------------------------------------ # §2 Provide defaults for every CONFIG_ symbol @@ -143,42 +144,6 @@ endif # ------------------------------------------------------------------ AUTOCONF_H := $(BUILD)/generated/autoconf.h -define generate-autoconf - @mkdir -p $(dir $(AUTOCONF_H)) - @echo " GEN $(AUTOCONF_H)" - @echo "/* AUTO-GENERATED — DO NOT EDIT */" > $(AUTOCONF_H) - @echo "/* Generated by scripts/Kconfig.mk */" >> $(AUTOCONF_H) - @echo "#pragma once" >> $(AUTOCONF_H) - @echo "" >> $(AUTOCONF_H) - @echo "/* Platform */" >> $(AUTOCONF_H) - @echo "#define CONFIG_NR_CPUS $(CONFIG_NR_CPUS)" >> $(AUTOCONF_H) - @echo "" >> $(AUTOCONF_H) - @echo "/* Scheduler */" >> $(AUTOCONF_H) - @echo "#define CONFIG_HZ $(CONFIG_HZ)" >> $(AUTOCONF_H) - @echo "#define CONFIG_NR_PRIORITIES $(CONFIG_NR_PRIORITIES)" >> $(AUTOCONF_H) - @echo "#define CONFIG_DEFAULT_PRIORITY $(CONFIG_DEFAULT_PRIORITY)" >> $(AUTOCONF_H) - @echo "#define CONFIG_IDLE_PRIORITY $(CONFIG_IDLE_PRIORITY)" >> $(AUTOCONF_H) - @echo "#define CONFIG_DEFAULT_TIMESLICE $(CONFIG_DEFAULT_TIMESLICE)" >> $(AUTOCONF_H) - @echo "" >> $(AUTOCONF_H) - @echo "/* Memory Management */" >> $(AUTOCONF_H) - @echo "#define CONFIG_PAGE_SIZE $(CONFIG_PAGE_SIZE)" >> $(AUTOCONF_H) - @echo "#define CONFIG_MAX_ORDER $(CONFIG_MAX_ORDER)" >> $(AUTOCONF_H) - @echo "#define CONFIG_KERNEL_STACK_SIZE $(CONFIG_KERNEL_STACK_SIZE)" >> $(AUTOCONF_H) - @echo "" >> $(AUTOCONF_H) - @echo "/* Security */" >> $(AUTOCONF_H) - $(if $(filter y,$(CONFIG_KASLR)), @echo "#define CONFIG_KASLR 1" >> $(AUTOCONF_H)) - @echo "#define CONFIG_KASLR_POLICY_ID $(CONFIG_KASLR_POLICY_ID)" >> $(AUTOCONF_H) - @echo "#define CONFIG_KASLR_LOG_LEVEL $(CONFIG_KASLR_LOG_LEVEL)" >> $(AUTOCONF_H) - $(if $(filter y,$(CONFIG_STACK_CANARY)), @echo "#define CONFIG_STACK_CANARY 1" >> $(AUTOCONF_H)) - @echo "" >> $(AUTOCONF_H) - @echo "/* Debug */" >> $(AUTOCONF_H) - $(if $(filter y,$(CONFIG_DEBUG)), @echo "#define CONFIG_DEBUG 1" >> $(AUTOCONF_H)) - $(if $(filter y,$(CONFIG_DEBUG_LOCKS)), @echo "#define CONFIG_DEBUG_LOCKS 1" >> $(AUTOCONF_H)) - $(if $(filter y,$(CONFIG_SELFTEST)), @echo "#define CONFIG_SELFTEST 1" >> $(AUTOCONF_H)) - $(if $(filter y,$(CONFIG_KLOG)), @echo "#define CONFIG_KLOG 1" >> $(AUTOCONF_H)) - $(if $(filter y,$(CONFIG_KERNEL_COMPRESSED)), @echo "#define CONFIG_KERNEL_COMPRESSED 1" >> $(AUTOCONF_H)) -endef - # ------------------------------------------------------------------ # §6 Utility targets # ------------------------------------------------------------------ @@ -187,29 +152,31 @@ endef .PHONY: defconfig savedefconfig showconfig defconfig: - @echo " DEFCFG arch/$(CONFIG_ARCH)/defconfig → .config" - @cp arch/$(CONFIG_ARCH)/defconfig .config + @echo " DEFCFG arch/$(CONFIG_ARCH)/defconfig → $(KCONFIG_CONFIG)" + @mkdir -p $(dir $(KCONFIG_CONFIG)) + @cp arch/$(CONFIG_ARCH)/defconfig $(KCONFIG_CONFIG) # 'make savedefconfig' — save current effective config savedefconfig: - @echo " SAVE .config" - @echo "# LumeOS Kernel Configuration (saved $$(date +%Y-%m-%d))" > .config - @echo "CONFIG_ARCH = $(CONFIG_ARCH)" >> .config - @echo "CONFIG_NR_CPUS = $(CONFIG_NR_CPUS)" >> .config - @echo "CONFIG_HZ = $(CONFIG_HZ)" >> .config - @echo "CONFIG_NR_PRIORITIES = $(CONFIG_NR_PRIORITIES)" >> .config - @echo "CONFIG_PAGE_SIZE = $(CONFIG_PAGE_SIZE)" >> .config - @echo "CONFIG_MAX_ORDER = $(CONFIG_MAX_ORDER)" >> .config - @echo "CONFIG_KERNEL_STACK_SIZE = $(CONFIG_KERNEL_STACK_SIZE)" >> .config - @echo "CONFIG_KASLR = $(CONFIG_KASLR)" >> .config - @echo "CONFIG_KASLR_POLICY_ID = $(CONFIG_KASLR_POLICY_ID)" >> .config - @echo "CONFIG_KASLR_LOG_LEVEL = $(CONFIG_KASLR_LOG_LEVEL)" >> .config - @echo "CONFIG_STACK_CANARY = $(CONFIG_STACK_CANARY)" >> .config - @echo "CONFIG_DEBUG = $(CONFIG_DEBUG)" >> .config - @echo "CONFIG_DEBUG_LOCKS = $(CONFIG_DEBUG_LOCKS)" >> .config - @echo "CONFIG_SELFTEST = $(CONFIG_SELFTEST)" >> .config - @echo "CONFIG_KLOG = $(CONFIG_KLOG)" >> .config - @echo "CONFIG_KERNEL_COMPRESSED = $(CONFIG_KERNEL_COMPRESSED)" >> .config + @echo " SAVE $(KCONFIG_CONFIG)" + @mkdir -p $(dir $(KCONFIG_CONFIG)) + @echo "# LumeOS Kernel Configuration (saved $$(date +%Y-%m-%d))" > $(KCONFIG_CONFIG) + @echo "CONFIG_ARCH = $(CONFIG_ARCH)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_NR_CPUS = $(CONFIG_NR_CPUS)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_HZ = $(CONFIG_HZ)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_NR_PRIORITIES = $(CONFIG_NR_PRIORITIES)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_PAGE_SIZE = $(CONFIG_PAGE_SIZE)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_MAX_ORDER = $(CONFIG_MAX_ORDER)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_KERNEL_STACK_SIZE = $(CONFIG_KERNEL_STACK_SIZE)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_KASLR = $(CONFIG_KASLR)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_KASLR_POLICY_ID = $(CONFIG_KASLR_POLICY_ID)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_KASLR_LOG_LEVEL = $(CONFIG_KASLR_LOG_LEVEL)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_STACK_CANARY = $(CONFIG_STACK_CANARY)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_DEBUG = $(CONFIG_DEBUG)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_DEBUG_LOCKS = $(CONFIG_DEBUG_LOCKS)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_SELFTEST = $(CONFIG_SELFTEST)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_KLOG = $(CONFIG_KLOG)" >> $(KCONFIG_CONFIG) + @echo "CONFIG_KERNEL_COMPRESSED = $(CONFIG_KERNEL_COMPRESSED)" >> $(KCONFIG_CONFIG) # 'make showconfig' — print effective configuration showconfig: diff --git a/scripts/build/Build.mk b/scripts/build/Build.mk new file mode 100644 index 0000000..0a15b38 --- /dev/null +++ b/scripts/build/Build.mk @@ -0,0 +1,10 @@ +targets += build/host-library-smoke build/host-test-smoke build/phys-library-smoke +target.build/host-library-smoke.kind := host-library +target.build/host-library-smoke.sources := scripts/build/tests/host_library.cc + +target.build/host-test-smoke.kind := host-test +target.build/host-test-smoke.sources := scripts/build/tests/host_test.cc +target.build/host-test-smoke.private-deps := build/host-library-smoke + +target.build/phys-library-smoke.kind := phys-library +target.build/phys-library-smoke.sources := scripts/build/tests/phys_library.cc diff --git a/scripts/build/archive.sh b/scripts/build/archive.sh new file mode 100755 index 0000000..79f0bb9 --- /dev/null +++ b/scripts/build/archive.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +set -eu +archive=$1 +ar=$2 +shift 2 +rm -f "$archive" +"$ar" rcs "$archive" "$@" + diff --git a/scripts/build/check-kernel-elf.sh b/scripts/build/check-kernel-elf.sh new file mode 100755 index 0000000..eb92b33 --- /dev/null +++ b/scripts/build/check-kernel-elf.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +set -eu +elf=$1 +readelf=$2 +nm=$3 +arch=$4 + +case "$arch" in + riscv) expected_machine='RISC-V' ;; + aarch64) expected_machine='AArch64' ;; + x86_64) expected_machine='Advanced Micro Devices X86-64' ;; + *) echo "ELF check: unsupported architecture: $arch" >&2; exit 2 ;; +esac + +machine=$($readelf -h "$elf" | sed -n 's/^[[:space:]]*Machine:[[:space:]]*//p') +[ "$machine" = "$expected_machine" ] || { + echo "ELF check: expected machine '$expected_machine', got '$machine'" >&2 + exit 1 +} + +entry=$($readelf -h "$elf" | sed -n 's/^[[:space:]]*Entry point address:[[:space:]]*//p') +[ -n "$entry" ] && [ "$entry" != 0x0 ] || { + echo "ELF check: kernel has no entry point" >&2 + exit 1 +} + +undefined=$($nm -u "$elf" || true) +[ -z "$undefined" ] || { + echo "ELF check: undefined symbols:" >&2 + printf '%s\n' "$undefined" >&2 + exit 1 +} + +if $readelf -W -l "$elf" | awk '$1 == "LOAD" && $0 ~ /W/ && $0 ~ /E/ { found=1 } END { exit !found }'; then + echo "ELF check: writable and executable LOAD segment" >&2 + exit 1 +fi + +$readelf -S "$elf" | grep -q '[.]rela[.]dyn' || { + echo "ELF check: missing relocation section .rela.dyn" >&2 + exit 1 +} + +echo "Kernel ELF OK: $machine, entry $entry" + diff --git a/scripts/build/environments/host.mk b/scripts/build/environments/host.mk new file mode 100644 index 0000000..0911ad3 --- /dev/null +++ b/scripts/build/environments/host.mk @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +HOSTCC ?= cc +HOSTCXX ?= c++ +HOSTAR ?= ar +HOSTCFLAGS ?= -O2 -g -Wall -Wextra +HOSTCXXFLAGS ?= $(HOSTCFLAGS) -std=c++23 + diff --git a/scripts/build/environments/kernel.mk b/scripts/build/environments/kernel.mk new file mode 100644 index 0000000..088cdf0 --- /dev/null +++ b/scripts/build/environments/kernel.mk @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +WARNINGS ?= -Wall -Wextra -Wno-unused-parameter + +ifeq ($(BUILD_VARIANT),release) +KERNEL_OPT_FLAGS := -O2 -g0 -DNDEBUG +else +KERNEL_OPT_FLAGS := -O2 -g +endif + +CFLAGS := $(WARNINGS) $(KERNEL_OPT_FLAGS) \ + -ffreestanding -nostdlib \ + -mcmodel=medany -fPIE -MMD -MP \ + $(TOOLCHAIN_CFLAGS) $(KCPPFLAGS) $(INCLUDES) \ + -I$(BUILD)/generated + +CFLAGS_LIBC := $(CFLAGS) -std=gnu23 -Iinclude/libc-shim \ + -Wno-parentheses -Wno-sign-compare + +CXXFLAGS := $(CFLAGS) $(TOOLCHAIN_CXXFLAGS) -std=c++23 \ + -fno-exceptions -fno-rtti -fno-use-cxa-atexit \ + -fno-threadsafe-statics + +# Pre-MMU assembly must never use GOT-indirect addressing. +ASFLAGS := $(filter-out -fPIE,$(CFLAGS)) -fno-pie + +LDFLAGS := -nostdlib -shared -Bsymbolic -z notext -z norelro \ + --no-dynamic-linker diff --git a/scripts/build/environments/phys.mk b/scripts/build/environments/phys.mk new file mode 100644 index 0000000..6a11c12 --- /dev/null +++ b/scripts/build/environments/phys.mk @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# Early physical-address execution environment. It deliberately has no heap, +# exceptions, RTTI, thread-safe statics, or PIE/GOT assumptions. +PHYS_CFLAGS := $(WARNINGS) -Os -g -ffreestanding -nostdlib \ + -fno-pie -fno-stack-protector $(TOOLCHAIN_CFLAGS) \ + $(KCPPFLAGS) $(INCLUDES) -I$(BUILD)/generated +PHYS_CXXFLAGS := $(PHYS_CFLAGS) $(TOOLCHAIN_CXXFLAGS) -std=c++23 \ + -fno-exceptions -fno-rtti -fno-use-cxa-atexit \ + -fno-threadsafe-statics +PHYS_ASFLAGS := $(PHYS_CFLAGS) + diff --git a/scripts/build/generate-asm-offsets.sh b/scripts/build/generate-asm-offsets.sh new file mode 100755 index 0000000..4e90f94 --- /dev/null +++ b/scripts/build/generate-asm-offsets.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +set -eu +output=$1 +assembly=$2 +sed_script=$3 +source=$4 +tmp="$output.tmp.$$" +{ + echo '/* AUTO-GENERATED — DO NOT EDIT */' + echo "/* Generated from $source */" + echo '#ifndef _LUME_GENERATED_ASM_OFFSETS_H' + echo '#define _LUME_GENERATED_ASM_OFFSETS_H' + echo + sed -n -f "$sed_script" "$assembly" + echo + echo '#endif /* _LUME_GENERATED_ASM_OFFSETS_H */' +} > "$tmp" +if [ -e "$output" ] && cmp -s "$tmp" "$output"; then + rm -f "$tmp" +else + mv -f "$tmp" "$output" +fi + diff --git a/scripts/build/generate-autoconf.sh b/scripts/build/generate-autoconf.sh new file mode 100755 index 0000000..493d630 --- /dev/null +++ b/scripts/build/generate-autoconf.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +set -eu +output=$1 +shift +tmp="$output.tmp.$$" +mkdir -p "$(dirname "$output")" +{ + echo '/* AUTO-GENERATED — DO NOT EDIT */' + echo '#pragma once' + while [ "$#" -gt 0 ]; do + name=$1 + value=$2 + kind=$3 + shift 3 + if [ "$kind" = bool ]; then + [ "$value" = y ] && echo "#define $name 1" + else + echo "#define $name $value" + fi + done +} > "$tmp" +if [ -e "$output" ] && cmp -s "$tmp" "$output"; then + rm -f "$tmp" +else + mv -f "$tmp" "$output" +fi + diff --git a/scripts/build/generate-initramfs.sh b/scripts/build/generate-initramfs.sh new file mode 100755 index 0000000..194e206 --- /dev/null +++ b/scripts/build/generate-initramfs.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +set -eu +generator=$1 +wrapper=$2 +output=$3 +uid=$4 +gid=$5 +source=$6 +GEN_INIT_CPIO=$generator "$wrapper" -o "$output" -u "$uid" -g "$gid" "$source" + diff --git a/scripts/build/link-kernel.sh b/scripts/build/link-kernel.sh new file mode 100755 index 0000000..31164e7 --- /dev/null +++ b/scripts/build/link-kernel.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +set -eu +output=$1 +size_tool=$2 +shift 2 +"$@" +"$size_tool" "$output" + diff --git a/scripts/build/probe-toolchain.sh b/scripts/build/probe-toolchain.sh new file mode 100755 index 0000000..2f1f600 --- /dev/null +++ b/scripts/build/probe-toolchain.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +set -eu +output=$1 +cc=$2 +cxx=$3 +ld=$4 +family=$5 +target=$6 +gcc_toolchain=$7 +sysroot=$8 + +set -- +if [ "$family" = clang ]; then + set -- "$@" "--target=$target" + [ -z "$gcc_toolchain" ] || set -- "$@" "--gcc-toolchain=$gcc_toolchain" + [ -z "$sysroot" ] || set -- "$@" "--sysroot=$sysroot" +fi + +probe() { + language=$1 + standard=$2 + shift 2 + compiler=$cc + [ "$language" = c++ ] && compiler=$cxx + printf '' | "$compiler" "$@" "-std=$standard" -x "$language" \ + -fsyntax-only - >/dev/null 2>&1 +} + +tmp="$output.tmp.$$" +mkdir -p "$(dirname "$output")" +{ + echo "cc=$($cc --version | head -n 1)" + echo "cxx=$($cxx --version | head -n 1)" + echo "ld=$($ld --version | head -n 1)" + echo "target=$target" + printf 'c23='; if probe c gnu23 "$@"; then echo yes; else echo no; fi + printf 'cxx23='; if probe c++ c++23 "$@"; then echo yes; else echo no; fi + printf 'fno-pie='; if probe c++ c++23 "$@" -fno-pie; then echo yes; else echo no; fi + printf 'mcmodel-medany='; if probe c++ c++23 "$@" -mcmodel=medany; then echo yes; else echo no; fi +} > "$tmp" +mv -f "$tmp" "$output" + +grep -q '^c23=yes$' "$output" +grep -q '^cxx23=yes$' "$output" +grep -q '^fno-pie=yes$' "$output" +grep -q '^mcmodel-medany=yes$' "$output" diff --git a/scripts/build/run-if-changed.sh b/scripts/build/run-if-changed.sh new file mode 100755 index 0000000..6cdc7c4 --- /dev/null +++ b/scripts/build/run-if-changed.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +set -eu + +cmdfile=$1 +output=$2 +description=$3 +shift 3 + +rebuild=false +if [ ! -e "$output" ] || [ ! -e "$cmdfile" ]; then + rebuild=true +fi + +while [ "$#" -gt 0 ] && [ "$1" != "--" ]; do + prerequisite=$1 + shift + if [ "$prerequisite" != FORCE ] && [ -e "$prerequisite" ] && \ + [ "$prerequisite" -nt "$output" ]; then + rebuild=true + fi +done + +[ "$#" -gt 0 ] || { echo "run-if-changed: missing --" >&2; exit 2; } +shift + +signature=$(printf '%s\0' "$@" | cksum) +old_signature= +if [ -e "$cmdfile" ]; then + old_signature=$(cat "$cmdfile") +fi +if [ "$signature" != "$old_signature" ]; then + rebuild=true +fi + +if [ "$rebuild" = true ]; then + printf ' %s\n' "$description" + mkdir -p "$(dirname "$output")" "$(dirname "$cmdfile")" + "$@" + tmp="$cmdfile.tmp.$$" + printf '%s\n' "$signature" > "$tmp" + mv -f "$tmp" "$cmdfile" +fi + diff --git a/scripts/build/targets.mk b/scripts/build/targets.mk new file mode 100644 index 0000000..1a66379 --- /dev/null +++ b/scripts/build/targets.mk @@ -0,0 +1,81 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2026 Richard Qin + +# Declarative target registry for the LumeOS build. +# +# Build.mk files populate target.<name>.* and append the name to targets. A +# target name is metadata, not a Make rule, so names may contain '/' and ':'. + +target-kinds := \ + interface-library header-library object-library source-set \ + static-library whole-archive host-library phys-library host-tool generated \ + binary-blob kernel-test host-test product +targets := +generated-actions := autoconf asm-offsets linker-script initramfs + +empty := +space := $(empty) $(empty) +comma := , + +# Convert a logical target/source name into a path-safe component. +target-key = $(subst :,_,$(subst /,_,$(1))) + +# Recursively collect a target and all of its dependencies. Dependency cycles +# are rejected separately before this is evaluated for build roots. +target-deps = $(sort $(target.$(1).deps) $(target.$(1).public-deps) \ + $(target.$(1).private-deps) $(target.$(1).interface-deps) \ + $(target.$(1).link-deps) $(target.$(1).tool-deps) \ + $(target.$(1).generated-deps) $(target.$(1).runtime-deps) \ + $(target.$(1).order-only-deps)) +target-closure = $(strip \ + $(if $(filter $(1),$(2)),$(error target dependency cycle: $(2) -> $(1))) \ + $(1) $(foreach dep,$(call target-deps,$(1)),$(call target-closure,$(dep),$(2) $(1)))) +target-link-deps = $(sort $(target.$(1).deps) $(target.$(1).public-deps) \ + $(target.$(1).private-deps) $(target.$(1).interface-deps) \ + $(target.$(1).link-deps)) +target-link-order = $(strip $(1) $(foreach dep,$(call target-link-deps,$(1)),\ + $(call target-link-order,$(dep)))) +unique-words = $(if $(strip $(1)),$(firstword $(1)) \ + $(call unique-words,$(filter-out $(firstword $(1)),$(1)))) + +duplicate-words = $(sort $(foreach word,$(1),\ + $(if $(word 2,$(filter $(word),$(1))),$(word)))) +all-target-sources = $(foreach target,$(targets),$(target.$(target).sources)) +duplicate-target-sources = $(call duplicate-words,$(all-target-sources)) + +define validate-target +$(if $(filter $(target.$(1).kind),$(target-kinds)),,$(error target '$(1)' has invalid kind '$(target.$(1).kind)')) +$(if $(filter header-library interface-library product generated binary-blob,$(target.$(1).kind)),$(if $(strip $(target.$(1).sources)),$(error target '$(1)' of kind $(target.$(1).kind) declares sources),),) +$(if $(filter host-tool,$(target.$(1).kind)),$(if $(word 2,$(target.$(1).sources)),$(error host-tool '$(1)' currently requires exactly one source),),) +$(foreach src,$(target.$(1).sources),$(if $(wildcard $(src)),,$(error target '$(1)' references missing source '$(src)'))) +$(foreach dep,$(call target-deps,$(1)),$(if $(filter $(dep),$(targets)),,$(error target '$(1)' references unknown dependency '$(dep)'))) +$(foreach dep,$(call target-deps,$(1)),$(if $(strip $(target.$(dep).visibility)),\ + $(if $(filter all $(1),$(target.$(dep).visibility)),,\ + $(error target '$(1)' cannot depend on '$(dep)': visibility is '$(target.$(dep).visibility)')),)) +$(if $(filter generated,$(target.$(1).kind)),$(if $(strip $(target.$(1).outputs)),,$(error generated target '$(1)' has no outputs)),) +$(if $(filter generated,$(target.$(1).kind)),$(if $(filter $(target.$(1).action),$(generated-actions)),,$(error generated target '$(1)' has invalid action '$(target.$(1).action)')),) +endef + +define validate-targets +$(if $(strip $(targets)),,$(error no build targets were registered)) +$(if $(filter-out $(words $(sort $(targets))),$(words $(targets))),$(error duplicate build target name),) +$(foreach target,$(targets),$(call validate-target,$(target))) +endef + +# Usage requirements are deliberately separate from link inputs. Public +# include paths and defines propagate through deps; private values apply only +# while compiling the target itself. +target-public-closure = $(sort $(1) $(foreach dep,$(target.$(1).public-deps) \ + $(target.$(1).deps),$(call target-public-closure,$(dep)))) +target-public-includes = $(sort $(foreach target,$(call target-public-closure,$(1)),$(target.$(target).public-includes))) +target-public-after-includes = $(sort $(foreach target,$(call target-public-closure,$(1)),$(target.$(target).public-after-includes))) +target-public-defines = $(sort $(foreach target,$(call target-public-closure,$(1)),$(target.$(target).public-defines))) + +target-usage-roots = $(sort $(1) $(target.$(1).deps) $(target.$(1).public-deps) \ + $(target.$(1).private-deps) $(target.$(1).interface-deps)) +target-compile-includes = $(sort $(target.$(1).private-includes) \ + $(foreach root,$(call target-usage-roots,$(1)),$(call target-public-includes,$(root)))) +target-compile-after-includes = $(sort $(target.$(1).private-after-includes) \ + $(foreach root,$(call target-usage-roots,$(1)),$(call target-public-after-includes,$(root)))) +target-compile-defines = $(sort $(target.$(1).private-defines) \ + $(foreach root,$(call target-usage-roots,$(1)),$(call target-public-defines,$(root)))) diff --git a/scripts/build/tests/host_library.cc b/scripts/build/tests/host_library.cc new file mode 100644 index 0000000..c545815 --- /dev/null +++ b/scripts/build/tests/host_library.cc @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +namespace lume::build::test { + +int HostLibrarySmokeTestSymbol() { return 0; } + +} // namespace lume::build::test + diff --git a/scripts/build/tests/host_test.cc b/scripts/build/tests/host_test.cc new file mode 100644 index 0000000..6b13417 --- /dev/null +++ b/scripts/build/tests/host_test.cc @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +namespace lume::build::test { +int HostLibrarySmokeTestSymbol(); +} + +int main() { return lume::build::test::HostLibrarySmokeTestSymbol(); } diff --git a/scripts/build/tests/phys_library.cc b/scripts/build/tests/phys_library.cc new file mode 100644 index 0000000..2cf1596 --- /dev/null +++ b/scripts/build/tests/phys_library.cc @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +extern "C" unsigned long LumePhysBuildSmoke(unsigned long value) { + return value ^ 0x4c554d45UL; +} diff --git a/scripts/build/toolchain.mk b/scripts/build/toolchain.mk new file mode 100644 index 0000000..49d4f0a --- /dev/null +++ b/scripts/build/toolchain.mk @@ -0,0 +1,103 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2026 Richard Qin + +# Toolchain selection: +# make GCC + GNU ld +# make LLVM=1 Clang + GNU ld +# make LLVM=1 LD_TYPE=lld Clang + LLD + +LLVM ?= 0 +LLVM_VERSION ?= 20 +LD_TYPE ?= bfd +LLVM_BINUTILS ?= 0 +CXX_STDLIB ?= libstdc++ +CXX_ABI ?= lume +COMPILER_RUNTIME ?= compiler-default + +GCC_TOOLCHAIN ?= +CROSS_COMPILE ?= + +ifeq ($(ARCH),riscv) +TARGET_TRIPLE := riscv64-unknown-linux-gnu +ifeq ($(strip $(GCC_TOOLCHAIN)),) +ifneq ($(wildcard /opt/riscv64-glibc/bin/riscv64-unknown-linux-gnu-g++),) +GCC_TOOLCHAIN := /opt/riscv64-glibc +endif +endif +ifeq ($(strip $(CROSS_COMPILE)),) +ifneq ($(strip $(GCC_TOOLCHAIN)),) +CROSS_COMPILE := $(GCC_TOOLCHAIN)/bin/$(TARGET_TRIPLE)- +else +CROSS_COMPILE := $(TARGET_TRIPLE)- +endif +endif +else ifeq ($(ARCH),aarch64) +TARGET_TRIPLE := aarch64-linux-gnu +else ifeq ($(ARCH),x86_64) +TARGET_TRIPLE := x86_64-linux-gnu +endif + +ifeq ($(strip $(CROSS_COMPILE)),) +CROSS_COMPILE := $(TARGET_TRIPLE)- +endif +ifeq ($(strip $(GCC_TOOLCHAIN)),) +GCC_TOOLCHAIN := $(patsubst %/bin/,%, $(dir $(CROSS_COMPILE))) +endif + +GCC_SYSROOT := $(strip $(shell $(CROSS_COMPILE)g++ -print-sysroot 2>/dev/null)) + +CLANG_SUFFIX := $(if $(LLVM_VERSION),-$(LLVM_VERSION),) +CLANG ?= clang$(CLANG_SUFFIX) +CLANGXX ?= clang++$(CLANG_SUFFIX) +LLD ?= ld.lld$(CLANG_SUFFIX) + +CLANG_TARGET_FLAGS := --target=$(TARGET_TRIPLE) +ifneq ($(strip $(GCC_TOOLCHAIN)),) +CLANG_TARGET_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) +endif +ifneq ($(strip $(GCC_SYSROOT)),) +CLANG_TARGET_FLAGS += --sysroot=$(GCC_SYSROOT) +endif + +ifeq ($(LLVM),1) +CC := $(CLANG) +CXX := $(CLANGXX) +COMPILER_FAMILY := clang +TOOLCHAIN_CFLAGS := $(CLANG_TARGET_FLAGS) +ifeq ($(CXX_STDLIB),libstdc++) +TOOLCHAIN_CXXFLAGS := -stdlib=libstdc++ +else +$(error unsupported CXX_STDLIB '$(CXX_STDLIB)' for the current imported runtime) +endif +ifeq ($(LD_TYPE),lld) +LD := $(LLD) +LINKER_FAMILY := lld +else +ifneq ($(CXX_STDLIB),libstdc++) +$(error GCC configuration currently requires CXX_STDLIB=libstdc++) +endif +LD := $(CROSS_COMPILE)ld +LINKER_FAMILY := bfd +endif +else +CC := $(CROSS_COMPILE)gcc +CXX := $(CROSS_COMPILE)g++ +LD := $(CROSS_COMPILE)ld +COMPILER_FAMILY := gcc +LINKER_FAMILY := bfd +endif + +ifeq ($(LLVM_BINUTILS),1) +AR := llvm-ar$(CLANG_SUFFIX) +NM := llvm-nm$(CLANG_SUFFIX) +OBJCOPY := llvm-objcopy$(CLANG_SUFFIX) +OBJDUMP := llvm-objdump$(CLANG_SUFFIX) +READELF := llvm-readelf$(CLANG_SUFFIX) +else +AR := $(CROSS_COMPILE)ar +NM := $(CROSS_COMPILE)nm +OBJCOPY := $(CROSS_COMPILE)objcopy +OBJDUMP := $(CROSS_COMPILE)objdump +READELF := $(CROSS_COMPILE)readelf +endif +SIZE := $(CROSS_COMPILE)size diff --git a/scripts/build/write-compdb.py b/scripts/build/write-compdb.py new file mode 100755 index 0000000..9ec5a49 --- /dev/null +++ b/scripts/build/write-compdb.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later + +import json +import pathlib +import sys + +source = pathlib.Path(sys.argv[1]) +output = pathlib.Path(sys.argv[2]) +directory = pathlib.Path.cwd() +entries = [] +for line in source.read_text().splitlines(): + file_name, object_name, command = line.split("\t", 2) + entries.append( + { + "directory": str(directory), + "file": file_name, + "output": object_name, + "command": command, + } + ) +output.parent.mkdir(parents=True, exist_ok=True) +temporary = output.with_suffix(output.suffix + ".tmp") +temporary.write_text(json.dumps(entries, indent=2) + "\n") +temporary.replace(output) + diff --git a/scripts/gen_initramfs.sh b/scripts/gen_initramfs.sh index 7eba2fd..8ad0cd7 100755 --- a/scripts/gen_initramfs.sh +++ b/scripts/gen_initramfs.sh @@ -247,4 +247,4 @@ done # If output_file is set we will generate cpio archive # we are careful to delete tmp files -usr/gen_init_cpio $output $timestamp $cpio_list +"${GEN_INIT_CPIO:-usr/gen_init_cpio}" $output $timestamp $cpio_list |
