Support external liburiparse and boost https://code.google.com/p/libkml/issues/detail?id=50 --- configure.ac.orig +++ configure.ac @@ -20,6 +20,8 @@ AC_FUNC_STRTOD AC_HEADER_STDBOOL AC_TYPE_SIZE_T +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])dnl backward compat + dnl Let Makefile know if we are GCC. AM_CONDITIONAL(GCC, test "$GCC" = yes) @@ -68,6 +70,49 @@ AC_ARG_WITH(python-lib-dir, [PYTHON_LIB_DIR=$withval],) AC_SUBST(PYTHON_LIB_DIR) +dnl use libs from system or our third_party? +dnl CPPFLAGS_saved="$CPPFLAGS" +internal_boost_version="_1_34_1" +AC_LANG_PUSH(C++) +AC_ARG_WITH([boost], + AC_HELP_STRING([--with-boost=DIR], [look in DIR for boost]), + [BOOST_INCS=$withval/include + test -d ${BOOST_INCS} \ + && AS_VAR_APPEND([CPPFLAGS],[" -I$BOOST_INCS"]) + AC_CHECK_HEADERS([boost/shared_ptr.hpp],, + [AC_MSG_ERROR([Required $ac_header not found])]) + ], + [AC_CHECK_HEADERS([boost/shared_ptr.hpp],, + [AC_MSG_WARN([Using third_party/boost$internal_boost_version]) + BOOST_INCS="\$(top_srcdir)/third_party/boost$internal_boost_version" +dnl AS_VAR_APPEND([CPPFLAGS],[" -I\$(top_srcdir)/$BOOST_INCS"]) + ]) + ]) +AC_LANG_POP +dnl CPPFLAGS="$CPPFLAGS_saved" +AC_SUBST(BOOST_INCS) +AM_CONDITIONAL([INTERNAL_BOOST], [test "x$BOOST_INCS" = "xthird_party/boost$internal_boost_version"]) + +dnl FIXME: Allow for using distro's zlib +AM_CONDITIONAL([INTERNAL_ZLIB], [true]) + +internal_uriparser_version="-0.7.5" +CPPFLAGS_saved="$CPPFLAGS" +AC_ARG_WITH([liburiparser], + AC_HELP_STRING([--with-liburiparser=DIR], [look in DIR for liburiparser]), + [LIBURIPARSER_DIR=$withval + test -d ${LIBURIPARSER_DIR}/include \ + && AS_VAR_APPEND([CPPFLAGS],[" -I$LIBURIPARSER_DIR/include"]) + AC_CHECK_HEADERS([uriparser/Uri.h],, + [AC_MSG_ERROR([Required $ac_header not found])]) + ], + [AC_CHECK_HEADERS([uriparser/Uri.h],, + [AC_MSG_WARN([Using third_party/uriparser$internal_uriparser_version]) + LIBURIPARSER_DIR="third_party/uriparser$internal_uriparser_version" + ]) + ]) +AC_SUBST(LIBURIPARSER_DIR) +AM_CONDITIONAL([INTERNAL_LIBURIPARSER], [test "x$LIBURIPARSER_DIR" = "xthird_party/uriparser$internal_uriparser_version"]) AC_CHECK_HEADERS(expat.h, [expat_h_found="yes"], [expat_h_found="no"]) if test $expat_h_found = "no" @@ -78,7 +123,10 @@ AC_CHECK_LIB(expat, XML_ParserCreate, [], AC_MSG_ERROR("Expat library not found. Use configure --help to see how to specify the search path")) AC_CHECK_HEADERS([float.h limits.h stdlib.h string.h]) -AC_CHECK_FUNCS([floor memset strstr]) +dnl saved_LIBS=$LIBS +dnl AC_SEARCH_LIBS([floor], [m]) +AC_CHECK_LIB([m], [floor]) +AC_CHECK_FUNCS([memset strstr]) dnl If SWIG is available we will try to generate bindings. AC_ARG_ENABLE(swig, --- examples/engine/Makefile.am.orig +++ examples/engine/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 + -I@BOOST_INCS@ if GCC AM_CXXFLAGS = -Wall -Werror -ansi -pedantic -fno-rtti --- examples/gpx/Makefile.am.orig +++ examples/gpx/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 + -I@BOOST_INCS@ if GCC AM_CXXFLAGS = -Wall -Werror -ansi -pedantic -fno-rtti --- examples/gx/Makefile.am.orig +++ examples/gx/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 + -I@BOOST_INCS@ if GCC AM_CXXFLAGS = -Wall -Werror -ansi -pedantic -fno-rtti --- examples/hellonet/Makefile.am.orig +++ examples/hellonet/Makefile.am @@ -1,7 +1,7 @@ if HAVE_CURL AM_CPPFLAGS = -I$(top_srcdir)/src \ -I$(top_srcdir)/examples/hellonet \ - -I$(top_srcdir)/third_party/boost_1_34_1 + -I@BOOST_INCS@ if GCC AM_CXXFLAGS = -Wall -Werror -ansi -pedantic -fno-rtti --- examples/helloworld/Makefile.am.orig +++ examples/helloworld/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src \ -I$(top_srcdir)/examples/helloworld \ - -I$(top_srcdir)/third_party/boost_1_34_1 + -I@BOOST_INCS@ if GCC --- examples/regionator/Makefile.am.orig +++ examples/regionator/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 \ + -I@BOOST_INCS@ \ -I$(top_srcdir)/third_party/zlib-1.2.3/contrib if GCC --- examples/xsd/Makefile.am.orig +++ examples/xsd/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src \ -I$(top_srcdir)/examples/xsd \ - -I$(top_srcdir)/third_party/boost_1_34_1 + -I@BOOST_INCS@ if GCC AM_CXXFLAGS = -Wall -Werror -ansi -pedantic -fno-rtti --- src/kml/base/Makefile.am.orig +++ src/kml/base/Makefile.am @@ -1,8 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 \ - -I$(top_srcdir)/third_party/googletest-r108/include \ - -I$(top_srcdir)/third_party/uriparser-0.7.5/include \ - -I$(top_srcdir)/third_party/zlib-1.2.3/contrib + -I@BOOST_INCS@ \ + -I$(top_srcdir)/third_party/googletest-r108/include if GCC AM_CXXFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror -ansi -pedantic -fno-rtti @@ -30,9 +28,19 @@ libkmlbase_la_SOURCES = \ xml_namespaces.cc \ zip_file.cc -libkmlbase_la_LIBADD = \ - $(top_builddir)/third_party/libminizip.la \ - $(top_builddir)/third_party/liburiparser.la +libkmlbase_la_LIBADD = +if INTERNAL_ZLIB +libkmlbase_la_LIBADD += \ + $(top_builddir)/third_party/libminizip.la +AM_CPPFLAGS += -I$(top_srcdir)/third_party/zlib-1.2.3/contrib +endif +if INTERNAL_LIBURIPARSER +AM_CPPFLAGS += -I$(top_srcdir)/@LIBURIPARSER_DIR@/include +liburiparser_la_file = $(top_builddir)/third_party/liburiparser.la +else +liburiparser_la_file = $(LIBURIPARSER_DIR)/lib/liburiparser.la +endif +libkmlbase_la_LIBADD += $(liburiparser_la_file) # These header files will be installed in $(includedir)/kml/base libkmlbaseincludedir = $(includedir)/kml/base @@ -138,7 +146,6 @@ math_util_test_LDADD = libkmlbase.la \ net_cache_test_SOURCES = net_cache_test.cc net_cache_test_CXXFLAGS = -DDATADIR=\"$(DATA_DIR)\" $(AM_TEST_CXXFLAGS) net_cache_test_LDADD = libkmlbase.la \ - $(top_builddir)/third_party/liburiparser.la \ $(top_builddir)/third_party/libgtest.la referent_test_SOURCES = referent_test.cc @@ -164,7 +171,6 @@ time_util_test_LDADD= libkmlbase.la \ uri_parser_test_SOURCES = uri_parser_test.cc uri_parser_test_CXXFLAGS = -DDATADIR=\"$(DATA_DIR)\" $(AM_TEST_CXXFLAGS) uri_parser_test_LDADD= libkmlbase.la \ - $(top_builddir)/third_party/liburiparser.la \ $(top_builddir)/third_party/libgtest.la util_test_SOURCES = util_test.cc --- src/kml/base/file_posix.cc.orig +++ src/kml/base/file_posix.cc @@ -25,8 +25,10 @@ // The file contains the implementation of the File methods specific to // POSIX platforms. +// err.. Ever heard about boost::filesystem? #include "kml/base/file.h" +#include /* unlink() */ #include #include #include --- src/kml/convenience/Makefile.am.orig +++ src/kml/convenience/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 \ + -I@BOOST_INCS@ \ -I$(top_srcdir)/third_party/googletest-r108/include if GCC --- src/kml/dom/Makefile.am.orig +++ src/kml/dom/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS= -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 \ + -I@BOOST_INCS@ \ -I$(top_srcdir)/third_party/googletest-r108/include if GCC --- src/kml/engine/Makefile.am.orig +++ src/kml/engine/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS= -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 \ + -I@BOOST_INCS@ \ -I$(top_srcdir)/third_party/googletest-r108/include if GCC --- src/kml/regionator/Makefile.am.orig +++ src/kml/regionator/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS= -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 \ + -I@BOOST_INCS@ \ -I$(top_srcdir)/third_party/googletest-r108/include --- src/kml/xsd/Makefile.am.orig +++ src/kml/xsd/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 \ + -I@BOOST_INCS@ \ -I$(top_srcdir)/third_party/googletest-r108/include if GCC --- src/swig/Makefile.am.orig +++ src/swig/Makefile.am @@ -1,7 +1,7 @@ SUBDIRS = java python AM_CPPFLAGS = -I$(top_srcdir)/src \ - -I$(top_srcdir)/third_party/boost_1_34_1 \ + -I@BOOST_INCS@ \ -I$(top_srcdir)/third_party/uriparser-0.7.5/include COMMONLIBS = $(top_builddir)/src/kml/engine/libkmlengine.la \ --- third_party/Makefile.am.orig +++ third_party/Makefile.am @@ -1,19 +1,26 @@ uriparser = uriparser-0.7.5 -AM_CPPFLAGS = -I$(top_srcdir)/third_party/zlib-1.2.3/contrib \ - -I$(top_srcdir)/third_party/$(uriparser)/include \ - -I$(top_srcdir)/third_party/googletest-r108 \ - -I$(top_srcdir)/third_party/googletest-r108/include +AM_CPPFLAGS = -lib_LTLIBRARIES = libminizip.la liburiparser.la +lib_LTLIBRARIES = noinst_LTLIBRARIES = libgtest.la +if INTERNAL_ZLIB +AM_CPPFLAGS += -I$(top_srcdir)/third_party/zlib-1.2.3/contrib +lib_LTLIBRARIES += libminizip.la + libminizip_la_SOURCES = \ zlib-1.2.3/contrib/minizip/unzip.c \ zlib-1.2.3/contrib/minizip/ioapi.c \ zlib-1.2.3/contrib/minizip/iomem_simple.c \ zlib-1.2.3/contrib/minizip/zip.c libminizip_la_LDFLAGS = -lz +endif + + +if INTERNAL_LIBURIPARSER +AM_CPPFLAGS += -I$(top_srcdir)/third_party/$(uriparser)/include +lib_LTLIBRARIES += liburiparser.la liburiparser_la_SOURCES = \ $(uriparser)/lib/UriCommon.c \ @@ -35,7 +42,10 @@ liburiparser_la_SOURCES = \ $(uriparser)/lib/UriResolve.c \ $(uriparser)/lib/UriShorten.c liburiparser_la_LDFLAGS = -version-info 1:5:0 +endif + +if INTERNAL_BOOST boost_root = boost_1_34_1 boost = $(boost_root)/boost boostinc = $(includedir)/kml/third_party/$(boost) @@ -76,6 +86,10 @@ libboostconfigplatformincludedir = $(boostinc)/config/platform libboostconfigplatforminclude_HEADERS = \ $(boost)/config/platform/linux.hpp \ $(boost)/config/platform/macos.hpp +endif + +AM_CPPFLAGS += -I$(top_srcdir)/third_party/googletest-r108 \ + -I$(top_srcdir)/third_party/googletest-r108/include googletest = googletest-r108 libgtest_la_SOURCES = \