diff mbox series

[v2,5/5] kconfig: refactor ncurses package checks for building nconf

Message ID 1526804213-8238-6-git-send-email-yamada.masahiro@socionext.com
State New
Headers show
Series kconfig: refactor package checks for GUI frontends | expand

Commit Message

Masahiro Yamada May 20, 2018, 8:16 a.m. UTC
Building nconf requires ncurses, but its presence is not checked.
Check and configure necessary packages by a shell script like the
other GUI frontends.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

Changes in v2:
  - Add fallback code in case distributions cannot find
    ncurses by pkg-config.

 scripts/kconfig/Makefile     | 16 ++++++++--------
 scripts/kconfig/nconf-cfg.sh | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 8 deletions(-)
 create mode 100644 scripts/kconfig/nconf-cfg.sh

-- 
2.7.4

Comments

Randy Dunlap May 20, 2018, 11:31 p.m. UTC | #1
On 05/20/2018 01:16 AM, Masahiro Yamada wrote:
> Building nconf requires ncurses, but its presence is not checked.

> Check and configure necessary packages by a shell script like the

> other GUI frontends.

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> ---

> 

> Changes in v2:

>   - Add fallback code in case distributions cannot find

>     ncurses by pkg-config.

> 


Hi,

Patch 4/5 for mconf works for me, but this one is failing.


$ make ARCH=x86_64 O=xx64 nconfig
make[1]: Entering directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
  GEN     ./Makefile
  UPD     scripts/kconfig/.nconf-cfg
  HOSTCC  scripts/kconfig/nconf.o
In file included from ../scripts/kconfig/nconf.c:15:0:
../scripts/kconfig/nconf.h:19:18: fatal error: menu.h: No such file or directory
 #include <menu.h>
                  ^
compilation terminated.
scripts/Makefile.host:107: recipe for target 'scripts/kconfig/nconf.o' failed
make[2]: *** [scripts/kconfig/nconf.o] Error 1
/home/rdunlap/lnx/next/linux-next-20180517/Makefile:525: recipe for target 'nconfig' failed
make[1]: *** [nconfig] Error 2
make[1]: Leaving directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
Makefile:146: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2


xx64/scripts/kconfig/.nconf-cfg contains:
libs="-lncursesw -lmenuw -lpanelw"

There are several menu.h files in /usr/include:
$ find . -name menu.h
./ncurses6/ncursesw/menu.h
./ncurses6/ncurses/menu.h
./ncursesw/menu.h
./claws-mail/gtk/menu.h
./ncurses/menu.h


>  scripts/kconfig/Makefile     | 16 ++++++++--------

>  scripts/kconfig/nconf-cfg.sh | 34 ++++++++++++++++++++++++++++++++++

>  2 files changed, 42 insertions(+), 8 deletions(-)

>  create mode 100644 scripts/kconfig/nconf-cfg.sh

> 

> diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile

> index 25a3d25..b90e801 100644

> --- a/scripts/kconfig/Makefile

> +++ b/scripts/kconfig/Makefile

> @@ -176,15 +176,12 @@ help:

>  # ===========================================================================

>  # Shared Makefile for the various kconfig executables:

>  # conf:	  Used for defconfig, oldconfig and related targets

> -# nconf:  Used for the nconfig target.

> -#         Utilizes ncurses

>  # object files used by all kconfig flavours

>  

>  conf-objs	:= conf.o  zconf.tab.o

> -nconf-objs     := nconf.o zconf.tab.o nconf.gui.o

>  kxgettext-objs	:= kxgettext.o zconf.tab.o

>  

> -hostprogs-y := conf nconf kxgettext

> +hostprogs-y := conf kxgettext

>  

>  targets		+= zconf.lex.c

>  clean-files	+= gconf.glade.h

> @@ -199,10 +196,13 @@ HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTC

>  HOSTCFLAGS_zconf.lex.o	:= -I$(src)

>  HOSTCFLAGS_zconf.tab.o	:= -I$(src)

>  

> -HOSTLOADLIBES_nconf	= $(shell \

> -				pkg-config --libs menuw panelw ncursesw 2>/dev/null \

> -				|| pkg-config --libs menu panel ncurses 2>/dev/null \

> -				|| echo "-lmenu -lpanel -lncurses"  )

> +# nconf: Used for the nconfig target based on ncurses

> +hostprogs-y	+= nconf

> +nconf-objs	:= nconf.o zconf.tab.o nconf.gui.o

> +

> +HOSTLOADLIBES_nconf	= $(shell . $(obj)/.nconf-cfg && echo $$libs)

> +

> +$(obj)/nconf.o: $(obj)/.nconf-cfg

>  

>  # mconf: Used for the menuconfig target based on lxdialog

>  hostprogs-y	+= mconf

> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh

> new file mode 100644

> index 0000000..8eb7948

> --- /dev/null

> +++ b/scripts/kconfig/nconf-cfg.sh

> @@ -0,0 +1,34 @@

> +#!/bin/sh

> +# SPDX-License-Identifier: GPL-2.0

> +

> +PKG="ncursesw menuw panelw"

> +PKG2="ncurses menu panel"

> +

> +if pkg-config --exists $PKG; then

> +	echo libs=\"$(pkg-config --libs $PKG)\"

> +	exit 0

> +fi

> +

> +if pkg-config --exists $PKG2; then

> +	echo libs=\"$(pkg-config --libs $PKG2)\"

> +	exit 0

> +fi

> +

> +# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses

> +# by pkg-config.

> +if [ -f /usr/include/ncursesw/ncurses.h ]; then

> +	echo libs=\"-lncursesw -lmenuw -lpanelw\"

> +	exit 0

> +fi

> +

> +if [ -f /usr/include/ncurses.h ]; then

> +	echo libs=\"-lncurses -lmenu -lpanel\"

> +	exit 0

> +fi

> +

> +echo >&2 "*"

> +echo >&2 "* Unable to find the ncurses."

> +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"

> +echo >&2 "* depending on your distribution)"

> +echo >&2 "*"

> +exit 1

> 



-- 
~Randy
Randy Dunlap May 20, 2018, 11:41 p.m. UTC | #2
On 05/20/2018 01:16 AM, Masahiro Yamada wrote:
> Building nconf requires ncurses, but its presence is not checked.

> Check and configure necessary packages by a shell script like the

> other GUI frontends.

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> ---

> 


> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh

> new file mode 100644

> index 0000000..8eb7948

> --- /dev/null

> +++ b/scripts/kconfig/nconf-cfg.sh

> @@ -0,0 +1,34 @@

> +#!/bin/sh

> +# SPDX-License-Identifier: GPL-2.0

> +

> +PKG="ncursesw menuw panelw"

> +PKG2="ncurses menu panel"

> +

> +if pkg-config --exists $PKG; then

> +	echo libs=\"$(pkg-config --libs $PKG)\"

> +	exit 0

> +fi

> +

> +if pkg-config --exists $PKG2; then

> +	echo libs=\"$(pkg-config --libs $PKG2)\"

> +	exit 0

> +fi

> +


I guess this one needs clags, especially -I, like the mconf patch contains...


> +# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses

> +# by pkg-config.

> +if [ -f /usr/include/ncursesw/ncurses.h ]; then

> +	echo libs=\"-lncursesw -lmenuw -lpanelw\"

> +	exit 0

> +fi

> +

> +if [ -f /usr/include/ncurses.h ]; then

> +	echo libs=\"-lncurses -lmenu -lpanel\"

> +	exit 0

> +fi

> +

> +echo >&2 "*"

> +echo >&2 "* Unable to find the ncurses."


                              the ncurses package."

> +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"

> +echo >&2 "* depending on your distribution)"


                                 distribution)."

> +echo >&2 "*"

> +exit 1

> 



-- 
~Randy
Masahiro Yamada May 21, 2018, 4:48 a.m. UTC | #3
2018-05-21 8:41 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:
> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:

>> Building nconf requires ncurses, but its presence is not checked.

>> Check and configure necessary packages by a shell script like the

>> other GUI frontends.

>>

>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>> ---

>>

>

>> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh

>> new file mode 100644

>> index 0000000..8eb7948

>> --- /dev/null

>> +++ b/scripts/kconfig/nconf-cfg.sh

>> @@ -0,0 +1,34 @@

>> +#!/bin/sh

>> +# SPDX-License-Identifier: GPL-2.0

>> +

>> +PKG="ncursesw menuw panelw"

>> +PKG2="ncurses menu panel"

>> +

>> +if pkg-config --exists $PKG; then

>> +     echo libs=\"$(pkg-config --libs $PKG)\"

>> +     exit 0

>> +fi

>> +

>> +if pkg-config --exists $PKG2; then

>> +     echo libs=\"$(pkg-config --libs $PKG2)\"

>> +     exit 0

>> +fi

>> +

>

> I guess this one needs clags, especially -I, like the mconf patch contains...




I thought so.

But, the current scripts/kconfig/Makefile
adds 'pkg-config --libs' to nconf,
but does nothing about 'pkg-config --cflags' for nconf.
Therefore, I kept the current behavior just in case.


The nconfig in the current version is not working for you, right?




>

>> +# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses

>> +# by pkg-config.

>> +if [ -f /usr/include/ncursesw/ncurses.h ]; then

>> +     echo libs=\"-lncursesw -lmenuw -lpanelw\"

>> +     exit 0

>> +fi

>> +

>> +if [ -f /usr/include/ncurses.h ]; then

>> +     echo libs=\"-lncurses -lmenu -lpanel\"

>> +     exit 0

>> +fi

>> +

>> +echo >&2 "*"

>> +echo >&2 "* Unable to find the ncurses."

>

>                               the ncurses package."

>

>> +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"

>> +echo >&2 "* depending on your distribution)"

>

>                                  distribution)."

>

>> +echo >&2 "*"

>> +exit 1

>>




-- 
Best Regards
Masahiro Yamada
Randy Dunlap May 21, 2018, 4:51 a.m. UTC | #4
On 05/20/2018 09:48 PM, Masahiro Yamada wrote:
> 2018-05-21 8:41 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:

>> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:

>>> Building nconf requires ncurses, but its presence is not checked.

>>> Check and configure necessary packages by a shell script like the

>>> other GUI frontends.

>>>

>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>>> ---

>>>

>>

>>> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh

>>> new file mode 100644

>>> index 0000000..8eb7948

>>> --- /dev/null

>>> +++ b/scripts/kconfig/nconf-cfg.sh

>>> @@ -0,0 +1,34 @@

>>> +#!/bin/sh

>>> +# SPDX-License-Identifier: GPL-2.0

>>> +

>>> +PKG="ncursesw menuw panelw"

>>> +PKG2="ncurses menu panel"

>>> +

>>> +if pkg-config --exists $PKG; then

>>> +     echo libs=\"$(pkg-config --libs $PKG)\"

>>> +     exit 0

>>> +fi

>>> +

>>> +if pkg-config --exists $PKG2; then

>>> +     echo libs=\"$(pkg-config --libs $PKG2)\"

>>> +     exit 0

>>> +fi

>>> +

>>

>> I guess this one needs clags, especially -I, like the mconf patch contains...

> 

> 

> 

> I thought so.

> 

> But, the current scripts/kconfig/Makefile

> adds 'pkg-config --libs' to nconf,

> but does nothing about 'pkg-config --cflags' for nconf.

> Therefore, I kept the current behavior just in case.

> 

> 

> The nconfig in the current version is not working for you, right?


That's correct.


Info:

$ make ARCH=x86_64 O=xx64 nconfig
make[1]: Entering directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
  GEN     ./Makefile
  UPD     scripts/kconfig/.nconf-cfg
  HOSTCC  scripts/kconfig/nconf.o
In file included from ../scripts/kconfig/nconf.c:15:0:
../scripts/kconfig/nconf.h:19:18: fatal error: menu.h: No such file or directory
 #include <menu.h>
                  ^
compilation terminated.
scripts/Makefile.host:107: recipe for target 'scripts/kconfig/nconf.o' failed
make[2]: *** [scripts/kconfig/nconf.o] Error 1
/home/rdunlap/lnx/next/linux-next-20180517/Makefile:525: recipe for target 'nconfig' failed
make[1]: *** [nconfig] Error 2
make[1]: Leaving directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'
Makefile:146: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2


xx64/scripts/kconfig/.nconf-cfg contains:
libs="-lncursesw -lmenuw -lpanelw"


>>> +# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses

>>> +# by pkg-config.

>>> +if [ -f /usr/include/ncursesw/ncurses.h ]; then

>>> +     echo libs=\"-lncursesw -lmenuw -lpanelw\"

>>> +     exit 0

>>> +fi

>>> +

>>> +if [ -f /usr/include/ncurses.h ]; then

>>> +     echo libs=\"-lncurses -lmenu -lpanel\"

>>> +     exit 0

>>> +fi

>>> +

>>> +echo >&2 "*"

>>> +echo >&2 "* Unable to find the ncurses."

>>

>>                               the ncurses package."

>>

>>> +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"

>>> +echo >&2 "* depending on your distribution)"

>>

>>                                  distribution)."

>>

>>> +echo >&2 "*"

>>> +exit 1

>>>

> 

> 

> 



-- 
~Randy
Masahiro Yamada May 21, 2018, 4:58 a.m. UTC | #5
2018-05-21 13:51 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:
> On 05/20/2018 09:48 PM, Masahiro Yamada wrote:

>> 2018-05-21 8:41 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:

>>> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:

>>>> Building nconf requires ncurses, but its presence is not checked.

>>>> Check and configure necessary packages by a shell script like the

>>>> other GUI frontends.

>>>>

>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>>>> ---

>>>>

>>>

>>>> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh

>>>> new file mode 100644

>>>> index 0000000..8eb7948

>>>> --- /dev/null

>>>> +++ b/scripts/kconfig/nconf-cfg.sh

>>>> @@ -0,0 +1,34 @@

>>>> +#!/bin/sh

>>>> +# SPDX-License-Identifier: GPL-2.0

>>>> +

>>>> +PKG="ncursesw menuw panelw"

>>>> +PKG2="ncurses menu panel"

>>>> +

>>>> +if pkg-config --exists $PKG; then

>>>> +     echo libs=\"$(pkg-config --libs $PKG)\"

>>>> +     exit 0

>>>> +fi

>>>> +

>>>> +if pkg-config --exists $PKG2; then

>>>> +     echo libs=\"$(pkg-config --libs $PKG2)\"

>>>> +     exit 0

>>>> +fi

>>>> +

>>>

>>> I guess this one needs clags, especially -I, like the mconf patch contains...

>>

>>

>>

>> I thought so.

>>

>> But, the current scripts/kconfig/Makefile

>> adds 'pkg-config --libs' to nconf,

>> but does nothing about 'pkg-config --cflags' for nconf.

>> Therefore, I kept the current behavior just in case.

>>

>>

>> The nconfig in the current version is not working for you, right?

>

> That's correct.

>

>

> Info:

>

> $ make ARCH=x86_64 O=xx64 nconfig

> make[1]: Entering directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'

>   GEN     ./Makefile

>   UPD     scripts/kconfig/.nconf-cfg

>   HOSTCC  scripts/kconfig/nconf.o

> In file included from ../scripts/kconfig/nconf.c:15:0:

> ../scripts/kconfig/nconf.h:19:18: fatal error: menu.h: No such file or directory

>  #include <menu.h>

>                   ^

> compilation terminated.

> scripts/Makefile.host:107: recipe for target 'scripts/kconfig/nconf.o' failed

> make[2]: *** [scripts/kconfig/nconf.o] Error 1

> /home/rdunlap/lnx/next/linux-next-20180517/Makefile:525: recipe for target 'nconfig' failed

> make[1]: *** [nconfig] Error 2

> make[1]: Leaving directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'

> Makefile:146: recipe for target 'sub-make' failed

> make: *** [sub-make] Error 2

>

>

> xx64/scripts/kconfig/.nconf-cfg contains:

> libs="-lncursesw -lmenuw -lpanelw"

>


Sorry, I mean
the nconfig in the Linus tree is not working, right?



-- 
Best Regards
Masahiro Yamada
Randy Dunlap May 21, 2018, 6:24 a.m. UTC | #6
On 05/20/2018 09:58 PM, Masahiro Yamada wrote:
> 2018-05-21 13:51 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:

>> On 05/20/2018 09:48 PM, Masahiro Yamada wrote:

>>> 2018-05-21 8:41 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:

>>>> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:

>>>>> Building nconf requires ncurses, but its presence is not checked.

>>>>> Check and configure necessary packages by a shell script like the

>>>>> other GUI frontends.

>>>>>

>>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>>>>> ---

>>>>>

>>>>

>>>>> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh

>>>>> new file mode 100644

>>>>> index 0000000..8eb7948

>>>>> --- /dev/null

>>>>> +++ b/scripts/kconfig/nconf-cfg.sh

>>>>> @@ -0,0 +1,34 @@

>>>>> +#!/bin/sh

>>>>> +# SPDX-License-Identifier: GPL-2.0

>>>>> +

>>>>> +PKG="ncursesw menuw panelw"

>>>>> +PKG2="ncurses menu panel"

>>>>> +

>>>>> +if pkg-config --exists $PKG; then

>>>>> +     echo libs=\"$(pkg-config --libs $PKG)\"

>>>>> +     exit 0

>>>>> +fi

>>>>> +

>>>>> +if pkg-config --exists $PKG2; then

>>>>> +     echo libs=\"$(pkg-config --libs $PKG2)\"

>>>>> +     exit 0

>>>>> +fi

>>>>> +

>>>>

>>>> I guess this one needs clags, especially -I, like the mconf patch contains...

>>>

>>>

>>>

>>> I thought so.

>>>

>>> But, the current scripts/kconfig/Makefile

>>> adds 'pkg-config --libs' to nconf,

>>> but does nothing about 'pkg-config --cflags' for nconf.

>>> Therefore, I kept the current behavior just in case.

>>>

>>>

>>> The nconfig in the current version is not working for you, right?

>>

>> That's correct.

>>

>>

>> Info:

>>

>> $ make ARCH=x86_64 O=xx64 nconfig

>> make[1]: Entering directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'

>>   GEN     ./Makefile

>>   UPD     scripts/kconfig/.nconf-cfg

>>   HOSTCC  scripts/kconfig/nconf.o

>> In file included from ../scripts/kconfig/nconf.c:15:0:

>> ../scripts/kconfig/nconf.h:19:18: fatal error: menu.h: No such file or directory

>>  #include <menu.h>

>>                   ^

>> compilation terminated.

>> scripts/Makefile.host:107: recipe for target 'scripts/kconfig/nconf.o' failed

>> make[2]: *** [scripts/kconfig/nconf.o] Error 1

>> /home/rdunlap/lnx/next/linux-next-20180517/Makefile:525: recipe for target 'nconfig' failed

>> make[1]: *** [nconfig] Error 2

>> make[1]: Leaving directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'

>> Makefile:146: recipe for target 'sub-make' failed

>> make: *** [sub-make] Error 2

>>

>>

>> xx64/scripts/kconfig/.nconf-cfg contains:

>> libs="-lncursesw -lmenuw -lpanelw"

>>

> 

> Sorry, I mean

> the nconfig in the Linus tree is not working, right?


It works just fine.  In a new linux-4.17-rc6 tree:

$ make ARCH=x86_64 O=xx64 V=1 nconfig
make -C /home/rdunlap/lnx/lnx-417-rc6/xx64 KBUILD_SRC=/home/rdunlap/lnx/lnx-417-rc6 \
-f /home/rdunlap/lnx/lnx-417-rc6/Makefile nconfig
make[1]: Entering directory '/home/rdunlap/lnx/lnx-417-rc6/xx64'
make -f ../scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
ln -fsn .. source
/bin/sh ../scripts/mkmakefile \
    .. . 4 17
  GEN     ./Makefile
make -f ../scripts/Makefile.build obj=scripts/kconfig nconfig
  gcc -Wp,-MD,scripts/kconfig/.nconf.o.d -Iscripts/kconfig -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89  -I/usr/include/ncursesw -DCURSES_LOC="<curses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -c -o scripts/kconfig/nconf.o ../scripts/kconfig/nconf.c
  gcc -Wp,-MD,scripts/kconfig/.nconf.gui.o.d -Iscripts/kconfig -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89  -I/usr/include/ncursesw -DCURSES_LOC="<curses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -c -o scripts/kconfig/nconf.gui.o ../scripts/kconfig/nconf.gui.c
  gcc  -o scripts/kconfig/nconf scripts/kconfig/nconf.o scripts/kconfig/zconf.tab.o scripts/kconfig/nconf.gui.o  -lmenu -lpanel -lncurses
scripts/kconfig/nconf  Kconfig
make[1]: Leaving directory '/home/rdunlap/lnx/lnx-417-rc6/xx64'



-- 
~Randy
Masahiro Yamada May 21, 2018, 6:58 a.m. UTC | #7
Randy,


2018-05-21 15:24 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:
> On 05/20/2018 09:58 PM, Masahiro Yamada wrote:

>> 2018-05-21 13:51 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:

>>> On 05/20/2018 09:48 PM, Masahiro Yamada wrote:

>>>> 2018-05-21 8:41 GMT+09:00 Randy Dunlap <rdunlap@infradead.org>:

>>>>> On 05/20/2018 01:16 AM, Masahiro Yamada wrote:

>>>>>> Building nconf requires ncurses, but its presence is not checked.

>>>>>> Check and configure necessary packages by a shell script like the

>>>>>> other GUI frontends.

>>>>>>

>>>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>>>>>> ---

>>>>>>

>>>>>

>>>>>> diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh

>>>>>> new file mode 100644

>>>>>> index 0000000..8eb7948

>>>>>> --- /dev/null

>>>>>> +++ b/scripts/kconfig/nconf-cfg.sh

>>>>>> @@ -0,0 +1,34 @@

>>>>>> +#!/bin/sh

>>>>>> +# SPDX-License-Identifier: GPL-2.0

>>>>>> +

>>>>>> +PKG="ncursesw menuw panelw"

>>>>>> +PKG2="ncurses menu panel"

>>>>>> +

>>>>>> +if pkg-config --exists $PKG; then

>>>>>> +     echo libs=\"$(pkg-config --libs $PKG)\"

>>>>>> +     exit 0

>>>>>> +fi

>>>>>> +

>>>>>> +if pkg-config --exists $PKG2; then

>>>>>> +     echo libs=\"$(pkg-config --libs $PKG2)\"

>>>>>> +     exit 0

>>>>>> +fi

>>>>>> +

>>>>>

>>>>> I guess this one needs clags, especially -I, like the mconf patch contains...

>>>>

>>>>

>>>>

>>>> I thought so.

>>>>

>>>> But, the current scripts/kconfig/Makefile

>>>> adds 'pkg-config --libs' to nconf,

>>>> but does nothing about 'pkg-config --cflags' for nconf.

>>>> Therefore, I kept the current behavior just in case.

>>>>

>>>>

>>>> The nconfig in the current version is not working for you, right?

>>>

>>> That's correct.

>>>

>>>

>>> Info:

>>>

>>> $ make ARCH=x86_64 O=xx64 nconfig

>>> make[1]: Entering directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'

>>>   GEN     ./Makefile

>>>   UPD     scripts/kconfig/.nconf-cfg

>>>   HOSTCC  scripts/kconfig/nconf.o

>>> In file included from ../scripts/kconfig/nconf.c:15:0:

>>> ../scripts/kconfig/nconf.h:19:18: fatal error: menu.h: No such file or directory

>>>  #include <menu.h>

>>>                   ^

>>> compilation terminated.

>>> scripts/Makefile.host:107: recipe for target 'scripts/kconfig/nconf.o' failed

>>> make[2]: *** [scripts/kconfig/nconf.o] Error 1

>>> /home/rdunlap/lnx/next/linux-next-20180517/Makefile:525: recipe for target 'nconfig' failed

>>> make[1]: *** [nconfig] Error 2

>>> make[1]: Leaving directory '/home/rdunlap/lnx/next/linux-next-20180517/xx64'

>>> Makefile:146: recipe for target 'sub-make' failed

>>> make: *** [sub-make] Error 2

>>>

>>>

>>> xx64/scripts/kconfig/.nconf-cfg contains:

>>> libs="-lncursesw -lmenuw -lpanelw"

>>>

>>

>> Sorry, I mean

>> the nconfig in the Linus tree is not working, right?

>

> It works just fine.  In a new linux-4.17-rc6 tree:

>

> $ make ARCH=x86_64 O=xx64 V=1 nconfig

> make -C /home/rdunlap/lnx/lnx-417-rc6/xx64 KBUILD_SRC=/home/rdunlap/lnx/lnx-417-rc6 \

> -f /home/rdunlap/lnx/lnx-417-rc6/Makefile nconfig

> make[1]: Entering directory '/home/rdunlap/lnx/lnx-417-rc6/xx64'

> make -f ../scripts/Makefile.build obj=scripts/basic

> rm -f .tmp_quiet_recordmcount

> ln -fsn .. source

> /bin/sh ../scripts/mkmakefile \

>     .. . 4 17

>   GEN     ./Makefile

> make -f ../scripts/Makefile.build obj=scripts/kconfig nconfig

>   gcc -Wp,-MD,scripts/kconfig/.nconf.o.d -Iscripts/kconfig -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89  -I/usr/include/ncursesw -DCURSES_LOC="<curses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -c -o scripts/kconfig/nconf.o ../scripts/kconfig/nconf.c

>   gcc -Wp,-MD,scripts/kconfig/.nconf.gui.o.d -Iscripts/kconfig -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89  -I/usr/include/ncursesw -DCURSES_LOC="<curses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -c -o scripts/kconfig/nconf.gui.o ../scripts/kconfig/nconf.gui.c

>   gcc  -o scripts/kconfig/nconf scripts/kconfig/nconf.o scripts/kconfig/zconf.tab.o scripts/kconfig/nconf.gui.o  -lmenu -lpanel -lncurses

> scripts/kconfig/nconf  Kconfig

> make[1]: Leaving directory '/home/rdunlap/lnx/lnx-417-rc6/xx64'

>


Ah, I see.

The output from check-lxdialog.sh is passed
to all objects:


# lxdialog stuff
check-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh

# Use recursively expanded variables so we do not call gcc unless
# we really need to do so. (Do not call gcc as part of make mrproper)
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
                    -DLOCALE





In fact, the ncurses options are passed even to the text-based
scripts/kconfig/conf.



masahiro@pug:~/ref/linux$ make V=1 oldconfig
make -f ./scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
make -f ./scripts/Makefile.build obj=scripts/kconfig oldconfig
  gcc -Wp,-MD,scripts/kconfig/.conf.o.d -Wall -Wmissing-prototypes
-Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
-D_GNU_SOURCE -I/usr/include/ncursesw -DCURSES_LOC="<ncurses.h>"
-DNCURSES_WIDECHAR=1 -DLOCALE   -c -o scripts/kconfig/conf.o
scripts/kconfig/conf.c
  bison -oscripts/kconfig/zconf.tab.c -t -l scripts/kconfig/zconf.y
  flex -oscripts/kconfig/zconf.lex.c -L scripts/kconfig/zconf.l
  gcc -Wp,-MD,scripts/kconfig/.zconf.tab.o.d -Wall
-Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
-std=gnu89    -D_GNU_SOURCE -I/usr/include/ncursesw
-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE
-Iscripts/kconfig -c -o scripts/kconfig/zconf.tab.o
scripts/kconfig/zconf.tab.c
  gcc  -o scripts/kconfig/conf scripts/kconfig/conf.o
scripts/kconfig/zconf.tab.o
scripts/kconfig/conf  --oldconfig Kconfig



I am fixing it, but forgot to mention that in my commit log.

Thanks!




-- 
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 25a3d25..b90e801 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -176,15 +176,12 @@  help:
 # ===========================================================================
 # Shared Makefile for the various kconfig executables:
 # conf:	  Used for defconfig, oldconfig and related targets
-# nconf:  Used for the nconfig target.
-#         Utilizes ncurses
 # object files used by all kconfig flavours
 
 conf-objs	:= conf.o  zconf.tab.o
-nconf-objs     := nconf.o zconf.tab.o nconf.gui.o
 kxgettext-objs	:= kxgettext.o zconf.tab.o
 
-hostprogs-y := conf nconf kxgettext
+hostprogs-y := conf kxgettext
 
 targets		+= zconf.lex.c
 clean-files	+= gconf.glade.h
@@ -199,10 +196,13 @@  HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTC
 HOSTCFLAGS_zconf.lex.o	:= -I$(src)
 HOSTCFLAGS_zconf.tab.o	:= -I$(src)
 
-HOSTLOADLIBES_nconf	= $(shell \
-				pkg-config --libs menuw panelw ncursesw 2>/dev/null \
-				|| pkg-config --libs menu panel ncurses 2>/dev/null \
-				|| echo "-lmenu -lpanel -lncurses"  )
+# nconf: Used for the nconfig target based on ncurses
+hostprogs-y	+= nconf
+nconf-objs	:= nconf.o zconf.tab.o nconf.gui.o
+
+HOSTLOADLIBES_nconf	= $(shell . $(obj)/.nconf-cfg && echo $$libs)
+
+$(obj)/nconf.o: $(obj)/.nconf-cfg
 
 # mconf: Used for the menuconfig target based on lxdialog
 hostprogs-y	+= mconf
diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
new file mode 100644
index 0000000..8eb7948
--- /dev/null
+++ b/scripts/kconfig/nconf-cfg.sh
@@ -0,0 +1,34 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+PKG="ncursesw menuw panelw"
+PKG2="ncurses menu panel"
+
+if pkg-config --exists $PKG; then
+	echo libs=\"$(pkg-config --libs $PKG)\"
+	exit 0
+fi
+
+if pkg-config --exists $PKG2; then
+	echo libs=\"$(pkg-config --libs $PKG2)\"
+	exit 0
+fi
+
+# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses
+# by pkg-config.
+if [ -f /usr/include/ncursesw/ncurses.h ]; then
+	echo libs=\"-lncursesw -lmenuw -lpanelw\"
+	exit 0
+fi
+
+if [ -f /usr/include/ncurses.h ]; then
+	echo libs=\"-lncurses -lmenu -lpanel\"
+	exit 0
+fi
+
+echo >&2 "*"
+echo >&2 "* Unable to find the ncurses."
+echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
+echo >&2 "* depending on your distribution)"
+echo >&2 "*"
+exit 1