u-boot/scripts/basic/fixdep.c

437 lines
10 KiB
C
Raw Normal View History

/*
* "Optimize" a list of dependencies as spit out by gcc -MD
* for the kernel build
* ===========================================================================
*
* Author Kai Germaschewski
* Copyright 2002 by Kai Germaschewski <kai.germaschewski@gmx.de>
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
*
* Introduction:
*
* gcc produces a very nice and correct list of dependencies which
* tells make when to remake a file.
*
* To use this list as-is however has the drawback that virtually
* every file in the kernel includes autoconf.h.
*
* If the user re-runs make *config, autoconf.h will be
* regenerated. make notices that and will rebuild every file which
* includes autoconf.h, i.e. basically all files. This is extremely
* annoying if the user just changed CONFIG_HIS_DRIVER from n to m.
*
* So we play the same trick that "mkdep" played before. We replace
* the dependency on autoconf.h by a dependency on every config
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
* option which is mentioned in any of the listed prerequisites.
*
* kconfig populates a tree in include/config/ with an empty file
* for each config symbol and when the configuration is updated
* the files representing changed config options are touched
* which then let make pick up the changes and the files that use
* the config symbols are rebuilt.
*
* So if the user changes his CONFIG_HIS_DRIVER option, only the objects
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
* which depend on "include/config/his/driver.h" will be rebuilt,
* so most likely only his driver ;-)
*
* The idea above dates, by the way, back to Michael E Chastain, AFAIK.
*
* So to get dependencies right, there are two issues:
* o if any of the files the compiler read changed, we need to rebuild
* o if the command line given to the compile the file changed, we
* better rebuild as well.
*
* The former is handled by using the -MD output, the later by saving
* the command line used to compile the old object and comparing it
* to the one we would now use.
*
* Again, also this idea is pretty old and has been discussed on
* kbuild-devel a long time ago. I don't have a sensibly working
* internet connection right now, so I rather don't mention names
* without double checking.
*
* This code here has been based partially based on mkdep.c, which
* says the following about its history:
*
* Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>.
* This is a C version of syncdep.pl by Werner Almesberger.
*
*
* It is invoked as
*
* fixdep <depfile> <target> <cmdline>
*
* and will read the dependency file <depfile>
*
* The transformed dependency snipped is written to stdout.
*
* It first generates a line
*
* cmd_<target> = <cmdline>
*
* and then basically copies the .<target>.d file to stdout, in the
* process filtering out the dependency on autoconf.h and adding
* dependencies on include/config/my/option.h for every
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
* CONFIG_MY_OPTION encountered in any of the prerequisites.
*
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
* We don't even try to really parse the header files, but
* merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will
* be picked up as well. It's not a problem with respect to
* correctness, since that can only give too many dependencies, thus
* we cannot miss a rebuild. Since people tend to not mention totally
* unrelated CONFIG_ options all over the place, it's not an
* efficiency problem either.
*
* (Note: it'd be easy to port over the complete mkdep state machine,
* but I don't think the added complexity is worth it)
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
char tmp_buf[256]; /* hack for U-Boot */
static void usage(void)
{
fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
exit(1);
}
/*
* In the intended usage of this program, the stdout is redirected to .*.cmd
* files. The return value of printf() and putchar() must be checked to catch
* any error, e.g. "No space left on device".
*/
static void xprintf(const char *format, ...)
{
va_list ap;
int ret;
va_start(ap, format);
ret = vprintf(format, ap);
if (ret < 0) {
perror("fixdep");
exit(1);
}
va_end(ap);
}
static void xputchar(int c)
{
int ret;
ret = putchar(c);
if (ret == EOF) {
perror("fixdep");
exit(1);
}
}
/*
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
* Print out a dependency path from a symbol name
*/
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
static void print_dep(const char *m, int slen, const char *dir)
{
kconfig / kbuild: re-sync with Linux 4.18 Align Kconfig and Kbuild logic to Linux 4.18 release with minimal impact on files outside of this scope. Our previous Kconfig sync was done by commit e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4"). A very small number of changes upstream since our sync with v4.17-rc4 that exist in the v4.18 release have already been applied here and have been omitted from the list in this commit (and are readily available in our own git history). The imported Linux commits are: [From prior to v4.17-rc4] 39a33ff80a25 kbuild: remove cc-option-align db547ef19064 Kbuild: don't add obj tree in additional includes b999596b963a Kbuild: don't add ../../ to include path [From v4.17 to v4.18] b3aa58d2e85d fixdep: suppress consecutive / from file paths in dependency list files 74656b682902 kbuild: disable new dtc graph and unit-address warnings 74d931716151 genksyms: remove symbol prefix support e6ecfb45072c kbuild: do not display CHK for filechk 0b669a5076fd kconfig: refactor Qt package checks for building qconf b464ef583dc7 kconfig: refactor GTK+ package checks for building gconf 1c5af5cf9308 kconfig: refactor ncurses package checks for building mconf and nconf 694c49a7c01c kconfig: drop localization support 96f60dfa5819 trace: Use -mcount-record for dynamic ftrace bb222ceeb327 kconfig: remove string expansion in file_lookup() 96d8e48da55a kconfig: remove string expansion for mainmenu after yyparse() 5b31a9746756 kconfig: remove sym_expand_string_value() 137c0118a900 kconfig: make default prompt of mainmenu less specific e298f3b49def kconfig: add built-in function support 2fd5b09c201e kconfig: add 'shell' built-in function 9de071536c87 kconfig: begin PARAM state only when seeing a command keyword 9ced3bddec08 kconfig: support user-defined function and recursively expanded variable 1175c02506ff kconfig: support simply expanded variable ed2a22f277c6 kconfig: support append assignment operator 82bc8bd82e5c kconfig: expand lefthand side of assignment statement 1d6272e6fe43 kconfig: add 'info', 'warning-if', and 'error-if' built-in functions a702a6176e2f kconfig: add 'filename' and 'lineno' built-in variables 915f64901eb3 kconfig: error out if a recursive variable references itself 2bece88f89fa kconfig: test: add Kconfig macro language tests 21c54b774744 kconfig: show compiler version text in the top comment 59f7b5847b0c kbuild: $(CHECK) doesnt need NOSTDINC_FLAGS twice 145167650b96 kbuild: add endianness flag to CHEKCFLAGS 1f2f01b122d7 kbuild: add machine size to CHECKFLAGS d6a0c8a1326b kconfig: Add testconfig into make help output bb6d83dde191 kbuild: Move last word of nconfig help to the previous line 8593080c0fcf kconfig: fix localmodconfig ed7d40bc67b8 tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with -mrecord-mcount b2d00d7c61c8 kconfig: fix line numbers for if-entries in menu tree ecd53ac2f2c6 kconfig: handle P_SYMBOL in print_symbol() 73d1c580f92b kconfig: loop boundary condition fix 48f6e3cf5bc6 kbuild: do not drop -I without parameter bd412d81b7ea kbuild: .PHONY is not a variable, but PHONY is 6916162c7308 kbuild: remove duplicated comments about PHONY Cc: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-03-11 22:11:17 +00:00
int c, prev_c = '/', i;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
xprintf(" $(wildcard %s/", dir);
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
for (i = 0; i < slen; i++) {
c = m[i];
if (c == '_')
c = '/';
else
c = tolower(c);
kconfig / kbuild: re-sync with Linux 4.18 Align Kconfig and Kbuild logic to Linux 4.18 release with minimal impact on files outside of this scope. Our previous Kconfig sync was done by commit e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4"). A very small number of changes upstream since our sync with v4.17-rc4 that exist in the v4.18 release have already been applied here and have been omitted from the list in this commit (and are readily available in our own git history). The imported Linux commits are: [From prior to v4.17-rc4] 39a33ff80a25 kbuild: remove cc-option-align db547ef19064 Kbuild: don't add obj tree in additional includes b999596b963a Kbuild: don't add ../../ to include path [From v4.17 to v4.18] b3aa58d2e85d fixdep: suppress consecutive / from file paths in dependency list files 74656b682902 kbuild: disable new dtc graph and unit-address warnings 74d931716151 genksyms: remove symbol prefix support e6ecfb45072c kbuild: do not display CHK for filechk 0b669a5076fd kconfig: refactor Qt package checks for building qconf b464ef583dc7 kconfig: refactor GTK+ package checks for building gconf 1c5af5cf9308 kconfig: refactor ncurses package checks for building mconf and nconf 694c49a7c01c kconfig: drop localization support 96f60dfa5819 trace: Use -mcount-record for dynamic ftrace bb222ceeb327 kconfig: remove string expansion in file_lookup() 96d8e48da55a kconfig: remove string expansion for mainmenu after yyparse() 5b31a9746756 kconfig: remove sym_expand_string_value() 137c0118a900 kconfig: make default prompt of mainmenu less specific e298f3b49def kconfig: add built-in function support 2fd5b09c201e kconfig: add 'shell' built-in function 9de071536c87 kconfig: begin PARAM state only when seeing a command keyword 9ced3bddec08 kconfig: support user-defined function and recursively expanded variable 1175c02506ff kconfig: support simply expanded variable ed2a22f277c6 kconfig: support append assignment operator 82bc8bd82e5c kconfig: expand lefthand side of assignment statement 1d6272e6fe43 kconfig: add 'info', 'warning-if', and 'error-if' built-in functions a702a6176e2f kconfig: add 'filename' and 'lineno' built-in variables 915f64901eb3 kconfig: error out if a recursive variable references itself 2bece88f89fa kconfig: test: add Kconfig macro language tests 21c54b774744 kconfig: show compiler version text in the top comment 59f7b5847b0c kbuild: $(CHECK) doesnt need NOSTDINC_FLAGS twice 145167650b96 kbuild: add endianness flag to CHEKCFLAGS 1f2f01b122d7 kbuild: add machine size to CHECKFLAGS d6a0c8a1326b kconfig: Add testconfig into make help output bb6d83dde191 kbuild: Move last word of nconfig help to the previous line 8593080c0fcf kconfig: fix localmodconfig ed7d40bc67b8 tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with -mrecord-mcount b2d00d7c61c8 kconfig: fix line numbers for if-entries in menu tree ecd53ac2f2c6 kconfig: handle P_SYMBOL in print_symbol() 73d1c580f92b kconfig: loop boundary condition fix 48f6e3cf5bc6 kbuild: do not drop -I without parameter bd412d81b7ea kbuild: .PHONY is not a variable, but PHONY is 6916162c7308 kbuild: remove duplicated comments about PHONY Cc: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-03-11 22:11:17 +00:00
if (c != '/' || prev_c != '/')
xputchar(c);
kconfig / kbuild: re-sync with Linux 4.18 Align Kconfig and Kbuild logic to Linux 4.18 release with minimal impact on files outside of this scope. Our previous Kconfig sync was done by commit e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4"). A very small number of changes upstream since our sync with v4.17-rc4 that exist in the v4.18 release have already been applied here and have been omitted from the list in this commit (and are readily available in our own git history). The imported Linux commits are: [From prior to v4.17-rc4] 39a33ff80a25 kbuild: remove cc-option-align db547ef19064 Kbuild: don't add obj tree in additional includes b999596b963a Kbuild: don't add ../../ to include path [From v4.17 to v4.18] b3aa58d2e85d fixdep: suppress consecutive / from file paths in dependency list files 74656b682902 kbuild: disable new dtc graph and unit-address warnings 74d931716151 genksyms: remove symbol prefix support e6ecfb45072c kbuild: do not display CHK for filechk 0b669a5076fd kconfig: refactor Qt package checks for building qconf b464ef583dc7 kconfig: refactor GTK+ package checks for building gconf 1c5af5cf9308 kconfig: refactor ncurses package checks for building mconf and nconf 694c49a7c01c kconfig: drop localization support 96f60dfa5819 trace: Use -mcount-record for dynamic ftrace bb222ceeb327 kconfig: remove string expansion in file_lookup() 96d8e48da55a kconfig: remove string expansion for mainmenu after yyparse() 5b31a9746756 kconfig: remove sym_expand_string_value() 137c0118a900 kconfig: make default prompt of mainmenu less specific e298f3b49def kconfig: add built-in function support 2fd5b09c201e kconfig: add 'shell' built-in function 9de071536c87 kconfig: begin PARAM state only when seeing a command keyword 9ced3bddec08 kconfig: support user-defined function and recursively expanded variable 1175c02506ff kconfig: support simply expanded variable ed2a22f277c6 kconfig: support append assignment operator 82bc8bd82e5c kconfig: expand lefthand side of assignment statement 1d6272e6fe43 kconfig: add 'info', 'warning-if', and 'error-if' built-in functions a702a6176e2f kconfig: add 'filename' and 'lineno' built-in variables 915f64901eb3 kconfig: error out if a recursive variable references itself 2bece88f89fa kconfig: test: add Kconfig macro language tests 21c54b774744 kconfig: show compiler version text in the top comment 59f7b5847b0c kbuild: $(CHECK) doesnt need NOSTDINC_FLAGS twice 145167650b96 kbuild: add endianness flag to CHEKCFLAGS 1f2f01b122d7 kbuild: add machine size to CHECKFLAGS d6a0c8a1326b kconfig: Add testconfig into make help output bb6d83dde191 kbuild: Move last word of nconfig help to the previous line 8593080c0fcf kconfig: fix localmodconfig ed7d40bc67b8 tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with -mrecord-mcount b2d00d7c61c8 kconfig: fix line numbers for if-entries in menu tree ecd53ac2f2c6 kconfig: handle P_SYMBOL in print_symbol() 73d1c580f92b kconfig: loop boundary condition fix 48f6e3cf5bc6 kbuild: do not drop -I without parameter bd412d81b7ea kbuild: .PHONY is not a variable, but PHONY is 6916162c7308 kbuild: remove duplicated comments about PHONY Cc: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-03-11 22:11:17 +00:00
prev_c = c;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
}
xprintf(".h) \\\n");
}
struct item {
struct item *next;
unsigned int len;
unsigned int hash;
char name[0];
};
#define HASHSZ 256
static struct item *hashtab[HASHSZ];
static unsigned int strhash(const char *str, unsigned int sz)
{
/* fnv32 hash */
unsigned int i, hash = 2166136261U;
for (i = 0; i < sz; i++)
hash = (hash ^ str[i]) * 0x01000193;
return hash;
}
/*
* Lookup a value in the configuration string.
*/
static int is_defined_config(const char *name, int len, unsigned int hash)
{
struct item *aux;
for (aux = hashtab[hash % HASHSZ]; aux; aux = aux->next) {
if (aux->hash == hash && aux->len == len &&
memcmp(aux->name, name, len) == 0)
return 1;
}
return 0;
}
/*
* Add a new value to the configuration string.
*/
static void define_config(const char *name, int len, unsigned int hash)
{
struct item *aux = malloc(sizeof(*aux) + len);
if (!aux) {
perror("fixdep:malloc");
exit(1);
}
memcpy(aux->name, name, len);
aux->len = len;
aux->hash = hash;
aux->next = hashtab[hash % HASHSZ];
hashtab[hash % HASHSZ] = aux;
}
/*
* Record the use of a CONFIG_* word.
*/
static void use_config(const char *m, int slen)
{
unsigned int hash = strhash(m, slen);
if (is_defined_config(m, slen, hash))
return;
define_config(m, slen, hash);
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
print_dep(m, slen, "include/config");
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
/* test if s ends in sub */
static int str_ends_with(const char *s, int slen, const char *sub)
{
int sublen = strlen(sub);
if (sublen > slen)
return 0;
return !memcmp(s + slen - sublen, sub, sublen);
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
static void parse_config_file(const char *p)
{
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
const char *q, *r;
const char *start = p;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
while ((p = strstr(p, "CONFIG_"))) {
if (p > start && (isalnum(p[-1]) || p[-1] == '_')) {
p += 7;
continue;
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
p += 7;
q = p;
while (isalnum(*q) || *q == '_')
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
q++;
if (str_ends_with(p, q - p, "_MODULE"))
r = q - 7;
else
r = q;
/*
* U-Boot also handles
* CONFIG_IS_ENABLED(...)
* CONFIG_IS_BUILTIN(...)
* CONFIG_IS_MODULE(...)
* CONFIG_VAL(...)
*/
linux/kconfig.h: add CPP macros useful for per-image config options The previous commit introduced a useful macro used in makefiles, in order to reference to different variables (CONFIG_... or CONFIG_SPL_...) depending on the build context. Per-image config option control is a PITA in C sources, too. Here are some macros useful in C/CPP expressions. CONFIG_IS_ENABLED(FOO) can be used as a shorthand for (!defined(CONFIG_SPL_BUILD) && defined(CONFIG_FOO)) || \ (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_FOO)) For example, it is useful to describe C code as follows, #if CONFIG_IS_ENABLED(OF_CONTROL) (device tree code) #else (board file code) #endif The ifdef conditional above is switched by CONFIG_OF_CONTROL during the U-Boot proper building (CONFIG_SPL_BUILD is not defined), and by CONFIG_SPL_OF_CONTROL during SPL building (CONFIG_SPL_BUILD is defined). The macro can be used in C context as well, so you can also write the equivalent code as follows: if (CONFIG_IS_ENABLED(OF_CONTROL)) { (device tree code) } else { (board file code) } Another useful macro is CONFIG_VALUE(). CONFIG_VALUE(FOO) is expanded into CONFIG_FOO if CONFIG_SPL_BUILD is undefined, and into CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined. You can write as follows: text_base = CONFIG_VALUE(TEXT_BASE); instead of: #ifdef CONFIG_SPL_BUILD text_base = CONFIG_SPL_TEXT_BASE; #else text_base = CONFIG_TEXT_BASE; #endif This commit also adds slight hacking on fixdep so that it can output a correct list of fixed dependencies. If the fixdep finds CONFIG_IS_ENABLED(FOO) in a source file, we want $(wildcard include/config/foo.h) in the U-boot proper building context, while we want $(wildcard include/config/spl/foo.h) in the SPL build context. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2015-08-11 22:31:43 +00:00
if ((q - p == 10 && !memcmp(p, "IS_ENABLED(", 11)) ||
(q - p == 10 && !memcmp(p, "IS_BUILTIN(", 11)) ||
(q - p == 9 && !memcmp(p, "IS_MODULE(", 10)) ||
(q - p == 3 && !memcmp(p, "VAL(", 4))) {
linux/kconfig.h: add CPP macros useful for per-image config options The previous commit introduced a useful macro used in makefiles, in order to reference to different variables (CONFIG_... or CONFIG_SPL_...) depending on the build context. Per-image config option control is a PITA in C sources, too. Here are some macros useful in C/CPP expressions. CONFIG_IS_ENABLED(FOO) can be used as a shorthand for (!defined(CONFIG_SPL_BUILD) && defined(CONFIG_FOO)) || \ (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_FOO)) For example, it is useful to describe C code as follows, #if CONFIG_IS_ENABLED(OF_CONTROL) (device tree code) #else (board file code) #endif The ifdef conditional above is switched by CONFIG_OF_CONTROL during the U-Boot proper building (CONFIG_SPL_BUILD is not defined), and by CONFIG_SPL_OF_CONTROL during SPL building (CONFIG_SPL_BUILD is defined). The macro can be used in C context as well, so you can also write the equivalent code as follows: if (CONFIG_IS_ENABLED(OF_CONTROL)) { (device tree code) } else { (board file code) } Another useful macro is CONFIG_VALUE(). CONFIG_VALUE(FOO) is expanded into CONFIG_FOO if CONFIG_SPL_BUILD is undefined, and into CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined. You can write as follows: text_base = CONFIG_VALUE(TEXT_BASE); instead of: #ifdef CONFIG_SPL_BUILD text_base = CONFIG_SPL_TEXT_BASE; #else text_base = CONFIG_TEXT_BASE; #endif This commit also adds slight hacking on fixdep so that it can output a correct list of fixed dependencies. If the fixdep finds CONFIG_IS_ENABLED(FOO) in a source file, we want $(wildcard include/config/foo.h) in the U-boot proper building context, while we want $(wildcard include/config/spl/foo.h) in the SPL build context. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2015-08-11 22:31:43 +00:00
p = q + 1;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
while (isalnum(*q) || *q == '_')
q++;
r = q;
if (r > p && tmp_buf[0]) {
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
memcpy(tmp_buf + 4, p, r - p);
r = tmp_buf + 4 + (r - p);
linux/kconfig.h: add CPP macros useful for per-image config options The previous commit introduced a useful macro used in makefiles, in order to reference to different variables (CONFIG_... or CONFIG_SPL_...) depending on the build context. Per-image config option control is a PITA in C sources, too. Here are some macros useful in C/CPP expressions. CONFIG_IS_ENABLED(FOO) can be used as a shorthand for (!defined(CONFIG_SPL_BUILD) && defined(CONFIG_FOO)) || \ (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_FOO)) For example, it is useful to describe C code as follows, #if CONFIG_IS_ENABLED(OF_CONTROL) (device tree code) #else (board file code) #endif The ifdef conditional above is switched by CONFIG_OF_CONTROL during the U-Boot proper building (CONFIG_SPL_BUILD is not defined), and by CONFIG_SPL_OF_CONTROL during SPL building (CONFIG_SPL_BUILD is defined). The macro can be used in C context as well, so you can also write the equivalent code as follows: if (CONFIG_IS_ENABLED(OF_CONTROL)) { (device tree code) } else { (board file code) } Another useful macro is CONFIG_VALUE(). CONFIG_VALUE(FOO) is expanded into CONFIG_FOO if CONFIG_SPL_BUILD is undefined, and into CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined. You can write as follows: text_base = CONFIG_VALUE(TEXT_BASE); instead of: #ifdef CONFIG_SPL_BUILD text_base = CONFIG_SPL_TEXT_BASE; #else text_base = CONFIG_TEXT_BASE; #endif This commit also adds slight hacking on fixdep so that it can output a correct list of fixed dependencies. If the fixdep finds CONFIG_IS_ENABLED(FOO) in a source file, we want $(wildcard include/config/foo.h) in the U-boot proper building context, while we want $(wildcard include/config/spl/foo.h) in the SPL build context. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2015-08-11 22:31:43 +00:00
p = tmp_buf;
}
}
/* end U-Boot hack */
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
if (r > p)
use_config(p, r - p);
p = q;
}
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
static void *read_file(const char *filename)
{
struct stat st;
int fd;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
char *buf;
fd = open(filename, O_RDONLY);
if (fd < 0) {
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
fprintf(stderr, "fixdep: error opening file: ");
perror(filename);
exit(2);
}
if (fstat(fd, &st) < 0) {
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
fprintf(stderr, "fixdep: error fstat'ing file: ");
perror(filename);
exit(2);
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
buf = malloc(st.st_size + 1);
if (!buf) {
perror("fixdep: malloc");
exit(2);
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
if (read(fd, buf, st.st_size) != st.st_size) {
perror("fixdep: read");
exit(2);
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
buf[st.st_size] = '\0';
close(fd);
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
return buf;
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
/* Ignore certain dependencies */
static int is_ignored_file(const char *s, int len)
{
return str_ends_with(s, len, "include/generated/autoconf.h") ||
str_ends_with(s, len, "include/generated/autoksyms.h");
}
/*
* Important: The below generated source_foo.o and deps_foo.o variable
* assignments are parsed not only by make, but also by the rather simple
* parser in scripts/mod/sumversion.c.
*/
static void parse_dep_file(char *m, const char *target)
{
char *p;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
int is_last, is_target;
int saw_any_target = 0;
int is_first_dep = 0;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
void *buf;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
while (1) {
/* Skip any "white space" */
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
while (*m == ' ' || *m == '\\' || *m == '\n')
m++;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
if (!*m)
break;
/* Find next "white space" */
p = m;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
while (*p && *p != ' ' && *p != '\\' && *p != '\n')
p++;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
is_last = (*p == '\0');
/* Is the token we found a target name? */
is_target = (*(p-1) == ':');
/* Don't write any target names into the dependency file */
if (is_target) {
/* The /next/ file is the first dependency */
is_first_dep = 1;
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
} else if (!is_ignored_file(m, p - m)) {
*p = '\0';
/*
* Do not list the source file as dependency, so that
* kbuild is not confused if a .c file is rewritten
* into .S or vice versa. Storing it in source_* is
* needed for modpost to compute srcversions.
*/
if (is_first_dep) {
/*
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
* If processing the concatenation of multiple
* dependency files, only process the first
* target name, which will be the original
* source name, and ignore any other target
* names, which will be intermediate temporary
* files.
*/
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
if (!saw_any_target) {
saw_any_target = 1;
xprintf("source_%s := %s\n\n",
target, m);
xprintf("deps_%s := \\\n", target);
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
}
is_first_dep = 0;
} else {
xprintf(" %s \\\n", m);
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
buf = read_file(m);
parse_config_file(buf);
free(buf);
}
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
if (is_last)
break;
/*
* Start searching for next token immediately after the first
* "whitespace" character that follows this token.
*/
m = p + 1;
}
if (!saw_any_target) {
fprintf(stderr, "fixdep: parse error; no targets found\n");
exit(1);
}
xprintf("\n%s: $(deps_%s)\n\n", target, target);
xprintf("$(deps_%s):\n", target);
}
int main(int argc, char *argv[])
{
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
const char *depfile, *target, *cmdline;
void *buf;
if (argc != 4)
usage();
depfile = argv[1];
target = argv[2];
cmdline = argv[3];
/* hack for U-Boot */
if (!strncmp(target, "spl/", 4))
strcpy(tmp_buf, "SPL_");
else if (!strncmp(target, "tpl/", 4))
strcpy(tmp_buf, "TPL_");
/* end U-Boot hack */
linux/kconfig.h: add CPP macros useful for per-image config options The previous commit introduced a useful macro used in makefiles, in order to reference to different variables (CONFIG_... or CONFIG_SPL_...) depending on the build context. Per-image config option control is a PITA in C sources, too. Here are some macros useful in C/CPP expressions. CONFIG_IS_ENABLED(FOO) can be used as a shorthand for (!defined(CONFIG_SPL_BUILD) && defined(CONFIG_FOO)) || \ (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_FOO)) For example, it is useful to describe C code as follows, #if CONFIG_IS_ENABLED(OF_CONTROL) (device tree code) #else (board file code) #endif The ifdef conditional above is switched by CONFIG_OF_CONTROL during the U-Boot proper building (CONFIG_SPL_BUILD is not defined), and by CONFIG_SPL_OF_CONTROL during SPL building (CONFIG_SPL_BUILD is defined). The macro can be used in C context as well, so you can also write the equivalent code as follows: if (CONFIG_IS_ENABLED(OF_CONTROL)) { (device tree code) } else { (board file code) } Another useful macro is CONFIG_VALUE(). CONFIG_VALUE(FOO) is expanded into CONFIG_FOO if CONFIG_SPL_BUILD is undefined, and into CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined. You can write as follows: text_base = CONFIG_VALUE(TEXT_BASE); instead of: #ifdef CONFIG_SPL_BUILD text_base = CONFIG_SPL_TEXT_BASE; #else text_base = CONFIG_TEXT_BASE; #endif This commit also adds slight hacking on fixdep so that it can output a correct list of fixed dependencies. If the fixdep finds CONFIG_IS_ENABLED(FOO) in a source file, we want $(wildcard include/config/foo.h) in the U-boot proper building context, while we want $(wildcard include/config/spl/foo.h) in the SPL build context. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2015-08-11 22:31:43 +00:00
xprintf("cmd_%s := %s\n\n", target, cmdline);
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
buf = read_file(depfile);
parse_dep_file(buf, target);
kbuild: fixdep: Resync this with v4.17 The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux 4.17-rc4") accidentally did not sync the fixdep program. This commit brings fixdep in line with the rest of that previous resync. This includes all of the following Linux kernel commits: fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/* 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches 14a596a7e6fd fixdep: remove stale references to uml-config.h ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options 87b95a81357d fixdep: refactor parse_dep_file() 5d1ef76f5a22 fixdep: move global variables to local variables of main() ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file() 4003fd80cba9 fixdep: factor out common code for reading files 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer 41f92cffba19 fixdep: remove unnecessary <arpa/inet.h> inclusion 7c2ec43a2154 fixdep: exit with error code in error branches of do_config_file() 4e433fc4d1a9 fixdep: trivial: typo fix and correction dee81e988674 fixdep: faster CONFIG_ search c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols d8329e35cc08 fixdep: accept extra dependencies on stdin 4c835b57b8de fixdep: constify strrcmp arguments Of note is that when applying dee81e988674 above our logic in that area required some careful consideration to continue to apply. [Fold in bugfix to allow us to include 638e69cf2230 from upstream] Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> [Merge everything to U-Boot, rework dee81e988674] Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
2020-02-24 17:50:32 +00:00
free(buf);
return 0;
}