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