]> git.stg.codes - stg.git/blob - projects/sgconf/build
Fix encoding hint in documentation
[stg.git] / projects / sgconf / build
1 #!/bin/sh
2
3 #   $Author: faust $
4 #   $Revision: 1.21 $
5 #   $Date: 2010/04/14 08:59:11 $
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 gcc... "
94 gcc --version > /dev/null 2> /dev/null
95 if [ $? != 0 ]
96 then
97     echo "FAIL!"
98     echo "gcc not found"
99     exit;
100 fi
101 echo "found"
102 echo -n "Checking g++... "
103 g++ --version > /dev/null 2> /dev/null
104 if [ $? != 0 ]
105 then
106     echo "FAIL!"
107     echo "g++ not found"
108     exit;
109 fi
110 echo "found"
111
112 echo -n "Checking endianess... "
113 echo "int main() { int probe = 0x00000001; return *(char *)&probe; }" > build_check.c
114 gcc $CXXFLAGS $LDFLAGS build_check.c -o fake > /dev/null 2> /dev/null
115 if [ $? != 0 ]
116 then
117     echo "FAIL!"
118     echo "Endianess checking failed"
119     exit;
120 else
121     ./fake
122     if [ $? = 1 ]
123     then
124         ARCH=le
125         CXXFLAGS="$CXXFLAGS -DARCH_LE"
126         echo "Little Endian"
127     else
128         ARCH=be
129         CXXFLAGS="$CXXFLAGS -DARCH_BE"
130         echo "Big Endian"
131     fi
132 fi
133 rm -f fake
134
135 echo -n "Checking for -lexpat... "
136 echo "int main() { return 0; }" > build_check.c
137 gcc $CXXFLAGS $LDFLAGS build_check.c -lexpat -o fake > /dev/null 2> /dev/null
138 if [ $? != 0 ]
139 then
140     CHECK_EXPAT=no
141     echo "no"
142 else
143     CHECK_EXPAT=yes
144     echo "yes"
145 fi
146 rm -f fake
147 rm -f build_check.c
148
149 if [ "$CHECK_EXPAT" != "yes" ]
150 then
151     echo "-lexpat not found!"
152     exit 1
153 fi
154
155 echo "OS=$OS" > $CONFFILE
156 echo "STG_TIME=yes" >> $CONFFILE
157 echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
158 echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
159 echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
160 echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
161 echo "ARCH=$ARCH" >> $CONFFILE
162 echo "CHECK_EXPAT=$CHECK_EXPAT" >> $CONFFILE
163 echo "DEFS=$DEFS" >> $CONFFILE
164 echo -n "STG_LIBS=" >> $CONFFILE
165 for lib in $STG_LIBS
166 do
167     echo -n "$lib " >> $CONFFILE
168 done
169 echo "" >> $CONFFILE
170 echo "LIB_THREAD=$LIB_THREAD" >> $CONFFILE
171 echo "SHELL=$SHELL" >> $CONFFILE
172 echo "CXXFLAGS=$CXXFLAGS" >> $CONFFILE
173 echo "LDFLAGS=$LDFLAGS" >> $CONFFILE
174 echo "PREFIX=$PREFIX" >> $CONFFILE
175 echo "BIN_MODE=$BIN_MODE" >> $CONFFILE
176 echo "DATA_MODE=$DATA_MODE" >> $CONFFILE
177 echo "OWNER=$OWNER" >> $CONFFILE
178
179 $MAKE $MAKEOPTS
180