]> www.hackdaworld.org Git - physik/nlsop.git/blob - configure
added data ok define
[physik/nlsop.git] / configure
1 #!/bin/sh
2
3 name="nlsop_server nlsop_client nlsop_gui"
4 main="nlsop"
5
6 #defaults
7 prefix=/usr
8 dfblib=""
9 dfbinc=""
10 apidir=""
11 nodfb=0
12
13 echo $run_cmd
14
15 usage() {
16         echo "usage $0 <options>"
17         echo "options:"
18         echo "--prefix=PREFIX   specify install prefix"
19         echo "--with-dfblib=DIR specify directfb lib dir"
20         echo "--with-dfbinc=DIR specify directfb include dir"
21         echo "--with-api=DIR    specify api dir"
22         echo
23         }
24
25 while [ "$1" ]; do
26         case "`echo $1 | awk -F= '{ print $1 }'`" in
27                 --prefix)       prefix=`echo $1 | awk -F= '{ print $2 }'`; shift;;
28                 --help)         usage; shift 1;;
29                 --with-dfblib)  dfblib=`echo $1 | awk -F= '{ print $2 }'`; shift;;
30                 --with-dfbinc)  dfbinc=`echo $1 | awk -F= '{ print $2 }'`; shift;;
31                 --without-dfb)  nodfb=1; shift ;;
32                 --with-api)     apidir=`echo $1 | awk -F= '{ print $2 }'`; shift;;
33         esac
34 done
35
36 echo "checking for api stuff ..."
37 api_dir="0"
38 if [ -z "$apidir" ]; then
39         for i in ../api ../../api; do
40                 if [ -f $i/CHANGELOG ]; then
41                         api_dir=$i
42                 fi
43         done
44 else
45         if [ -f $apidir/CHANGELOG ]; then
46                 api_dir=$apidir
47         fi
48 fi
49 if [ "$api_dir" = "0" ]; then
50         echo "api files not found ..."
51         echo "WARNING: your build will fail."
52         echo "please get the api files first (see README file)."
53         api_dir="./"
54 fi
55
56 echo "checking for dfb stuff ..."
57 dfb_inc_dir="0"
58 if [ -z "$dfbinc" ]; then
59         for i in /usr/include /usr/local/include; do
60                 if [ -d $i/directfb ]; then
61                         dfb_inc_dir=$i/directfb
62                 fi
63         done
64 else
65         if [ -d $dfbinc/directfb ]; then
66                 dfb_inc_dir=$dfbinc/directfb
67         fi
68 fi
69 if [ "$dfb_inc_dir" = "0" ]; then
70         echo "dfb includes not found ..."
71         nodfb=1
72 fi
73 dfb_lib_dir="0"
74 if [ -z "$dfblib" ]; then
75         for i in /usr/lib /usr/local/lib; do
76                 if [ -f $i/libdirectfb.so ]; then
77                         dfb_lib_dir=$i
78                 fi
79         done
80 else
81         if [ -f $dfblib/libdirectfb.so ]; then
82                 dfb_lib_dir=$dfblib
83         fi
84 fi
85 if [ "$dfb_lib_dir" = "0" ]; then
86         echo "dfb libs not found ..."
87         nodfb=1
88 fi
89
90 [ "$nodfb" = "0" ] && echo "directfb installation looks good :)"
91
92 GENLIBS="-lm -lncurses"
93 GENAPI="network.o event.o list.o display.o input.o"
94
95 echo "creating Makefile"
96
97 cat > Makefile << EOF
98 # $main Makefile, created `date`
99
100 INCLUDEDIR = /usr/include
101 EOF
102
103 if [ "$nodfb" = "0" ]; then
104
105 cat >> Makefile << EOF
106 CFLAGS = -DDEBUG -DUSE_DFB_API -DFONT=\"$prefix/share/$main/decker.ttf\" -O3 -Wall -I$dfb_inc_dir
107 LIBS = -L$dfb_lib_dir -ldirectfb $GENLIBS
108
109 OBJS = random.o dfbapi.o $GENAPI
110 EOF
111
112 else
113
114 cat >> Makefile << EOF
115 CFLAGS = -DDEBUG -DNODFB -O3 -Wall
116 LIBS = -lm -lncurses
117
118 OBJS = random.o $GENAPI
119 EOF
120
121 fi
122
123 cat >> Makefile << EOF
124 OBJS2 = $name
125
126 links:
127 EOF
128
129 for i in $GENAPI; do
130         foo="`echo $i | sed 's/\.o//g'`"
131         cat >> Makefile << EOF
132         ln -sf $api_dir/$foo/${foo}.{c,h} .
133 EOF
134 done
135
136 for i in $name; do
137 cat >> Makefile << EOF
138
139 $i: links \$(OBJS)
140         \$(CC) \$(CFLAGS) -o \$@ \$(OBJS) \$(LIBS) ${i}.c
141
142 EOF
143 done
144
145 cat >> Makefile << EOF
146 nlsop: links $name
147         \$(CC) \$(CFLAGS) -o \$@ \$(OBJS) \$(LIBS) nlsop.c
148
149 EOF
150
151 cat >> Makefile << EOF
152 all: $main
153
154 clean:
155         rm -f \$(OBJS) \$(OBJS2)
156
157 remake: clean all
158
159 install:
160         mkdir -p $prefix/bin
161         cp $name $prefix/bin
162         mkdir -p $prefix/share/$main
163         cp decker.ttf $prefix/share/$main
164         chmod 644 $prefix/share/$main/decker.ttf
165 EOF
166
167 echo "done"