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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

Kbuild.include 11 KiB

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>
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>
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>
6 years ago
kbuild: add a makefile macro useful with per-image config options Commit e02ee2548afe ("kconfig: switch to single .config configuration") made the configuration itself pretty simple, instead, we lost the way to systematically enable/disable config options for each image independently. Our current strategy is, put entries into Makefile.spl for options we need separate enabling, or once enable the options globally in Kconfig and then undef them in Makefile.uncmd_spl if we do not want to compile the features for SPL at all. Things are getting really messy. Besides, "ifdef CONFIG_SPL_BUILD" are sprinkled everywhere in makefiles. This commit adds a variable to help describe makefile simpler. $(SPL_) evaluates to "SPL_" during the SPL build, while to an empty string during building U-boot proper. So, you can write obj-$(CONFIG_$(SPL_)FOO) += foo.o instead of ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FOO) += foo.o else obj-$(CONFIG_FOO) += foo.o endif If CONFIG_SPL_FOO does not exist in Kconfig, it is equivalent to ifndef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FOO) += foo.o endif This is the pattern we often see in our current makefiles. To take advantage of this macro, we should prefix SPL_ for the SPL version of the option when we need independent control between U-boot and SPL. With this naming scheme, I hope our makefiles will be much simplified. It means we want to rename existing config options as follows in the long run: CONFIG_SPL_SERIAL_SUPPORT -> CONFIG_SPL_SERIAL CONFIG_SPL_I2C_SUPPORT -> CONFIG_SPL_I2C CONFIG_SPL_GPIO_SUPPORT -> CONFIG_SPL_GPIO CONFIG_SPL_SPI_SUPPORT -> CONFIG_SPL_SPI CONFIG_SPL_DISABLE_OF_CONTROL -> CONFIG_SPL_OF_CONTROL (inverting the logic) Then drivers/Makefile would be re-worked as follows: obj-$(CONFIG_$(SPL_)SERIAL) += serial/ obj-$(CONFIG_$(SPL_)I2C) += i2c/ obj-$(CONFIG_$(SPL_)GPIO) += gpio/ obj-$(CONFIG_$(SPL_)SPI) += spi/ ... Eventually, SPL-specialized entries in Makefile.spl would go away. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
5 years ago
kbuild: add a makefile macro useful with per-image config options Commit e02ee2548afe ("kconfig: switch to single .config configuration") made the configuration itself pretty simple, instead, we lost the way to systematically enable/disable config options for each image independently. Our current strategy is, put entries into Makefile.spl for options we need separate enabling, or once enable the options globally in Kconfig and then undef them in Makefile.uncmd_spl if we do not want to compile the features for SPL at all. Things are getting really messy. Besides, "ifdef CONFIG_SPL_BUILD" are sprinkled everywhere in makefiles. This commit adds a variable to help describe makefile simpler. $(SPL_) evaluates to "SPL_" during the SPL build, while to an empty string during building U-boot proper. So, you can write obj-$(CONFIG_$(SPL_)FOO) += foo.o instead of ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FOO) += foo.o else obj-$(CONFIG_FOO) += foo.o endif If CONFIG_SPL_FOO does not exist in Kconfig, it is equivalent to ifndef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FOO) += foo.o endif This is the pattern we often see in our current makefiles. To take advantage of this macro, we should prefix SPL_ for the SPL version of the option when we need independent control between U-boot and SPL. With this naming scheme, I hope our makefiles will be much simplified. It means we want to rename existing config options as follows in the long run: CONFIG_SPL_SERIAL_SUPPORT -> CONFIG_SPL_SERIAL CONFIG_SPL_I2C_SUPPORT -> CONFIG_SPL_I2C CONFIG_SPL_GPIO_SUPPORT -> CONFIG_SPL_GPIO CONFIG_SPL_SPI_SUPPORT -> CONFIG_SPL_SPI CONFIG_SPL_DISABLE_OF_CONTROL -> CONFIG_SPL_OF_CONTROL (inverting the logic) Then drivers/Makefile would be re-worked as follows: obj-$(CONFIG_$(SPL_)SERIAL) += serial/ obj-$(CONFIG_$(SPL_)I2C) += i2c/ obj-$(CONFIG_$(SPL_)GPIO) += gpio/ obj-$(CONFIG_$(SPL_)SPI) += spi/ ... Eventually, SPL-specialized entries in Makefile.spl would go away. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
5 years ago
kbuild: add a makefile macro useful with per-image config options Commit e02ee2548afe ("kconfig: switch to single .config configuration") made the configuration itself pretty simple, instead, we lost the way to systematically enable/disable config options for each image independently. Our current strategy is, put entries into Makefile.spl for options we need separate enabling, or once enable the options globally in Kconfig and then undef them in Makefile.uncmd_spl if we do not want to compile the features for SPL at all. Things are getting really messy. Besides, "ifdef CONFIG_SPL_BUILD" are sprinkled everywhere in makefiles. This commit adds a variable to help describe makefile simpler. $(SPL_) evaluates to "SPL_" during the SPL build, while to an empty string during building U-boot proper. So, you can write obj-$(CONFIG_$(SPL_)FOO) += foo.o instead of ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FOO) += foo.o else obj-$(CONFIG_FOO) += foo.o endif If CONFIG_SPL_FOO does not exist in Kconfig, it is equivalent to ifndef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FOO) += foo.o endif This is the pattern we often see in our current makefiles. To take advantage of this macro, we should prefix SPL_ for the SPL version of the option when we need independent control between U-boot and SPL. With this naming scheme, I hope our makefiles will be much simplified. It means we want to rename existing config options as follows in the long run: CONFIG_SPL_SERIAL_SUPPORT -> CONFIG_SPL_SERIAL CONFIG_SPL_I2C_SUPPORT -> CONFIG_SPL_I2C CONFIG_SPL_GPIO_SUPPORT -> CONFIG_SPL_GPIO CONFIG_SPL_SPI_SUPPORT -> CONFIG_SPL_SPI CONFIG_SPL_DISABLE_OF_CONTROL -> CONFIG_SPL_OF_CONTROL (inverting the logic) Then drivers/Makefile would be re-worked as follows: obj-$(CONFIG_$(SPL_)SERIAL) += serial/ obj-$(CONFIG_$(SPL_)I2C) += i2c/ obj-$(CONFIG_$(SPL_)GPIO) += gpio/ obj-$(CONFIG_$(SPL_)SPI) += spi/ ... Eventually, SPL-specialized entries in Makefile.spl would go away. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. ####
  2. # kbuild: Generic definitions
  3. # Convenient variables
  4. comma := ,
  5. quote := "
  6. squote := '
  7. empty :=
  8. space := $(empty) $(empty)
  9. pound := \#
  10. ###
  11. # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
  12. dot-target = $(dir $@).$(notdir $@)
  13. ###
  14. # The temporary file to save gcc -MD generated dependencies must not
  15. # contain a comma
  16. depfile = $(subst $(comma),_,$(dot-target).d)
  17. ###
  18. # filename of target with directory and extension stripped
  19. basetarget = $(basename $(notdir $@))
  20. ###
  21. # filename of first prerequisite with directory and extension stripped
  22. baseprereq = $(basename $(notdir $<))
  23. ###
  24. # Escape single quote for use in echo statements
  25. escsq = $(subst $(squote),'\$(squote)',$1)
  26. ###
  27. # Easy method for doing a status message
  28. kecho := :
  29. quiet_kecho := echo
  30. silent_kecho := :
  31. kecho := $($(quiet)kecho)
  32. ###
  33. # filechk is used to check if the content of a generated file is updated.
  34. # Sample usage:
  35. # define filechk_sample
  36. # echo $KERNELRELEASE
  37. # endef
  38. # version.h : Makefile
  39. # $(call filechk,sample)
  40. # The rule defined shall write to stdout the content of the new file.
  41. # The existing file will be compared with the new one.
  42. # - If no file exist it is created
  43. # - If the content differ the new file is used
  44. # - If they are equal no change, and no timestamp update
  45. # - stdin is piped in from the first prerequisite ($<) so one has
  46. # to specify a valid file as first prerequisite (often the kbuild file)
  47. define filechk
  48. $(Q)set -e; \
  49. $(kecho) ' CHK $@'; \
  50. mkdir -p $(dir $@); \
  51. $(filechk_$(1)) < $< > $@.tmp; \
  52. if [ -r $@ ] && cmp -s $@ $@.tmp; then \
  53. rm -f $@.tmp; \
  54. else \
  55. $(kecho) ' UPD $@'; \
  56. mv -f $@.tmp $@; \
  57. fi
  58. endef
  59. ######
  60. # gcc support functions
  61. # See documentation in Documentation/kbuild/makefiles.txt
  62. # cc-cross-prefix
  63. # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
  64. # Return first prefix where a prefix$(CC) is found in PATH.
  65. # If no $(CC) found in PATH with listed prefixes return nothing
  66. cc-cross-prefix = \
  67. $(word 1, $(foreach c,$(1), \
  68. $(shell set -e; \
  69. if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
  70. echo $(c); \
  71. fi)))
  72. # output directory for tests below
  73. TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
  74. # try-run
  75. # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
  76. # Exit code chooses option. "$$TMP" is can be used as temporary file and
  77. # is automatically cleaned up.
  78. # modifed for U-Boot: prevent cc-option from leaving .*.su files
  79. try-run = $(shell set -e; \
  80. TMP="$(TMPOUT).$$$$.tmp"; \
  81. TMPO="$(TMPOUT).$$$$.o"; \
  82. TMPSU="$(TMPOUT).$$$$.su"; \
  83. if ($(1)) >/dev/null 2>&1; \
  84. then echo "$(2)"; \
  85. else echo "$(3)"; \
  86. fi; \
  87. rm -f "$$TMP" "$$TMPO" "$$TMPSU")
  88. # as-option
  89. # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
  90. as-option = $(call try-run,\
  91. $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
  92. # as-instr
  93. # Usage: cflags-y += $(call as-instr,instr,option1,option2)
  94. as-instr = $(call try-run,\
  95. printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
  96. # cc-option
  97. # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
  98. cc-option = $(call try-run,\
  99. $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
  100. # cc-option-yn
  101. # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
  102. cc-option-yn = $(call try-run,\
  103. $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
  104. # cc-option-align
  105. # Prefix align with either -falign or -malign
  106. cc-option-align = $(subst -functions=0,,\
  107. $(call cc-option,-falign-functions=0,-malign-functions=0))
  108. # cc-disable-warning
  109. # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
  110. cc-disable-warning = $(call try-run,\
  111. $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
  112. # cc-name
  113. # Expands to either gcc or clang
  114. cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
  115. # cc-version
  116. cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
  117. # cc-fullversion
  118. cc-fullversion = $(shell $(CONFIG_SHELL) \
  119. $(srctree)/scripts/gcc-version.sh -p $(CC))
  120. # cc-ifversion
  121. # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
  122. cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4))
  123. # added for U-Boot
  124. binutils-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/binutils-version.sh $(AS))
  125. dtc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/dtc-version.sh $(DTC))
  126. # cc-ldoption
  127. # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
  128. cc-ldoption = $(call try-run,\
  129. $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
  130. # ld-option
  131. # Usage: LDFLAGS += $(call ld-option, -X)
  132. ld-option = $(call try-run,\
  133. $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
  134. # ar-option
  135. # Usage: KBUILD_ARFLAGS := $(call ar-option,D)
  136. # Important: no spaces around options
  137. ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
  138. # ld-version
  139. # Note this is mainly for HJ Lu's 3 number binutil versions
  140. ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
  141. # ld-ifversion
  142. # Usage: $(call ld-ifversion, -ge, 22252, y)
  143. ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4))
  144. ######
  145. ###
  146. # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
  147. # Usage:
  148. # $(Q)$(MAKE) $(build)=dir
  149. build := -f $(srctree)/scripts/Makefile.build obj
  150. ###
  151. # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
  152. # Usage:
  153. # $(Q)$(MAKE) $(modbuiltin)=dir
  154. modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj
  155. ###
  156. # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj=
  157. # Usage:
  158. # $(Q)$(MAKE) $(dtbinst)=dir
  159. dtbinst := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.dtbinst obj
  160. ###
  161. # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=
  162. # Usage:
  163. # $(Q)$(MAKE) $(clean)=dir
  164. clean := -f $(srctree)/scripts/Makefile.clean obj
  165. ###
  166. # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.headersinst obj=
  167. # Usage:
  168. # $(Q)$(MAKE) $(hdr-inst)=dir
  169. hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
  170. # Prefix -I with $(srctree) if it is not an absolute path.
  171. # skip if -I has no parameter
  172. addtree = $(if $(patsubst -I%,%,$(1)), \
  173. $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1))
  174. # Find all -I options and call addtree
  175. flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
  176. # echo command.
  177. # Short version is used, if $(quiet) equals `quiet_', otherwise full one.
  178. echo-cmd = $(if $($(quiet)cmd_$(1)),\
  179. echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
  180. # printing commands
  181. cmd = @$(echo-cmd) $(cmd_$(1))
  182. # Add $(obj)/ for paths that are not absolute
  183. objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
  184. ###
  185. # if_changed - execute command if any prerequisite is newer than
  186. # target, or command line has changed
  187. # if_changed_dep - as if_changed, but uses fixdep to reveal dependencies
  188. # including used config symbols
  189. # if_changed_rule - as if_changed but execute rule instead
  190. # See Documentation/kbuild/makefiles.txt for more info
  191. ifneq ($(KBUILD_NOCMDDEP),1)
  192. # Check if both arguments has same arguments. Result is empty string if equal.
  193. # User may override this check using make KBUILD_NOCMDDEP=1
  194. arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
  195. $(filter-out $(cmd_$@), $(cmd_$(1))) )
  196. else
  197. arg-check = $(if $(strip $(cmd_$@)),,1)
  198. endif
  199. # Replace >$< with >$$< to preserve $ when reloading the .cmd file
  200. # (needed for make)
  201. # Replace >#< with >\#< to avoid starting a comment in the .cmd file
  202. # (needed for make)
  203. # Replace >'< with >'\''< to be able to enclose the whole string in '...'
  204. # (needed for the shell)
  205. make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1)))))
  206. # Find any prerequisites that is newer than target or that does not exist.
  207. # PHONY targets skipped in both cases.
  208. any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
  209. # Execute command if command has changed or prerequisite(s) are updated.
  210. #
  211. if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
  212. @set -e; \
  213. $(echo-cmd) $(cmd_$(1)); \
  214. printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
  215. # Execute the command and also postprocess generated .d dependencies file.
  216. if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
  217. @set -e; \
  218. $(echo-cmd) $(cmd_$(1)); \
  219. scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
  220. rm -f $(depfile); \
  221. mv -f $(dot-target).tmp $(dot-target).cmd)
  222. # Usage: $(call if_changed_rule,foo)
  223. # Will check if $(cmd_foo) or any of the prerequisites changed,
  224. # and if so will execute $(rule_foo).
  225. if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \
  226. @set -e; \
  227. $(rule_$(1)))
  228. ###
  229. # why - tell why a a target got build
  230. # enabled by make V=2
  231. # Output (listed in the order they are checked):
  232. # (1) - due to target is PHONY
  233. # (2) - due to target missing
  234. # (3) - due to: file1.h file2.h
  235. # (4) - due to command line change
  236. # (5) - due to missing .cmd file
  237. # (6) - due to target not in $(targets)
  238. # (1) PHONY targets are always build
  239. # (2) No target, so we better build it
  240. # (3) Prerequisite is newer than target
  241. # (4) The command line stored in the file named dir/.target.cmd
  242. # differed from actual command line. This happens when compiler
  243. # options changes
  244. # (5) No dir/.target.cmd file (used to store command line)
  245. # (6) No dir/.target.cmd file and target not listed in $(targets)
  246. # This is a good hint that there is a bug in the kbuild file
  247. ifeq ($(KBUILD_VERBOSE),2)
  248. why = \
  249. $(if $(filter $@, $(PHONY)),- due to target is PHONY, \
  250. $(if $(wildcard $@), \
  251. $(if $(strip $(any-prereq)),- due to: $(any-prereq), \
  252. $(if $(arg-check), \
  253. $(if $(cmd_$@),- due to command line change, \
  254. $(if $(filter $@, $(targets)), \
  255. - due to missing .cmd file, \
  256. - due to $(notdir $@) not in $$(targets) \
  257. ) \
  258. ) \
  259. ) \
  260. ), \
  261. - due to target missing \
  262. ) \
  263. )
  264. echo-why = $(call escsq, $(strip $(why)))
  265. endif
  266. ifdef CONFIG_SPL_BUILD
  267. SPL_ := SPL_
  268. ifeq ($(CONFIG_TPL_BUILD),y)
  269. SPL_TPL_ := TPL_
  270. else
  271. SPL_TPL_ := SPL_
  272. endif
  273. else
  274. SPL_ :=
  275. SPL_TPL_ :=
  276. endif