5 # $Date: 2010/04/14 08:58:43 $
6 ######################################################
11 major=`printf "%s" "$release" | cut -d. -f1`
13 CONFFILE="../../Makefile.conf"
19 VAR_DIR="./inst/var/stargazer"
24 MAKEOPTS="$MAKEOPTS -j1"
25 CFLAGS="$CFLAGS -ggdb3 -W -Wall -Wextra"
26 CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -Wextra"
33 CFLAGS="$CFLAGS -ggdb3 -W -Wall -I/usr/local/include"
34 CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -I/usr/local/include"
35 LDFLAGS="$LDFLAGS -L/usr/local/lib"
37 if [ "$sys" = "Linux" ]
43 if [ "$sys" = "FreeBSD" ]
55 if [ "$sys" = "Darwin" ]
58 ETC_DIR="./inst/freebsd/etc/stargazer"
62 if [ "$OS" = "unknown" ]
64 printf "#############################################################################\n"
65 printf "# Sorry, but sgconv is currently supported by Linux, FreeBSD and Darwin. #\n"
66 printf "#############################################################################\n"
70 printf "#############################################################################\n"
71 printf " Building sgconv for $sys $release\n"
72 printf "#############################################################################\n"
83 if [ "$OS" = "linux" ]
90 DEFS="$DEFS -DFREE_BSD"
95 DEFS="$DEFS -DFREE_BSD5"
98 if [ "$OS" == "darwin" ]
100 DEFS="$DEFS -DDARWIN"
119 printf "Checking CC... "
120 $CC --version > /dev/null 2> /dev/null
124 printf "$CC not found\n"
128 printf "Checking CXX... "
129 $CXX --version > /dev/null 2> /dev/null
133 printf "$CXX not found\n"
138 printf "Checking endianess... "
139 printf "int main() { int probe = 0x00000001; return *(char *)&probe; }\n" > build_check.c
140 $CC $CFLAGS $LDFLAGS -L/usr/lib/mysql -L/usr/local/lib/mysql build_check.c -o fake > /dev/null 2> /dev/null
144 printf "Endianess checking failed\n"
151 CXXFLAGS="$CXXFLAGS -DARCH_LE"
152 CFLAGS="$CFLAGS -DARCH_LE"
153 printf "Little Endian\n"
156 CXXFLAGS="$CXXFLAGS -DARCH_BE"
157 CFLAGS="$CFLAGS -DARCH_BE"
158 printf "Big Endian\n"
163 printf "Checking for fb_config... "
164 FB_VERSION=`fb_config --version 2> /dev/null`
168 printf "Checking for -lfbclient... "
169 printf "int main() { return 0; }\n" > build_check.c
170 $CXX $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
177 FB_LDFLAGS="-lfbclient"
184 printf "Checking for fb_config --cflags... "
185 FB_CFLAGS=`fb_config --cflags`
191 printf "[$FB_CFLAGS]\n"
192 printf "Checking for fb_config --libs "
193 FB_LDFLAGS=`fb_config --libs`
200 printf "[$FB_LDFLAGS]\n"
205 printf "Checking for mysql_config... "
206 printf "#include <mysql.h>\nint main() { return 0; }\n" > build_check.c
207 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
211 printf "Checking for -lmysqlclient... "
212 $CC $CFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
218 CHECK_MYSQLCLIENT=yes
224 printf "Checking for mysql_config --cflags... "
225 MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
231 printf "[$MYSQL_CFLAGS]\n"
232 printf "Checking for mysql_config --libs_r... "
233 MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
239 CHECK_MYSQLCLIENT=yes
240 printf "[$MYSQL_LDFLAGS]\n"
245 printf "Checking for pg_config... "
246 printf "#include <libpq-fe.h>\nint main() { return 0; }\n" > build_check.c
247 PG_VERSION=`pg_config --version 2> /dev/null`
251 printf "Checking for -lpq... "
252 $CXX $CXXFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
264 printf "Checking for pg_config --includedir... "
265 PG_CFLAGS="-I"`pg_config --includedir 2> /dev/null`
271 printf "[$PG_CFLAGS]\n"
272 printf "Checking for pg_config --libdir... "
273 PG_LDFLAGS="-L"`pg_config --libdir 2> /dev/null`
280 printf "[$PG_LDFLAGS]\n"
287 if [ "$CHECK_FBCLIENT" = "yes" ]
295 if [ "$CHECK_PQ" = "yes" ]
301 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
307 printf "OS=$OS\n" > $CONFFILE
308 printf "STG_TIME=yes\n" >> $CONFFILE
309 printf "DEBUG=$DEBUG\n" >> $CONFFILE
310 printf "DIR_BUILD=$BUILD_DIR\n" >> $CONFFILE
311 printf "DIR_LIB=\$(DIR_BUILD)/../../lib\n" >> $CONFFILE
312 printf "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs\n" >> $CONFFILE
313 printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE
314 printf "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules\n" >> $CONFFILE
315 printf "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins\n" >> $CONFFILE
316 printf "ARCH=$ARCH\n" >> $CONFFILE
317 printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE
318 if [ "$CHECK_FBCLIENT" = "yes" ]
320 printf "FB_CFLAGS=$FB_CFLAGS\n" >> $CONFFILE
321 printf "FB_LDFLAGS=$FB_LDFLAGS\n" >> $CONFFILE
323 printf "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT\n" >> $CONFFILE
324 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
326 printf "MYSQL_CFLAGS=$MYSQL_CFLAGS\n" >> $CONFFILE
327 printf "MYSQL_LDFLAGS=$MYSQL_LDFLAGS\n" >> $CONFFILE
329 printf "CHECK_PQ=$CHECK_PQ\n" >> $CONFFILE
330 if [ "$CHECK_PQ" = "yes" ]
332 printf "PG_CFLAGS=$PG_CFLAGS\n" >> $CONFFILE
333 printf "PG_LDFLAGS=$PG_LDFLAGS\n" >> $CONFFILE
335 printf "DEFS=$DEFS\n" >> $CONFFILE
336 printf "STG_LIBS=" >> $CONFFILE
339 printf "$lib " >> $CONFFILE
341 printf "\n" >> $CONFFILE
342 printf "PLUGINS=" >> $CONFFILE
343 for plugin in $PLUGINS
345 printf "$plugin " >> $CONFFILE
347 printf "\n" >> $CONFFILE
348 printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE
349 printf "CFLAGS=$CFLAGS\n" >> $CONFFILE
350 printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE
351 printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE
352 printf "PREFIX=$PREFIX\n" >> $CONFFILE
353 printf "BIN_MODE=$BIN_MODE\n" >> $CONFFILE
354 printf "DATA_MODE=$DATA_MODE\n" >> $CONFFILE
355 printf "DIR_MODE=$DIR_MODE\n" >> $CONFFILE
356 printf "OWNER=$OWNER\n" >> $CONFFILE
357 printf "VAR_DIR=$VAR_DIR\n" >> $CONFFILE
359 mkdir -p ../stargazer/modules
361 if [ "$1" != "debug" ]
365 printf "\n\n\nDebug build. Type $MAKE explicitly\n"