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