Skip to content

Commit 4bb784a

Browse files
authored
Merge pull request #126 from sysprog21/refine-kconfiglib
Refine Kconfig integration and build system
2 parents 4f4ee7c + 72fb57b commit 4bb784a

File tree

17 files changed

+75
-11162
lines changed

17 files changed

+75
-11162
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ jobs:
4747
shell: bash
4848
- name: default build
4949
run: |
50-
tools/kconfig/defconfig.py --kconfig configs/Kconfig configs/defconfig
51-
tools/kconfig/genconfig.py configs/Kconfig
50+
make defconfig
5251
make
5352
5453
coding-style:

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tools/kconfig"]
2+
path = tools/kconfig
3+
url = https://github.com/sysprog21/Kconfiglib

Makefile

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
# Ensure tools/kconfig submodule is initialized
2+
ifeq ($(wildcard tools/kconfig/menuconfig.py),)
3+
$(shell git submodule update --init tools/kconfig)
4+
endif
5+
16
-include .config
27

38
check_goal := $(strip $(MAKECMDGOALS))
4-
ifneq ($(check_goal), config)
5-
ifneq "$(CONFIG_CONFIGURED)" "y"
6-
$(error You must first run 'make config')
7-
endif
9+
ifeq ($(filter $(check_goal),config defconfig),)
10+
ifneq "$(CONFIG_CONFIGURED)" "y"
11+
$(error You must first run 'make config' or 'make defconfig')
12+
endif
813
endif
914

10-
# Rules
15+
# Target variables initialization
1116

1217
target-y :=
1318
target.o-y :=
@@ -58,11 +63,12 @@ libtwin.a_includes-y := \
5863
include \
5964
src
6065

61-
# Features
66+
# Optional features
67+
6268
libtwin.a_files-$(CONFIG_LOGGING) += src/log.c
6369
libtwin.a_files-$(CONFIG_CURSOR) += src/cursor.c
6470

65-
# Renderer
71+
# Rendering backends
6672
libtwin.a_files-$(CONFIG_RENDERER_BUILTIN) += src/draw-builtin.c
6773
libtwin.a_files-$(CONFIG_RENDERER_PIXMAN) += src/draw-pixman.c
6874
libtwin.a_cflags-$(CONFIG_RENDERER_PIXMAN) += $(shell pkg-config --cflags pixman-1)
@@ -156,29 +162,43 @@ demo-$(BACKEND)_ldflags-y := \
156162
$(TARGET_LIBS)
157163
endif
158164

165+
# Font editor tool
166+
159167
ifeq ($(CONFIG_TOOLS), y)
160168
target-$(CONFIG_TOOL_FONTEDIT) += font-edit
161169
font-edit_files-y = \
162-
tools/font-edit/sfit.c \
163-
tools/font-edit/font-edit.c
170+
tools/font-edit/sfit.c \
171+
tools/font-edit/font-edit.c
164172
font-edit_includes-y := tools/font-edit
165173
font-edit_cflags-y := \
166-
$(shell pkg-config --cflags cairo) \
167-
$(shell sdl2-config --cflags)
174+
$(shell pkg-config --cflags cairo) \
175+
$(shell sdl2-config --cflags)
168176
font-edit_ldflags-y := \
169-
$(shell pkg-config --libs cairo) \
170-
$(shell sdl2-config --libs)
177+
$(shell pkg-config --libs cairo) \
178+
$(shell sdl2-config --libs)
171179
endif
172180

181+
# Build system integration
182+
173183
CFLAGS += -include config.h
174184

175-
check_goal := $(strip $(MAKECMDGOALS))
176-
ifneq ($(check_goal), config)
185+
# Only include build rules when not running configuration targets
186+
ifeq ($(filter $(check_goal),config defconfig),)
177187
include mk/common.mk
178188
endif
179189

180-
# Menuconfig
190+
KCONFIGLIB := tools/kconfig/kconfiglib.py
191+
$(KCONFIGLIB):
192+
git submodule update --init tools/kconfig
193+
194+
# Load default configuration
195+
.PHONY: defconfig
196+
defconfig: $(KCONFIGLIB)
197+
@tools/kconfig/defconfig.py --kconfig configs/Kconfig configs/defconfig
198+
@tools/kconfig/genconfig.py configs/Kconfig
199+
200+
# Interactive configuration
181201
.PHONY: config
182-
config: configs/Kconfig
183-
@tools/kconfig/menuconfig.py $<
184-
@tools/kconfig/genconfig.py $<
202+
config: $(KCONFIGLIB) configs/Kconfig
203+
@tools/kconfig/menuconfig.py configs/Kconfig
204+
@tools/kconfig/genconfig.py configs/Kconfig

configs/Kconfig

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ config CONFIGURED
44
bool
55
default y
66

7+
# Dependency detection using Kbuild toolchain functions
8+
config HAVE_SDL2
9+
def_bool $(success,pkg-config --exists sdl2)
10+
11+
config HAVE_PIXMAN
12+
def_bool $(success,pkg-config --exists pixman-1)
13+
14+
config HAVE_LIBPNG
15+
def_bool $(success,pkg-config --exists libpng)
16+
17+
config HAVE_LIBJPEG
18+
def_bool $(success,pkg-config --exists libjpeg)
19+
720
choice
821
prompt "Backend Selection"
922
default BACKEND_SDL
@@ -14,6 +27,7 @@ config BACKEND_FBDEV
1427

1528
config BACKEND_SDL
1629
bool "SDL video output support"
30+
depends on HAVE_SDL2
1731

1832
config BACKEND_VNC
1933
bool "VNC server output support"
@@ -28,6 +42,7 @@ config RENDERER_BUILTIN
2842

2943
config RENDERER_PIXMAN
3044
bool "Pixman based rendering"
45+
depends on HAVE_PIXMAN
3146

3247
endchoice
3348

@@ -83,10 +98,12 @@ menu "Image Loaders"
8398

8499
config LOADER_PNG
85100
bool "Enable PNG loader"
101+
depends on HAVE_LIBPNG
86102
default y
87103

88104
config LOADER_JPEG
89105
bool "Enable JPEG loader"
106+
depends on HAVE_LIBJPEG
90107
default y
91108

92109
config LOADER_GIF
@@ -131,7 +148,7 @@ config DEMO_LINE
131148
depends on DEMO_APPLICATIONS
132149

133150
config DEMO_SPLINE
134-
bool "Build spline demp"
151+
bool "Build spline demo"
135152
default y
136153
depends on DEMO_APPLICATIONS
137154

mk/common.mk

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,17 @@ clean: __FORCE
678678
__FORCE:
679679
@true
680680

681-
ifneq "$(MAKECMDGOALS)" "clean"
682-
-include $(target-depends)
681+
# Only include dependencies when building known targets
682+
build-goals := all clean $(target-builds)
683+
ifneq ($(MAKECMDGOALS),)
684+
# MAKECMDGOALS is not empty, check if it's a known target
685+
ifneq ($(filter $(MAKECMDGOALS),$(build-goals)),)
686+
# Known target, include dependencies (except for clean)
687+
ifneq "$(MAKECMDGOALS)" "clean"
688+
-include $(target-depends)
689+
endif
690+
endif
691+
else
692+
# Empty MAKECMDGOALS means building 'all', include dependencies
693+
-include $(target-depends)
683694
endif

tools/kconfig

Submodule kconfig added at e1f15e3

tools/kconfig/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

tools/kconfig/LICENSE

Lines changed: 0 additions & 13 deletions
This file was deleted.

tools/kconfig/README.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

tools/kconfig/defconfig.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)