From 35e26cec3434754a20338ed2a7fe5310352baf67 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 25 Apr 2025 12:56:56 -0500 Subject: [PATCH] Move defconfig to new infrastructure. --- Makefile | 8 ++++++-- kconfig/Makefile | 6 +----- scripts/genconfig.sh | 2 ++ scripts/help.txt | 3 ++- scripts/portability.sh | 15 +++++++++++++++ 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 09fed076..5c8a6e3d 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,13 @@ export CROSS_COMPILE CFLAGS OPTIMIZE LDOPTIMIZE CC HOSTCC V STRIP ASAN all: toybox KCONFIG_CONFIG ?= .config +KCONFIG_TOP ?= Config.in toybox generated/unstripped/toybox: $(KCONFIG_CONFIG) *.[ch] lib/*.[ch] toys/*/*.c scripts/*.sh Config.in scripts/make.sh .PHONY: clean distclean baseline bloatcheck install install_flat \ - uninstall uninstall_flat tests help change \ + uninstall uninstall_flat tests help change defconfig \ list list_example list_pending root run_root .SUFFIXES: # Disable legacy behavior @@ -29,11 +30,14 @@ $(KCONFIG_CONFIG): $(KCONFIG_TOP) else echo "Not configured (run '$(MAKE) defconfig' or '$(MAKE) menuconfig')";\ exit 1; fi -$(KCONFIG_TOP): generated/Config.in generated/Config.probed +$(KCONFIG_TOP): generated/Config.in generated/Config.probed generated/unstripped/kconfig generated/Config.probed: generated/Config.in generated/Config.in: toys/*/*.c scripts/genconfig.sh scripts/genconfig.sh +defconfig: $(KCONFIG_TOP) generated/Config.in + generated/unstripped/kconfig -d > $(KCONFIG_CONFIG) + # Development targets baseline: generated/unstripped/toybox @cp generated/unstripped/toybox generated/unstripped/toybox_old diff --git a/kconfig/Makefile b/kconfig/Makefile index 3bd5f6a4..c7b9409e 100644 --- a/kconfig/Makefile +++ b/kconfig/Makefile @@ -6,7 +6,7 @@ KCONFIG_TOP = Config.in KCONFIG_PROJECT = ToyBox obj = ./kconfig PHONY += clean help oldconfig menuconfig config silentoldconfig \ - randconfig allyesconfig allnoconfig allmodconfig defconfig + randconfig allyesconfig allnoconfig allmodconfig menuconfig: $(obj)/mconf $(KCONFIG_TOP) $< $(KCONFIG_TOP) @@ -30,8 +30,6 @@ allnoconfig: $(obj)/conf $(KCONFIG_TOP) $< -n $(KCONFIG_TOP) > /dev/null KCONFIG_ALLCONFIG ?= /dev/null -defconfig: $(obj)/conf $(KCONFIG_TOP) - $< -D $(KCONFIG_ALLCONFIG) $(KCONFIG_TOP) > /dev/null macos_defconfig: $(obj)/conf $(KCONFIG_TOP) KCONFIG_ALLCONFIG=$(obj)/macos_miniconfig $< -n $(KCONFIG_TOP) > /dev/null @@ -48,8 +46,6 @@ help:: @echo ' oldconfig - Update current config utilising a provided .config as base' @echo ' silentoldconfig - Same as oldconfig, but quietly' @echo ' randconfig - New config with random answer to all options' - @echo ' defconfig - New config with default answer to all options' - @echo ' This is the maximum sane configuration.' @echo ' allyesconfig - New config where all options are accepted with yes' @echo " This may not actually compile, it's a starting point" @echo ' for further configuration (probably with menuconfig)' diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh index 5d46f70c..a1c6e2b5 100755 --- a/scripts/genconfig.sh +++ b/scripts/genconfig.sh @@ -92,3 +92,5 @@ echo -e "list_example:\n\t@echo $(echo $EXAMPLE | tr ' ' '\n' | sort | xargs)"&& echo -e "list_pending:\n\t@echo $(echo $PENDING | tr ' ' '\n' | sort | xargs)"&& echo -e ".PHONY: $WORKING $PENDING" | $SED 's/ \([^ ]\)/ test_\1/g' ) > .singlemake + +brun kconfig -h > "$GENDIR"/help.h || exit 1 diff --git a/scripts/help.txt b/scripts/help.txt index 5117f977..77245074 100644 --- a/scripts/help.txt +++ b/scripts/help.txt @@ -1,4 +1,5 @@ - toybox - Build toybox. + toybox - Build unified toybox with commands selected in .config + defconfig - Write .config with default answers (max sane config). COMMANDNAME - Build individual toybox command as a standalone binary. list - List COMMANDNAMEs you can build standalone. list_example - List example commands (often used by the test suite) diff --git a/scripts/portability.sh b/scripts/portability.sh index 98412c76..570d9e29 100644 --- a/scripts/portability.sh +++ b/scripts/portability.sh @@ -46,3 +46,18 @@ fi # If the build is using gnu tools, make them behave less randomly. export LANG=c export LC_ALL=C + +# Respond to V= by echoing command lines as well as running them +do_loudly() { + { [ -n "$V" ] && echo "$@" || echo -n "$DOTPROG" ; } >&2 + "$@" +} + +# Run a C file from scripts/*.c using $HOSTCC as necessary +brun() { + [ ! -e "$UNSTRIPPED"/$1 -o "$UNSTRIPPED"/$1 -ot scripts/$1.c ] && + { mkdir -p "$UNSTRIPPED" && + do_loudly $HOSTCC scripts/$1.c -o "$UNSTRIPPED"/$1 || exit 1; } + do_loudly "$UNSTRIPPED"/$1 "${@:2}" +} + -- 2.39.5