* [PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y
@ 2020-04-15 7:57 Masahiro Yamada
2020-04-15 7:57 ` [PATCH 2/3] kbuild: update flex and bison rules to Linux 5.7-rc1 Masahiro Yamada
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Masahiro Yamada @ 2020-04-15 7:57 UTC (permalink / raw)
To: barebox; +Cc: Masahiro Yamada
[ Linux commit 5f2fb52fac15a8a8e10ce020dd532504a8abfc4e ]
In old days, the "host-progs" syntax was used for specifying host
programs. It was renamed to the current "hostprogs-y" in 2004.
It is typically useful in scripts/Makefile because it allows Kbuild to
selectively compile host programs based on the kernel configuration.
This commit renames like follows:
always -> always-y
hostprogs-y -> hostprogs
So, scripts/Makefile will look like this:
always-$(CONFIG_BUILD_BIN2C) += ...
always-$(CONFIG_KALLSYMS) += ...
...
hostprogs := $(always-y) $(always-m)
I think this makes more sense because a host program is always a host
program, irrespective of the kernel configuration. We want to specify
which ones to compile by CONFIG options, so always-y will be handier.
The "always", "hostprogs-y", "hostprogs-m" will be kept for backward
compatibility for a while.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.build | 6 ++++--
scripts/Makefile.clean | 4 ++--
scripts/Makefile.host | 8 ++++----
scripts/Makefile.lib | 9 ++++++++-
4 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index db687d5f9..a6ed83e6d 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -16,6 +16,8 @@ lib-y :=
lib-m :=
pbl-y :=
always :=
+always-y :=
+always-m :=
targets :=
subdir-y :=
subdir-m :=
@@ -43,7 +45,7 @@ include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-di
include scripts/Makefile.lib
# Do not include host rules unless needed
-ifneq ($(hostprogs-y)$(hostprogs-m),)
+ifneq ($(hostprogs)$(hostprogs-y)$(hostprogs-m),)
include scripts/Makefile.host
endif
@@ -80,7 +82,7 @@ endif
__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(pbl-target) $(extra-y)) \
$(if $(KBUILD_MODULES),$(obj-m)) \
- $(subdir-ym) $(always)
+ $(subdir-ym) $(always-y)
@:
# Linus' kernel sanity checking tool
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index d1e4a7800..6e6c9ef7c 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -36,8 +36,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
# directory
__clean-files := $(extra-y) $(extra-m) $(extra-) \
- $(always) $(targets) $(clean-files) \
- $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
+ $(always) $(always-y) $(always-m) $(always-) $(targets) $(clean-files) \
+ $(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
# as clean-files is given relative to the current directory, this adds
# a $(obj) prefix, except for absolute paths
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 170952f68..61f0a7714 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -6,21 +6,21 @@
# Both C and C++ are supported, but preferred language is C for such utilities.
#
# Sample syntax (see Documentation/kbuild/makefiles.txt for reference)
-# hostprogs-y := bin2hex
+# hostprogs := bin2hex
# Will compile bin2hex.c and create an executable named bin2hex
#
-# hostprogs-y := lxdialog
+# hostprogs := lxdialog
# lxdialog-objs := checklist.o lxdialog.o
# Will compile lxdialog.c and checklist.c, and then link the executable
# lxdialog, based on checklist.o and lxdialog.o
#
-# hostprogs-y := qconf
+# hostprogs := qconf
# qconf-cxxobjs := qconf.o
# qconf-objs := menu.o
# Will compile qconf as a C++ program, and menu as a C program.
# They are linked as C++ code to the executable qconf
-__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
+__hostprogs := $(sort $(hostprogs))
# C code
# Executables compiled from a single .c file
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a94e16fe0..2b64b5432 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -1,3 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+# Backward compatibility
+always-y += $(always)
+hostprogs += $(hostprogs-y) $(hostprogs-m)
+
# Figure out what we need to build from the various variables
# ===========================================================================
@@ -85,10 +90,12 @@ obj-dirs := $(dir $(multi-objs) $(obj-y) $(pbl-y))
real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
+always-y += $(always-m)
+
# Add subdir path
extra-y := $(addprefix $(obj)/,$(extra-y))
-always := $(addprefix $(obj)/,$(always))
+always-y := $(addprefix $(obj)/,$(always-y))
targets := $(addprefix $(obj)/,$(targets))
obj-y := $(addprefix $(obj)/,$(obj-y))
obj-m := $(addprefix $(obj)/,$(obj-m))
--
2.25.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] kbuild: update flex and bison rules to Linux 5.7-rc1
2020-04-15 7:57 [PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y Masahiro Yamada
@ 2020-04-15 7:57 ` Masahiro Yamada
2020-04-15 7:57 ` [PATCH 3/3] fixdep: update " Masahiro Yamada
2020-04-15 9:29 ` [PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2020-04-15 7:57 UTC (permalink / raw)
To: barebox; +Cc: Masahiro Yamada
Import the following commits from Linux, and re-sync.
- 6ba7dc6616ce
"kbuild: make bison create C file and header in a single pattern rule"
- cf8dfd15e5fb
"kbuild: move flex and bison rules to Makefile.host"
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.host | 20 +++++++++++++++++++-
scripts/Makefile.lib | 22 ----------------------
2 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 61f0a7714..8f4d62f22 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -1,3 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# LEX
+# ---------------------------------------------------------------------------
+quiet_cmd_flex = LEX $@
+ cmd_flex = $(LEX) -o$@ -L $<
+
+$(obj)/%.lex.c: $(src)/%.l FORCE
+ $(call if_changed,flex)
+
+# YACC
+# ---------------------------------------------------------------------------
+quiet_cmd_bison = YACC $(basename $@).[ch]
+ cmd_bison = $(YACC) -o $(basename $@).c --defines=$(basename $@).h -t -l $<
+
+$(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
+ $(call if_changed,bison)
+
# ==========================================================================
# Building binaries on the host system
# Binaries are used during the compilation of the kernel, for example
@@ -5,7 +23,7 @@
#
# Both C and C++ are supported, but preferred language is C for such utilities.
#
-# Sample syntax (see Documentation/kbuild/makefiles.txt for reference)
+# Sample syntax (see Documentation/kbuild/makefiles.rst for reference)
# hostprogs := bin2hex
# Will compile bin2hex.c and create an executable named bin2hex
#
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 2b64b5432..d4c2ed15b 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -195,28 +195,6 @@ $(foreach m, $(notdir $1), \
$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
endef
-# LEX
-# ---------------------------------------------------------------------------
-quiet_cmd_flex = LEX $@
- cmd_flex = $(LEX) -o$@ -L $<
-
-$(obj)/%.lex.c: $(src)/%.l FORCE
- $(call if_changed,flex)
-
-# YACC
-# ---------------------------------------------------------------------------
-quiet_cmd_bison = YACC $@
- cmd_bison = $(YACC) -o$@ -t -l $<
-
-$(obj)/%.tab.c: $(src)/%.y FORCE
- $(call if_changed,bison)
-
-quiet_cmd_bison_h = YACC $@
- cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $<
-
-$(obj)/%.tab.h: $(src)/%.y FORCE
- $(call if_changed,bison_h)
-
# Shipped files
# ===========================================================================
--
2.25.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] fixdep: update to Linux 5.7-rc1
2020-04-15 7:57 [PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y Masahiro Yamada
2020-04-15 7:57 ` [PATCH 2/3] kbuild: update flex and bison rules to Linux 5.7-rc1 Masahiro Yamada
@ 2020-04-15 7:57 ` Masahiro Yamada
2020-04-15 9:29 ` [PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2020-04-15 7:57 UTC (permalink / raw)
To: barebox; +Cc: Masahiro Yamada
scripts/basic/ works for barebox as drop-in.
Update scripts/basic/ to Linux 5.7-rc1.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/basic/.gitignore | 2 +-
scripts/basic/Makefile | 19 ++++---------
scripts/basic/fixdep.c | 61 ++++++++++++++++++++++++++++------------
3 files changed, 49 insertions(+), 33 deletions(-)
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
index dc24f5f4c..98ae1f509 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 9e92d899a..290dd27d2 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 facbd603a..877ca2c88 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>
@@ -109,6 +105,36 @@ static void usage(void)
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);
+ }
+}
+
/*
* Print out a dependency path from a symbol name
*/
@@ -116,7 +142,7 @@ 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);
--
2.25.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y
2020-04-15 7:57 [PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y Masahiro Yamada
2020-04-15 7:57 ` [PATCH 2/3] kbuild: update flex and bison rules to Linux 5.7-rc1 Masahiro Yamada
2020-04-15 7:57 ` [PATCH 3/3] fixdep: update " Masahiro Yamada
@ 2020-04-15 9:29 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2020-04-15 9:29 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: barebox
On Wed, Apr 15, 2020 at 04:57:03PM +0900, Masahiro Yamada wrote:
> [ Linux commit 5f2fb52fac15a8a8e10ce020dd532504a8abfc4e ]
>
> In old days, the "host-progs" syntax was used for specifying host
> programs. It was renamed to the current "hostprogs-y" in 2004.
>
> It is typically useful in scripts/Makefile because it allows Kbuild to
> selectively compile host programs based on the kernel configuration.
>
> This commit renames like follows:
>
> always -> always-y
> hostprogs-y -> hostprogs
>
> So, scripts/Makefile will look like this:
>
> always-$(CONFIG_BUILD_BIN2C) += ...
> always-$(CONFIG_KALLSYMS) += ...
> ...
> hostprogs := $(always-y) $(always-m)
>
> I think this makes more sense because a host program is always a host
> program, irrespective of the kernel configuration. We want to specify
> which ones to compile by CONFIG options, so always-y will be handier.
>
> The "always", "hostprogs-y", "hostprogs-m" will be kept for backward
> compatibility for a while.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
Series applied, thanks
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-15 9:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15 7:57 [PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y Masahiro Yamada
2020-04-15 7:57 ` [PATCH 2/3] kbuild: update flex and bison rules to Linux 5.7-rc1 Masahiro Yamada
2020-04-15 7:57 ` [PATCH 3/3] fixdep: update " Masahiro Yamada
2020-04-15 9:29 ` [PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox