License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
# ===========================================================================
|
|
|
|
# Kernel configuration targets
|
|
|
|
# These targets are used from top-level makefile
|
|
|
|
|
2008-08-25 08:51:27 +00:00
|
|
|
ifdef KBUILD_KCONFIG
|
|
|
|
Kconfig := $(KBUILD_KCONFIG)
|
|
|
|
else
|
2010-09-04 21:10:20 +00:00
|
|
|
Kconfig := Kconfig
|
2008-08-25 08:51:27 +00:00
|
|
|
endif
|
2007-10-25 18:42:18 +00:00
|
|
|
|
2021-03-13 19:48:33 +00:00
|
|
|
ifndef KBUILD_DEFCONFIG
|
|
|
|
KBUILD_DEFCONFIG := defconfig
|
|
|
|
endif
|
|
|
|
|
2015-04-08 11:30:42 +00:00
|
|
|
ifeq ($(quiet),silent_)
|
|
|
|
silent := -s
|
|
|
|
endif
|
|
|
|
|
2021-03-13 19:48:32 +00:00
|
|
|
export KCONFIG_DEFCONFIG_LIST :=
|
kconfig: use /boot/config-* etc. as DEFCONFIG_LIST only for native build
When the .config file is missing, 'make config', 'make menuconfig', etc.
uses a file listed in DEFCONFIG_LIST, if found, as base configuration.
Ususally, /boot/config-$(uname -r) exists, and is used as default.
However, when you are cross-compiling the kernel, it does not make
sense to use /boot/config-* on the build host. It should default to
arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG).
UML previously did not use DEFCONFIG_LIST at all, but it should be
able to use arch/um/configs/$(KBUILD_DEFCONFIG) as a base config file.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-04-10 14:31:58 +00:00
|
|
|
ifndef cross_compiling
|
2021-03-13 19:48:32 +00:00
|
|
|
kernel-release := $(shell uname -r)
|
kconfig: use /boot/config-* etc. as DEFCONFIG_LIST only for native build
When the .config file is missing, 'make config', 'make menuconfig', etc.
uses a file listed in DEFCONFIG_LIST, if found, as base configuration.
Ususally, /boot/config-$(uname -r) exists, and is used as default.
However, when you are cross-compiling the kernel, it does not make
sense to use /boot/config-* on the build host. It should default to
arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG).
UML previously did not use DEFCONFIG_LIST at all, but it should be
able to use arch/um/configs/$(KBUILD_DEFCONFIG) as a base config file.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-04-10 14:31:58 +00:00
|
|
|
KCONFIG_DEFCONFIG_LIST += \
|
2021-03-13 19:48:32 +00:00
|
|
|
/lib/modules/$(kernel-release)/.config \
|
|
|
|
/etc/kernel-config \
|
kconfig: use /boot/config-* etc. as DEFCONFIG_LIST only for native build
When the .config file is missing, 'make config', 'make menuconfig', etc.
uses a file listed in DEFCONFIG_LIST, if found, as base configuration.
Ususally, /boot/config-$(uname -r) exists, and is used as default.
However, when you are cross-compiling the kernel, it does not make
sense to use /boot/config-* on the build host. It should default to
arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG).
UML previously did not use DEFCONFIG_LIST at all, but it should be
able to use arch/um/configs/$(KBUILD_DEFCONFIG) as a base config file.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-04-10 14:31:58 +00:00
|
|
|
/boot/config-$(kernel-release)
|
2021-03-13 19:48:32 +00:00
|
|
|
endif
|
kconfig: use /boot/config-* etc. as DEFCONFIG_LIST only for native build
When the .config file is missing, 'make config', 'make menuconfig', etc.
uses a file listed in DEFCONFIG_LIST, if found, as base configuration.
Ususally, /boot/config-$(uname -r) exists, and is used as default.
However, when you are cross-compiling the kernel, it does not make
sense to use /boot/config-* on the build host. It should default to
arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG).
UML previously did not use DEFCONFIG_LIST at all, but it should be
able to use arch/um/configs/$(KBUILD_DEFCONFIG) as a base config file.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-04-10 14:31:58 +00:00
|
|
|
KCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
|
2021-03-13 19:48:32 +00:00
|
|
|
|
2023-11-23 09:05:40 +00:00
|
|
|
ifneq ($(findstring c, $(KBUILD_EXTRA_WARN)),)
|
|
|
|
export KCONFIG_WARN_UNKNOWN_SYMBOLS=1
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),)
|
|
|
|
export KCONFIG_WERROR=1
|
|
|
|
endif
|
|
|
|
|
2012-11-22 00:06:04 +00:00
|
|
|
# We need this, in case the user has it in its environment
|
|
|
|
unexport CONFIG_
|
|
|
|
|
2021-02-21 13:03:18 +00:00
|
|
|
config-prog := conf
|
|
|
|
menuconfig-prog := mconf
|
|
|
|
nconfig-prog := nconf
|
|
|
|
gconfig-prog := gconf
|
|
|
|
xconfig-prog := qconf
|
2018-08-15 00:36:49 +00:00
|
|
|
|
2021-02-21 13:03:18 +00:00
|
|
|
define config_rule
|
|
|
|
PHONY += $(1)
|
|
|
|
$(1): $(obj)/$($(1)-prog)
|
|
|
|
$(Q)$$< $(silent) $(Kconfig)
|
2018-08-15 00:36:49 +00:00
|
|
|
|
2021-02-21 13:03:18 +00:00
|
|
|
PHONY += build_$(1)
|
|
|
|
build_$(1): $(obj)/$($(1)-prog)
|
|
|
|
endef
|
2018-08-15 00:36:49 +00:00
|
|
|
|
2021-02-21 13:03:18 +00:00
|
|
|
$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c))))
|
2018-08-15 00:36:49 +00:00
|
|
|
|
2021-02-21 13:03:18 +00:00
|
|
|
PHONY += localmodconfig localyesconfig
|
2018-03-01 11:18:01 +00:00
|
|
|
localyesconfig localmodconfig: $(obj)/conf
|
kbuild: use $(src) instead of $(srctree)/$(src) for source directory
Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for
checked-in source files. It is merely a convention without any functional
difference. In fact, $(obj) and $(src) are exactly the same, as defined
in scripts/Makefile.build:
src := $(obj)
When the kernel is built in a separate output directory, $(src) does
not accurately reflect the source directory location. While Kbuild
resolves this discrepancy by specifying VPATH=$(srctree) to search for
source files, it does not cover all cases. For example, when adding a
header search path for local headers, -I$(srctree)/$(src) is typically
passed to the compiler.
This introduces inconsistency between upstream and downstream Makefiles
because $(src) is used instead of $(srctree)/$(src) for the latter.
To address this inconsistency, this commit changes the semantics of
$(src) so that it always points to the directory in the source tree.
Going forward, the variables used in Makefiles will have the following
meanings:
$(obj) - directory in the object tree
$(src) - directory in the source tree (changed by this commit)
$(objtree) - the top of the kernel object tree
$(srctree) - the top of the kernel source tree
Consequently, $(srctree)/$(src) in upstream Makefiles need to be replaced
with $(src).
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
2024-04-27 14:55:02 +00:00
|
|
|
$(Q)$(PERL) $(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
|
2019-12-17 04:18:18 +00:00
|
|
|
$(Q)if [ -f .config ]; then \
|
|
|
|
cmp -s .tmp.config .config || \
|
|
|
|
(mv -f .config .config.old.1; \
|
|
|
|
mv -f .tmp.config .config; \
|
|
|
|
$< $(silent) --oldconfig $(Kconfig); \
|
|
|
|
mv -f .config.old.1 .config.old) \
|
|
|
|
else \
|
|
|
|
mv -f .tmp.config .config; \
|
|
|
|
$< $(silent) --oldconfig $(Kconfig); \
|
2009-05-07 15:09:55 +00:00
|
|
|
fi
|
2009-04-30 02:52:22 +00:00
|
|
|
$(Q)rm -f .tmp.config
|
|
|
|
|
2015-04-08 09:11:57 +00:00
|
|
|
# These targets map 1:1 to the commandline options of 'conf'
|
2018-07-20 07:46:29 +00:00
|
|
|
#
|
|
|
|
# Note:
|
|
|
|
# syncconfig has become an internal implementation detail and is now
|
|
|
|
# deprecated for external use
|
2015-04-08 09:11:57 +00:00
|
|
|
simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
|
2019-11-04 22:10:08 +00:00
|
|
|
alldefconfig randconfig listnewconfig olddefconfig syncconfig \
|
2021-10-17 17:43:13 +00:00
|
|
|
helpnewconfig yes2modconfig mod2yesconfig mod2noconfig
|
2019-11-04 22:10:08 +00:00
|
|
|
|
2015-04-08 09:11:57 +00:00
|
|
|
PHONY += $(simple-targets)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-04-08 09:11:57 +00:00
|
|
|
$(simple-targets): $(obj)/conf
|
2020-08-21 02:43:58 +00:00
|
|
|
$(Q)$< $(silent) --$@ $(Kconfig)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-10-29 15:41:28 +00:00
|
|
|
PHONY += savedefconfig defconfig
|
2018-03-01 06:34:37 +00:00
|
|
|
|
2010-07-31 21:35:34 +00:00
|
|
|
savedefconfig: $(obj)/conf
|
2020-08-21 02:43:58 +00:00
|
|
|
$(Q)$< $(silent) --$@=defconfig $(Kconfig)
|
2010-07-31 21:35:34 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
defconfig: $(obj)/conf
|
2019-05-27 14:37:21 +00:00
|
|
|
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
|
2015-04-08 11:30:42 +00:00
|
|
|
@$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
|
|
|
|
$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
|
2015-09-23 05:40:34 +00:00
|
|
|
else
|
|
|
|
@$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
|
|
|
|
$(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
|
2005-04-16 22:20:36 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
%_defconfig: $(obj)/conf
|
2015-04-08 11:30:42 +00:00
|
|
|
$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2023-08-31 19:13:39 +00:00
|
|
|
configfiles = $(wildcard $(srctree)/kernel/configs/$(1) $(srctree)/arch/$(SRCARCH)/configs/$(1))
|
|
|
|
all-config-fragments = $(call configfiles,*.config)
|
|
|
|
config-fragments = $(call configfiles,$@)
|
2014-08-06 22:21:00 +00:00
|
|
|
|
2015-03-13 06:21:43 +00:00
|
|
|
%.config: $(obj)/conf
|
2023-08-31 19:13:39 +00:00
|
|
|
$(if $(config-fragments),, $(error $@ fragment does not exists on this architecture))
|
2023-12-05 10:45:59 +00:00
|
|
|
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m $(KCONFIG_CONFIG) $(config-fragments)
|
2019-06-04 18:14:53 +00:00
|
|
|
$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
|
2014-08-06 22:21:00 +00:00
|
|
|
|
2014-08-08 23:25:47 +00:00
|
|
|
PHONY += tinyconfig
|
2015-03-13 06:21:43 +00:00
|
|
|
tinyconfig:
|
2021-03-13 19:48:34 +00:00
|
|
|
$(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig
|
|
|
|
$(Q)$(MAKE) -f $(srctree)/Makefile tiny.config
|
2014-08-08 23:25:47 +00:00
|
|
|
|
2018-03-13 09:12:03 +00:00
|
|
|
# CHECK: -o cache_dir=<path> working?
|
|
|
|
PHONY += testconfig
|
|
|
|
testconfig: $(obj)/conf
|
kbuild: use $(src) instead of $(srctree)/$(src) for source directory
Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for
checked-in source files. It is merely a convention without any functional
difference. In fact, $(obj) and $(src) are exactly the same, as defined
in scripts/Makefile.build:
src := $(obj)
When the kernel is built in a separate output directory, $(src) does
not accurately reflect the source directory location. While Kbuild
resolves this discrepancy by specifying VPATH=$(srctree) to search for
source files, it does not cover all cases. For example, when adding a
header search path for local headers, -I$(srctree)/$(src) is typically
passed to the compiler.
This introduces inconsistency between upstream and downstream Makefiles
because $(src) is used instead of $(srctree)/$(src) for the latter.
To address this inconsistency, this commit changes the semantics of
$(src) so that it always points to the directory in the source tree.
Going forward, the variables used in Makefiles will have the following
meanings:
$(obj) - directory in the object tree
$(src) - directory in the source tree (changed by this commit)
$(objtree) - the top of the kernel object tree
$(srctree) - the top of the kernel source tree
Consequently, $(srctree)/$(src) in upstream Makefiles need to be replaced
with $(src).
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
2024-04-27 14:55:02 +00:00
|
|
|
$(Q)$(PYTHON3) -B -m pytest $(src)/tests \
|
2018-03-13 09:12:03 +00:00
|
|
|
-o cache_dir=$(abspath $(obj)/tests/.cache) \
|
|
|
|
$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
|
2019-08-25 01:31:27 +00:00
|
|
|
clean-files += tests/.cache
|
2018-03-13 09:12:03 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
# Help text used by make help
|
|
|
|
help:
|
2023-08-31 19:13:39 +00:00
|
|
|
@echo 'Configuration targets:'
|
2005-04-16 22:20:36 +00:00
|
|
|
@echo ' config - Update current config utilising a line-oriented program'
|
2018-06-02 09:08:03 +00:00
|
|
|
@echo ' nconfig - Update current config utilising a ncurses menu based program'
|
2005-04-16 22:20:36 +00:00
|
|
|
@echo ' menuconfig - Update current config utilising a menu based program'
|
2015-04-06 09:27:45 +00:00
|
|
|
@echo ' xconfig - Update current config utilising a Qt based front-end'
|
2015-05-31 17:35:51 +00:00
|
|
|
@echo ' gconfig - Update current config utilising a GTK+ based front-end'
|
2005-04-16 22:20:36 +00:00
|
|
|
@echo ' oldconfig - Update current config utilising a provided .config as base'
|
2009-04-30 02:52:22 +00:00
|
|
|
@echo ' localmodconfig - Update current config disabling modules not loaded'
|
2020-05-12 15:36:07 +00:00
|
|
|
@echo ' except those preserved by LMC_KEEP environment variable'
|
2009-04-30 02:52:23 +00:00
|
|
|
@echo ' localyesconfig - Update current config converting local mods to core'
|
2020-05-12 15:36:07 +00:00
|
|
|
@echo ' except those preserved by LMC_KEEP environment variable'
|
2010-07-31 21:35:31 +00:00
|
|
|
@echo ' defconfig - New config with default from ARCH supplied defconfig'
|
2010-07-31 21:35:34 +00:00
|
|
|
@echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
|
2006-02-25 20:52:50 +00:00
|
|
|
@echo ' allnoconfig - New config where all options are answered with no'
|
2010-07-31 21:35:31 +00:00
|
|
|
@echo ' allyesconfig - New config where all options are accepted with yes'
|
|
|
|
@echo ' allmodconfig - New config selecting modules when possible'
|
|
|
|
@echo ' alldefconfig - New config with all symbols set to default'
|
|
|
|
@echo ' randconfig - New config with random answer to all options'
|
2019-12-17 09:42:06 +00:00
|
|
|
@echo ' yes2modconfig - Change answers from yes to mod if possible'
|
|
|
|
@echo ' mod2yesconfig - Change answers from mod to yes if possible'
|
2021-10-17 17:43:13 +00:00
|
|
|
@echo ' mod2noconfig - Change answers from mod to no if possible'
|
2010-07-31 21:35:28 +00:00
|
|
|
@echo ' listnewconfig - List new options'
|
2019-11-04 22:10:08 +00:00
|
|
|
@echo ' helpnewconfig - List new options and help text'
|
2018-01-26 22:59:00 +00:00
|
|
|
@echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
|
|
|
|
@echo ' default value without prompting'
|
2014-08-08 23:25:47 +00:00
|
|
|
@echo ' tinyconfig - Configure the tiniest possible kernel'
|
2018-06-02 09:08:02 +00:00
|
|
|
@echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
|
2023-08-31 19:13:39 +00:00
|
|
|
@echo ''
|
|
|
|
@echo 'Configuration topic targets:'
|
|
|
|
@$(foreach f, $(all-config-fragments), \
|
|
|
|
if help=$$(grep -m1 '^# Help: ' $(f)); then \
|
|
|
|
printf ' %-25s - %s\n' '$(notdir $(f))' "$${help#*: }"; \
|
|
|
|
fi;)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
# ===========================================================================
|
|
|
|
# object files used by all kconfig flavours
|
2021-04-13 15:08:17 +00:00
|
|
|
common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
|
|
|
|
preprocess.o symbol.o util.o
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2019-01-24 10:47:30 +00:00
|
|
|
$(obj)/lexer.lex.o: $(obj)/parser.tab.h
|
kbuild: use $(src) instead of $(srctree)/$(src) for source directory
Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for
checked-in source files. It is merely a convention without any functional
difference. In fact, $(obj) and $(src) are exactly the same, as defined
in scripts/Makefile.build:
src := $(obj)
When the kernel is built in a separate output directory, $(src) does
not accurately reflect the source directory location. While Kbuild
resolves this discrepancy by specifying VPATH=$(srctree) to search for
source files, it does not cover all cases. For example, when adding a
header search path for local headers, -I$(srctree)/$(src) is typically
passed to the compiler.
This introduces inconsistency between upstream and downstream Makefiles
because $(src) is used instead of $(srctree)/$(src) for the latter.
To address this inconsistency, this commit changes the semantics of
$(src) so that it always points to the directory in the source tree.
Going forward, the variables used in Makefiles will have the following
meanings:
$(obj) - directory in the object tree
$(src) - directory in the source tree (changed by this commit)
$(objtree) - the top of the kernel object tree
$(srctree) - the top of the kernel source tree
Consequently, $(srctree)/$(src) in upstream Makefiles need to be replaced
with $(src).
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
2024-04-27 14:55:02 +00:00
|
|
|
HOSTCFLAGS_lexer.lex.o := -I $(src)
|
|
|
|
HOSTCFLAGS_parser.tab.o := -I $(src)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-12-21 08:33:04 +00:00
|
|
|
# conf: Used for defconfig, oldconfig and related targets
|
2020-02-01 16:49:24 +00:00
|
|
|
hostprogs += conf
|
2018-12-21 08:33:04 +00:00
|
|
|
conf-objs := conf.o $(common-objs)
|
|
|
|
|
2018-05-22 07:22:21 +00:00
|
|
|
# nconf: Used for the nconfig target based on ncurses
|
2020-02-01 16:49:24 +00:00
|
|
|
hostprogs += nconf
|
2023-12-03 10:25:23 +00:00
|
|
|
nconf-objs := nconf.o nconf.gui.o mnconf-common.o $(common-objs)
|
2018-05-22 07:22:21 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs)
|
|
|
|
HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags)
|
|
|
|
HOSTCFLAGS_nconf.gui.o = $(call read-file, $(obj)/nconf-cflags)
|
2018-05-22 07:22:21 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
$(obj)/nconf: | $(obj)/nconf-libs
|
|
|
|
$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags
|
2018-05-22 07:22:21 +00:00
|
|
|
|
|
|
|
# mconf: Used for the menuconfig target based on lxdialog
|
2020-02-01 16:49:24 +00:00
|
|
|
hostprogs += mconf
|
kbuild: change *FLAGS_<basetarget>.o to take the path relative to $(obj)
Kbuild provides per-file compiler flag addition/removal:
CFLAGS_<basetarget>.o
CFLAGS_REMOVE_<basetarget>.o
AFLAGS_<basetarget>.o
AFLAGS_REMOVE_<basetarget>.o
CPPFLAGS_<basetarget>.lds
HOSTCFLAGS_<basetarget>.o
HOSTCXXFLAGS_<basetarget>.o
The <basetarget> is the filename of the target with its directory and
suffix stripped.
This syntax comes into a trouble when two files with the same basename
appear in one Makefile, for example:
obj-y += foo.o
obj-y += dir/foo.o
CFLAGS_foo.o := <some-flags>
Here, the <some-flags> applies to both foo.o and dir/foo.o
The real world problem is:
scripts/kconfig/util.c
scripts/kconfig/lxdialog/util.c
Both files are compiled into scripts/kconfig/mconf, but only the
latter should be given with the ncurses flags.
It is more sensible to use the relative path to the Makefile, like this:
obj-y += foo.o
CFLAGS_foo.o := <some-flags>
obj-y += dir/foo.o
CFLAGS_dir/foo.o := <other-flags>
At first, I attempted to replace $(basetarget) with $*. The $* variable
is replaced with the stem ('%') part in a pattern rule. This works with
most of cases, but does not for explicit rules.
For example, arch/ia64/lib/Makefile reuses rule_as_o_S in its own
explicit rules, so $* will be empty, resulting in ignoring the per-file
AFLAGS.
I introduced a new variable, target-stem, which can be used also from
explicit rules.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Marc Zyngier <maz@kernel.org>
2019-08-30 04:34:01 +00:00
|
|
|
lxdialog := $(addprefix lxdialog/, \
|
|
|
|
checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
|
2023-12-03 10:25:23 +00:00
|
|
|
mconf-objs := mconf.o $(lxdialog) mnconf-common.o $(common-objs)
|
2018-05-22 07:22:21 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs)
|
2018-05-22 07:22:21 +00:00
|
|
|
$(foreach f, mconf.o $(lxdialog), \
|
2022-12-11 02:54:48 +00:00
|
|
|
$(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags)))
|
2010-08-16 04:19:04 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
$(obj)/mconf: | $(obj)/mconf-libs
|
|
|
|
$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags
|
2018-05-22 07:22:19 +00:00
|
|
|
|
|
|
|
# qconf: Used for the xconfig target based on Qt
|
2020-02-01 16:49:24 +00:00
|
|
|
hostprogs += qconf
|
2020-07-29 17:02:38 +00:00
|
|
|
qconf-cxxobjs := qconf.o qconf-moc.o
|
2018-12-21 08:33:07 +00:00
|
|
|
qconf-objs := images.o $(common-objs)
|
2018-05-22 07:22:19 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
HOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs)
|
|
|
|
HOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
|
|
|
|
HOSTCXXFLAGS_qconf-moc.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
|
|
|
|
$(obj)/qconf: | $(obj)/qconf-libs
|
|
|
|
$(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags
|
2018-05-22 07:22:19 +00:00
|
|
|
|
|
|
|
quiet_cmd_moc = MOC $@
|
2022-12-11 02:54:48 +00:00
|
|
|
cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@
|
2018-05-22 07:22:19 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin
|
2020-07-29 17:02:37 +00:00
|
|
|
$(call if_changed,moc)
|
|
|
|
|
2020-07-29 17:02:38 +00:00
|
|
|
targets += qconf-moc.cc
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-22 07:22:20 +00:00
|
|
|
# gconf: Used for the gconfig target based on GTK+
|
2020-02-01 16:49:24 +00:00
|
|
|
hostprogs += gconf
|
2018-12-21 08:33:07 +00:00
|
|
|
gconf-objs := gconf.o images.o $(common-objs)
|
2018-05-22 07:22:20 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
HOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs)
|
|
|
|
HOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags)
|
2018-05-22 07:22:20 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
$(obj)/gconf: | $(obj)/gconf-libs
|
|
|
|
$(obj)/gconf.o: | $(obj)/gconf-cflags
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-22 07:22:19 +00:00
|
|
|
# check if necessary packages are available, and configure build flags
|
2023-01-13 04:23:59 +00:00
|
|
|
cmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin); touch $(obj)/$*conf-bin
|
2018-05-22 07:22:19 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh
|
|
|
|
$(call cmd,conf_cfg)
|
2018-05-22 07:22:19 +00:00
|
|
|
|
2022-12-11 02:54:48 +00:00
|
|
|
clean-files += *conf-cflags *conf-libs *conf-bin
|