kconfig/lxdialog/check-lxdialog.sh
author "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
Thu Jul 28 22:09:31 2011 +0200 (2011-07-28)
changeset 2573 424fa2092ace
parent 2125 4009fc9c47d5
permissions -rw-r--r--
scripts/libc: do not build add-ons by default

Currently, no --enable-add-ons option is passed to libc configure when
"$(do_libc_add_ons_list ,)" is empty, which makes configure automatically search
for present add-ons. In that case, all present add-ons are built, although
no add-on was selected by the user in the config. Moreover, this can make the
configure fail if some non-standard add-ons like eglibc-localedef are present.

This behavior also leads to an inconsistency from a user point of view between
the following cases:
- LIBC_ADDONS_LIST="", LIBC_GLIBC_USE_PORTS=n and THREADS="none" in the config,
which makes "$(do_libc_add_ons_list ,)" return "", so all present add-ons
are built.
- LIBC_ADDONS_LIST="", LIBC_GLIBC_USE_PORTS=n and THREADS!="none" in the
config, which makes "$(do_libc_add_ons_list ,)" return the add-on supporting
the chosen threading implementation, e.g. "nptl", so only this add-on is
built.

This patch disables the building of all add-ons in that case.

It is still possible to build all present add-ons by adding --enable-add-ons to
LIBC_GLIBC_EXTRA_CONFIG_ARRAY.

Signed-off-by: "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
yann@1
     1
#!/bin/sh
yann@1
     2
# Check ncurses compatibility
yann@1
     3
yann@1
     4
# What library to link
yann@1
     5
ldflags()
yann@1
     6
{
yann@1087
     7
	for ext in so a dylib ; do
yann@1087
     8
		for lib in ncursesw ncurses curses ; do
yann@2125
     9
			$cc -print-file-name=lib${lib}.${ext} | grep -q /
yann@2125
    10
			if [ $? -eq 0 ]; then
yann@2125
    11
				echo "-l${lib}"
yann@1087
    12
				exit
yann@1087
    13
			fi
yann@1087
    14
		done
yann@1087
    15
	done
yann@1
    16
	exit 1
yann@1
    17
}
yann@1
    18
yann@1
    19
# Where is ncurses.h?
yann@1
    20
ccflags()
yann@1
    21
{
yann@2125
    22
	if [ -f /usr/include/ncurses/ncurses.h ]; then
yann@2125
    23
		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
yann@2125
    24
	elif [ -f /usr/include/ncurses/curses.h ]; then
yann@2125
    25
		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
yann@2448
    26
	elif [ -f /usr/include/ncursesw/curses.h ]; then
yann@2448
    27
		echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
yann@2125
    28
	elif [ -f /usr/include/ncurses.h ]; then
yann@2125
    29
		echo '-DCURSES_LOC="<ncurses.h>"'
yann@1
    30
	else
yann@2125
    31
		echo '-DCURSES_LOC="<curses.h>"'
yann@1
    32
	fi
yann@1
    33
}
yann@1
    34
yann@1
    35
# Temp file, try to clean up after us
yann@1
    36
tmp=.lxdialog.tmp
yann@1
    37
trap "rm -f $tmp" 0 1 2 3 15
yann@1
    38
yann@1
    39
# Check if we can link to ncurses
yann@1
    40
check() {
yann@2125
    41
        $cc -xc - -o $tmp 2>/dev/null <<'EOF'
yann@1087
    42
#include CURSES_LOC
yann@1087
    43
main() {}
yann@1087
    44
EOF
yann@1087
    45
	if [ $? != 0 ]; then
yann@1087
    46
	    echo " *** Unable to find the ncurses libraries or the"       1>&2
yann@1087
    47
	    echo " *** required header files."                            1>&2
yann@1087
    48
	    echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
yann@1087
    49
	    echo " *** "                                                  1>&2
yann@1087
    50
	    echo " *** Install ncurses (ncurses-devel) and try again."    1>&2
yann@1087
    51
	    echo " *** "                                                  1>&2
yann@1087
    52
	    exit 1
yann@1
    53
	fi
yann@1
    54
}
yann@1
    55
yann@1
    56
usage() {
yann@1229
    57
	printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
yann@1
    58
}
yann@1
    59
yann@706
    60
if [ $# -eq 0 ]; then
yann@1
    61
	usage
yann@1
    62
	exit 1
yann@1
    63
fi
yann@1
    64
yann@1
    65
cc=""
yann@1
    66
case "$1" in
yann@1
    67
	"-check")
yann@1
    68
		shift
yann@1
    69
		cc="$@"
yann@1
    70
		check
yann@1
    71
		;;
yann@1
    72
	"-ccflags")
yann@1
    73
		ccflags
yann@1
    74
		;;
yann@1
    75
	"-ldflags")
yann@1
    76
		shift
yann@1
    77
		cc="$@"
yann@1
    78
		ldflags
yann@1
    79
		;;
yann@1
    80
	"*")
yann@1
    81
		usage
yann@1
    82
		exit 1
yann@1
    83
		;;
yann@1
    84
esac