fix initramfs
[openwrt.git] / scripts / config / lxdialog / check-lxdialog.sh
1 #!/usr/bin/env bash
2 # Check ncurses compatibility
3
4 # What library to link
5 ldflags()
6 {
7 for ext in so dylib; do
8 for dir in "" /usr/local/lib /opt/local/lib; do
9 $cc ${dir:+-L$dir} -print-file-name=libncursesw.$ext | grep -q /
10 if [ $? -eq 0 ]; then
11 echo $dir '-lncursesw'
12 exit
13 fi
14 $cc ${dir:+-L$dir} -print-file-name=libncurses.$ext | grep -q /
15 if [ $? -eq 0 ]; then
16 echo $dir '-lncurses'
17 exit
18 fi
19 $cc ${dir:+-L$dir} -print-file-name=libcurses.$ext | grep -q /
20 if [ $? -eq 0 ]; then
21 echo $dir '-lcurses'
22 exit
23 fi
24 done
25 done
26 exit 1
27 }
28
29 # Where is ncurses.h?
30 ccflags()
31 {
32 if [ -f /usr/include/ncurses/ncurses.h ]; then
33 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
34 elif [ -f /usr/include/ncurses/curses.h ]; then
35 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
36 elif [ -f /opt/local/include/ncurses/ncurses.h ]; then
37 echo '-I/opt/local/include -I/opt/local/include/ncurses -DCURSES_LOC="<ncurses/ncurses.h>"'
38 elif [ -f /usr/include/ncurses.h ]; then
39 echo '-DCURSES_LOC="<ncurses.h>"'
40 else
41 echo '-DCURSES_LOC="<curses.h>"'
42 fi
43 }
44
45 # Temp file, try to clean up after us
46 tmp=.lxdialog.tmp
47 trap "rm -f $tmp" 0 1 2 3 15
48
49 # Check if we can link to ncurses
50 check() {
51 echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
52 if [ $? != 0 ]; then
53 echo " *** Unable to find the ncurses libraries." 1>&2
54 echo " *** make menuconfig require the ncurses libraries" 1>&2
55 echo " *** " 1>&2
56 echo " *** Install ncurses (ncurses-devel) and try again" 1>&2
57 echo " *** " 1>&2
58 exit 1
59 fi
60 }
61
62 usage() {
63 printf "Usage: $0 [-check compiler options|-header|-library]\n"
64 }
65
66 if [ $# -eq 0 ]; then
67 usage
68 exit 1
69 fi
70
71 cc=""
72 case "$1" in
73 "-check")
74 shift
75 cc="$@"
76 check
77 ;;
78 "-ccflags")
79 ccflags
80 ;;
81 "-ldflags")
82 shift
83 cc="$@"
84 ldflags
85 ;;
86 "*")
87 usage
88 exit 1
89 ;;
90 esac
This page took 0.047343 seconds and 5 git commands to generate.