kconfig/lxdialog: more portable and use ncurses from macports on MacOS
authorTitus von Boxberg <titus@v9g.de>
Mon May 24 16:33:45 2010 +0200 (2010-05-24)
changeset 197320f02d426e15
parent 1972 7939e7e0573d
child 1974 444d434c658f
kconfig/lxdialog: more portable and use ncurses from macports on MacOS

check-lxdialog.sh now correctly tests for ncurses and is a bit more portable.
On Darwin it uses the ncurses from macports.
kconfig/kconfig.mk
kconfig/lxdialog/check-lxdialog.sh
     1.1 --- a/kconfig/kconfig.mk	Mon May 24 16:34:55 2010 +0200
     1.2 +++ b/kconfig/kconfig.mk	Mon May 24 16:33:45 2010 +0200
     1.3 @@ -65,7 +65,7 @@
     1.4  check_lxdialog = $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh
     1.5  
     1.6  # Build flags
     1.7 -CFLAGS = 
     1.8 +CFLAGS =
     1.9  LDFLAGS =
    1.10  
    1.11  # Compiler flags to use gettext
     2.1 --- a/kconfig/lxdialog/check-lxdialog.sh	Mon May 24 16:34:55 2010 +0200
     2.2 +++ b/kconfig/lxdialog/check-lxdialog.sh	Mon May 24 16:33:45 2010 +0200
     2.3 @@ -1,14 +1,24 @@
     2.4  #!/bin/sh
     2.5  # Check ncurses compatibility
     2.6  
     2.7 +OS=`uname`
     2.8 +
     2.9 +# Under MACOS make sure that the macports-installed version is used.
    2.10 +case "$OS" in
    2.11 +	Darwin) BASEDIR="/opt/local";;
    2.12 +	*)      BASEDIR="/usr";;
    2.13 +esac
    2.14 +
    2.15 +INCLUDEPATH="${BASEDIR}/include"
    2.16 +LIBPATH="${BASEDIR}/lib"
    2.17 +
    2.18  # What library to link
    2.19  ldflags()
    2.20  {
    2.21  	for ext in so a dylib ; do
    2.22  		for lib in ncursesw ncurses curses ; do
    2.23 -			$cc -print-file-name=lib${lib}.${ext} | grep -q /
    2.24 -			if [ $? -eq 0 ]; then
    2.25 -				echo "-l${lib}"
    2.26 +			if [ -f "${LIBPATH}/lib${lib}.${ext}" ]; then
    2.27 +				echo "-L${LIBPATH} -l${lib}"
    2.28  				exit
    2.29  			fi
    2.30  		done
    2.31 @@ -19,14 +29,20 @@
    2.32  # Where is ncurses.h?
    2.33  ccflags()
    2.34  {
    2.35 -	if [ -f /usr/include/ncurses/ncurses.h ]; then
    2.36 -		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
    2.37 -	elif [ -f /usr/include/ncurses/curses.h ]; then
    2.38 -		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
    2.39 -	elif [ -f /usr/include/ncurses.h ]; then
    2.40 -		echo '-DCURSES_LOC="<ncurses.h>"'
    2.41 +	if [ -f "${INCLUDEPATH}/ncursesw/ncurses.h" ]; then
    2.42 +		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncursesw/ncurses.h>\""
    2.43 +	elif [ -f "${INCLUDEPATH}/ncurses/ncurses.h" ]; then
    2.44 +		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncurses/ncurses.h>\""
    2.45 +	elif [ -f "${INCLUDEPATH}/ncursesw/curses.h" ]; then
    2.46 +		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncursesw/curses.h>\""
    2.47 +	elif [ -f "${INCLUDEPATH}/ncurses/curses.h" ]; then
    2.48 +		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncurses/curses.h>\""
    2.49 +	elif [ -f "${INCLUDEPATH}/ncurses.h" ]; then
    2.50 +		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncurses.h>\""
    2.51 +	elif [ -f "${INCLUDEPATH}/curses.h" ]; then
    2.52 +		echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<curses.h>\""
    2.53  	else
    2.54 -		echo '-DCURSES_LOC="<curses.h>"'
    2.55 +		exit 1
    2.56  	fi
    2.57  }
    2.58  
    2.59 @@ -36,7 +52,8 @@
    2.60  
    2.61  # Check if we can link to ncurses
    2.62  check() {
    2.63 -        $cc -xc - -o $tmp 2>/dev/null <<'EOF'
    2.64 +        IF=`echo $(ccflags) | sed -e 's/"//g'`
    2.65 +        $cc $IF $(ldflags) -xc - -o $tmp 2>/dev/null <<'EOF'
    2.66  #include CURSES_LOC
    2.67  main() {}
    2.68  EOF