Compile menu.c as an independent compilation unit.
Signed-off-by: Masahiro Yamada <[email protected]>
---
scripts/kconfig/Makefile | 4 ++--
scripts/kconfig/internal.h | 9 +++++++++
scripts/kconfig/menu.c | 1 +
scripts/kconfig/parser.y | 5 ++---
4 files changed, 14 insertions(+), 5 deletions(-)
create mode 100644 scripts/kconfig/internal.h
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 1d1a7f83ee8d..5a215880b268 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -143,8 +143,8 @@ help:
# ===========================================================================
# object files used by all kconfig flavours
-common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
- symbol.o util.o
+common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
+ preprocess.o symbol.o util.o
$(obj)/lexer.lex.o: $(obj)/parser.tab.h
HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
diff --git a/scripts/kconfig/internal.h b/scripts/kconfig/internal.h
new file mode 100644
index 000000000000..2f7298c21b64
--- /dev/null
+++ b/scripts/kconfig/internal.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef INTERNAL_H
+#define INTERNAL_H
+
+struct menu;
+
+extern struct menu *current_menu, *current_entry;
+
+#endif /* INTERNAL_H */
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 8b2108b74821..606ba8a63c24 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -9,6 +9,7 @@
#include <string.h>
#include "lkc.h"
+#include "internal.h"
static const char nohelp_text[] = "There is no help available for this option.";
diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index e90889edf5b3..2af7ce4e1531 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -12,6 +12,7 @@
#include <stdbool.h>
#include "lkc.h"
+#include "internal.h"
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
@@ -28,7 +29,7 @@ static bool zconf_endtoken(const char *tokenname,
struct symbol *symbol_hash[SYMBOL_HASHSIZE];
-static struct menu *current_menu, *current_entry;
+struct menu *current_menu, *current_entry;
%}
@@ -713,5 +714,3 @@ void zconfdump(FILE *out)
}
}
}
-
-#include "menu.c"
--
2.27.0
Masahiro Yamada <[email protected]> writes:
> --- /dev/null
> +++ b/scripts/kconfig/internal.h
> @@ -0,0 +1,9 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +#ifndef INTERNAL_H
> +#define INTERNAL_H
> +
> +struct menu;
> +
> +extern struct menu *current_menu, *current_entry;
> +
> +#endif /* INTERNAL_H */
Maybe call it menu.h instead of internal.h? Unless you have plans
to put other "internal" stuff in there.
> --- a/scripts/kconfig/parser.y
> +++ b/scripts/kconfig/parser.y
> @@ -28,7 +29,7 @@ static bool zconf_endtoken(const char *tokenname,
>
> struct symbol *symbol_hash[SYMBOL_HASHSIZE];
>
> -static struct menu *current_menu, *current_entry;
> +struct menu *current_menu, *current_entry;
Why not put these in menu.c?
On Thu, Apr 15, 2021 at 7:54 PM Boris Kolpackov <[email protected]> wrote:
>
> Masahiro Yamada <[email protected]> writes:
>
> > --- /dev/null
> > +++ b/scripts/kconfig/internal.h
> > @@ -0,0 +1,9 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +#ifndef INTERNAL_H
> > +#define INTERNAL_H
> > +
> > +struct menu;
> > +
> > +extern struct menu *current_menu, *current_entry;
> > +
> > +#endif /* INTERNAL_H */
>
> Maybe call it menu.h instead of internal.h? Unless you have plans
> to put other "internal" stuff in there.
Yes, I will use this header for further cleanups
of headers.
>
> > --- a/scripts/kconfig/parser.y
> > +++ b/scripts/kconfig/parser.y
> > @@ -28,7 +29,7 @@ static bool zconf_endtoken(const char *tokenname,
> >
> > struct symbol *symbol_hash[SYMBOL_HASHSIZE];
> >
> > -static struct menu *current_menu, *current_entry;
> > +struct menu *current_menu, *current_entry;
>
> Why not put these in menu.c?
These variables are defined here
before I started to maintain Kconfig.
For now, I am just removing the 'static' directive.
--
Best Regards
Masahiro Yamada