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
5
.config
Normal file
5
.config
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Generated Configuration
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
# CONFIG_DRIVER_USB is not set
|
||||
# CONFIG_FS_EXT4 is not set
|
||||
# CONFIG_NET_WIFI is not set
|
||||
1
.source/os2
Symbolic link
1
.source/os2
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/home/michael/src/os2//home/michael/src/os2
|
||||
1
.source/scripts
Symbolic link
1
.source/scripts
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/home/michael/src/os2/external/kbuild-standalone/kbuild/scripts
|
||||
51
Makefile
51
Makefile
|
|
@ -1,10 +1,13 @@
|
|||
ifneq ($(V),1)
|
||||
Q := @
|
||||
else
|
||||
Q :=
|
||||
endif
|
||||
ARCH := x86_64
|
||||
LIMINE_VERSION=v11.2.0
|
||||
KERNEL := kernel.elf
|
||||
|
||||
IMG := boot.iso
|
||||
|
||||
QEMUFLAGS := -m 16G
|
||||
|
||||
HOST_CC := gcc
|
||||
HOST_CFLAGS := -O2 -pipe
|
||||
|
|
@ -52,47 +55,51 @@ ifeq ($(ARCH),x86_64)
|
|||
KDIRS += amd64/
|
||||
endif
|
||||
|
||||
obj-y := $(KDIRS)
|
||||
|
||||
CFILES := $(shell find $(KDIRS) -type f -name '*.c')
|
||||
ASFILES := $(shell find $(KDIRS) -type f -name '*.S')
|
||||
OBJ := $(CFILES:.c=.o) $(ASFILES:.S=.o)
|
||||
HEADER_DEPS := $(CFILES:.c=.d) $(ASFILES:.S=.d)
|
||||
|
||||
QEMUFLAGS := -m 16G
|
||||
|
||||
print-%:
|
||||
@echo $($(*))
|
||||
$(Q)echo $($(*))
|
||||
|
||||
.PHONY: default
|
||||
default:
|
||||
@compiledb -n make $(IMG)
|
||||
@make $(IMG) -j$(shell nproc)
|
||||
$(Q)compiledb -n make $(IMG)
|
||||
$(Q)make $(IMG) -j$(shell nproc)
|
||||
|
||||
.PHONY: all
|
||||
all: $(IMG)
|
||||
@compiledb -n make
|
||||
$(Q)compiledb -n make
|
||||
|
||||
$(KERNEL): $(OBJ) linker.ld
|
||||
@echo " LD $@"
|
||||
@$(LD) $(OBJ) $(LDFLAGS) -o $@
|
||||
$(Q)echo " LD $@"
|
||||
$(Q)$(LD) $(OBJ) $(LDFLAGS) -o $@
|
||||
|
||||
-include $(HEADER_DEPS)
|
||||
|
||||
%.o: %.c
|
||||
@echo " CC $@"
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(Q)echo " CC $@"
|
||||
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.S
|
||||
@echo " CC $@"
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(Q)echo " CC $@"
|
||||
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo " CLEAN kernel"
|
||||
@rm -rf $(KERNEL) $(OBJ) $(HEADER_DEPS) bin
|
||||
@echo " CLEAN $(IMG)"
|
||||
@rm -rf $(IMG)
|
||||
@echo " CLEAN iso_root"
|
||||
@rm -rf iso_root
|
||||
@echo " CLEAN os_root"
|
||||
@rm -rf os_root
|
||||
$(Q)echo " CLEAN kernel"
|
||||
$(Q)rm -rf $(KERNEL) $(OBJ) $(HEADER_DEPS) bin
|
||||
$(Q)echo " CLEAN $(IMG)"
|
||||
$(Q)rm -rf $(IMG)
|
||||
$(Q)echo " CLEAN iso_root"
|
||||
$(Q)rm -rf iso_root
|
||||
$(Q)echo " CLEAN os_root"
|
||||
$(Q)rm -rf os_root
|
||||
|
||||
$(IMG): limine/limine $(KERNEL) limine.conf
|
||||
rm -rf iso_root
|
||||
|
|
@ -154,3 +161,7 @@ edk2-ovmf:
|
|||
distclean:
|
||||
make clean
|
||||
rm -rf limine
|
||||
|
||||
.PHONY += config
|
||||
config:
|
||||
$(Q)scripts/config.sh
|
||||
|
|
|
|||
5
amd64/Makefile
Normal file
5
amd64/Makefile
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += arch/
|
||||
obj-y += drivers/
|
||||
obj-y += init/
|
||||
obj-y += kernel/
|
||||
4
amd64/arch/Makefile
Normal file
4
amd64/arch/Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += msr.o
|
||||
obj-y += page.o
|
||||
obj-y += reg.o
|
||||
4
amd64/drivers/Makefile
Normal file
4
amd64/drivers/Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += apic.o
|
||||
obj-y += pio.o
|
||||
obj-y += serial.o
|
||||
2
amd64/init/Makefile
Normal file
2
amd64/init/Makefile
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += amd64_init.o
|
||||
3
amd64/kernel/Makefile
Normal file
3
amd64/kernel/Makefile
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += atomic.o
|
||||
obj-y += spinlock.o
|
||||
2
drivers/Makefile
Normal file
2
drivers/Makefile
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += tty/
|
||||
4
drivers/tty/Makefile
Normal file
4
drivers/tty/Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += tty.o
|
||||
obj-y += vt100.o
|
||||
|
||||
3
init/Makefile
Normal file
3
init/Makefile
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += main.o
|
||||
obj-y += requests.o
|
||||
2
kernel/Makefile
Normal file
2
kernel/Makefile
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += device.o
|
||||
8
lib/Makefile
Normal file
8
lib/Makefile
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += errno.o
|
||||
obj-y += math.o
|
||||
obj-y += printf.o
|
||||
obj-y += rbtree.o
|
||||
obj-y += sort.o
|
||||
obj-y += string.o
|
||||
|
||||
5
mem/Makefile
Normal file
5
mem/Makefile
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += buddy.o
|
||||
obj-y += mem.o
|
||||
obj-y += page.o
|
||||
obj-y += slab.o
|
||||
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