]> git.stg.codes - stg.git/blob - projects/sgconf_xml/build
Виправлено помилки виклику localtime із різних потоків
[stg.git] / projects / sgconf_xml / build
1 #!/bin/sh
2
3 #   $Author: nobunaga $
4 #   $Revision: 1.2 $
5 #   $Date: 2008/01/05 12:11:02 $
6 ######################################################
7
8 OS=unknown
9 sys=`uname -s`
10 release=`uname -r | cut -b1`
11 BUILD_DIR=`pwd`
12 CONFFILE="../../Makefile.conf"
13 PREFIX="/"
14 BIN_MODE=0755
15 DATA_MODE=0644
16 OWNER=root
17
18 if [ -z $1 ]
19 then
20     MAKEOPTS="-j1"
21 else
22     if [ "$1" = "debug" ]
23     then
24         DEFS="-DDEBUG"
25         MAKEOPTS="-j1"
26         CXXFLAGS="$CXXFLAGS -g3 -W -Wall"
27     else
28         MAKEOPTS="-j1"
29     fi
30 fi
31
32 CXXFLAGS="$CXXFLAGS -I/usr/local/include"
33 LDFLAGS="$LDFLAGS -L/usr/local/lib"
34
35 if [ "$sys" = "Linux" ]
36 then
37     OS=linux
38     release=""
39     MAKE="make"
40 fi
41
42 if [ "$sys" = "FreeBSD" ]
43 then
44     case $release in
45         4) OS=bsd;;
46         5) OS=bsd5;;
47         6) OS=bsd5;;    
48         7) OS=bsd7;;
49         8) OS=bsd7;;
50         *) OS=unknown;;
51     esac
52     MAKE="gmake"
53 fi
54
55 if [ "$OS" = "unknown" ]
56 then 
57     echo "#############################################################################"
58     echo "# Sorry, but sgconf currently supported by Linux, FreeBSD 4.x, 5.x, 6.x  #"
59     echo "#############################################################################"
60     exit 1
61 fi
62
63 echo "#############################################################################"
64 echo "       Building sgconf for $sys $release"
65 echo "#############################################################################"
66
67 STG_LIBS="conffiles.lib
68           crypto.lib 
69           common.lib 
70           srvconf.lib"
71
72 if [ "$OS" = "linux" ]
73 then
74     DEFS="$DEFS -DLINUX"
75     LIB_THREAD=-lpthread
76     SHELL="/bin/bash"
77 else
78     if [ "$OS" = "bsd" ]
79     then
80         DEFS="$DEFS -DFREE_BSD"
81     else
82         DEFS="$DEFS -DFREE_BSD5"
83         if [ "$OS" = "bsd7" ]
84         then
85             LIB_THREAD=-lpthread
86         else
87             LIB_THREAD=-lc_r
88         fi
89     fi
90     SHELL="/usr/local/bin/bash"
91 fi
92
93 echo -n "Checking endianess... "
94 echo "int main() { int probe = 0x00000001; return *(char *)&probe; }" > build_check.c
95 gcc $CXXFLAGS $LDFLAGS build_check.c -o fake > /dev/null 2> /dev/null
96 if [ $? != 0 ]
97 then
98     echo "FAIL!"
99     echo "Endianess checking failed"
100     exit;
101 else
102     ./fake
103     if [ $? = 1 ]
104     then
105         ARCH=le
106         CXXFLAGS="$CXXFLAGS -DARCH_LE"
107         echo "Little Endian"
108     else
109         ARCH=be
110         CXXFLAGS="$CXXFLAGS -DARCH_BE"
111         echo "Big Endian"
112     fi
113 fi
114 rm -f fake
115
116 echo -n "Checking for -lexpat... "
117 echo "int main() { return 0; }" > build_check.c
118 gcc $CXXFLAGS $LDFLAGS build_check.c -lexpat -o fake > /dev/null 2> /dev/null
119 if [ $? != 0 ]
120 then
121     CHECK_EXPAT=no
122     echo "no"
123 else
124     CHECK_EXPAT=yes
125     echo "yes"
126 fi
127 rm -f fake
128 rm -f build_check.c
129
130 if [ "$CHECK_EXPAT" != "yes" ]
131 then
132     echo "-lexpat not found!"
133     exit 1
134 fi
135
136 echo "OS=$OS" > $CONFFILE
137 echo "STG_TIME=yes" >> $CONFFILE
138 echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
139 echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
140 echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
141 echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
142 echo "ARCH=$ARCH" >> $CONFFILE
143 echo "CHECK_EXPAT=$CHECK_EXPAT" >> $CONFFILE
144 echo "DEFS=$DEFS" >> $CONFFILE
145 echo -n "STG_LIBS=" >> $CONFFILE
146 for lib in $STG_LIBS
147 do
148     echo -n "$lib " >> $CONFFILE
149 done
150 echo "" >> $CONFFILE
151 echo "LIB_THREAD=$LIB_THREAD" >> $CONFFILE
152 echo "SHELL=$SHELL" >> $CONFFILE
153 echo "CXXFLAGS=$CXXFLAGS" >> $CONFFILE
154 echo "LDFLAGS=$LDFLAGS" >> $CONFFILE
155 echo "PREFIX=$PREFIX" >> $CONFFILE
156 echo "BIN_MODE=$BIN_MODE" >> $CONFFILE
157 echo "DATA_MODE=$DATA_MODE" >> $CONFFILE
158 echo "OWNER=$OWNER" >> $CONFFILE
159
160 $MAKE $MAKEOPTS
161