summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* kconfig: add warn-unknown-symbols sanity checkSergey Senozhatsky2023-09-012-2/+28
| | | | | | | | | | | | | | | | | Introduce KCONFIG_WARN_UNKNOWN_SYMBOLS environment variable, which makes Kconfig warn about unknown config symbols. This is especially useful for continuous kernel uprevs when some symbols can be either removed or renamed between kernel releases (which can go unnoticed otherwise). By default KCONFIG_WARN_UNKNOWN_SYMBOLS generates warnings, which are non-terminal. There is an additional environment variable KCONFIG_WERROR that overrides this behaviour and turns warnings into errors. Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: dummy-tools: make MPROFILE_KERNEL checks work on BEJiri Slaby2023-09-011-2/+1
| | | | | | | | | | | | | | | | Commit 2eab791f940b ("kbuild: dummy-tools: support MPROFILE_KERNEL checks for ppc") added support for ppc64le's checks for -mprofile-kernel. Now, commit aec0ba7472a7 ("powerpc/64: Use -mprofile-kernel for big endian ELFv2 kernels") added support for -mprofile-kernel even on big-endian ppc. So lift the check in gcc-check-mprofile-kernel.sh to support big-endian too. Fixes: aec0ba7472a7 ("powerpc/64: Use -mprofile-kernel for big endian ELFv2 kernels") Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* Documentation/llvm: refresh docsNick Desaulniers2023-09-011-44/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent fixes for an embargoed hardware security vulnerability failed to link with ld.lld (LLVM's linker). [0] To be fair, our documentation mentions ``CC=clang`` foremost with ``LLVM=1`` being buried "below the fold." We want to encourage the use of ``LLVM=1`` rather than just ``CC=clang``. Make that suggestion "above the fold" and "front and center" in our docs. While here, the following additional changes were made: - remove the bit about CROSS_COMPILE setting --target=, that's no longer true. - Add ARCH=loongarch to the list of maintained targets (though we're still working on getting defconfig building cleanly at the moment; we're pretty close). - Bump ARCH=powerpc from CC=clang to LLVM=1 status. - Promote ARCH=riscv from being Maintained to being Supported. Android is working towards supporting RISC-V, and we have excellent support from multiple companies in this regard. - Note that the toolchain distribution on kernel.org has been built with profile data from kernel builds. - Note how to use ccache with clang. Link: https://github.com/ClangBuiltLinux/linux/issues/1907 [0] Reviewed-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* modpost: Skip .llvm.call-graph-profile section checkDenis Nikitin2023-09-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | .llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=). Note that .llvm.call-graph-profile intentionally uses REL relocations to decrease the object size, for more details see https://reviews.llvm.org/D104080. The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed. This change fixes the kernel build with clang and a sample profile which currently fails with: "FATAL: modpost: Please add code to calculate addend for this architecture" Signed-off-by: Denis Nikitin <denik@chromium.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Fangrui Song <maskray@google.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: support modules_sign for external modules as wellMasahiro Yamada2023-09-012-18/+18
| | | | | | | | | | The modules_sign target is currently only available for in-tree modules, but it actually works for external modules as well. Move the modules_sign rule to the common part. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* kbuild: support 'make modules_sign' with CONFIG_MODULE_SIG_ALL=nMasahiro Yamada2023-09-011-4/+5
| | | | | | | | | | | | | | | | | | | | | Commit d890f510c8e4 ("MODSIGN: Add modules_sign make target") introduced 'make modules_sign' to manually sign modules. Some time later, commit d9d8d7ed498e ("MODSIGN: Add option to not sign modules during modules_install") introduced CONFIG_MODULE_SIG_ALL. If it was disabled, mod_sign_cmd was set to no-op ('true' command). It affected not only 'make modules_install' but also 'make modules_sign'. With CONFIG_MODULE_SIG_ALL=n, neither modules_install nor modules_sign is able to sign modules. Kbuild has kept that behavior, and nobody has complained about it, but I think it is weird. CONFIG_MODULE_SIG_ALL=n should turn off signing only for modules_install. If users want to sign modules manually, modules_sign should be offered. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* kbuild: move more module installation code to scripts/Makefile.modinstMasahiro Yamada2023-09-012-29/+38
| | | | | | | Move more relevant code to scripts/Makefile.modinst. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* kbuild: reduce the number of mkdir calls during modules_installMasahiro Yamada2023-09-011-1/+7
| | | | | | | | | Calling 'mkdir' for every module results in redundant syscalls. Use $(sort ...) to drop the duplicated directories. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* kbuild: remove $(MODLIB)/source symlinkMasahiro Yamada2023-08-291-6/+2
| | | | | | | | | | | | | | | This reverts the old commit "kbuild: Introduce source symlink in /lib/modules/.../". [1] The current Kbuild does not require $(MODLIB)/source. If the kernel was built in a separate output directory, $(MODLIB)/build/Makefile wraps the Makefile in the source tree. It is enough for building external modules. [1] https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=e09e58867154b8aae0a3ac26a9b1c05962f5a355 Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* kbuild: move depmod rule to scripts/Makefile.modinstMasahiro Yamada2023-08-293-13/+16
| | | | | | | | | depmod is a part of the module installation. scripts/Makefile.modinst is a better place to run it. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* kbuild: add modules_sign to no-{compiler,sync-config}-targetsMasahiro Yamada2023-08-291-2/+2
| | | | | | | Like modules_install, modules_sign should avoid the syncconfig. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* kbuild: do not run depmod for 'make modules_sign'Masahiro Yamada2023-08-291-0/+2
| | | | | | | | | | | | | Commit 961ab4a3cd66 ("kbuild: merge scripts/Makefile.modsign to scripts/Makefile.modinst") started to run depmod at the end of 'make modules_sign'. Move the depmod rule to scripts/Makefile.modinst and run it only when $(modules_sign_only) is empty. Fixes: 961ab4a3cd66 ("kbuild: merge scripts/Makefile.modsign to scripts/Makefile.modinst") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* kbuild: deb-pkg: support DEB_BUILD_OPTIONS=parallel=N in debian/rulesMasahiro Yamada2023-08-292-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'make srcdeb-pkg' generates a source package, which you can build later by using dpkg-buildpackage. In older dpkg versions, 'dpkg-buildpackage --jobs=N' sets not only DEB_BUILD_OPTIONS but also MAKEFLAGS. Hence, passing -j or --jobs to dpkg-buildpackage was enough for kicking the parallel execution. The behavior was changed by commit 1d0ea9b2ba3f ("dpkg-buildpackage: Change -j, --jobs semantics to non-force mode") of dpkg project. [1] Since then, 'dpkg-buildpackage --jobs=N' sets only DEB_BUILD_OPTIONS, which is not parsed by the current debian/rules. To build the package in parallel, you need to pass the alternative --jobs-force option or set the MAKEFLAGS environment variable. Debian policy [2] suggests the following code snippet for debian/rules. ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) MAKEFLAGS += -j$(NUMJOBS) endif I tweaked the code to filter out parallel=1 and passed --jobs=1 to dpkg-buildpackage from scripts/Makefile.package. It is needed to force 'make deb-pkg' without the -j option to run in serial. Please note that dpkg-buildpackage sets parallel=<nproc> in DEB_BUILD_OPTIONS by default (that is, --jobs=auto is the default) and --jobs=1 is needed to restore the serial execution. When dpkg-buildpackage is invoked from Kbuild, the number of jobs is inherited from the top level Makefile. Passing --jobs=1 to dpkg-buildpackage allows debian/rules to skip parsing DEB_BUILD_OPTIONS. [1] https://salsa.debian.org/dpkg-team/dpkg/-/commit/1d0ea9b2ba3f6a2de5b1a6ff55f3df7b71f73db6 [2] https://www.debian.org/doc/debian-policy/ch-source.html#s-debianrules-options Reported-by: Bastian Germann <bage@linutronix.de> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* alpha: remove <asm/export.h>Masahiro Yamada2023-08-221-1/+0
| | | | | | | | | All *.S files under arch/alpha/ have been converted to include <linux/export.h> instead of <asm/export.h>. Remove <asm/export.h>. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* alpha: replace #include <asm/export.h> with #include <linux/export.h>Masahiro Yamada2023-08-2232-32/+32
| | | | | | | | | | | | Commit ddb5cdbafaaa ("kbuild: generate KSYMTAB entries by modpost") deprecated <asm/export.h>, which is now a wrapper of <linux/export.h>. Replace #include <asm/export.h> with #include <linux/export.h>. After all the <asm/export.h> lines are converted, <asm/export.h> and <asm-generic/export.h> will be removed. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* ia64: remove <asm/export.h>Masahiro Yamada2023-08-221-1/+0
| | | | | | | | | All *.S files under arch/ia64/ have been converted to include <linux/export.h> instead of <asm/export.h>. Remove <asm/export.h>. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* ia64: replace #include <asm/export.h> with #include <linux/export.h>Masahiro Yamada2023-08-2221-25/+21
| | | | | | | | | | | | Commit ddb5cdbafaaa ("kbuild: generate KSYMTAB entries by modpost") deprecated <asm/export.h>, which is now a wrapper of <linux/export.h>. Replace #include <asm/export.h> with #include <linux/export.h>. After all the <asm/export.h> lines are converted, <asm/export.h> and <asm-generic/export.h> will be removed. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* sparc: remove <asm/export.h>Masahiro Yamada2023-08-221-1/+0
| | | | | | | | | | All *.S files under arch/sparc/ have been converted to include <linux/export.h> instead of <asm/export.h>. Remove <asm/export.h>. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Sam Ravnborg <sam@ravnborg.org>
* sparc: replace #include <asm/export.h> with #include <linux/export.h>Masahiro Yamada2023-08-2239-39/+40
| | | | | | | | | | | | | Commit ddb5cdbafaaa ("kbuild: generate KSYMTAB entries by modpost") deprecated <asm/export.h>, which is now a wrapper of <linux/export.h>. Replace #include <asm/export.h> with #include <linux/export.h>. After all the <asm/export.h> lines are converted, <asm/export.h> and <asm-generic/export.h> will be removed. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Sam Ravnborg <sam@ravnborg.org>
* kbuild: remove include/ksym from CLEAN_FILESMasahiro Yamada2023-08-221-1/+1
| | | | | | | | This is a remnant of commit 5e9e95cc9148 ("kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion"). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
* MAINTAINERS: Add usr/ (initramfs generation) to KBUILDNicolas Schier2023-08-211-0/+1
| | | | | | | | Add scripts for generating initramfs to KBUILD, to prevent idling of patches for usr/. Signed-off-by: Nicolas Schier <n.schier@avm.de> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* extrawarn: move -Wrestrict into W=1 warningsArnd Bergmann2023-08-201-3/+2
| | | | | | | There are few of these, so enable them whenever W=1 is enabled. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* extrawarn: enable format and stringop overflow warnings in W=1Arnd Bergmann2023-08-201-5/+6
| | | | | | | | | | | | | | | | | | | The stringop and format warnings got disabled globally when they were newly introduced in commit bd664f6b3e376 ("disable new gcc-7.1.1 warnings for now"), 217c3e0196758 ("disable stringop truncation warnings for now") and 5a76021c2eff7 ("gcc-10: disable 'stringop-overflow' warning for now"). In all cases, the sentiment at the time was that the warnings are useful, and we actually addressed a number of real bugs based on them, but we never managed to eliminate them all because even the build bots using W=1 builds only see the -Wstringop-truncation warnings that are enabled at that level. Move these into the W=1 section to give them a larger build coverage and actually eliminate them over time. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: avoid duplicate warning optionsArnd Bergmann2023-08-201-17/+26
| | | | | | | | | | | Some warning options are disabled at one place and then conditionally re-enabled later in scripts/Makefile.extrawarn. For consistency, rework this file so each of those warnings only gets etiher enabled or disabled based on the W= flags but not both. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: consolidate warning flags in scripts/Makefile.extrawarnArnd Bergmann2023-08-202-88/+90
| | | | | | | | | | | | | Warning options are enabled and disabled in inconsistent ways and inconsistent locations. Start rearranging those by moving all options into Makefile.extrawarn. This should not change any behavior, but makes sure we can group them in a way that ensures that each warning that got temporarily disabled is turned back on at an appropriate W=1 level later on. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: port qconf to work with Qt6 in addition to Qt5Boris Kolpackov2023-08-162-21/+44
| | | | | | | | Tested with Qt5 5.15 and Qt6 6.4. Note that earlier versions of Qt5 are no longer guaranteed to work. Signed-off-by: Boris Kolpackov <boris@codesynthesis.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* docs: kbuild: Document search jump featureJesse Taube2023-08-131-0/+8
| | | | | | | | | | | | | Menuconfig has a feature where you can "press the key in the (#) prefix to jump directly to that location. You will be returned to the current search results after exiting this new menu." This feature is poorly documented, so add it to the kconfig.rst documentation. Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: nconf: Add search jump featureJesse Taube2023-08-133-15/+140
| | | | | | | | | | | | | Menuconfig has a feature where you can "press the key in the (#) prefix to jump directly to that location. You will be returned to the current search results after exiting this new menu." This commit adds this feature to nconfig, with almost identical code. Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* scripts/setlocalversion: also consider annotated tags of the form ↵Rasmus Villemoes2023-08-081-10/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vx.y.z-${file_localversion} Commit 6ab7e1f95e96 ("setlocalversion: use only the correct release tag for git-describe") was absolutely correct to limit which annotated tags would be used to compute the -01234-gabcdef suffix. Otherwise, if some random annotated tag exists closer to HEAD than the vX.Y.Z one, the commit count would be too low. However, since the version string always includes the ${file_localversion} part, now the problem is that the count can be too high. For example, building an 6.4.6-rt8 kernel with a few patches on top, I currently get $ make -s kernelrelease 6.4.6-rt8-00128-gd78b7f406397 But those 128 commits include the 100 commits that are in v6.4.6..v6.4.6-rt8, so this is somewhat misleading. Amend the logic so that, in addition to the linux-next consideration, the script also looks for a tag corresponding to the 6.4.6-rt8 part of what will become the `uname -r` string. With this patch (so 29 patches on top of v6.4.6-rt8), one instead gets $ make -s kernelrelease 6.4.6-rt8-00029-gd533209291a2 While there, note that the line git describe --exact-match --match=$tag $tag 2>/dev/null obviously asks if $tag is an annotated tag, but it does not actually tell if the commit pointed to has any relation to HEAD. So remove both uses of --exact-match, and instead just ask if the description generated is identical to the tag we provided. Since we then already have the result of git describe --match=$tag we also end up reducing the number of times we invoke "git describe". Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* scripts/setlocalversion: clean up stale commentRasmus Villemoes2023-08-081-1/+1
| | | | | | | | | Nobody has complained since 2a73cce2dad3 ("scripts/setlocalversion: remove mercurial, svn and git-svn supports"), so let's also clean up the header comment accordingly. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: deb-pkg: split debian/rulesMasahiro Yamada2023-08-082-29/+33
| | | | | | | | | | | | | | debian/rules is generated by shell, but the escape sequence (\$) is unreadable. debian/rules embeds only two variables (ARCH and KERNELRELEASE). Split them out to debian/rules.vars, and check-in the rest of Makefile code to scripts/package/debian/rules. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* kbuild: deb-pkg: use Debian compliant shebang for debian/rulesMasahiro Yamada2023-08-082-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Debian Policy "4.9. Main building script: debian/rules" requires "debian/rules must start with the line #!/usr/bin/make -f". [1] Currently, Kbuild does not follow this policy. When Kbuild generates debian/rules, "#!$(command -v $MAKE) -f" is expanded by shell. The resuling string may not be "#!/usr/bin/make -f". There was a reason to opt out the Debian policy. If you run '/path/to/my/custom/make deb-pkg', debian/rules must also be invoked by the same Make program. If #!/usr/bin/make were hard-coded in debian/rules, the sub-make would be executed by a possibly different Make version. This is problematic due to the MAKEFLAGS incompatibility, especially the job server flag. Old Make versions used --jobserver-fds to propagate job server file descriptors, but Make >= 4.2 uses --jobserver-auth. The flag disagreement between the parent/child Makes would result in a process fork explosion. However, having a non-standard path in the shebang causes another issue; the generated source package is not portable as such a path does not exist in other build environments. This commit solves those conflicting demands. Hard-code '#!/usr/bin/make -f' in debian/rules to create a portable and Debian-compliant source package. Pass '--rules-file=$(MAKE) -f debian/rules' when dpkg-buildpackage is invoked from Makefile so that debian/rules is executed by the same Make program as used to start Kbuild. [1] https://www.debian.org/doc/debian-policy/ch-source.html#main-building-script-debian-rules Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
* modpost: remove ElF_Rela variables from for-loop in section_rel(a)Masahiro Yamada2023-07-311-14/+11
| | | | | | | | | Remove the Elf_Rela variables used in the for-loop in section_rel(). This makes the code consistent; section_rel() only uses Elf_Rel, section_rela() only uses Elf_Rela. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* modpost: clean up MIPS64 little endian relocation codeMasahiro Yamada2023-07-312-55/+43
| | | | | | | | | MIPS64 little endian target has an odd encoding of r_info. This commit makes the special handling less ugly. It is still ugly, but #if conditionals will go away, at least. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* modpost: pass r_type to addend_*_rel()Masahiro Yamada2023-07-311-13/+11
| | | | | | | | | All of addend_*_rel() need the Elf_Rela pointer just for calculating ELF_R_TYPE(r->r_info). You can do it on the caller to de-duplicate the code. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* modpost: change return type of addend_*_rel()Masahiro Yamada2023-07-311-39/+24
| | | | | | | Now that none of addend_*_rel() returns a meaningful value (the return value is always 0), change all of them to return the value of r_addend. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: skip build dependency check on non-rpm systemsMasahiro Yamada2023-07-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | Commit 8818039f959b ("kbuild: add ability to make source rpm buildable using koji") added the BuildRequires: field. Checking the build dependency is fine, but one annoyance is that 'make (bin)rpm-pkg' fails on non-rpm systems [1]. For example, Debian provides rpmbuild via 'apt install rpm', but of course cannot meet the requirement listed in the BuildRequires: field. It is possible to pass RPMOPTS=--nodeps to work around it, but it is reasonable to do it automatically. If 'rpm -q rpm' fails, it is not an RPM-managed system. (The command 'rpm' is not installed at all, or was installed by other means.) In that case, pass --nodeps to skip the build dependency check. [1]: https://lore.kernel.org/linux-kbuild/Y6mkdYQYmjUz7bqV@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com/ Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: refactor *rpm-pkg targetsMasahiro Yamada2023-07-252-33/+29
| | | | | | | | | | | | | | Merge the similar build targets. Also, make the output location consistent. Previously, source packages were created in the build directory, while binary packages under ~/rpmbuild/RPMS/. Now, Kbuild creates the rpmbuild/ directory in the build directory, and saves all packages under it. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: build the kernel in-place for rpm-pkgMasahiro Yamada2023-07-251-0/+1
| | | | | | | | | Currently, 'make rpm-pkg' always builds the kernel from the pristine source tree in the ~/rpmbuild/BUILD/ directory. Build the kernel incrementally just like 'make binrpm-pkg'. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: rename binkernel.spec to kernel.specMasahiro Yamada2023-07-254-4/+6
| | | | | | | | Now kernel.spec and binkernel.spec have the exactly same contents. Use kernel.spec for binrpm-pkg as well. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: split out the body of spec fileMasahiro Yamada2023-07-252-120/+120
| | | | | | | | | | Most of the lines in the spec file are independent of any build condition. Split the body of the spec file into scripts/package/kernel.spec. scripts/package/mkspec will prepend some env-dependent variables. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: introduce %{with_devel} switch to select devel packageMasahiro Yamada2023-07-252-29/+26
| | | | | | | | | | scripts/package/mkspec preprocesses the spec file by sed, but it is unreadable. This commit removes the last portion of the sed scripting. Remove the $S$M prefixes from the conditionally generated lines. Instead, surround the code with %if %{with_devel} ... %endif. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: run modules_install for non-modular kernelMasahiro Yamada2023-07-251-9/+6
| | | | | | | | For the same reason as commit 4243afdb9326 ("kbuild: builddeb: always make modules_install, to install modules.builtin*"), run modules_install even when CONFIG_MODULES=n to install modules.builtin*. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: invoke the kernel build from rpmbuild for binrpm-pkgMasahiro Yamada2023-07-252-16/+17
| | | | | | | | | | To reduce the preprocess of the spec file, invoke the kernel build from rpmbuild. Run init/build-version to increment the release number not only for binrpm-pkg but also for srcrpm-pkg and rpm-pkg. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: use a dummy string for _arch when undefinedMasahiro Yamada2023-07-251-3/+2
| | | | | | | If this affects only %{buildroot}, it should be enough to use a fixed string for _arch when it is undefined. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: derive the Version from %{KERNELRELEASE}Masahiro Yamada2023-07-251-3/+1
| | | | | | Avoid hard-coding the Version field in the generated spec file. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: refactor kernel-devel RPM package and linux-headers Deb packageMasahiro Yamada2023-07-253-33/+41
| | | | | | | | | | | | | | | The kernel-devel RPM package and the linux-headers Debian package provide headers and scripts needed for building external modules. They copy the necessary files in slightly different ways - the RPM copies almost everything except some exclude patterns, while the Debian copies less number of files. There is no need to maintain different code to do the same thing. Split the Debian code out to scripts/package/install-extmod-build, which is called from both of the packages. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: add a phony target to run a command with Kbuild env varsMasahiro Yamada2023-07-253-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are some cases where we want to run a command with the same environment variables as Kbuild uses. For example, 'make coccicheck' invokes scripts/coccicheck from the top Makefile so that the script can reference to ${LINUXINCLUDE}, ${KBUILD_EXTMOD}, etc. The top Makefile defines several phony targets that run a script. We do it also for an internally used script, which results in a somewhat complex call graph. One example: debian/rules binary-arch -> make intdeb-pkg -> scripts/package/builddeb It is also tedious to add a dedicated target like 'intdeb-pkg' for each use case. Add a generic target 'run-command' to run an arbitrary command in an environment with all Kbuild variables set. The usage is: $ make run-command KBUILD_RUN_COMMAND=<command> The concept is similar to: $ dpkg-architecture -c <command> This executes <command> in an environment which has all DEB_* variables defined. Convert the existing 'make intdeb-pkg'. Another possible usage is to interrogate a Make variable. $ make run-command KBUILD_RUN_COMMAND='echo $(KBUILD_CFLAGS)' might be useful to see KBUILD_CFLAGS set by the top Makefile. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: replace $KERNELRELEASE in spec file with %{KERNELRELEASE}Masahiro Yamada2023-07-251-29/+30
| | | | | | Avoid hard-coding the value of KERNELRELEASE in the generated spec file. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kbuild: rpm-pkg: replace $__KERNELRELEASE in spec file with %{version}Masahiro Yamada2023-07-251-2/+2
| | | | | | ${version} will be replaced with the value of the Version field. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>