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"
82 if [ "$OS" = "linux" ]
90 DEFS="$DEFS -DFREE_BSD"
95 DEFS="$DEFS -DFREE_BSD5"
98 if [ "$OS" == "darwin" ]
100 DEFS="$DEFS -DDARWIN"
129 printf "Checking CC... "
130 $CC --version > /dev/null 2> /dev/null
134 printf "$CC not found\n"
138 printf "Checking CXX... "
139 $CXX --version > /dev/null 2> /dev/null
143 printf "$CXX not found\n"
147 printf "Checking AR... "
148 $AR --version > /dev/null 2> /dev/null
152 printf "$AR not found\n"
156 printf "Checking RANLIB... "
157 $RANLIB --version > /dev/null 2> /dev/null
161 printf "$RANLIB not found\n"
166 printf "Checking endianess... "
167 printf "int main() { int probe = 0x00000001; return *(char *)&probe; }\n" > build_check.c
168 $CC $CFLAGS $LDFLAGS -L/usr/lib/mysql -L/usr/local/lib/mysql build_check.c -o fake > /dev/null 2> /dev/null
172 printf "Endianess checking failed\n"
179 CXXFLAGS="$CXXFLAGS -DARCH_LE"
180 CFLAGS="$CFLAGS -DARCH_LE"
181 printf "Little Endian\n"
184 CXXFLAGS="$CXXFLAGS -DARCH_BE"
185 CFLAGS="$CFLAGS -DARCH_BE"
186 printf "Big Endian\n"
191 printf "Checking for iconv 2nd argument... "
192 printf "#include <iconv.h>\nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c
193 $CC $CFLAGS $LDFLAGS -Werror build_check.c $LIBICONV -o fake > /dev/null 2> /dev/null
198 DEFS="$DEFS -DCONST_ICONV"
203 printf "Checking for fb_config... "
204 FB_VERSION=`fb_config --version 2> /dev/null`
208 printf "Checking for -lfbclient... "
209 printf "int main() { return 0; }\n" > build_check.c
210 $CC $CFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
217 FB_LDFLAGS="-lfbclient"
224 printf "Checking for fb_config --cflags... "
225 FB_CFLAGS=`fb_config --cflags`
231 printf "[$FB_CFLAGS]\n"
232 printf "Checking for fb_config --libs "
233 FB_LDFLAGS=`fb_config --libs`
240 printf "[$FB_LDFLAGS]\n"
245 printf "Checking for mysql_config... "
246 printf "#include <mysql.h>\nint main() { return 0; }\n" > build_check.c
247 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
251 printf "Checking for -lmysqlclient... "
252 $CC $CFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
258 CHECK_MYSQLCLIENT=yes
264 printf "Checking for mysql_config --cflags... "
265 MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
271 printf "[$MYSQL_CFLAGS]\n"
272 printf "Checking for mysql_config --libs_r... "
273 MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
279 CHECK_MYSQLCLIENT=yes
280 printf "[$MYSQL_LDFLAGS]\n"
285 printf "Checking for pg_config... "
286 printf "#include <libpq-fe.h>\nint main() { return 0; }\n" > build_check.c
287 PG_VERSION=`pg_config --version 2> /dev/null`
291 printf "Checking for -lpq... "
292 $CC $CFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
304 printf "Checking for pg_config --includedir... "
305 PG_CFLAGS="-I"`pg_config --includedir 2> /dev/null`
311 printf "[$PG_CFLAGS]\n"
312 printf "Checking for pg_config --libdir... "
313 PG_LDFLAGS="-L"`pg_config --libdir 2> /dev/null`
320 printf "[$PG_LDFLAGS]\n"
327 if [ "$CHECK_FBCLIENT" = "yes" ]
335 if [ "$CHECK_PQ" = "yes" ]
341 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
347 printf "OS=$OS\n" > $CONFFILE
348 printf "STG_TIME=yes\n" >> $CONFFILE
349 printf "DEBUG=$DEBUG\n" >> $CONFFILE
350 printf "DIR_BUILD=$BUILD_DIR\n" >> $CONFFILE
351 printf "DIR_LIB=\$(DIR_BUILD)/../../lib\n" >> $CONFFILE
352 printf "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs\n" >> $CONFFILE
353 printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE
354 printf "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules\n" >> $CONFFILE
355 printf "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins\n" >> $CONFFILE
356 printf "ARCH=$ARCH\n" >> $CONFFILE
357 printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE
358 if [ "$CHECK_FBCLIENT" = "yes" ]
360 printf "FB_CFLAGS=$FB_CFLAGS\n" >> $CONFFILE
361 printf "FB_LDFLAGS=$FB_LDFLAGS\n" >> $CONFFILE
363 printf "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT\n" >> $CONFFILE
364 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
366 printf "MYSQL_CFLAGS=$MYSQL_CFLAGS\n" >> $CONFFILE
367 printf "MYSQL_LDFLAGS=$MYSQL_LDFLAGS\n" >> $CONFFILE
369 printf "CHECK_PQ=$CHECK_PQ\n" >> $CONFFILE
370 if [ "$CHECK_PQ" = "yes" ]
372 printf "PG_CFLAGS=$PG_CFLAGS\n" >> $CONFFILE
373 printf "PG_LDFLAGS=$PG_LDFLAGS\n" >> $CONFFILE
375 printf "DEFS=$DEFS\n" >> $CONFFILE
376 printf "STG_LIBS=" >> $CONFFILE
379 printf "$lib " >> $CONFFILE
381 printf "\n" >> $CONFFILE
382 printf "PLUGINS=" >> $CONFFILE
383 for plugin in $PLUGINS
385 printf "$plugin " >> $CONFFILE
387 printf "\n" >> $CONFFILE
388 printf "CC=$CC\n" >> $CONFFILE
389 printf "CXX=$CXX\n" >> $CONFFILE
390 printf "AR=$AR\n" >> $CONFFILE
391 printf "RANLIB=$RANLIB\n" >> $CONFFILE
392 printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE
393 printf "CFLAGS=$CFLAGS\n" >> $CONFFILE
394 printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE
395 printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE
396 printf "LIBICONV=$LIBICONV\n" >> $CONFFILE
397 printf "PREFIX=$PREFIX\n" >> $CONFFILE
398 printf "BIN_MODE=$BIN_MODE\n" >> $CONFFILE
399 printf "DATA_MODE=$DATA_MODE\n" >> $CONFFILE
400 printf "DIR_MODE=$DIR_MODE\n" >> $CONFFILE
401 printf "OWNER=$OWNER\n" >> $CONFFILE
402 printf "VAR_DIR=$VAR_DIR\n" >> $CONFFILE
404 mkdir -p ../stargazer/modules
406 if [ "$1" != "debug" ]
410 printf "\n\n\nDebug build. Type $MAKE explicitly\n"