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 22:07:57 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
# ===========================================================================
|
|
|
|
# Kernel configuration targets
|
|
|
|
# These targets are used from top-level makefile
|
|
|
|
|
2008-08-25 16:51:27 +08:00
|
|
|
ifdef KBUILD_KCONFIG
|
|
|
|
Kconfig := $(KBUILD_KCONFIG)
|
|
|
|
else
|
2010-09-05 05:10:20 +08:00
|
|
|
Kconfig := Kconfig
|
2008-08-25 16:51:27 +08:00
|
|
|
endif
|
2007-10-26 02:42:18 +08:00
|
|
|
|
2021-03-14 03:48:33 +08:00
|
|
|
ifndef KBUILD_DEFCONFIG
|
|
|
|
KBUILD_DEFCONFIG := defconfig
|
|
|
|
endif
|
|
|
|
|
2015-04-08 19:30:42 +08:00
|
|
|
ifeq ($(quiet),silent_)
|
|
|
|
silent := -s
|
|
|
|
endif
|
|
|
|
|
2021-03-14 03:48:32 +08: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 22:31:58 +08:00
|
|
|
ifndef cross_compiling
|
2021-03-14 03:48:32 +08: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 22:31:58 +08:00
|
|
|
KCONFIG_DEFCONFIG_LIST += \
|
2021-03-14 03:48:32 +08: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 22:31:58 +08:00
|
|
|
/boot/config-$(kernel-release)
|
2021-03-14 03:48:32 +08: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 22:31:58 +08:00
|
|
|
KCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
|
2021-03-14 03:48:32 +08:00
|
|
|
|
2012-11-22 08:06:04 +08:00
|
|
|
# We need this, in case the user has it in its environment
|
|
|
|
unexport CONFIG_
|
|
|
|
|
2021-02-21 21:03:18 +08:00
|
|
|
config-prog := conf
|
|
|
|
menuconfig-prog := mconf
|
|
|
|
nconfig-prog := nconf
|
|
|
|
gconfig-prog := gconf
|
|
|
|
xconfig-prog := qconf
|
2018-08-15 08:36:49 +08:00
|
|
|
|
2021-02-21 21:03:18 +08:00
|
|
|
define config_rule
|
|
|
|
PHONY += $(1)
|
|
|
|
$(1): $(obj)/$($(1)-prog)
|
|
|
|
$(Q)$$< $(silent) $(Kconfig)
|
2018-08-15 08:36:49 +08:00
|
|
|
|
2021-02-21 21:03:18 +08:00
|
|
|
PHONY += build_$(1)
|
|
|
|
build_$(1): $(obj)/$($(1)-prog)
|
|
|
|
endef
|
2018-08-15 08:36:49 +08:00
|
|
|
|
2021-02-21 21:03:18 +08:00
|
|
|
$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c))))
|
2018-08-15 08:36:49 +08:00
|
|
|
|
2021-02-21 21:03:18 +08:00
|
|
|
PHONY += localmodconfig localyesconfig
|
2018-03-01 19:18:01 +08:00
|
|
|
localyesconfig localmodconfig: $(obj)/conf
|
2019-12-17 12:18:19 +08:00
|
|
|
$(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
|
2019-12-17 12:18:18 +08: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 23:09:55 +08:00
|
|
|
fi
|
2009-04-30 10:52:22 +08:00
|
|
|
$(Q)rm -f .tmp.config
|
|
|
|
|
2015-04-08 17:11:57 +08:00
|
|
|
# These targets map 1:1 to the commandline options of 'conf'
|
2018-07-20 15:46:29 +08:00
|
|
|
#
|
|
|
|
# Note:
|
|
|
|
# syncconfig has become an internal implementation detail and is now
|
|
|
|
# deprecated for external use
|
2015-04-08 17:11:57 +08:00
|
|
|
simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
|
2019-11-05 06:10:08 +08:00
|
|
|
alldefconfig randconfig listnewconfig olddefconfig syncconfig \
|
2021-10-18 01:43:13 +08:00
|
|
|
helpnewconfig yes2modconfig mod2yesconfig mod2noconfig
|
2019-11-05 06:10:08 +08:00
|
|
|
|
2015-04-08 17:11:57 +08:00
|
|
|
PHONY += $(simple-targets)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-04-08 17:11:57 +08:00
|
|
|
$(simple-targets): $(obj)/conf
|
2020-08-21 10:43:58 +08:00
|
|
|
$(Q)$< $(silent) --$@ $(Kconfig)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-10-29 23:41:28 +08:00
|
|
|
PHONY += savedefconfig defconfig
|
2018-03-01 14:34:37 +08:00
|
|
|
|
2010-08-01 05:35:34 +08:00
|
|
|
savedefconfig: $(obj)/conf
|
2020-08-21 10:43:58 +08:00
|
|
|
$(Q)$< $(silent) --$@=defconfig $(Kconfig)
|
2010-08-01 05:35:34 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
defconfig: $(obj)/conf
|
2019-05-27 22:37:21 +08:00
|
|
|
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
|
2015-04-08 19:30:42 +08:00
|
|
|
@$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
|
|
|
|
$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
|
2015-09-23 13:40:34 +08:00
|
|
|
else
|
|
|
|
@$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
|
|
|
|
$(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
|
2005-04-17 06:20:36 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
%_defconfig: $(obj)/conf
|
2015-04-08 19:30:42 +08:00
|
|
|
$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-03-13 14:21:43 +08:00
|
|
|
configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
|
2014-08-07 06:21:00 +08:00
|
|
|
|
2015-03-13 14:21:43 +08:00
|
|
|
%.config: $(obj)/conf
|
|
|
|
$(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
|
|
|
|
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
|
2019-06-05 02:14:53 +08:00
|
|
|
$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
|
2014-08-07 06:21:00 +08:00
|
|
|
|
2014-08-09 07:25:47 +08:00
|
|
|
PHONY += tinyconfig
|
2015-03-13 14:21:43 +08:00
|
|
|
tinyconfig:
|
2021-03-14 03:48:34 +08:00
|
|
|
$(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig
|
|
|
|
$(Q)$(MAKE) -f $(srctree)/Makefile tiny.config
|
2014-08-09 07:25:47 +08:00
|
|
|
|
2018-03-13 17:12:03 +08:00
|
|
|
# CHECK: -o cache_dir=<path> working?
|
|
|
|
PHONY += testconfig
|
|
|
|
testconfig: $(obj)/conf
|
2020-08-21 10:43:58 +08:00
|
|
|
$(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
|
2018-03-13 17:12:03 +08:00
|
|
|
-o cache_dir=$(abspath $(obj)/tests/.cache) \
|
|
|
|
$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
|
2019-08-25 09:31:27 +08:00
|
|
|
clean-files += tests/.cache
|
2018-03-13 17:12:03 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
# Help text used by make help
|
|
|
|
help:
|
|
|
|
@echo ' config - Update current config utilising a line-oriented program'
|
2018-06-02 17:08:03 +08:00
|
|
|
@echo ' nconfig - Update current config utilising a ncurses menu based program'
|
2005-04-17 06:20:36 +08:00
|
|
|
@echo ' menuconfig - Update current config utilising a menu based program'
|
2015-04-06 17:27:45 +08:00
|
|
|
@echo ' xconfig - Update current config utilising a Qt based front-end'
|
2015-06-01 01:35:51 +08:00
|
|
|
@echo ' gconfig - Update current config utilising a GTK+ based front-end'
|
2005-04-17 06:20:36 +08:00
|
|
|
@echo ' oldconfig - Update current config utilising a provided .config as base'
|
2009-04-30 10:52:22 +08:00
|
|
|
@echo ' localmodconfig - Update current config disabling modules not loaded'
|
2020-05-12 23:36:07 +08:00
|
|
|
@echo ' except those preserved by LMC_KEEP environment variable'
|
2009-04-30 10:52:23 +08:00
|
|
|
@echo ' localyesconfig - Update current config converting local mods to core'
|
2020-05-12 23:36:07 +08:00
|
|
|
@echo ' except those preserved by LMC_KEEP environment variable'
|
2010-08-01 05:35:31 +08:00
|
|
|
@echo ' defconfig - New config with default from ARCH supplied defconfig'
|
2010-08-01 05:35:34 +08:00
|
|
|
@echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
|
2006-02-26 04:52:50 +08:00
|
|
|
@echo ' allnoconfig - New config where all options are answered with no'
|
2010-08-01 05:35:31 +08: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 17:42:06 +08:00
|
|
|
@echo ' yes2modconfig - Change answers from yes to mod if possible'
|
|
|
|
@echo ' mod2yesconfig - Change answers from mod to yes if possible'
|
2021-10-18 01:43:13 +08:00
|
|
|
@echo ' mod2noconfig - Change answers from mod to no if possible'
|
2010-08-01 05:35:28 +08:00
|
|
|
@echo ' listnewconfig - List new options'
|
2019-11-05 06:10:08 +08:00
|
|
|
@echo ' helpnewconfig - List new options and help text'
|
2018-01-27 06:59:00 +08:00
|
|
|
@echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
|
|
|
|
@echo ' default value without prompting'
|
2014-08-09 07:25:47 +08:00
|
|
|
@echo ' tinyconfig - Configure the tiniest possible kernel'
|
2018-06-02 17:08:02 +08:00
|
|
|
@echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
# ===========================================================================
|
|
|
|
# object files used by all kconfig flavours
|
2021-04-13 23:08:17 +08:00
|
|
|
common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
|
|
|
|
preprocess.o symbol.o util.o
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2019-01-24 18:47:30 +08:00
|
|
|
$(obj)/lexer.lex.o: $(obj)/parser.tab.h
|
2019-05-13 14:22:16 +08:00
|
|
|
HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
|
|
|
|
HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-12-21 16:33:04 +08:00
|
|
|
# conf: Used for defconfig, oldconfig and related targets
|
2020-02-02 00:49:24 +08:00
|
|
|
hostprogs += conf
|
2018-12-21 16:33:04 +08:00
|
|
|
conf-objs := conf.o $(common-objs)
|
|
|
|
|
2018-05-22 15:22:21 +08:00
|
|
|
# nconf: Used for the nconfig target based on ncurses
|
2020-02-02 00:49:24 +08:00
|
|
|
hostprogs += nconf
|
2018-12-21 16:33:04 +08:00
|
|
|
nconf-objs := nconf.o nconf.gui.o $(common-objs)
|
2018-05-22 15:22:21 +08:00
|
|
|
|
2022-12-11 10:54:48 +08: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 15:22:21 +08:00
|
|
|
|
2022-12-11 10:54:48 +08:00
|
|
|
$(obj)/nconf: | $(obj)/nconf-libs
|
|
|
|
$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags
|
2018-05-22 15:22:21 +08:00
|
|
|
|
|
|
|
# mconf: Used for the menuconfig target based on lxdialog
|
2020-02-02 00:49:24 +08: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 12:34:01 +08:00
|
|
|
lxdialog := $(addprefix lxdialog/, \
|
|
|
|
checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
|
|
|
|
mconf-objs := mconf.o $(lxdialog) $(common-objs)
|
2018-05-22 15:22:21 +08:00
|
|
|
|
2022-12-11 10:54:48 +08:00
|
|
|
HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs)
|
2018-05-22 15:22:21 +08:00
|
|
|
$(foreach f, mconf.o $(lxdialog), \
|
2022-12-11 10:54:48 +08:00
|
|
|
$(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags)))
|
2010-08-16 12:19:04 +08:00
|
|
|
|
2022-12-11 10:54:48 +08:00
|
|
|
$(obj)/mconf: | $(obj)/mconf-libs
|
|
|
|
$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags
|
2018-05-22 15:22:19 +08:00
|
|
|
|
|
|
|
# qconf: Used for the xconfig target based on Qt
|
2020-02-02 00:49:24 +08:00
|
|
|
hostprogs += qconf
|
2020-07-30 01:02:38 +08:00
|
|
|
qconf-cxxobjs := qconf.o qconf-moc.o
|
2018-12-21 16:33:07 +08:00
|
|
|
qconf-objs := images.o $(common-objs)
|
2018-05-22 15:22:19 +08:00
|
|
|
|
2022-12-11 10:54:48 +08: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 15:22:19 +08:00
|
|
|
|
|
|
|
quiet_cmd_moc = MOC $@
|
2022-12-11 10:54:48 +08:00
|
|
|
cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@
|
2018-05-22 15:22:19 +08:00
|
|
|
|
2022-12-11 10:54:48 +08:00
|
|
|
$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin
|
2020-07-30 01:02:37 +08:00
|
|
|
$(call if_changed,moc)
|
|
|
|
|
2020-07-30 01:02:38 +08:00
|
|
|
targets += qconf-moc.cc
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-22 15:22:20 +08:00
|
|
|
# gconf: Used for the gconfig target based on GTK+
|
2020-02-02 00:49:24 +08:00
|
|
|
hostprogs += gconf
|
2018-12-21 16:33:07 +08:00
|
|
|
gconf-objs := gconf.o images.o $(common-objs)
|
2018-05-22 15:22:20 +08:00
|
|
|
|
2022-12-11 10:54:48 +08:00
|
|
|
HOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs)
|
|
|
|
HOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags)
|
2018-05-22 15:22:20 +08:00
|
|
|
|
2022-12-11 10:54:48 +08:00
|
|
|
$(obj)/gconf: | $(obj)/gconf-libs
|
|
|
|
$(obj)/gconf.o: | $(obj)/gconf-cflags
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-22 15:22:19 +08:00
|
|
|
# check if necessary packages are available, and configure build flags
|
2022-12-11 10:54:48 +08:00
|
|
|
cmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin)
|
2018-05-22 15:22:19 +08:00
|
|
|
|
2022-12-11 10:54:48 +08:00
|
|
|
$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh
|
|
|
|
$(call cmd,conf_cfg)
|
2018-05-22 15:22:19 +08:00
|
|
|
|
2022-12-11 10:54:48 +08:00
|
|
|
clean-files += *conf-cflags *conf-libs *conf-bin
|