Skip to content

Commit d3ee4b6

Browse files
committed
modularize feature: restructure for dynamic loading
1 parent b9694c7 commit d3ee4b6

4 files changed

Lines changed: 32 additions & 8 deletions

File tree

Makefile

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ SOFTWARE = BCACHE_TOOLS \
6969
ZLIB \
7070
ZSTD
7171

72+
FEATURE_COMPONENTS = append_base_layout \
73+
create_initramfs \
74+
determine_real_args \
75+
genkernel_conf \
76+
initramfs_append_func \
77+
longusage \
78+
parse_cmdline
79+
7280
SOFTWARE_VERSION = $(foreach entry, $(SOFTWARE), "VERSION_$(entry)=${VERSION_$(entry)}\n")
7381

7482
PREFIX = /usr/local
@@ -80,12 +88,15 @@ else
8088
endif
8189
MANDIR = $(PREFIX)/share/man
8290

91+
FEATURE_FILES = $(addprefix $(addprefix $(BUILD_DIR)/features/, $(GK_FEATURES))/, $(FEATURE_COMPONENTS))
92+
8393
all: $(BUILD_DIR)/genkernel $(BUILD_DIR)/build-config man kconfig
8494

8595
debug:
8696
@echo "ARCH_KCONF=$(ARCH_KCONF)"
8797
@echo "GENERATED_KCONF=$(GENERATED_KCONF)"
8898
@echo "PACKAGE_VERSION=$(PACKAGE_VERSION)"
99+
@echo "FEATURE_FILES: $(FEATURE_FILES)"
89100

90101
kconfig: $(GENERATED_KCONF)
91102
man: $(addprefix $(BUILD_DIR)/,$(MANPAGE))
@@ -186,8 +197,23 @@ $(BUILD_DIR)/software.sh:
186197
echo -e $(SOFTWARE_VERSION) > $(BUILD_DIR)/temp/versions
187198
cat $(BUILD_DIR)/temp/versions defaults/software.sh > $(BUILD_DIR)/software.sh
188199

189-
$(BUILD_DIR)/doc/genkernel.8.txt:
190-
install -D doc/genkernel.8.txt $(BUILD_DIR)/doc/genkernel.8.txt
200+
$(BUILD_DIR)/temp/%:
201+
install -d $(@D)
202+
echo > $@
203+
ifdef GK_FEATURES
204+
cat $(addsuffix /$(@F) <(echo), $(addprefix features/,${GK_FEATURES})) > $@
205+
endif
206+
207+
$(BUILD_DIR)/doc/genkernel.8.txt: $(BUILD_DIR)/temp/man_genkernel_8
208+
install -d $(BUILD_DIR)/doc/
209+
cat doc/genkernel.8.txt | sed \
210+
-e '/\/\/ BEGIN FEATURES man_genkernel_8/ r $(BUILD_DIR)/temp/man_genkernel_8' \
211+
> $(BUILD_DIR)/doc/genkernel.8.txt
212+
213+
$(BUILD_DIR)/genkernel.conf: $(BUILD_DIR)/temp/genkernel_conf
214+
cat genkernel.conf | sed \
215+
-e '/# BEGIN FEATURES genkernel_conf/ r $(BUILD_DIR)/temp/genkernel_conf' \
216+
> $(BUILD_DIR)/genkernel.conf
191217

192218
$(BUILD_DIR)/%: %
193219
install -D $< $@

gen_cmdline.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ longusage() {
137137
echo " --no-nfs Exclude NFS support"
138138
echo " --netboot Create a self-contained env in the initramfs"
139139
echo " --no-netboot Exclude netboot env"
140-
#BEGIN FEATURES longusage()
141-
#END FEATURES longusage()
140+
$(. load_features longusage)
142141
echo " --do-keymap-auto Forces keymap selection at boot"
143142
echo " --keymap Enables keymap selection support"
144143
echo " --no-keymap Disables keymap selection support"
@@ -447,8 +446,7 @@ parse_cmdline() {
447446
CMD_BOOTLOADER="no"
448447
print_info 3 "CMD_BOOTLOADER: ${CMD_BOOTLOADER}"
449448
;;
450-
#BEGIN FEATURES parse_cmdline()
451-
#END FEATURES parse_cmdline()
449+
$(. load_features.sh parse_cmdline)
452450
--nfs|--no-nfs)
453451
CMD_NFS=$(parse_optbool "$*")
454452
print_info 3 "CMD_NFS: ${CMD_NFS}"

gen_initramfs.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@ append_base_layout() {
472472
isTrue "${MICROCODE_INITRAMFS}" && build_parameters+=( --microcode-initramfs ) || build_parameters+=( --no-microcode-initramfs )
473473
isTrue "${RAMDISKMODULES}" && build_parameters+=( --ramdisk-modules ) || build_parameters+=( --no-ramdisk-modules )
474474
isTrue "${BUSYBOX}" && build_parameters+=( --busybox ) || build_parameters+=( --no-busybox )
475-
#BEGIN FEATURES append_base_layout()
476-
#END FEATURES append_base_layout()
475+
$(. load_features append_base_layout)
477476
isTrue "${FIRMWARE}" && build_parameters+=( --firmware ) || build_parameters+=( --no-firmware )
478477
[ -n "${FIRMWARE_DIR}" ] && build_parameters+=( --firmware-dir="${FIRMWARE_DIR}" )
479478
[ -n "${FIRMWARE_FILES}" ] && build_parameters+=( --firmware-files="${FIRMWARE_FILES}" )

load_features.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ls features/*/$1 > /dev/null 2>&1 && cat features/*/$1

0 commit comments

Comments
 (0)