Skip to content

Commit 6539f3f

Browse files
committed
Squashed 'scripts/kconfig/' changes from d2ca262..d263320
d263320 kconfig.Makefile: remove .mconf-cfg and .nconf-cfg dependency 90bdd1b Makefile: fix ordering to account for parser and lexical analyzer changes 7038293 kconfig: fixes and sync to next-20240830 cc6e694 kconfig: sync to next-20240823 67a7737 update-upstream-kconfig.sh: account for list.h move dce7653 kconfig: fix parallel builds for menuconfig 00828d7 kconfig.Makefile: allow dynamic Kconfig generation 43ccad2 README.kconfig 98bda61 README.kconfig: add fio-tests 71c4377 .gitignore: ignore *.o files ec3a810 kconfig.Makefile: use KCONFIG_DIR ed6c1d6 README.kconfig: add projects using this subtree 6a80663 .gitignore: expand to add more junk 882cbaa add internal.h from upstream linux 0fb0075 Makefile: process parser.tab.o before lexer.lex.o ff7edd2 .gitignore / clean: add parser.tab.c and .lex.c to clean 754427d kconfig.Makefile: fix usage of setlocalversion bb58485 kconfig: sync up to linux-next next-20220204 12c2c4c Fix directory targets be25db5 Add .gitignore again 7e02172 kconfig.Makefile: use local directory for helper e7941cd kconfig: move all data to local directory 37b6768 Move all files to kconfig directory 1f32753 scripts: move scripts to local directory 1f591b9 Provide license and basic README 2bf95cc Initial import REVERT: d2ca262 linux: generate refs automatically REVERT: bd240c8 Initial import: kdevops goes on a diet git-subtree-dir: scripts/kconfig git-subtree-split: d263320
1 parent d2ca262 commit 6539f3f

40 files changed

+2507
-2091
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ parser.tab.c
2222
lxdialog/*.o.cmd
2323
lxdialog/*.o
2424

25+
*conf-bin
26+
*conf-cflags
27+
*conf-libs

Kbuild.include

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ empty :=
1616
space := $(empty) $(empty)
1717
space_escape := _-_SPACE_-_
1818
pound := \#
19+
define newline
20+
21+
22+
endef
1923

2024
###
2125
# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
@@ -45,6 +49,16 @@ escsq = $(subst $(squote),'\$(squote)',$1)
4549
silent_kecho := :
4650
kecho := $($(quiet)kecho)
4751

52+
###
53+
# Read a file, replacing newlines with spaces
54+
#
55+
# Make 4.2 or later can read a file by using its builtin function.
56+
ifneq ($(filter-out 4.0 4.1, $(MAKE_VERSION)),)
57+
read-file = $(subst $(newline),$(space),$(file < $1))
58+
else
59+
read-file = $(shell cat $1 2>/dev/null)
60+
endif
61+
4862
###
4963
# filechk is used to check if the content of a generated file is updated.
5064
# Sample usage:
@@ -71,3 +85,77 @@ define filechk
7185
mv -f [email protected] $@; \
7286
fi
7387
endef
88+
89+
# pring log
90+
#
91+
# If quiet is "silent_", print nothing and sink stdout
92+
# If quiet is "quiet_", print short log
93+
# If quiet is empty, print short log and whole command
94+
silent_log_print = exec >/dev/null;
95+
quiet_log_print = $(if $(quiet_cmd_$1), echo ' $(call escsq,$(quiet_cmd_$1)$(why))';)
96+
log_print = echo '$(pound) $(call escsq,$(or $(quiet_cmd_$1),cmd_$1 $@)$(why))'; \
97+
echo ' $(call escsq,$(cmd_$1))';
98+
99+
# Delete the target on interruption
100+
#
101+
# GNU Make automatically deletes the target if it has already been changed by
102+
# the interrupted recipe. So, you can safely stop the build by Ctrl-C (Make
103+
# will delete incomplete targets), and resume it later.
104+
#
105+
# However, this does not work when the stderr is piped to another program, like
106+
# $ make >&2 | tee log
107+
# Make dies with SIGPIPE before cleaning the targets.
108+
#
109+
# To address it, we clean the target in signal traps.
110+
#
111+
# Make deletes the target when it catches SIGHUP, SIGINT, SIGQUIT, SIGTERM.
112+
# So, we cover them, and also SIGPIPE just in case.
113+
#
114+
# Of course, this is unneeded for phony targets.
115+
delete-on-interrupt = \
116+
$(if $(filter-out $(PHONY), $@), \
117+
$(foreach sig, HUP INT QUIT TERM PIPE, \
118+
trap 'rm -f $@; trap - $(sig); kill -s $(sig) $$$$' $(sig);))
119+
120+
# print and execute commands
121+
cmd = @$(if $(cmd_$(1)),set -e; $($(quiet)log_print) $(delete-on-interrupt) $(cmd_$(1)),:)
122+
123+
###
124+
# why - tell why a target got built
125+
# enabled by make V=2
126+
# Output (listed in the order they are checked):
127+
# (1) - due to target is PHONY
128+
# (2) - due to target missing
129+
# (3) - due to: file1.h file2.h
130+
# (4) - due to command line change
131+
# (5) - due to missing .cmd file
132+
# (6) - due to target not in $(targets)
133+
# (1) PHONY targets are always build
134+
# (2) No target, so we better build it
135+
# (3) Prerequisite is newer than target
136+
# (4) The command line stored in the file named dir/.target.cmd
137+
# differed from actual command line. This happens when compiler
138+
# options changes
139+
# (5) No dir/.target.cmd file (used to store command line)
140+
# (6) No dir/.target.cmd file and target not listed in $(targets)
141+
# This is a good hint that there is a bug in the kbuild file
142+
ifneq ($(findstring 2, $(KBUILD_VERBOSE)),)
143+
_why = \
144+
$(if $(filter $@, $(PHONY)),- due to target is PHONY, \
145+
$(if $(wildcard $@), \
146+
$(if $(newer-prereqs),- due to: $(newer-prereqs), \
147+
$(if $(cmd-check), \
148+
$(if $(savedcmd_$@),- due to command line change, \
149+
$(if $(filter $@, $(targets)), \
150+
- due to missing .cmd file, \
151+
- due to $(notdir $@) not in $$(targets) \
152+
) \
153+
) \
154+
) \
155+
), \
156+
- due to target missing \
157+
) \
158+
)
159+
160+
why = $(space)$(strip $(_why))
161+
endif

Makefile

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,72 @@
66
#
77
# Part of the https://github.com/mcgrof/kconfig.git
88

9-
CFLAGS=-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
10-
LXDIALOG := lxdialog/checklist.o lxdialog/inputbox.o lxdialog/menubox.o lxdialog/textbox.o lxdialog/util.o lxdialog/yesno.o
9+
CFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes
10+
CFLAGS += -O2 -fomit-frame-pointer
11+
CFLAGS += -I ./
12+
lxdialog := $(addprefix lxdialog/, \
13+
checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
1114

12-
default: mconf
15+
kconfig: conf mconf nconf
1316

14-
common-objs := confdata.o expr.o menu.o parser.tab.o lexer.lex.c \
15-
preprocess.o symbol.o util.o
17+
common-objs := lexer.lex.o parser.tab.o confdata.o expr.o menu.o \
18+
preprocess.o symbol.o util.o
1619

17-
lexer.lex.c: lexer.l
20+
lexer.lex.c: lexer.l parser.tab.h
1821
@flex -olexer.lex.c -L lexer.l
1922

20-
parser.tab.c: parser.y
23+
parser.tab.c parser.tab.h: parser.y
2124
@bison -oparser.tab.c --defines=parser.tab.h -t -l parser.y
2225

23-
conf: conf.o $(common-objs)
24-
$(CC) -o conf $^
26+
conf: $(common-objs) conf.o
27+
$(CC) -o conf -I./ $^
2528

26-
mconf_CFLAGS := $(shell test -f $(CURDIR)/.mconf-cfg && . $(CURDIR)/.mconf-cfg && echo $$cflags) -DLOCALE
27-
mconf_LDFLAGS := $(shell test -f $(CURDIR)/.mconf-cfg && . $(CURDIR)/.mconf-cfg && echo $$libs)
28-
mconf: CFLAGS += ${mconf_CFLAGS}
29+
HOSTLDLIBS_nconf = $(call read-file, nconf-libs)
30+
HOSTCFLAGS_nconf.o = $(call read-file, nconf-cflags)
31+
nconf: CFLAGS += ${HOSTCFLAGS_nconf.o}
2932

30-
nconf_CFLAGS := $(shell test -f $(CURDIR)/.nconf-cfg && . $(CURDIR)/.nconf-cfg && echo $$cflags) -DLOCALE
31-
nconf_LDFLAGS := $(shell test -f $(CURDIR)/.nconf-cfg && . $(CURDIR)/.nconf-cfg && echo $$libs)
32-
nconf: CFLAGS += ${nconf_CFLAGS}
33+
HOSTLDLIBS_mconf = $(call read-file, mconf-libs)
34+
$(foreach f, mconf.o $(lxdialog), \
35+
$(eval HOSTCFLAGS_$f = $$(call read-file, mconf-cflags)))
36+
mconf: CFLAGS += ${HOSTCFLAGS_mconf.o}
3337

38+
export HOSTPKG_CONFIG := pkg-config
3439
include $(CURDIR)/Kbuild.include
3540
# check if necessary packages are available, and configure build flags
36-
define filechk_conf_cfg
37-
$(CURDIR)/$<
38-
endef
41+
cmd_conf_cfg = $(CURDIR)/$< $(addprefix $*conf-, cflags libs bin); touch $*conf-bin
3942

40-
.%conf-cfg: %conf-cfg.sh
41-
$(call filechk,conf_cfg)
43+
%conf-cflags %conf-libs %conf-bin: %conf-cfg.sh
44+
$(call cmd,conf_cfg)
4245

43-
MCONF_DEPS := mconf.o $(LXDIALOG) $(common-objs)
44-
mconf: .mconf-cfg conf $(MCONF_DEPS)
45-
$(CC) -o mconf $(MCONF_DEPS) $(mconf_LDFLAGS)
46+
MCONF_DEPS := $(common-objs) mconf.o $(lxdialog) mnconf-common.o
47+
mconf: | mconf-libs
48+
mconf.o: | mconf-cflags
49+
mconf: $(MCONF_DEPS) conf
50+
$(CC) -o mconf -I./ $(MCONF_DEPS) $(HOSTLDLIBS_mconf)
4651

47-
NCONF_DEPS := nconf.o nconf.gui.o parser.tab.c
48-
nconf: .nconf-cfg conf $(NCONF_DEPS)
49-
$(CC) -o nconf $(NCONF_DEPS) $(nconf_LDFLAGS)
52+
NCONF_DEPS := $(common-objs) nconf.o nconf.gui.o mnconf-common.o
53+
nconf: | nconf-libs
54+
nconf.o: | nconf-cflags
55+
nconf: $(NCONF_DEPS) conf
56+
$(CC) -o nconf $(NCONF_DEPS) $(HOSTLDLIBS_nconf)
57+
58+
clean-files := conf mconf conf
59+
clean-files += *.o lxdialog/*.o
60+
clean-files += parser.tab.c parser.tab.h .lex.c
61+
clean-files += *conf-cflags *conf-libs *conf-bin
5062

5163
.PHONY: help
5264
help:
5365
@echo "Configuration options:"
66+
@echo "kconfig - builds only requirements menuconfig and nconfig"
5467
@echo "menuconfig - demos the menuconfig functionality"
5568
@echo "nconfig - demos the nconfig functionality"
5669
@echo "allyesconfig - enables all bells and whistles"
5770
@echo "allnoconfig - disables all bells and whistles"
5871
@echo "randconfig - random configuration"
5972
@echo "defconfig-* - If you have files in the defconfig directory use default config from there"
60-
@echo
61-
@echo "Variable options:"
62-
@echo "make V=n [targets] 1: verbose build (Makefile)"
63-
@echo " 2: verbose playbooks (Ansible)"
64-
@echo " V=1 and V=2 can be combined with V=12"
6573

6674
.PHONY: clean
6775
clean:
68-
@rm -f conf mconf conf *.o lxdialog/*.o *.o parser.tab.c .mconf-cfg *.lex.c
76+
@rm -f $(clean-files)
6977
@rm -rf *.o.d

array_size.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef ARRAY_SIZE_H
3+
#define ARRAY_SIZE_H
4+
5+
/**
6+
* ARRAY_SIZE - get the number of elements in array @arr
7+
* @arr: array to be sized
8+
*/
9+
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
10+
11+
#endif /* ARRAY_SIZE_H */

0 commit comments

Comments
 (0)