Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile.build 14 KiB

kconfig: switch to Kconfig This commit enables Kconfig. Going forward, we use Kconfig for the board configuration. mkconfig will never be used. Nor will include/config.mk be generated. Kconfig must be adjusted for U-Boot because our situation is a little more complicated than Linux Kernel. We have to generate multiple boot images (Normal, SPL, TPL) from one source tree. Each image needs its own configuration input. Usage: Run "make <board>_defconfig" to do the board configuration. It will create the .config file and additionally spl/.config, tpl/.config if SPL, TPL is enabled, respectively. You can use "make config", "make menuconfig" etc. to create a new .config or modify the existing one. Use "make spl/config", "make spl/menuconfig" etc. for spl/.config and do likewise for tpl/.config file. The generic syntax of configuration targets for SPL, TPL is: <target_image>/<config_command> Here, <target_image> is either 'spl' or 'tpl' <config_command> is 'config', 'menuconfig', 'xconfig', etc. When the configuration is done, run "make". (Or "make <board>_defconfig all" will do the configuration and build in one time.) For futher information of how Kconfig works in U-Boot, please read the comment block of scripts/multiconfig.py. By the way, there is another item worth remarking here: coexistence of Kconfig and board herder files. Prior to Kconfig, we used C headers to define a set of configs. We expect a very long term to migrate from C headers to Kconfig. Two different infractructure must coexist in the interim. In our former configuration scheme, include/autoconf.mk was generated for use in makefiles. It is still generated under include/, spl/include/, tpl/include/ directory for the Normal, SPL, TPL image, respectively. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Acked-by: Simon Glass <sjg@chromium.org>
6 years ago
kconfig: switch to Kconfig This commit enables Kconfig. Going forward, we use Kconfig for the board configuration. mkconfig will never be used. Nor will include/config.mk be generated. Kconfig must be adjusted for U-Boot because our situation is a little more complicated than Linux Kernel. We have to generate multiple boot images (Normal, SPL, TPL) from one source tree. Each image needs its own configuration input. Usage: Run "make <board>_defconfig" to do the board configuration. It will create the .config file and additionally spl/.config, tpl/.config if SPL, TPL is enabled, respectively. You can use "make config", "make menuconfig" etc. to create a new .config or modify the existing one. Use "make spl/config", "make spl/menuconfig" etc. for spl/.config and do likewise for tpl/.config file. The generic syntax of configuration targets for SPL, TPL is: <target_image>/<config_command> Here, <target_image> is either 'spl' or 'tpl' <config_command> is 'config', 'menuconfig', 'xconfig', etc. When the configuration is done, run "make". (Or "make <board>_defconfig all" will do the configuration and build in one time.) For futher information of how Kconfig works in U-Boot, please read the comment block of scripts/multiconfig.py. By the way, there is another item worth remarking here: coexistence of Kconfig and board herder files. Prior to Kconfig, we used C headers to define a set of configs. We expect a very long term to migrate from C headers to Kconfig. Two different infractructure must coexist in the interim. In our former configuration scheme, include/autoconf.mk was generated for use in makefiles. It is still generated under include/, spl/include/, tpl/include/ directory for the Normal, SPL, TPL image, respectively. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Acked-by: Simon Glass <sjg@chromium.org>
6 years ago
kconfig: switch to single .config configuration When Kconfig for U-boot was examined, one of the biggest issues was how to support multiple images (Normal, SPL, TPL). There were actually two options, "single .config" and "multiple .config". After some discussions and thought experiments, I chose the latter, i.e. to create ".config", "spl/.config", "tpl/.config" for Normal, SPL, TPL, respectively. It is true that the "multiple .config" strategy provided us the maximum flexibility and helped to avoid duplicating CONFIGs among Normal, SPL, TPL, but I have noticed some fatal problems: [1] It is impossible to share CONFIG options across the images. If you change the configuration of Main image, you often have to adjust some SPL configurations correspondingly. Currently, we cannot handle the dependencies between them. It means one of the biggest advantages of Kconfig is lost. [2] It is too painful to change both ".config" and "spl/.config". Sunxi guys started to work around this problem by creating a new configuration target. Commit cbdd9a9737cc (sunxi: kconfig: Add %_felconfig rule to enable FEL build of sunxi platforms.) added "make *_felconfig" to enable CONFIG_SPL_FEL on both images. Changing the configuration of multiple images in one command is a generic demand. The current implementation cannot propose any good solution about this. [3] Kconfig files are getting ugly and difficult to understand. Commit b724bd7d6349 (dm: Kconfig: Move CONFIG_SYS_MALLOC_F_LEN to Kconfig) has sprinkled "if !SPL_BUILD" over the Kconfig files. [4] The build system got more complicated than it should be. To adjust Linux-originated Kconfig to U-Boot, the helper script "scripts/multiconfig.sh" was introduced. Writing a complicated text processor is a shell script sometimes caused problems. Now I believe the "single .config" will serve us better. With it, all the problems above would go away. Instead, we will have to add some CONFIG_SPL_* (and CONFIG_TPL_*) options such as CONFIG_SPL_DM, but we will not have much. Anyway, this is what we do now in scripts/Makefile.spl. I admit my mistake with my apology and this commit switches to the single .config configuration. It is not so difficult to do that: - Remove unnecessary processings from scripts/multiconfig.sh This file will remain for a while to support the current defconfig format. It will be removed after more cleanups are done. - Adjust some makefiles and Kconfigs - Add some entries to include/config_uncmd_spl.h and the new file scripts/Makefile.uncmd_spl. Some CONFIG options that are not supported on SPL must be disabled because one .config is shared between SPL and U-Boot proper going forward. I know this is not a beautiful solution and I think we can do better, but let's see how much we will have to describe them. - update doc/README.kconfig More cleaning up patches will follow this. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Reviewed-by: Simon Glass <sjg@chromium.org>
5 years ago
kconfig: switch to Kconfig This commit enables Kconfig. Going forward, we use Kconfig for the board configuration. mkconfig will never be used. Nor will include/config.mk be generated. Kconfig must be adjusted for U-Boot because our situation is a little more complicated than Linux Kernel. We have to generate multiple boot images (Normal, SPL, TPL) from one source tree. Each image needs its own configuration input. Usage: Run "make <board>_defconfig" to do the board configuration. It will create the .config file and additionally spl/.config, tpl/.config if SPL, TPL is enabled, respectively. You can use "make config", "make menuconfig" etc. to create a new .config or modify the existing one. Use "make spl/config", "make spl/menuconfig" etc. for spl/.config and do likewise for tpl/.config file. The generic syntax of configuration targets for SPL, TPL is: <target_image>/<config_command> Here, <target_image> is either 'spl' or 'tpl' <config_command> is 'config', 'menuconfig', 'xconfig', etc. When the configuration is done, run "make". (Or "make <board>_defconfig all" will do the configuration and build in one time.) For futher information of how Kconfig works in U-Boot, please read the comment block of scripts/multiconfig.py. By the way, there is another item worth remarking here: coexistence of Kconfig and board herder files. Prior to Kconfig, we used C headers to define a set of configs. We expect a very long term to migrate from C headers to Kconfig. Two different infractructure must coexist in the interim. In our former configuration scheme, include/autoconf.mk was generated for use in makefiles. It is still generated under include/, spl/include/, tpl/include/ directory for the Normal, SPL, TPL image, respectively. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Acked-by: Simon Glass <sjg@chromium.org>
6 years ago
kconfig: switch to single .config configuration When Kconfig for U-boot was examined, one of the biggest issues was how to support multiple images (Normal, SPL, TPL). There were actually two options, "single .config" and "multiple .config". After some discussions and thought experiments, I chose the latter, i.e. to create ".config", "spl/.config", "tpl/.config" for Normal, SPL, TPL, respectively. It is true that the "multiple .config" strategy provided us the maximum flexibility and helped to avoid duplicating CONFIGs among Normal, SPL, TPL, but I have noticed some fatal problems: [1] It is impossible to share CONFIG options across the images. If you change the configuration of Main image, you often have to adjust some SPL configurations correspondingly. Currently, we cannot handle the dependencies between them. It means one of the biggest advantages of Kconfig is lost. [2] It is too painful to change both ".config" and "spl/.config". Sunxi guys started to work around this problem by creating a new configuration target. Commit cbdd9a9737cc (sunxi: kconfig: Add %_felconfig rule to enable FEL build of sunxi platforms.) added "make *_felconfig" to enable CONFIG_SPL_FEL on both images. Changing the configuration of multiple images in one command is a generic demand. The current implementation cannot propose any good solution about this. [3] Kconfig files are getting ugly and difficult to understand. Commit b724bd7d6349 (dm: Kconfig: Move CONFIG_SYS_MALLOC_F_LEN to Kconfig) has sprinkled "if !SPL_BUILD" over the Kconfig files. [4] The build system got more complicated than it should be. To adjust Linux-originated Kconfig to U-Boot, the helper script "scripts/multiconfig.sh" was introduced. Writing a complicated text processor is a shell script sometimes caused problems. Now I believe the "single .config" will serve us better. With it, all the problems above would go away. Instead, we will have to add some CONFIG_SPL_* (and CONFIG_TPL_*) options such as CONFIG_SPL_DM, but we will not have much. Anyway, this is what we do now in scripts/Makefile.spl. I admit my mistake with my apology and this commit switches to the single .config configuration. It is not so difficult to do that: - Remove unnecessary processings from scripts/multiconfig.sh This file will remain for a while to support the current defconfig format. It will be removed after more cleanups are done. - Adjust some makefiles and Kconfigs - Add some entries to include/config_uncmd_spl.h and the new file scripts/Makefile.uncmd_spl. Some CONFIG options that are not supported on SPL must be disabled because one .config is shared between SPL and U-Boot proper going forward. I know this is not a beautiful solution and I think we can do better, but let's see how much we will have to describe them. - update doc/README.kconfig More cleaning up patches will follow this. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Reviewed-by: Simon Glass <sjg@chromium.org>
5 years ago
kbuild: improve Kbuild speed Kbuild brought about many advantages for us but a significant performance regression was reported by Simon Glass. After some discussions and analysis, it turned out its main cause is in $(call cc-option,...). Historically, U-Boot parses all config.mk (arch/*/config.mk and board/*/config.mk) every time descending into subdirectories. That means cc-options are evaluated over and over again. $(call cc-option,...) is useful but costly. So we want to evaluate them only in ./Makefile and spl/Makefile and export compiler flags. This commit changes the build system as follows: - Modify scripts/Makefile.build to not include config.mk Instead, add $(PLATFORM_CPPFLAGS) to asflags-y, ccflags-y, cppflags-y. - Export many variables Going forward, Kbuild will not parse config.mk files when it descends into subdirectories. If we want to set variables in config.mk and use them in subdirectories, they must be exported. This is the list of variables to get exported: PLATFORM_CPPFLAGS CPUDIR BOARDDIR OBJCOPYFLAGS LDFLAGS LDFLAGS_FINAL (used in nand_spl/board/*/*/Makefile) CONFIG_STANDALONE_LOAD_ADDR (used in examples/standalone/Makefile) SYM_PREFIX (used in examples/standalone/Makefile) RELFLAGS (used in examples/standalone/Makefile) - Delete CPPFLAGS This variable has been replaced with PLATFORM_CPPFLAGS - Copy gcclibdir from example/standalone/Makefile to arch/sparc/config.mk The reference in CONFIG_STANDALONE_LOAD_ADDR must be resolved before it is exported. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Reported-by: Simon Glass <sjg@chromium.org> Acked-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> [on Sandbox] Tested-by: Stephen Warren <swarren@nvidia.com> [on Tegra]
6 years ago
kbuild: sync with Linux 4.1 Update some build scripts to match Linux 4.1. Commit-based syncing was done so as not to break U-Boot specific changes. The previous big sync was from Linux 3.18-rc1 by commit 176d09827725 (kbuild: sync misc scripts with Linux 3.18-rc1). The commits imported from Linux (some with adjustments) are: [1] commit 9fb5e5372208973984a23ee6f5f025c05d364633 Author: Robert Richter <rrichter@cavium.com> dts, kbuild: Factor out dtbs install rules to Makefile.dtbinst [2] commit 371fdc77af44f4cb32475fd499e1d912ccc30890 Author: Masahiro Yamada <yamada.m@jp.panasonic.com> kbuild: collect shorthands into scripts/Kbuild.include [3] commit a29b82326ed4eb5567b03c85b52c6891578d5a03 Author: Michal Marek <mmarek@suse.cz> kbuild: Remove duplicate $(cmd) definition in Makefile.clean [4] commit 1846dfbde3e8a53f3673dcb1c1b79fd9b3f8d40d Author: Masahiro Yamada <yamada.m@jp.panasonic.com> kbuild: remove redundant -rR flag of hdr-inst [5] commit 34948e0bbf98640fc1821751b01d2f0cd17d84d5 Author: Michal Marek <mmarek@suse.cz> kbuild: Drop support for clean-rule [6] commit a16c5f99a28c9945165c46da27fff8e6f26f8736 Author: Michal Marek <mmarek@suse.cz> kbuild: Fix removal of the debian/ directory [7] commit d0d38cd9e853db11e0242b3df4c9c3c4a663fbb4 Author: Masahiro Yamada <yamada.m@jp.panasonic.com> kbuild: use mixed-targets when two or more config targets are given [8] commit dd33c03b18b3f2db791eb6a17c37d2de66e4de18 Author: Masahiro Yamada <yamada.m@jp.panasonic.com> kbuild: fix cc-ifversion macro [9] commit 665d92e38f65d70796aad2b8e49e42e80815d4a4 Author: Masahiro Yamada <yamada.m@jp.panasonic.com> kbuild: do not add $(call ...) to invoke cc-version or cc-fullversion [10] commit 6dcb4e5edf39e3b65a75ca76f087b2fdbee8a808 Author: Masahiro Yamada <yamada.m@jp.panasonic.com> kbuild: allow cc-ifversion to have the argument for false condition [11] commit c0a80c0c27e5e65b180a25e6c4c2f7ef9e386cd3 Author: Heiko Carstens <heiko.carstens@de.ibm.com> ftrace: allow architectures to specify ftrace compile options [12] commit 0b24becc810dc3be6e3f94103a866f214c282394 Author: Andrey Ryabinin <a.ryabinin@samsung.com> kasan: add kernel address sanitizer infrastructure [13] commit 4218affdf57f938c04e3a916a9685ee27079f377 Author: Masahiro Yamada <yamada.m@jp.panasonic.com> kbuild: remove warning about "make depend" [14] commit 77479b38e2f58890eb221a0418357502a5b41cd6 Author: Nathan Rossi <nathan.rossi@xilinx.com> kbuild: Create directory for target DTB Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Robert Richter <rrichter@cavium.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com> Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Michal Marek <mmarek@suse.cz> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
5 years ago
kconfig: re-sync with Linux 4.17-rc4 Align Kconfig to Linux 4.17-rc4 with minimal impact on non-kconfig files. Previous Kconfig sync was done by commit bf7ab1e70fd762 ("kconfig: re-sync with Linux 4.10") and it achieved almost perfect alignment with a few (intended) exceptions, caused by below U-boot commits: [A] v2015.04 5f9eb2207500 ("kbuild: remove scripts/multiconfig.sh") [B] v2015.07 20c20826efab ("Kconfig: Enable usage of escape char '\' in string values") [C] v2016.01 da58dec86616 ("Various Makefiles: Add SPDX-License-Identifier tags") [D] v2016.03 5b8031ccb4ed ("Add more SPDX-License-Identifier tags") [E] v2016.03 192bc6948b02 ("Fix GCC format-security errors and convert sprintfs.") Here is the list of Kconfig commits which followed the v4.10 alignment: [F] v2018.01 0931ed3c0d0f ("kconfig/symbol.c: use correct pointer type argument for sizeof") [G] v2018.03 1414e09b4f25 ("kconfig: revert change that was not needed for -Wformat-security") [H] v2018.05 83d290c56fab ("SPDX: Convert all of our single license tags to Linux Kernel style") Commit [F] was subsequently applied to Linux kernel as commit [I] with the same patch id, so it won't contribute to further misalignment. [I] v4.15-rc1 88127dae6ed9 ("kconfig/symbol.c: use correct pointer type argument for sizeof") Commit [G] is a Kconfig-specific revert of commit [E]. Commit [H] relocated and reformatted the license doing no functional change. In summary, the only functional change that makes U-boot Kconfig diverge from Linux Kconfig is commit [B]. After a brief analysis, the purpose of [B] seems to be placing "\n" literals in string symbols like CONFIG_AUTOBOOT_PROMPT="autoboot in %d seconds\n" in order to pass them directly to printf and expect correct output at runtime. Currently, Linux doesn't seem to have this requirement, so for the moment [B] looks like a U-boot specific feature/fix. From point of view of further Kconfig alignment and backporting efforts, it is highly desired that commits like [B] are propagated to Linux and any Kconfig fixes/features are contributed to Linux kernel first. This specific Kconfig re-sync just keeps [B] in place. Contrary to 4.10 Kconfig re-sync (which achieves zero non-kconfig changes), 4.17-rc4 re-sync does some amount of updates in Kbuild (striving to keep them at minimum), due to a number of reasons: * Kbuild is affected by the removal of Kconfig "*shipped" files and now requires flex and bison pre-installed on the host. * PYTHON{2,3} variables are defined in top-level Makefile as prerequisite for running the newly developed Kconfig unit tests. * silentoldconfig becomes an "internal implementation detail" deprecated for external use, being renamed to syncconfig. The exact non-kconfig files touched by this commit are: $ git show --format="" --stat -- ':!scripts/kconfig' .gitignore | 2 ++ Makefile | 9 +++++++-- scripts/Makefile.build | 11 +++++++++++ scripts/Makefile.lib | 41 ++++++++++++----------------------------- The imported Linux commits touching the above files are: c054be10ffdbd5 ("remove gperf left-overs from build system") 73a4f6dbe70a1b ("kbuild: add LEX and YACC variables") 033dba2ec06c47 ("kbuild: prepare to remove C files pre-generated by flex and bison") eea199b445f64c ("kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX") e71de5ee08dcb0 ("kbuild: remove remaining use of undefined YACC_PREFIX") d59fbbd09d5d6b ("kbuild: replace hardcoded bison in cmd_bison_h with $(YACC)") 911a91c39cabcb H ("kconfig: rename silentoldconfig to syncconfig") 59889300274569 (".gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore") 9a8dfb394c0467 ("kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile") 833e622459432e H ("genksyms: generate lexer and parser during build instead of shipping") b23d1a241f4eb4 H ("kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically") e9781b52d4e0e3 H ("kbuild: add PYTHON2 and PYTHON3 variables") The commits marked with 'H' are assessed as "hard" (build will fail) prerequisites and the rest of them are assessed as "soft" prerequisites for the re-sync. In spite of relatively high number of non-H commits, they belong to this Kconfig update topic-wise and decrease the number of cherry pick conflicts for many commits in this series. Additional effort can be put in eliminating the soft prerequisites, if really needed. The commits which contributed to this Kconfig re-sync are listed below. Whenever a conflict resolution has been performed (mostly by hand, but sometimes automatically by git), it is revealed by the '!' sign in the second column, which means a patch id mismatch between Linux and U-boot commits: 9be3213b14d44f ("gconfig: remove misleading parentheses around a condition") ff85a1a80e0034 ("kconfig: Check for libncurses before menuconfig") ad8181060788c8 ("kconfig: fix sparse warnings in nconfig") cb77f0d623ff33 ! ("scripts: Switch to more portable Perl shebang") bb3290d91695bb ! ("Remove gperf usage from toolchain") c054be10ffdbd5 ("remove gperf left-overs from build system") b24413180f5600 ! ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license") 9059a3493efea6 ! ("kconfig: fix relational operators for bool and tristate symbols") 2c37e08464a850 ("kconfig: Warn if choice default is not in choice") 33ca1a24866373 ("kconfig: Document the 'menu' struct") 52aede4ba5efd1 ("kconfig: Document the 'symbol' struct") c873443430ebd1 ("kconfig: Sync zconf.y with zconf.tab.c_shipped") 9a826842ff2fbd ("kconfig: Rename menu_check_dep() to rewrite_m()") fa8cedaef814ce ("kconfig: Clarify expression rewriting") f77850d3fe0c96 ("kconfig: Clean up modules handling and fix crash") e3b03bf29d6b99 ("kconfig: display recursive dependency resolution hint just once") 73a4f6dbe70a1b ! ("kbuild: add LEX and YACC variables") 033dba2ec06c47 ! ("kbuild: prepare to remove C files pre-generated by flex and bison") 29c833061c1d8c ("kconfig: generate lexer and parser during build instead of shipping") 26e47a3c11a25c ("kconfig: Don't leak symbol names during parsing") 24161a6711c945 ("kconfig: Don't leak 'source' filenames during parsing") bc28fe1d5ede88 ("kconfig: Don't leak 'option' arguments during parsing") 0724a7c32a54e3 ("kconfig: Don't leak main menus during parsing") ae7440ef0c8013 ("kconfig: Fix automatic menu creation mem leak") 5b1374b3b3c2fc ("kconfig: Fix expr_free() E_NOT leak") 7cf33f88e29410 ("kconfig: Fix choice symbol expression leak") 05cccce580456d ("kconfig: Document automatic submenu creation code") 0735f7e5def2ab ("kconfig: Document important expression functions") df60f4b92d3d0b ("kconfig: Remove menu_end_entry()") b92d804a51796b ("kconfig: drop 'boolean' keyword") 6479f327dea60d ("kconfig: Warn if there is more than one help text") 52e58a3caeba5d ("kconfig: make input_mode static") 5a3dc717b3c785 ("kconfig: make xfgets() really static") 84dd95d4f87a0d ("kconfig: make conf_unsaved a local variable of conf_read()") 765f4cdef6f80d ("kconfig: use default 'yy' prefix for lexer and parser") eea199b445f64c ("kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX") e71de5ee08dcb0 ("kbuild: remove remaining use of undefined YACC_PREFIX") d59fbbd09d5d6b ! ("kbuild: replace hardcoded bison in cmd_bison_h with $(YACC)") 3e41ba05b6d60c ("kconfig: Document SYMBOL_OPTIONAL logic") d3465af60f4471 ("kconfig: Clarify choice dependency propagation") 9d1a9e8bc18bea ("kconfig: Document 'if' flattening logic") b53688014e3325 ("kconfig: Clarify menu and 'if' dependency propagation") d0fd0428ecf04b ("kconfig: fix make xconfig when gettext is missing") 312ee68752faaa ("kconfig: announce removal of oldnoconfig if used") 1ccb27143360bd ("kconfig: make "Selected by:" and "Implied by:" readable") cedd55d49dee94 ! ("kconfig: Remove silentoldconfig from help and docs; fix kconfig/conf's help") 1b9eda2e4892cb ("kconfig: Warn if help text is blank") cb67ab2cd2b8ab ("kconfig: do not write choice values when their dependency becomes n") 4f208f392103e8 ("kconfig: show '?' prompt even if no help text is available") cd58a91def2acc ("kconfig: remove 'config*' pattern from .gitignnore") d2a04648a5dbc3 ("kconfig: remove check_stdin()") f3ff6fb5db68bc ("kconfig: echo stdin to stdout if either is redirected") 9e3e10c725360b ("kconfig: send error messages to stderr") d717f24d8c6808 ("kconfig: add xrealloc() helper") 523ca58b7db2e3 ("kconfig: remove const qualifier from sym_expand_string_value()") cd81fc82b93fa4 ("kconfig: add xstrdup() helper") f4bc1eefc1608e ("kconfig: set SYMBOL_AUTO to the symbol marked with defconfig_list") bf0bbdcf100322 ("kconfig: Don't leak choice names during parsing") 1a90ce36c6eff6 ("kconfig: Update ncurses package names for menuconfig") 5ae6fcc4bb82bd ("kconfig: fix line number in recursive inclusion error message") 07a422bb213adb ! ("kbuild: restore autoksyms.h touch to the top Makefile") 9a47ceec543bfb ("kconfig: clean-up reverse dependency help implementation") d9119b5925a03b ("kconfig: Print reverse dependencies in groups") f467c5640c29ad ("kconfig: only write '# CONFIG_FOO is not set' for visible symbols") 59a80b5e892dde ("kconfig: do not call check_conf() for olddefconfig") 4bb3a5b085cd6f ("kconfig: remove unneeded input_mode test in conf()") 99f0b6578bab44 ("kconfig: remove redundant input_mode test for check_conf() loop") 2aad9b89621386 ("kconfig: hide irrelevant sub-menus for oldconfig") 81d2bc2273052e ("kconfig: invoke oldconfig instead of silentoldconfig from local*config") 911a91c39cabcb ! ("kconfig: rename silentoldconfig to syncconfig") 2a61625835c7c8 ! ("kconfig: remove redundant streamline_config.pl prerequisite") 022a4bf6b59dfd ("kconfig: tests: add framework for Kconfig unit testing") 1903c511905984 ("kconfig: tests: add basic choice tests") 49ac3c0c3aa3b7 ("kconfig: tests: test automatic submenu creation") b76960c0f6b25d ("kconfig: tests: test if new symbols in choice are asked") 930c429a656fdb ("kconfig: tests: check unneeded "is not set" with unmet dependency") ee236610653ede ("kconfig: tests: check visibility of tristate choice values in y choice") beaaddb625400e ("kconfig: tests: test defconfig when two choices interact") 3e4888c2e3d77d ("kconfig: tests: test randconfig for choice in choice") 29c434f367ea7b ("kconfig: tests: test if recursive dependencies are detected") e2c75e7667c737 ("kconfig: tests: test if recursive inclusion is detected") f622f827958162 ("kconfig: warn unmet direct dependency of tristate symbols selected by y") f8f69dc0b4e070 ("kconfig: make unmet dependency warnings readable") 26561514cc9def ("kconfig: do not include both curses.h and ncurses.h for nconfig") 32a94b8b0c3e5a ("kconfig: remove duplicated file name and lineno of recursive inclusion") 379a8eb8eb1a55 ("kconfig: detect recursive inclusion earlier") 18492685e479fd ("kconfig: use yylineno option instead of manual lineno increments") 59889300274569 ! (".gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore") 9a8dfb394c0467 ! ("kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile") 833e622459432e ! ("genksyms: generate lexer and parser during build instead of shipping") b23d1a241f4eb4 ! ("kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically") 17baab68d337a0 ("kconfig: extend output of 'listnewconfig'") e9781b52d4e0e3 ! ("kbuild: add PYTHON2 and PYTHON3 variables") The current Kconfig update generates below build-time warnings: YACC scripts/dtc/dtc-parser.tab.h scripts/dtc/dtc-parser.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr] YACC scripts/dtc/dtc-parser.tab.c scripts/dtc/dtc-parser.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr] This seems to happen because the Kbuild updates apparently didn't make room for both "*shipped"-based builds and flex/bison-based builds. A similar problem has been reported for genksyms parser in v4.17-rc1 commit 833e622459432e ("genksyms: generate lexer and parser during build instead of shipping"). I have figured out empirically that the warnings are healed after updating the in-tree U-boot DTC to upstream v1.4.6-9, same as done by Linux v4.17-rc1 commit 9130ba88464032 ("scripts/dtc: Update to upstream version v1.4.6-9-gaadd0b65c987"). Whether fixing the DTC-related yacc warnings should be done together with the Kconfig re-sync, I would like to hear from community. My testing was limited to: - make defconfig all - make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- r8a7795_ulcb_defconfig all - comparing .config before and after the re-sync - running the newly imported Kconfig unit tests as seen below: $ make testconfig Tested-by: Petr Vorel <petr.vorel@gmail.com> ============================= test session starts ============================= scripts/kconfig/tests/auto_submenu/__init__.py::test PASSED [ 7%] scripts/kconfig/tests/choice/__init__.py::test_oldask0 PASSED [ 14%] scripts/kconfig/tests/choice/__init__.py::test_oldask1 PASSED [ 21%] scripts/kconfig/tests/choice/__init__.py::test_allyes PASSED [ 28%] scripts/kconfig/tests/choice/__init__.py::test_allmod PASSED [ 35%] scripts/kconfig/tests/choice/__init__.py::test_allno PASSED [ 42%] scripts/kconfig/tests/choice/__init__.py::test_alldef PASSED [ 50%] scripts/kconfig/tests/choice_value_with_m_dep/__init__.py::test PASSED [ 57%] scripts/kconfig/tests/err_recursive_inc/__init__.py::test PASSED [ 64%] scripts/kconfig/tests/inter_choice/__init__.py::test PASSED [ 71%] scripts/kconfig/tests/new_choice_with_dep/__init__.py::test PASSED [ 78%] scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py::test PASSED [ 85%] scripts/kconfig/tests/rand_nested_choice/__init__.py::test PASSED [ 92%] scripts/kconfig/tests/warn_recursive_dep/__init__.py::test PASSED [100%] ========================== 14 passed in 0.34 seconds ========================== Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com> Tested-by: Petr Vorel <petr.vorel@gmail.com>
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. # SPDX-License-Identifier: GPL-2.0
  2. # ==========================================================================
  3. # Building
  4. # ==========================================================================
  5. # Modified for U-Boot
  6. prefix := tpl
  7. src := $(patsubst $(prefix)/%,%,$(obj))
  8. ifeq ($(obj),$(src))
  9. prefix := spl
  10. src := $(patsubst $(prefix)/%,%,$(obj))
  11. ifeq ($(obj),$(src))
  12. prefix := .
  13. endif
  14. endif
  15. PHONY := __build
  16. __build:
  17. # Init all relevant variables used in kbuild files so
  18. # 1) they have correct type
  19. # 2) they do not inherit any value from the environment
  20. obj-y :=
  21. obj-m :=
  22. lib-y :=
  23. lib-m :=
  24. always :=
  25. targets :=
  26. subdir-y :=
  27. subdir-m :=
  28. EXTRA_AFLAGS :=
  29. EXTRA_CFLAGS :=
  30. EXTRA_CPPFLAGS :=
  31. EXTRA_LDFLAGS :=
  32. asflags-y :=
  33. ccflags-y :=
  34. cppflags-y :=
  35. ldflags-y :=
  36. subdir-asflags-y :=
  37. subdir-ccflags-y :=
  38. # Read auto.conf if it exists, otherwise ignore
  39. # Modified for U-Boot
  40. -include include/config/auto.conf
  41. -include $(prefix)/include/autoconf.mk
  42. include scripts/Makefile.uncmd_spl
  43. include scripts/Kbuild.include
  44. # For backward compatibility check that these variables do not change
  45. save-cflags := $(CFLAGS)
  46. # The filename Kbuild has precedence over Makefile
  47. kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
  48. kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
  49. include $(kbuild-file)
  50. # Added for U-Boot
  51. asflags-y += $(PLATFORM_CPPFLAGS)
  52. ccflags-y += $(PLATFORM_CPPFLAGS)
  53. cppflags-y += $(PLATFORM_CPPFLAGS)
  54. # If the save-* variables changed error out
  55. ifeq ($(KBUILD_NOPEDANTIC),)
  56. ifneq ("$(save-cflags)","$(CFLAGS)")
  57. $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y)
  58. endif
  59. endif
  60. include scripts/Makefile.lib
  61. ifdef host-progs
  62. ifneq ($(hostprogs-y),$(host-progs))
  63. $(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!)
  64. hostprogs-y += $(host-progs)
  65. endif
  66. endif
  67. # Do not include host rules unless needed
  68. ifneq ($(hostprogs-y)$(hostprogs-m),)
  69. include scripts/Makefile.host
  70. endif
  71. # Uncommented for U-Boot
  72. # We need to create output dicrectory for SPL and TPL even for in-tree build
  73. #ifneq ($(KBUILD_SRC),)
  74. # Create output directory if not already present
  75. _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
  76. # Create directories for object files if directory does not exist
  77. # Needed when obj-y := dir/file.o syntax is used
  78. _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
  79. #endif
  80. ifndef obj
  81. $(warning kbuild: Makefile.build is included improperly)
  82. endif
  83. # ===========================================================================
  84. ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
  85. lib-target := $(obj)/lib.a
  86. endif
  87. ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
  88. builtin-target := $(obj)/built-in.o
  89. endif
  90. modorder-target := $(obj)/modules.order
  91. # We keep a list of all modules in $(MODVERDIR)
  92. __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
  93. $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
  94. $(subdir-ym) $(always)
  95. @:
  96. # Linus' kernel sanity checking tool
  97. ifneq ($(KBUILD_CHECKSRC),0)
  98. ifeq ($(KBUILD_CHECKSRC),2)
  99. quiet_cmd_force_checksrc = CHECK $<
  100. cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
  101. else
  102. quiet_cmd_checksrc = CHECK $<
  103. cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
  104. endif
  105. endif
  106. # Do section mismatch analysis for each module/built-in.o
  107. ifdef CONFIG_DEBUG_SECTION_MISMATCH
  108. cmd_secanalysis = ; scripts/mod/modpost $@
  109. endif
  110. # Compile C sources (.c)
  111. # ---------------------------------------------------------------------------
  112. # Default is built-in, unless we know otherwise
  113. modkern_cflags = \
  114. $(if $(part-of-module), \
  115. $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
  116. $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
  117. quiet_modtag := $(empty) $(empty)
  118. $(real-objs-m) : part-of-module := y
  119. $(real-objs-m:.o=.i) : part-of-module := y
  120. $(real-objs-m:.o=.s) : part-of-module := y
  121. $(real-objs-m:.o=.lst): part-of-module := y
  122. $(real-objs-m) : quiet_modtag := [M]
  123. $(real-objs-m:.o=.i) : quiet_modtag := [M]
  124. $(real-objs-m:.o=.s) : quiet_modtag := [M]
  125. $(real-objs-m:.o=.lst): quiet_modtag := [M]
  126. $(obj-m) : quiet_modtag := [M]
  127. # Default for not multi-part modules
  128. modname = $(basetarget)
  129. $(multi-objs-m) : modname = $(modname-multi)
  130. $(multi-objs-m:.o=.i) : modname = $(modname-multi)
  131. $(multi-objs-m:.o=.s) : modname = $(modname-multi)
  132. $(multi-objs-m:.o=.lst) : modname = $(modname-multi)
  133. $(multi-objs-y) : modname = $(modname-multi)
  134. $(multi-objs-y:.o=.i) : modname = $(modname-multi)
  135. $(multi-objs-y:.o=.s) : modname = $(modname-multi)
  136. $(multi-objs-y:.o=.lst) : modname = $(modname-multi)
  137. quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
  138. cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
  139. $(obj)/%.s: $(src)/%.c FORCE
  140. $(call if_changed_dep,cc_s_c)
  141. quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@
  142. cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $<
  143. $(obj)/%.i: $(src)/%.c FORCE
  144. $(call if_changed_dep,cc_i_c)
  145. cmd_gensymtypes = \
  146. $(CPP) -D__GENKSYMS__ $(c_flags) $< | \
  147. $(GENKSYMS) $(if $(1), -T $(2)) \
  148. $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \
  149. $(if $(KBUILD_PRESERVE),-p) \
  150. -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
  151. quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
  152. cmd_cc_symtypes_c = \
  153. set -e; \
  154. $(call cmd_gensymtypes,true,$@) >/dev/null; \
  155. test -s $@ || rm -f $@
  156. $(obj)/%.symtypes : $(src)/%.c FORCE
  157. $(call cmd,cc_symtypes_c)
  158. # C (.c) files
  159. # The C file is compiled and updated dependency information is generated.
  160. # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
  161. quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
  162. ifndef CONFIG_MODVERSIONS
  163. cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
  164. else
  165. # When module versioning is enabled the following steps are executed:
  166. # o compile a .tmp_<file>.o from <file>.c
  167. # o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
  168. # not export symbols, we just rename .tmp_<file>.o to <file>.o and
  169. # are done.
  170. # o otherwise, we calculate symbol versions using the good old
  171. # genksyms on the preprocessed source and postprocess them in a way
  172. # that they are usable as a linker script
  173. # o generate <file>.o from .tmp_<file>.o using the linker to
  174. # replace the unresolved symbols __crc_exported_symbol with
  175. # the actual value of the checksum generated by genksyms
  176. cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
  177. cmd_modversions = \
  178. if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
  179. $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
  180. > $(@D)/.tmp_$(@F:.o=.ver); \
  181. \
  182. $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
  183. -T $(@D)/.tmp_$(@F:.o=.ver); \
  184. rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
  185. else \
  186. mv -f $(@D)/.tmp_$(@F) $@; \
  187. fi;
  188. endif
  189. ifdef CONFIG_FTRACE_MCOUNT_RECORD
  190. ifdef BUILD_C_RECORDMCOUNT
  191. ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
  192. RECORDMCOUNT_FLAGS = -w
  193. endif
  194. # Due to recursion, we must skip empty.o.
  195. # The empty.o file is created in the make process in order to determine
  196. # the target endianness and word size. It is made before all other C
  197. # files, including recordmcount.
  198. sub_cmd_record_mcount = \
  199. if [ $(@) != "scripts/mod/empty.o" ]; then \
  200. $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \
  201. fi;
  202. recordmcount_source := $(srctree)/scripts/recordmcount.c \
  203. $(srctree)/scripts/recordmcount.h
  204. else
  205. sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
  206. "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
  207. "$(if $(CONFIG_64BIT),64,32)" \
  208. "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \
  209. "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
  210. "$(if $(part-of-module),1,0)" "$(@)";
  211. recordmcount_source := $(srctree)/scripts/recordmcount.pl
  212. endif
  213. cmd_record_mcount = \
  214. if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \
  215. "$(CC_FLAGS_FTRACE)" ]; then \
  216. $(sub_cmd_record_mcount) \
  217. fi;
  218. endif
  219. define rule_cc_o_c
  220. $(call echo-cmd,checksrc) $(cmd_checksrc) \
  221. $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
  222. $(cmd_modversions) \
  223. $(call echo-cmd,record_mcount) \
  224. $(cmd_record_mcount) \
  225. scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
  226. $(dot-target).tmp; \
  227. rm -f $(depfile); \
  228. mv -f $(dot-target).tmp $(dot-target).cmd
  229. endef
  230. # Built-in and composite module parts
  231. $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
  232. $(call cmd,force_checksrc)
  233. $(call if_changed_rule,cc_o_c)
  234. # Single-part modules are special since we need to mark them in $(MODVERDIR)
  235. $(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
  236. $(call cmd,force_checksrc)
  237. $(call if_changed_rule,cc_o_c)
  238. @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
  239. quiet_cmd_cc_lst_c = MKLST $@
  240. cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
  241. $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
  242. System.map $(OBJDUMP) > $@
  243. $(obj)/%.lst: $(src)/%.c FORCE
  244. $(call if_changed_dep,cc_lst_c)
  245. # Compile assembler sources (.S)
  246. # ---------------------------------------------------------------------------
  247. modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
  248. $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
  249. $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
  250. quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
  251. cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
  252. $(obj)/%.s: $(src)/%.S FORCE
  253. $(call if_changed_dep,as_s_S)
  254. quiet_cmd_as_o_S = AS $(quiet_modtag) $@
  255. cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
  256. $(obj)/%.o: $(src)/%.S FORCE
  257. $(call if_changed_dep,as_o_S)
  258. targets += $(real-objs-y) $(real-objs-m) $(lib-y)
  259. targets += $(extra-y) $(MAKECMDGOALS) $(always)
  260. # Linker scripts preprocessor (.lds.S -> .lds)
  261. # ---------------------------------------------------------------------------
  262. quiet_cmd_cpp_lds_S = LDS $@
  263. cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
  264. -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
  265. $(obj)/%.lds: $(src)/%.lds.S FORCE
  266. $(call if_changed_dep,cpp_lds_S)
  267. # ASN.1 grammar
  268. # ---------------------------------------------------------------------------
  269. quiet_cmd_asn1_compiler = ASN.1 $@
  270. cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
  271. $(subst .h,.c,$@) $(subst .c,.h,$@)
  272. .PRECIOUS: $(objtree)/$(obj)/%-asn1.c $(objtree)/$(obj)/%-asn1.h
  273. $(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
  274. $(call cmd,asn1_compiler)
  275. # Build the compiled-in targets
  276. # ---------------------------------------------------------------------------
  277. # To build objects in subdirs, we need to descend into the directories
  278. $(sort $(subdir-obj-y)): $(subdir-ym) ;
  279. #
  280. # Rule to compile a set of .o files into one .o file
  281. #
  282. ifdef builtin-target
  283. quiet_cmd_link_o_target = LD $@
  284. # If the list of objects to link is empty, just create an empty built-in.o
  285. cmd_link_o_target = $(if $(strip $(obj-y)),\
  286. $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \
  287. $(cmd_secanalysis),\
  288. rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@)
  289. $(builtin-target): $(obj-y) FORCE
  290. $(call if_changed,link_o_target)
  291. targets += $(builtin-target)
  292. endif # builtin-target
  293. #
  294. # Rule to create modules.order file
  295. #
  296. # Create commands to either record .ko file or cat modules.order from
  297. # a subdirectory
  298. modorder-cmds = \
  299. $(foreach m, $(modorder), \
  300. $(if $(filter %/modules.order, $m), \
  301. cat $m;, echo kernel/$m;))
  302. $(modorder-target): $(subdir-ym) FORCE
  303. $(Q)(cat /dev/null; $(modorder-cmds)) > $@
  304. #
  305. # Rule to compile a set of .o files into one .a file
  306. #
  307. ifdef lib-target
  308. quiet_cmd_link_l_target = AR $@
  309. cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
  310. $(lib-target): $(lib-y) FORCE
  311. $(call if_changed,link_l_target)
  312. targets += $(lib-target)
  313. endif
  314. #
  315. # Rule to link composite objects
  316. #
  317. # Composite objects are specified in kbuild makefile as follows:
  318. # <composite-object>-objs := <list of .o files>
  319. # or
  320. # <composite-object>-y := <list of .o files>
  321. link_multi_deps = \
  322. $(filter $(addprefix $(obj)/, \
  323. $($(subst $(obj)/,,$(@:.o=-objs))) \
  324. $($(subst $(obj)/,,$(@:.o=-y)))), $^)
  325. quiet_cmd_link_multi-y = LD $@
  326. cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
  327. quiet_cmd_link_multi-m = LD [M] $@
  328. cmd_link_multi-m = $(cmd_link_multi-y)
  329. $(multi-used-y): FORCE
  330. $(call if_changed,link_multi-y)
  331. $(call multi_depend, $(multi-used-y), .o, -objs -y)
  332. $(multi-used-m): FORCE
  333. $(call if_changed,link_multi-m)
  334. @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod)
  335. $(call multi_depend, $(multi-used-m), .o, -objs -y)
  336. targets += $(multi-used-y) $(multi-used-m)
  337. # Add intermediate targets:
  338. # When building objects with specific suffix patterns, add intermediate
  339. # targets that the final targets are derived from.
  340. intermediate_targets = $(foreach sfx, $(2), \
  341. $(patsubst %$(strip $(1)),%$(sfx), \
  342. $(filter %$(strip $(1)), $(targets))))
  343. # %.lex.o <- %.lex.c <- %.l
  344. # %.tab.o <- %.tab.[ch] <- %.y
  345. targets += $(call intermediate_targets, .lex.o, .lex.c) \
  346. $(call intermediate_targets, .tab.o, .tab.c .tab.h)
  347. # Descending
  348. # ---------------------------------------------------------------------------
  349. PHONY += $(subdir-ym)
  350. $(subdir-ym):
  351. $(Q)$(MAKE) $(build)=$@
  352. # Add FORCE to the prequisites of a target to force it to be always rebuilt.
  353. # ---------------------------------------------------------------------------
  354. PHONY += FORCE
  355. FORCE:
  356. # Read all saved command lines and dependencies for the $(targets) we
  357. # may be building above, using $(if_changed{,_dep}). As an
  358. # optimization, we don't need to read them if the target does not
  359. # exist, we will rebuild anyway in that case.
  360. targets := $(wildcard $(sort $(targets)))
  361. cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
  362. ifneq ($(cmd_files),)
  363. include $(cmd_files)
  364. endif
  365. # Declare the contents of the .PHONY variable as phony. We keep that
  366. # information in a variable se we can use it in if_changed and friends.
  367. .PHONY: $(PHONY)