]> git.stg.codes - stg.git/blob - projects/stargazer/build
Добавлено игнорирование всяких вспомогательных и отладочных файлов
[stg.git] / projects / stargazer / build
1     #!/bin/sh
2
3 #   $Revision: 1.57 $
4 #   $Author: faust $
5 #   $Date: 2010/05/09 12:39:01 $
6 ######################################################
7
8 # Installation path prefix
9
10 PREFIX=""
11
12 # Binaries access bits
13
14 BIN_MODE=0755
15
16 # Data files access bits
17
18 DATA_MODE=0644
19
20 # Binaries and data files owner
21
22 OWNER=root
23
24 # Name of the firebird's group
25 # Need for chown directory with firebird db
26
27 FIREBIRD_GROUP=firebird
28
29 # Database address
30 # Firebird must have priviledges to read/write for specified path
31
32 DB_ADDRESS="localhost:/var/stargazer/stargazer.fdb"
33
34 # Database user
35 # This user must have priviledges to create database
36
37 DB_USER="stg"
38
39 # Database password
40
41 DB_PASSWORD="123456"
42
43 # Full path to isql utility
44 # Note: Debian users have to specify path to isql-fb utility
45
46 FIREBIRD_ISQL="/opt/firebird/bin/isql"
47
48 OS=unknown
49 sys=`uname -s`
50 release=`uname -r | cut -b1`
51 BUILD_DIR=`pwd`
52 CONFFILE="../../Makefile.conf"
53 VAR_DIR="./inst/var/stargazer"
54 MIN_XMLRPCC_VERSION="1.06.27"
55 XMLRPC_FEATURES="c++2 abyss-server"
56
57
58 if [ -z $1 ]
59 then
60     DEFS="$DEFS -DNDEBUG"
61     MAKEOPTS="-j1"
62 else
63     if [ "$1" = "debug" ]
64     then
65         DEFS="$DEFS -DDEBUG"
66         MAKEOPTS="-j1"
67         CXXFLAGS="$CXXFLAGS -g3 -W -Wall"
68     else
69         DEFS="$DEFS -DNDEBUG"
70         MAKEOPTS="-j1"
71     fi
72 fi
73
74 CXXFLAGS="$CXXFLAGS -I/usr/local/include"
75 LDFLAGS="$LDFLAGS -L/usr/local/lib"
76
77 if [ "$sys" = "Linux" ]
78 then
79     OS=linux
80     release=""
81     ETC_DIR="./inst/linux/etc/stargazer"
82     MAKE="make"
83 fi
84
85 if [ "$sys" = "FreeBSD" ]
86 then
87     case $release in
88         4) OS=bsd;;
89         5) OS=bsd5;;
90         6) OS=bsd5;;
91         7) OS=bsd7;;
92         8) OS=bsd7;;
93         *) OS=unknown;;
94     esac
95     ETC_DIR="./inst/freebsd/etc/stargazer"
96     MAKE="gmake"
97 fi
98
99 if [ "$OS" = "unknown" ]
100 then 
101     echo "#############################################################################"
102     echo "# Sorry, but stargazer currently supported by Linux, FreeBSD 4.x, 5.x, 6.x  #"
103     echo "#############################################################################"
104     exit 1
105 fi
106
107 echo "#############################################################################"
108 echo "       Building STG 2.4 for $sys $release"
109 echo "#############################################################################"
110
111 STG_LIBS="stg_logger.lib 
112           stg_locker.lib
113           crypto.lib 
114           common.lib 
115           script_executer.lib 
116           conffiles.lib
117           hostallow.lib 
118           pinger.lib 
119           dotconfpp.lib"
120
121 PLUGINS="authorization/ao
122          authorization/inetaccess
123          configuration/sgconfig
124          other/ping
125          other/rscript
126          other/radius
127          store/files
128          capture/cap_nf"
129
130 if [ "$OS" = "linux" ]
131 then
132     DEFS="$DEFS -DLINUX"
133     PLUGINS="$PLUGINS
134              capture/ether_linux
135              capture/ipq_linux"
136     SHELL="/bin/bash"
137     LIB_THREAD=-lpthread
138 else
139     if [ "$OS" = "bsd" ]
140     then
141         DEFS="$DEFS -DFREE_BSD"
142         LIB_THREAD=-lc_r
143     else
144         DEFS="$DEFS -DFREE_BSD5"
145         if [ "$OS" = "bsd7" ]
146         then
147             LIB_THREAD=-lpthread
148         else
149             LIB_THREAD=-lc_r
150         fi
151     fi
152     PLUGINS="$PLUGINS
153              capture/ether_freebsd
154              capture/divert_freebsd"
155     SHELL="/usr/local/bin/bash"
156 fi
157
158 echo -n "Checking endianess... "
159 echo "int main() { int probe = 0x00000001; return *(char *)&probe; }" > build_check.c
160 gcc $CXXFLAGS $LDFLAGS build_check.c -o fake > /dev/null 2> /dev/null
161 if [ $? != 0 ]
162 then
163     echo "FAIL!"
164     echo "Endianess checking failed"
165     exit;
166 else
167     ./fake
168     if [ $? = 1 ]
169     then
170         ARCH=le
171         CXXFLAGS="$CXXFLAGS -DARCH_LE"
172         echo "Little Endian"
173     else
174         ARCH=be
175         CXXFLAGS="$CXXFLAGS -DARCH_BE"
176         echo "Big Endian"
177     fi
178 fi
179 rm -f fake
180
181 echo -n "Checking for -lexpat... "
182 echo "int main() { return 0; }" > build_check.c
183 gcc $CXXFLAGS $LDFLAGS build_check.c -lexpat -o fake > /dev/null 2> /dev/null
184 if [ $? != 0 ]
185 then
186     CHECK_EXPAT=no
187     echo "no"
188 else
189     CHECK_EXPAT=yes
190     echo "yes"
191 fi
192 rm -f fake
193
194 echo -n "Checking for -lfbclient... "
195 gcc $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
196 if [ $? != 0 ]
197 then
198     CHECK_FBCLIENT=no
199     echo "no"
200 else
201     CHECK_FBCLIENT=yes
202     echo "yes"
203 fi
204 rm -f fake
205
206 echo -n "Checking for mysql_config... "
207 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
208 if [ $? != 0 ]
209 then
210     echo "no";
211     echo -n "Checking for -lmysqlclient... "
212     gcc $CXXFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
213     if [ $? != 0 ]
214     then
215         CHECK_MYSQLCLIENT=no
216         echo "no"
217     else
218         CHECK_MYSQLCLIENT=yes
219         echo "yes"
220     fi
221     rm -f fake
222 else
223     echo "yes"
224     echo -n "Checking for mysql_config --cflags... "
225     MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
226     if [ $? != 0 ]
227     then
228         CHECK_MYSQLCLIENT=no
229         echo "no"
230     else
231         #CXXFLAGS="$CXXFLAGS $MYSQL_CFLAGS"
232         echo "[$MYSQL_CFLAGS]"
233         echo -n "Checking for mysql_config --libs_r... "
234         MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
235         if [ $? != 0 ]
236         then
237             CHECK_MYSQLCLIENT=no
238             echo "no"
239         else
240             CHECK_MYSQLCLIENT=yes
241             #LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS"
242             echo "[$MYSQL_LDFLAGS]"
243         fi
244     fi
245 fi
246
247 echo -n "Checking for pg_config... "
248 PG_VERSION=`pg_config --version 2> /dev/null`
249 if [ $? != 0 ]
250 then
251     echo "no";
252     echo -n "Checking for -lpq... "
253     gcc $CXXFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
254     if [ $? != 0 ]
255     then
256         CHECK_PQ=no
257         echo "no"
258     else
259         CHECK_PQ=yes
260         echo "yes"
261     fi
262     rm -f fake
263 else
264     echo "yes";
265     echo -n "Checking for pg_config --includedir... "
266     PG_CFLAGS=`pg_config --includedir 2> /dev/null`
267     if [ $? != 0 ]
268     then
269         CHECK_PQ=no
270         echo "no"
271     else
272         echo "[$PG_CFLAGS]"
273         echo -n "Checking for pg_config --libdir... "
274         PG_LDFLAGS=`pg_config --libdir 2> /dev/null`
275         if [ $? != 0 ]
276         then
277             CHECK_PQ=no
278             echo "no"
279         else
280             CHECK_PQ=yes
281             echo "[$PG_LDFLAGS]"
282         fi
283     fi
284 fi
285
286 echo -n "Checking for xmlrpc-c-config... "
287 XMLRPCC_VERSION=`xmlrpc-c-config $XMLRPC_FEATURES --version 2> /dev/null`
288 if [ $? != 0 ]
289 then
290     echo "no";
291     echo -n "Checking for -lxmlrpc... "
292     gcc $CXXFLAGS $LDFLAGS build_check.c -lxmlrpc $LIB_THREAD -o fake > /dev/null 2> /dev/null
293     if [ $? != 0 ]
294     then
295         CHECK_XMLRPC=no
296         echo "no"
297     else
298         CHECK_XMLRPC=yes
299         echo "yes"
300     fi
301     rm -f fake
302 elif [ "$XMLRPCC_VERSION" \< "$MIN_XMLRPCC_VERSION" ]
303 then
304     echo "no (need at least $MIN_XMLRPCC_VERSION, actual $XMLRPCC_VERSION)";
305     CHECK_XMLRPC=no
306 else
307     echo "yes (version $XMLRPCC_VERSION)";
308     echo -n "Checking for xmlrpc-c-config --cflags... "
309     XMLRPC_CFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --cflags 2> /dev/null`
310     if [ $? != 0 ]
311     then
312         CHECK_XMLRPC=no
313         echo "no"
314     else
315         echo "[$XMLRPC_CFLAGS]"
316         echo -n "Checking for xmlrpc-c-config --libs... "
317         XMLRPC_LDFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --libs 2> /dev/null`
318         if [ $? != 0 ]
319         then
320             CHECK_XMLRPC=no
321             echo "no"
322         else
323             CHECK_XMLRPC=yes
324             echo "[$XMLRPC_LDFLAGS]"
325         fi
326     fi
327 fi
328
329 rm -f build_check.c
330
331 if [ "$CHECK_EXPAT" != "yes" ]
332 then
333     echo "-lexpat not found!"
334     exit 1
335 fi
336
337 if [ "$CHECK_FBCLIENT" = "yes" ]
338 then
339     STG_LIBS="$STG_LIBS
340               ibpp.lib"
341     PLUGINS="$PLUGINS
342              store/firebird"
343 fi
344
345 if [ "$CHECK_PQ" = "yes" ]
346 then
347     PLUGINS="$PLUGINS
348              store/postgresql"
349 fi
350
351 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
352 then
353     PLUGINS="$PLUGINS
354              store/mysql"
355 fi
356
357 if [ "$CHECK_XMLRPC" = "yes" ]
358 then
359     PLUGINS="$PLUGINS
360              configuration/rpcconfig"
361 fi
362
363 echo "OS=$OS" > $CONFFILE
364 echo "STG_TIME=yes" >> $CONFFILE
365 echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
366 echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
367 echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
368 echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
369 echo "DIR_MOD=\$(DIR_BUILD)/modules" >> $CONFFILE
370 echo "DIR_PLUGINS=\$(DIR_BUILD)/plugins" >> $CONFFILE
371 echo "ARCH=$ARCH" >> $CONFFILE
372 echo "CHECK_EXPAT=$CHECK_EXPAT" >> $CONFFILE
373 echo "CHECK_FBCLIENT=$CHECK_FBCLIENT" >> $CONFFILE
374 echo "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT" >> $CONFFILE
375 echo "CHECK_PQ=$CHECK_PQ" >> $CONFFILE
376 echo "CHECK_XMLRPC=$CHECK_XMLRPC" >> $CONFFILE
377 echo "DEFS=$DEFS" >> $CONFFILE
378 echo -n "STG_LIBS=" >> $CONFFILE
379 for lib in $STG_LIBS
380 do
381     echo -n "$lib " >> $CONFFILE
382 done
383 echo "" >> $CONFFILE
384 echo -n "PLUGINS=" >> $CONFFILE
385 for plugin in $PLUGINS
386 do
387     echo -n "$plugin " >> $CONFFILE
388 done
389 echo "" >> $CONFFILE
390 echo "SHELL=$SHELL" >> $CONFFILE
391 echo "CXXFLAGS=$CXXFLAGS" >> $CONFFILE
392 echo "LDFLAGS=$LDFLAGS" >> $CONFFILE
393 echo "LIB_THREAD=$LIB_THREAD" >> $CONFFILE
394 echo "PREFIX=$PREFIX" >> $CONFFILE
395 echo "BIN_MODE=$BIN_MODE" >> $CONFFILE
396 echo "DATA_MODE=$DATA_MODE" >> $CONFFILE
397 echo "OWNER=$OWNER" >> $CONFFILE
398 echo "VAR_DIR=$VAR_DIR" >> $CONFFILE
399 echo "ETC_DIR=$ETC_DIR" >> $CONFFILE
400 echo "DB_ADDRESS=$DB_ADDRESS" >> $CONFFILE
401 echo "DB_USER=$DB_USER" >> $CONFFILE
402 echo "DB_PASSWORD=$DB_PASSWORD" >> $CONFFILE
403 echo "FIREBIRD_ISQL=$FIREBIRD_ISQL" >> $CONFFILE
404 echo "FIREBIRD_GROUP=$FIREBIRD_GROUP" >> $CONFFILE
405
406 mkdir -p modules
407
408 if [ "$1" != "debug" ]
409 then
410     $MAKE $MAKEOPTS
411 else
412     echo -e "\n\n\nDebug build. Type $MAKE explicitly"
413 fi