-echo "OS=$OS" > $CONFFILE
-echo "STG_TIME=yes" >> $CONFFILE
-echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
-echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
-echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
-echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
-echo "ARCH=$ARCH" >> $CONFFILE
-echo "DEFS=$DEFS" >> $CONFFILE
-echo -n "STG_LIBS=" >> $CONFFILE
+printf "Checking for iconv 2nd argument... "
+printf "#include <iconv.h>\nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c
+$CC $CFLAGS $LDFLAGS -Werror build_check.c $LIBICONV -o fake > /dev/null 2> /dev/null
+if [ $? != 0 ]
+then
+ printf "non-const\n"
+else
+ DEFS="$DEFS -DCONST_ICONV"
+ printf "const\n"
+fi
+rm -f fake
+
+printf "Checking for -lyajl... "
+pkg-config --version > /dev/null 2> /dev/null
+if [ "$?" = "0" ]
+then
+ pkg-config --atleast-version=2.0.0 yajl
+ if [ "$?" != "0" ]
+ then
+ CHECK_YAJL=no
+ printf "no\n"
+ exit;
+ else
+ CHECK_YAJL=yes
+ printf `pkg-config --modversion yajl`"\n"
+ fi
+else
+ printf "#include <stdio.h>\n" > build_check.c
+ printf "#include <yajl/yajl_version.h>\n" >> build_check.c
+ printf "int main() { printf(\"%%d\", yajl_version()); return 0; }\n" >> build_check.c
+ $CC $CFLAGS $LDFLAGS build_check.c -lyajl -o fake > /dev/null 2> /dev/null
+ if [ $? != 0 ]
+ then
+ CHECK_YAJL=no
+ printf "no\n"
+ exit;
+ else
+ YAJL_VERSION=`./fake`
+ if [ $YAJL_VERSION -ge 20000 ]
+ then
+ CHECK_YAJL=yes
+ printf "${YAJL_VERSION}\n"
+ else
+ CHECK_YAJL=no
+ printf "no. Need at least version 2.0.0, existing version is ${YAJL_VERSION}\n"
+ exit;
+ fi
+ fi
+ rm -f fake
+fi
+
+printf "Checking for boost::scoped_ptr... "
+printf "#include <boost/scoped_ptr.hpp>\nint main() { boost::scoped_ptr<int> test(new int(1)); return 0; }\n" > build_check.cpp
+$CXX $CXXFLAGS $LDFLAGS build_check.cpp -o fake # > /dev/null 2> /dev/null
+if [ $? != 0 ]
+then
+ CHECK_BOOST_SCOPED_PTR=no
+ printf "no\n"
+ exit;
+else
+ CHECK_BOOST_SCOPED_PTR=yes
+ printf "yes\n"
+fi
+rm -f fake
+
+rm -f build_check.c
+rm -f build_check.cpp
+
+if [ "$CHECK_YAJL" = "yes" -a "$CHECK_BOOST_SCOPED_PTR" = "yes" ]
+then
+ STG_LIBS="$STG_LIBS
+ json.lib"
+fi
+
+printf "OS=$OS\n" > $CONFFILE
+printf "STG_TIME=yes\n" >> $CONFFILE
+printf "DEBUG=$DEBUG\n" >> $CONFFILE
+printf "DIR_BUILD=$BUILD_DIR\n" >> $CONFFILE
+printf "DIR_LIB=\$(DIR_BUILD)/../../lib\n" >> $CONFFILE
+printf "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs\n" >> $CONFFILE
+printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE
+printf "ARCH=$ARCH\n" >> $CONFFILE
+printf "DEFS=$DEFS\n" >> $CONFFILE
+printf "STG_LIBS=" >> $CONFFILE