summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2020-04-15 16:57:05 +0900
committerSascha Hauer <s.hauer@pengutronix.de>2020-04-15 11:28:27 +0200
commit8a3bd269763dc4883e63dad579613c3cbaa1a985 (patch)
tree5d6ed7a5a856c3b41dabb3bb2cc860dfe6a80947 /scripts
parentf7eda6657c01c6e34e8aa66ea3a8cdb4024dec0b (diff)
downloadbarebox-8a3bd269763dc4883e63dad579613c3cbaa1a985.tar.gz
barebox-8a3bd269763dc4883e63dad579613c3cbaa1a985.tar.xz
fixdep: update to Linux 5.7-rc1
scripts/basic/ works for barebox as drop-in. Update scripts/basic/ to Linux 5.7-rc1. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/basic/.gitignore2
-rw-r--r--scripts/basic/Makefile19
-rw-r--r--scripts/basic/fixdep.c61
3 files changed, 49 insertions, 33 deletions
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
index dc24f5f4c7..98ae1f5095 100644
--- a/scripts/basic/.gitignore
+++ b/scripts/basic/.gitignore
@@ -1,2 +1,2 @@
-docproc
+# SPDX-License-Identifier: GPL-2.0-only
fixdep
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index 9e92d899a5..290dd27d28 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -1,15 +1,6 @@
-###
-# Makefile.basic list the most basic programs used during the build process.
-# The programs listed herein is what is needed to do the basic stuff,
-# such as fix dependency file.
-# This initial step is needed to avoid files to be recompiled
-# when barebox configuration changes (which is what happens when
-# .config is included by main Makefile.
-# ---------------------------------------------------------------------------
-# fixdep: Used to generate dependency information during build process
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# fixdep: used to generate dependency information during build process
-hostprogs-y := fixdep
-always := $(hostprogs-y)
-
-# fixdep is needed to compile other host programs
-$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
+hostprogs := fixdep
+always-y := $(hostprogs)
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index facbd603ad..877ca2c882 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -77,11 +77,6 @@
* dependencies on include/config/my/option.h for every
* CONFIG_MY_OPTION encountered in any of the prerequisites.
*
- * It will also filter out all the dependencies on *.ver. We need
- * to make sure that the generated version checksum are globally up
- * to date before even starting the recursive build, so it's too late
- * at this point anyway.
- *
* 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
@@ -99,6 +94,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
@@ -110,13 +106,43 @@ static void usage(void)
}
/*
+ * 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);
+ }
+}
+
+/*
* Print out a dependency path from a symbol name
*/
static void print_dep(const char *m, int slen, const char *dir)
{
int c, prev_c = '/', i;
- printf(" $(wildcard %s/", dir);
+ xprintf(" $(wildcard %s/", dir);
for (i = 0; i < slen; i++) {
c = m[i];
if (c == '_')
@@ -124,10 +150,10 @@ static void print_dep(const char *m, int slen, const char *dir)
else
c = tolower(c);
if (c != '/' || prev_c != '/')
- putchar(c);
+ xputchar(c);
prev_c = c;
}
- printf(".h) \\\n");
+ xprintf(".h) \\\n");
}
struct item {
@@ -220,7 +246,7 @@ static void parse_config_file(const char *p)
}
p += 7;
q = p;
- while (*q && (isalnum(*q) || *q == '_'))
+ while (isalnum(*q) || *q == '_')
q++;
if (str_ends_with(p, q - p, "_MODULE"))
r = q - 7;
@@ -268,8 +294,7 @@ static void *read_file(const char *filename)
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") ||
- str_ends_with(s, len, ".ver");
+ str_ends_with(s, len, "include/generated/autoksyms.h");
}
/*
@@ -324,13 +349,13 @@ static void parse_dep_file(char *m, const char *target)
*/
if (!saw_any_target) {
saw_any_target = 1;
- printf("source_%s := %s\n\n",
- target, m);
- printf("deps_%s := \\\n", target);
+ xprintf("source_%s := %s\n\n",
+ target, m);
+ xprintf("deps_%s := \\\n", target);
}
is_first_dep = 0;
} else {
- printf(" %s \\\n", m);
+ xprintf(" %s \\\n", m);
}
buf = read_file(m);
@@ -353,8 +378,8 @@ static void parse_dep_file(char *m, const char *target)
exit(1);
}
- printf("\n%s: $(deps_%s)\n\n", target, target);
- printf("$(deps_%s):\n", target);
+ xprintf("\n%s: $(deps_%s)\n\n", target, target);
+ xprintf("$(deps_%s):\n", target);
}
int main(int argc, char *argv[])
@@ -369,7 +394,7 @@ int main(int argc, char *argv[])
target = argv[2];
cmdline = argv[3];
- printf("cmd_%s := %s\n\n", target, cmdline);
+ xprintf("cmd_%s := %s\n\n", target, cmdline);
buf = read_file(depfile);
parse_dep_file(buf, target);