]> git.stg.codes - stg.git/blob - projects/rscriptd/build
Fixed installation.
[stg.git] / projects / rscriptd / build
1 #!/bin/sh
2
3 #   $Author: faust $
4 #   $Revision: 1.21 $
5 #   $Date: 2010/04/14 08:58:52 $
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 DIR_MODE=0755
17 OWNER=root
18
19 if [ -z $1 ]
20 then
21     MAKEOPTS="-j1"
22     DEBUG="no"
23 else
24     if [ "$1" = "debug" ]
25     then
26         DEFS="-DDEBUG"
27         MAKEOPTS="-j1"
28         CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall"
29         DEBUG="yes"
30     else
31         MAKEOPTS="-j1"
32         DEBUG="no"
33     fi
34 fi
35
36 CXXFLAGS="$CXXFLAGS -I/usr/local/include"
37 LDFLAGS="$LDFLAGS -L/usr/local/lib"
38
39 if [ "$sys" = "Linux" ]
40 then
41     OS=linux
42     release=""
43     MAKE="make"
44 fi
45
46 if [ "$sys" = "FreeBSD" ]
47 then
48     case $release in
49         4) OS=bsd;;
50         5) OS=bsd5;;
51         6) OS=bsd5;;
52         7) OS=bsd7;;
53         8) OS=bsd7;;
54         9) OS=bsd7;;
55         *) OS=unknown;;
56     esac
57     MAKE="gmake"
58 fi
59
60 if [ "$OS" = "unknown" ]
61 then 
62     echo "#############################################################################"
63     echo "# Sorry, but rscriptd currently supported by Linux, FreeBSD 4.x, 5.x, 6.x  #"
64     echo "#############################################################################"
65     exit 1
66 fi
67
68 echo "#############################################################################"
69 echo "       Building rscriptd for $sys $release"
70 echo "#############################################################################"
71
72 STG_LIBS="logger.lib 
73           locker.lib
74           crypto.lib 
75           common.lib 
76           scriptexecuter.lib 
77           conffiles.lib"
78
79 if [ "$OS" = "linux" ]
80 then
81     DEFS="$DEFS -DLINUX"
82     LIB_THREAD=-lpthread
83 else
84     if [ "$OS" = "bsd" ]
85     then
86         DEFS="$DEFS -DFREE_BSD"
87         LIB_THREAD=-lc_r
88     else
89         DEFS="$DEFS -DFREE_BSD5"
90         if [ "$OS" = "bsd7" ]
91         then
92             LIB_THREAD=-lpthread
93         else
94             LIB_THREAD=-lc_r
95         fi
96     fi
97 fi
98
99 if [ -z "$CC" ]
100 then
101     CC=gcc
102 fi
103
104 if [ -z "$CXX" ]
105 then
106     CXX=g++
107 fi
108
109 echo -n "Checking CC... "
110 $CC --version > /dev/null 2> /dev/null
111 if [ $? != 0 ]
112 then
113     echo "FAIL!"
114     echo "$CC not found"
115     exit;
116 fi
117 echo "found"
118 echo -n "Checking CXX... "
119 $CXX --version > /dev/null 2> /dev/null
120 if [ $? != 0 ]
121 then
122     echo "FAIL!"
123     echo "$CXX not found"
124     exit;
125 fi
126 echo "found"
127
128 echo -n "Checking endianess... "
129 echo "int main() { int probe = 0x00000001; return *(char *)&probe; }" > build_check.c
130 $CC $CFLAGS $LDFLAGS build_check.c -o fake > /dev/null 2> /dev/null
131 if [ $? != 0 ]
132 then
133     echo "FAIL!"
134     echo "Endianess checking failed"
135     exit;
136 else
137     ./fake
138     if [ $? = 1 ]
139     then
140         ARCH=le
141         CXXFLAGS="$CXXFLAGS -DARCH_LE"
142         CFLAGS="$CFLAGS -DARCH_LE"
143         echo "Little Endian"
144     else
145         ARCH=be
146         CXXFLAGS="$CXXFLAGS -DARCH_BE"
147         CFLAGS="$CFLAGS -DARCH_BE"
148         echo "Big Endian"
149     fi
150 fi
151 rm -f fake
152 rm -f build_check.c
153
154 echo "OS=$OS" > $CONFFILE
155 echo "STG_TIME=yes" >> $CONFFILE
156 echo "DEBUG=$DEBUG" >> $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 "DEFS=$DEFS" >> $CONFFILE
163 echo -n "STG_LIBS=" >> $CONFFILE
164 for lib in $STG_LIBS
165 do
166     echo -n "$lib " >> $CONFFILE
167 done
168 echo "" >> $CONFFILE
169 echo "LIB_THREAD=$LIB_THREAD" >> $CONFFILE
170 echo "CXXFLAGS=$CXXFLAGS" >> $CONFFILE
171 echo "CFLAGS=$CFLAGS" >> $CONFFILE
172 echo "LDFLAGS=$LDFLAGS" >> $CONFFILE
173 echo "PREFIX=$PREFIX" >> $CONFFILE
174 echo "BIN_MODE=$BIN_MODE" >> $CONFFILE
175 echo "DATA_MODE=$DATA_MODE" >> $CONFFILE
176 echo "DIR_MODE=$DIR_MODE" >> $CONFFILE
177 echo "OWNER=$OWNER" >> $CONFFILE
178
179 $MAKE $MAKEOPTS
180