mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
9b5f0b1da9
Update the files under scripts/kconfig/ to match Linux 4.1. Some Kconfig sources have diverged from those in the kernel, so commit-base syncing was done not to lose U-Boot specific updates. The commits cherry-picked from Linux are: [1] commit be8af2d54a66911693eddc556e4f7a866670082b Author: Bjørn Forsman <bjorn.forsman@gmail.com> kconfig/lxdialog: get ncurses CFLAGS with pkg-config [2] commit 3943f42c11896ce82ad3da132c8a5630313bdd0e Author: Andrey Utkin <andrey.krieger.utkin@gmail.com> Replace mentions of "list_struct" to "list_head" [3] commit e4e458b45c5861808674eebfea94cee2258bb2ea Author: Arjun Sreedharan <arjun024@gmail.com> calloc/xcalloc: Fix argument order [4] commit 09950bc256e3628d275f90e016e6f5a039fbdcab Author: Olof Johansson <olof@lixom.net> merge_config.sh: Display usage if given too few arguments [5] commit b6a2ab2cd4739a9573ed41677e53171987b8da34 Author: Colin Ian King <colin.king@canonical.com> kconfig: use va_end to match corresponding va_start [6] commit 70529b1a1784503169416df19ce3d68746401340 Author: Michal Marek <mmarek@suse.cz> kconfig: Get rid of the P() macro in headers [7] commit 463157444e377bf9b279101b1f16a94c4648c03a Author: Michal Marek <mmarek@suse.cz> kconfig: Remove dead code [8] commit ad8d40cda3ad22ad9e8863d55a5c88f85c0173f0 Author: Michal Marek <mmarek@suse.cz> kconfig: Remove unnecessary prototypes from headers [9] commit de4619937229378e81f95e99c9866acc8e207d34 Author: Masahiro Yamada <yamada.masahiro@socionext.com> kbuild: mergeconfig: fix "jobserver unavailable" warning [10] commit b9fe99c5b994c6ddc57780993966b18899526c0b Author: Masahiro Yamada <yamada.masahiro@socionext.com> kbuild: mergeconfig: move an error check to merge_config.sh [11] commit 371cfd4ff0611d8bc5d18bbb9cc6a2bc3d56cd3d Author: Masahiro Yamada <yamada.masahiro@socionext.com> kbuild: mergeconfig: remove redundant $(objtree) [12] commit 3a975b8cfcbe026b535f83bde9a3c009bae214f9 Author: Masahiro Yamada <yamada.masahiro@socionext.com> merge_config.sh: improve indentation [13] commit bc8f8f5fc47cd02c2c5f3580dac2fe6695af1edd Author: Masahiro Yamada <yamada.masahiro@socionext.com> merge_config.sh: rename MAKE to RUNMAKE [14] commit 63a91033d52e64a22e571fe84924c0b7f21c280d Author: Masahiro Yamada <yamada.masahiro@socionext.com> kbuild: add generic mergeconfig target, %.config [15] commit 1cba0c305758c3c1786ecaceb03e142c95a4edc9 Author: Michal Marek <mmarek@suse.cz> kconfig: Simplify Makefile [16] commit 0a1f00a1c86421cc07cec87011c7cf4df68ee54b Author: Michal Marek <mmarek@suse.cz> kconfig: Do not print status messages in make -s mode Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Bjørn Forsman <bjorn.forsman@gmail.com> Signed-off-by: Andrey Utkin <andrey.krieger.utkin@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Arjun Sreedharan <arjun024@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
147 lines
2.9 KiB
C
147 lines
2.9 KiB
C
/*
|
|
* Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org>
|
|
* Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org>
|
|
*
|
|
* Released under the terms of the GNU GPL v2.0.
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "lkc.h"
|
|
|
|
/* file already present in list? If not add it */
|
|
struct file *file_lookup(const char *name)
|
|
{
|
|
struct file *file;
|
|
const char *file_name = sym_expand_string_value(name);
|
|
|
|
for (file = file_list; file; file = file->next) {
|
|
if (!strcmp(name, file->name)) {
|
|
free((void *)file_name);
|
|
return file;
|
|
}
|
|
}
|
|
|
|
file = xmalloc(sizeof(*file));
|
|
memset(file, 0, sizeof(*file));
|
|
file->name = file_name;
|
|
file->next = file_list;
|
|
file_list = file;
|
|
return file;
|
|
}
|
|
|
|
/* write a dependency file as used by kbuild to track dependencies */
|
|
int file_write_dep(const char *name)
|
|
{
|
|
struct symbol *sym, *env_sym;
|
|
struct expr *e;
|
|
struct file *file;
|
|
FILE *out;
|
|
|
|
if (!name)
|
|
name = ".kconfig.d";
|
|
out = fopen("..config.tmp", "w");
|
|
if (!out)
|
|
return 1;
|
|
fprintf(out, "deps_config := \\\n");
|
|
for (file = file_list; file; file = file->next) {
|
|
if (file->next)
|
|
fprintf(out, "\t%s \\\n", file->name);
|
|
else
|
|
fprintf(out, "\t%s\n", file->name);
|
|
}
|
|
fprintf(out, "\n%s: \\\n"
|
|
"\t$(deps_config)\n\n", conf_get_autoconfig_name());
|
|
|
|
expr_list_for_each_sym(sym_env_list, e, sym) {
|
|
struct property *prop;
|
|
const char *value;
|
|
|
|
prop = sym_get_env_prop(sym);
|
|
env_sym = prop_get_symbol(prop);
|
|
if (!env_sym)
|
|
continue;
|
|
value = getenv(env_sym->name);
|
|
if (!value)
|
|
value = "";
|
|
fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value);
|
|
fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name());
|
|
fprintf(out, "endif\n");
|
|
}
|
|
|
|
fprintf(out, "\n$(deps_config): ;\n");
|
|
fclose(out);
|
|
rename("..config.tmp", name);
|
|
return 0;
|
|
}
|
|
|
|
|
|
/* Allocate initial growable string */
|
|
struct gstr str_new(void)
|
|
{
|
|
struct gstr gs;
|
|
gs.s = xmalloc(sizeof(char) * 64);
|
|
gs.len = 64;
|
|
gs.max_width = 0;
|
|
strcpy(gs.s, "\0");
|
|
return gs;
|
|
}
|
|
|
|
/* Free storage for growable string */
|
|
void str_free(struct gstr *gs)
|
|
{
|
|
if (gs->s)
|
|
free(gs->s);
|
|
gs->s = NULL;
|
|
gs->len = 0;
|
|
}
|
|
|
|
/* Append to growable string */
|
|
void str_append(struct gstr *gs, const char *s)
|
|
{
|
|
size_t l;
|
|
if (s) {
|
|
l = strlen(gs->s) + strlen(s) + 1;
|
|
if (l > gs->len) {
|
|
gs->s = realloc(gs->s, l);
|
|
gs->len = l;
|
|
}
|
|
strcat(gs->s, s);
|
|
}
|
|
}
|
|
|
|
/* Append printf formatted string to growable string */
|
|
void str_printf(struct gstr *gs, const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
char s[10000]; /* big enough... */
|
|
va_start(ap, fmt);
|
|
vsnprintf(s, sizeof(s), fmt, ap);
|
|
str_append(gs, s);
|
|
va_end(ap);
|
|
}
|
|
|
|
/* Retrieve value of growable string */
|
|
const char *str_get(struct gstr *gs)
|
|
{
|
|
return gs->s;
|
|
}
|
|
|
|
void *xmalloc(size_t size)
|
|
{
|
|
void *p = malloc(size);
|
|
if (p)
|
|
return p;
|
|
fprintf(stderr, "Out of memory.\n");
|
|
exit(1);
|
|
}
|
|
|
|
void *xcalloc(size_t nmemb, size_t size)
|
|
{
|
|
void *p = calloc(nmemb, size);
|
|
if (p)
|
|
return p;
|
|
fprintf(stderr, "Out of memory.\n");
|
|
exit(1);
|
|
}
|