Skip to contentSkip to conversation

kconfig: Check for libncurses before menuconfig

PATCH Superseded Borislav Petkov 2 participants 7 messages Apr 9, 2017 – Jun 9, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kconfig: Check for libncurses before menuconfig

From: Borislav Petkov <[email protected]>

There is a check and a nice user-friendly message when the curses library is not present on the system and the user wants to do "make menuconfig". It doesn't get issued, though. Instead, we fail the build when mconf.c doesn't find the curses.h header:

HOSTCC scripts/kconfig/mconf.o
In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory

   #include CURSES_LOC
                      ^

compilation terminated.

Make that check a prerequisite to mconf so that the user sees the error message instead:

  $ make menuconfig
   *** Unable to find the ncurses libraries or the
   *** required header files.
   *** 'make menuconfig' requires the ncurses libraries.
   ***
   *** Install ncurses (ncurses-devel) and try again.
   ***
  scripts/kconfig/Makefile:203: recipe for target 'scripts/kconfig/dochecklxdialog' failed
  make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
  Makefile:548: recipe for target 'menuconfig' failed
  make: *** [menuconfig] Error 2
---
 scripts/kconfig/Makefile | 2 ++
 1 file changed, 2 insertions(+)
scripts/kconfig/Makefile +2 -0
index 90a091b6ae4d..e58220ce65b9 100644
@@ -24,6 +24,8 @@ xconfig: $(obj)/qconf
 gconfig: $(obj)/gconf
 	$< $(silent) $(Kconfig)
 
+$(obj)/mconf: $(obj)/dochecklxdialog
+
 menuconfig: $(obj)/mconf
 	$< $(silent) $(Kconfig)
 
Signature · 1 line
2.11.0
#1 lore raw

Hi Borislav,

2017-04-09 22:07 GMT+09:00 Borislav Petkov <[email protected]>:

Quoted 7 lines

From: Borislav Petkov <[email protected]>

There is a check and a nice user-friendly message when the curses library is not present on the system and the user wants to do "make menuconfig". It doesn't get issued, though. Instead, we fail the build when mconf.c doesn't find the curses.h header:

Quoted 6 lines

HOSTCC scripts/kconfig/mconf.o
In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory

   #include CURSES_LOC
                      ^

compilation terminated.

Strange, I could not reproduce this.

As far as I tested,
"make menuconfig" invoked dochecklxdialog without this patch.

mconf depends on $(lxdiaglog) at line 184:
mconf-objs := mconf.o zconf.tab.o $(lxdialog)

$(lxdialog) depends on dochecklxdialog at line 199:
$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog

Quoted 42 lines

Make that check a prerequisite to mconf so that the user sees the error message instead:

  $ make menuconfig
   *** Unable to find the ncurses libraries or the
   *** required header files.
   *** 'make menuconfig' requires the ncurses libraries.
   ***
   *** Install ncurses (ncurses-devel) and try again.
   ***
  scripts/kconfig/Makefile:203: recipe for target 'scripts/kconfig/dochecklxdialog' failed
  make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
  Makefile:548: recipe for target 'menuconfig' failed
  make: *** [menuconfig] Error 2
---
 scripts/kconfig/Makefile | 2 ++
 1 file changed, 2 insertions(+)
scripts/kconfig/Makefile +2 -1
index 90a091b6ae4d..e58220ce65b9 100644
@@ -24,6 +24,8 @@ xconfig: $(obj)/qconf
 gconfig: $(obj)/gconf
        $< $(silent) $(Kconfig)
 
+$(obj)/mconf: $(obj)/dochecklxdialog
+
 menuconfig: $(obj)/mconf
        $< $(silent) $(Kconfig)
 
--

2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 1 line · Masahiro Yamada

Strange, I could not reproduce this.

Remove libncurses5-dev or whatever it is called on your system and do:

$ make menuconfig
  HOSTCC  scripts/kconfig/mconf.o
In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory
 #include CURSES_LOC
                    ^
compilation terminated.
scripts/Makefile.host:124: recipe for target 'scripts/kconfig/mconf.o' failed
make[1]: *** [scripts/kconfig/mconf.o] Error 1
Makefile:548: recipe for target 'menuconfig' failed
make: *** [menuconfig] Error 2
Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#3 lore raw

Hi Borislav,

2017-05-21 5:33 GMT+09:00 Borislav Petkov <[email protected]>:

Quoted 5 lines · Masahiro Yamada
Quoted 1 line

Strange, I could not reproduce this.

Remove libncurses5-dev or whatever it is called on your system and do:

Quoted 11 lines
$ make menuconfig
  HOSTCC  scripts/kconfig/mconf.o
In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory
 #include CURSES_LOC
                    ^
compilation terminated.
scripts/Makefile.host:124: recipe for target 'scripts/kconfig/mconf.o' failed
make[1]: *** [scripts/kconfig/mconf.o] Error 1
Makefile:548: recipe for target 'menuconfig' failed
make: *** [menuconfig] Error 2

OK, I see.

So, it is $(obj)/mconf.o instead of $(obj)/mconf
that should depend on $(obj)/dochecklxdialog.

Could you change line 199

  $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog

to

  $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog

and send v2, please?

This will make sure dochecklxdialog is run before compiling mconf.o in parallel building.

Thanks!

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw

PATCH v2 1/1 kconfig: Check for libncurses before menuconfig

Quoted 9 lines · Masahiro Yamada

Could you change line 199

  $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog

to

  $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog

and send v2, please?

Here it is:

---
From: Borislav Petkov <[email protected]>
Date: Sun, 9 Apr 2017 15:07:08 +0200
Subject: [PATCH v2] kconfig: Check for libncurses before menuconfig

There is a check and a nice user-friendly message when the curses library is not present on the system and the user wants to do "make menuconfig". It doesn't get issued, though. Instead, we fail the build when mconf.c doesn't find the curses.h header:

HOSTCC scripts/kconfig/mconf.o
In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory

   #include CURSES_LOC
                      ^

compilation terminated.

Make sure dochecklxdialog gets run before mconf is compiled so that the user sees the error message instead:

  $ make menuconfig
   *** Unable to find the ncurses libraries or the
   *** required header files.
   *** 'make menuconfig' requires the ncurses libraries.
   ***
   *** Install ncurses (ncurses-devel) and try again.
   ***
  scripts/kconfig/Makefile:203: recipe for target 'scripts/kconfig/dochecklxdialog' failed
  make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
  Makefile:548: recipe for target 'menuconfig' failed
  make: *** [menuconfig] Error 2
---
 scripts/kconfig/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/Makefile +1 -1
index 90a091b6ae4d..eb8144643b78 100644
@@ -196,7 +196,7 @@ clean-files     += config.pot linux.pot
 
 # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
 PHONY += $(obj)/dochecklxdialog
-$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
+$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog
 $(obj)/dochecklxdialog:
 	$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
 
Signature · 7 lines
2.11.0

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
Acked-by on v2 1/1
#5 lore raw

2017-05-21 18:44 GMT+09:00 Borislav Petkov <[email protected]>:

Quoted 57 lines · Masahiro Yamada
Quoted 9 lines

Could you change line 199

  $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog

to

  $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog

and send v2, please?

Here it is:

---
From: Borislav Petkov <[email protected]>
Date: Sun, 9 Apr 2017 15:07:08 +0200
Subject: [PATCH v2] kconfig: Check for libncurses before menuconfig

There is a check and a nice user-friendly message when the curses library is not present on the system and the user wants to do "make menuconfig". It doesn't get issued, though. Instead, we fail the build when mconf.c doesn't find the curses.h header:

HOSTCC scripts/kconfig/mconf.o
In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory

   #include CURSES_LOC
                      ^

compilation terminated.

Make sure dochecklxdialog gets run before mconf is compiled so that the user sees the error message instead:

  $ make menuconfig
   *** Unable to find the ncurses libraries or the
   *** required header files.
   *** 'make menuconfig' requires the ncurses libraries.
   ***
   *** Install ncurses (ncurses-devel) and try again.
   ***
  scripts/kconfig/Makefile:203: recipe for target 'scripts/kconfig/dochecklxdialog' failed
  make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
  Makefile:548: recipe for target 'menuconfig' failed
  make: *** [menuconfig] Error 2
---
 scripts/kconfig/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/Makefile +0 -0
index 90a091b6ae4d..eb8144643b78 100644

scripts/kconfig/Makefile clean-files += config.pot linux.pot · line 202

Quoted 8 lines
scripts/kconfig/Makefile +1 -1
@@ -196,7 +196,7 @@ clean-files     += config.pot linux.pot
 
 # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
 PHONY += $(obj)/dochecklxdialog
-$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
+$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog
 $(obj)/dochecklxdialog:
        $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
 

I will pick it up for v4.13 if it is not applied via kconfig. I still will somebody can maintain the kconfig subsystem, though.

Signature · 2 lines
Best Regards
Masahiro Yamada
#6 lore raw
In reply to Borislav Petkov

2017-05-21 18:44 GMT+09:00 Borislav Petkov <[email protected]>:

Quoted 45 lines · Masahiro Yamada
Quoted 9 lines

Could you change line 199

  $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog

to

  $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog

and send v2, please?

Here it is:

---
From: Borislav Petkov <[email protected]>
Date: Sun, 9 Apr 2017 15:07:08 +0200
Subject: [PATCH v2] kconfig: Check for libncurses before menuconfig

There is a check and a nice user-friendly message when the curses library is not present on the system and the user wants to do "make menuconfig". It doesn't get issued, though. Instead, we fail the build when mconf.c doesn't find the curses.h header:

HOSTCC scripts/kconfig/mconf.o
In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory

   #include CURSES_LOC
                      ^

compilation terminated.

Make sure dochecklxdialog gets run before mconf is compiled so that the user sees the error message instead:

  $ make menuconfig
   *** Unable to find the ncurses libraries or the
   *** required header files.
   *** 'make menuconfig' requires the ncurses libraries.
   ***
   *** Install ncurses (ncurses-devel) and try again.
   ***
  scripts/kconfig/Makefile:203: recipe for target 'scripts/kconfig/dochecklxdialog' failed
  make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
  Makefile:548: recipe for target 'menuconfig' failed
  make: *** [menuconfig] Error 2
Quoted 4 lines

---

Applied to linux-kbuild/fixes. Thanks!

Signature · 2 lines
Best Regards
Masahiro Yamada