config initial test
Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
parent
d2ef885e8d
commit
552f45c258
17 changed files with 168 additions and 20 deletions
30
scripts/Makefile.build
Normal file
30
scripts/Makefile.build
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# kernel makefile
|
||||
-include .config
|
||||
|
||||
include $(obj)Makefile
|
||||
|
||||
# 1. Filter subdirectories (items ending in /) from files
|
||||
subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
|
||||
real-objs-y := $(filter-out %/, $(obj-y))
|
||||
|
||||
# 2. Target to build everything in this directory
|
||||
__build: $(subdir-y) $(real-objs-y)
|
||||
@echo " Built-in $(obj)"
|
||||
|
||||
# 3. Rule to descend into subdirectories
|
||||
$(subdir-y):
|
||||
@$(MAKE) -f scripts/Makefile.build obj=$(obj)$@/
|
||||
|
||||
# 4. Standard rule to compile .c files to .o
|
||||
%.o: %.c
|
||||
@echo " CC $(obj)$@"
|
||||
@$(CC) $(CFLAGS) -c $< -o $(obj)$@
|
||||
|
||||
%.o: %.S
|
||||
@echo " CC $(obj)$@"
|
||||
@$(CC) $(CFLAGS) -c $< -o $(obj)$@
|
||||
|
||||
|
||||
.PHONY: __build $(subdir-y)
|
||||
|
||||
58
scripts/config.sh
Executable file
58
scripts/config.sh
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
CONFIG_FILE=".config"
|
||||
|
||||
# --- The Engine ---
|
||||
run_menuconfig() {
|
||||
local TITLE="$1"
|
||||
shift
|
||||
local OPTIONS=("$@") # Array of "KEY" "DESCRIPTION"
|
||||
local DIALOG_ARGS=()
|
||||
|
||||
# 1. Build the dialog arguments dynamically
|
||||
for ((i=0; i<${#OPTIONS[@]}; i+=2)); do
|
||||
KEY="${OPTIONS[i]}"
|
||||
DESC="${OPTIONS[i+1]}"
|
||||
|
||||
# Check current state in .config
|
||||
STATE="OFF"
|
||||
if grep -q "^CONFIG_${KEY}=y" "$CONFIG_FILE" 2>/dev/null; then
|
||||
STATE="ON"
|
||||
fi
|
||||
|
||||
DIALOG_ARGS+=("$KEY" "$DESC" "$STATE")
|
||||
done
|
||||
|
||||
# 2. Show the menu
|
||||
CHOICES=$(dialog --stdout --backtitle "Project Setup" \
|
||||
--title "$TITLE" \
|
||||
--checklist "Use SPACE to toggle, ENTER to save:" 15 70 10 \
|
||||
"${DIALOG_ARGS[@]}")
|
||||
|
||||
# 3. Save if user didn't cancel
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "# Generated Configuration" > "$CONFIG_FILE"
|
||||
for OPTION in $CHOICES; do
|
||||
CLEAN=$(echo "$OPTION" | tr -d '"')
|
||||
echo "CONFIG_${CLEAN}=y" >> "$CONFIG_FILE"
|
||||
done
|
||||
# Add "is not set" for everything else to be professional
|
||||
for ((i=0; i<${#OPTIONS[@]}; i+=2)); do
|
||||
KEY="${OPTIONS[i]}"
|
||||
if ! grep -q "CONFIG_${KEY}=y" "$CONFIG_FILE"; then
|
||||
echo "# CONFIG_${KEY} is not set" >> "$CONFIG_FILE"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# --- How you use it ---
|
||||
# Format: "VARIABLE_NAME" "Human Readable Description"
|
||||
MY_FEATURES=(
|
||||
"DRIVER_USB" "Include USB Driver Support"
|
||||
"FS_EXT4" "Enable EXT4 Filesystem"
|
||||
"NET_WIFI" "Wireless Networking Support"
|
||||
"DEBUG_SYMBOLS" "Compile with Debug Symbols"
|
||||
)
|
||||
|
||||
run_menuconfig "System Features" "${MY_FEATURES[@]}"
|
||||
|
||||
Loading…
Reference in a new issue