]> git.stg.codes - stg.git/blob - projects/libs/build
Fixed compiler complaints.
[stg.git] / projects / libs / 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 # Dir access bits
21
22 DIR_MODE=0755
23
24 # Binaries and data files owner
25
26 OWNER=root
27
28 OS=unknown
29 sys=`uname -s`
30 release=`uname -r`
31 major=`printf "%s" "$release" | cut -d. -f1`
32 BUILD_DIR=`pwd`
33 CONFFILE="../../Makefile.conf"
34
35
36 if [ "$1" = "debug" ]
37 then
38     DEFS="$DEFS -DDEBUG"
39     MAKEOPTS="$MAKEOPTS -j1"
40     CFLAGS="$CFLAGS -ggdb3 -W -Wall"
41     CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall"
42     DEBUG="yes"
43 else
44     DEFS="$DEFS -DNDEBUG"
45     DEBUG="no"
46 fi
47
48 CFLAGS="$CFLAGS -I/usr/local/include"
49 CXXFLAGS="$CXXFLAGS -I/usr/local/include"
50 LDFLAGS="$LDFLAGS -L/usr/local/lib"
51
52 if [ "$sys" = "Linux" ]
53 then
54     OS=linux
55     MAKE="make"
56 fi
57
58 if [ "$sys" = "FreeBSD" ]
59 then
60     case $major in
61         4) OS=bsd;;
62         5) OS=bsd5;;
63         6) OS=bsd5;;
64         7) OS=bsd7;;
65         *) OS=bsd7;;
66     esac
67     MAKE="gmake"
68 fi
69
70 if [ "$sys" = "Darwin" ]
71 then
72     OS=darwin
73     MAKE="gmake"
74 fi
75
76 if [ "$OS" = "unknown" ]
77 then
78     printf "#############################################################################\n"
79     printf "# Sorry, but we currently support Linux, FreeBSD and Darwin.                #\n"
80     printf "#############################################################################\n"
81     exit 1
82 fi
83
84 printf "#############################################################################\n"
85 printf "       Building STG 2.4 libs for $sys $release\n"
86 printf "#############################################################################\n"
87
88 STG_LIBS="logger.lib
89           crypto.lib
90           common.lib
91           scriptexecuter.lib
92           conffiles.lib
93           pinger.lib
94           dotconfpp.lib
95           smux.lib
96           ia.lib
97           srvconf.lib"
98
99 if [ "$OS" = "linux" ]
100 then
101     DEFS="$DEFS -DLINUX"
102 else
103     if [ "$OS" = "bsd" ]
104     then
105         DEFS="$DEFS -DFREE_BSD"
106     else
107         if [ "$OS" = "bsd7" ]
108         then
109             DEFS="$DEFS -DFREE_BSD5"
110         else
111             if [ "$OS" == "darwin" ]
112             then
113                 DEFS="$DEFS -DDARWIN"
114             fi
115         fi
116     fi
117 fi
118
119 if [ -z "$CC" ]
120 then
121     CC=gcc
122 fi
123
124 if [ -z "$CXX" ]
125 then
126     CXX=g++
127 fi
128
129 printf "Checking CC... "
130 $CC --version > /dev/null 2> /dev/null
131 if [ $? != 0 ]
132 then
133     printf "FAIL!\n"
134     printf "$CC not found\n"
135     exit;
136 fi
137 printf "found\n"
138 printf "Checking CXX... "
139 $CXX --version > /dev/null 2> /dev/null
140 if [ $? != 0 ]
141 then
142     printf "FAIL!\n"
143     printf "$CXX not found\n"
144     exit;
145 fi
146 printf "found\n"
147
148 printf "Checking endianess... "
149 printf "int main() { int probe = 0x00000001; return *(char *)&probe; }\n" > build_check.c
150 $CC $CFLAGS $LDFLAGS build_check.c -o fake
151 if [ $? != 0 ]
152 then
153     printf "FAIL!\n"
154     printf "Endianess checking failed\n"
155     exit;
156 else
157     ./fake
158     if [ $? = 1 ]
159     then
160         ARCH=le
161         CXXFLAGS="$CXXFLAGS -DARCH_LE"
162         CFLAGS="$CFLAGS -DARCH_LE"
163         printf "Little Endian\n"
164     else
165         ARCH=be
166         CXXFLAGS="$CXXFLAGS -DARCH_BE"
167         CFLAGS="$CFLAGS -DARCH_BE"
168         printf "Big Endian\n"
169     fi
170 fi
171 rm -f fake
172
173 printf "Checking for -lexpat... "
174 printf "#include <expat.h>\nint main() { return 0; }\n" > build_check.c
175 $CXX $CXXFLAGS $LDFLAGS build_check.c -lexpat -o fake > /dev/null 2> /dev/null
176 if [ $? != 0 ]
177 then
178     CHECK_EXPAT=no
179     printf "no\n"
180 else
181     CHECK_EXPAT=yes
182     printf "yes\n"
183 fi
184 rm -f fake
185
186 printf "Checking for -lfbclient... "
187 printf "int main() { return 0; }\n" > build_check.c
188 $CXX $CXXFLAGS $LDFLAGS build_check.c -lfbclient -o fake > /dev/null 2> /dev/null
189 if [ $? != 0 ]
190 then
191     CHECK_FBCLIENT=no
192     printf "no\n"
193 else
194     CHECK_FBCLIENT=yes
195     printf "yes\n"
196 fi
197 rm -f fake
198
199 rm -f build_check.c
200
201 if [ "$CHECK_EXPAT" != "yes" ]
202 then
203     printf -- "-lexpat not found!\n"
204     exit 1
205 fi
206
207 if [ "$CHECK_FBCLIENT" = "yes" ]
208 then
209     STG_LIBS="$STG_LIBS
210               ibpp.lib"
211 fi
212
213 printf "OS=$OS\n" > $CONFFILE
214 printf "STG_TIME=yes\n" >> $CONFFILE
215 printf "DEBUG=$DEBUG\n" >> $CONFFILE
216 printf "DIR_BUILD=$BUILD_DIR\n" >> $CONFFILE
217 printf "DIR_LIB=\$(DIR_BUILD)/../../lib\n" >> $CONFFILE
218 printf "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs\n" >> $CONFFILE
219 printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE
220 printf "ARCH=$ARCH\n" >> $CONFFILE
221 printf "CHECK_EXPAT=$CHECK_EXPAT\n" >> $CONFFILE
222 printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE
223 printf "DEFS=$DEFS\n" >> $CONFFILE
224 printf "STG_LIBS=" >> $CONFFILE
225 for lib in $STG_LIBS
226 do
227     printf "$lib " >> $CONFFILE
228 done
229 printf "\n" >> $CONFFILE
230 printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE
231 printf "CFLAGS=$CFLAGS\n" >> $CONFFILE
232 printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE
233 printf "PREFIX=$PREFIX\n" >> $CONFFILE
234 printf "BIN_MODE=$BIN_MODE\n" >> $CONFFILE
235 printf "DATA_MODE=$DATA_MODE\n" >> $CONFFILE
236 printf "DIR_MODE=$DIR_MODE\n" >> $CONFFILE
237 printf "OWNER=$OWNER\n" >> $CONFFILE
238
239 if [ "$1" != "debug" ]
240 then
241     $MAKE $MAKEOPTS
242 else
243     printf "\n\n\nDebug build. Type $MAKE explicitly\n"
244 fi