Skip to content
Commits on Source (105)
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
BreakBeforeBraces: Mozilla
IndentWidth: 4
ConstructorInitializerIndentWidth: 0
ReflowComments: false
AlwaysBreakTemplateDeclarations: true
*.o
*~
Makefile.in
aclocal.m4
autom4te.cache/
config.guess
config.h.in
config.h.in~
config.sub
configure
compile
depcomp
fileformat.pb-c.c
fileformat.pb-c.h
install-sh
legacy/Makefile.in
ltmain.sh
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
missing
nodecachefilereader
osmformat.pb-c.c
osmformat.pb-c.h
osm2pgsql
build
Makefile
config.h
config.log
config.nice
config.status
legacy/.deps/
legacy/Makefile
libtool
.deps/
stamp-h1
INSTALL
log
test-driver
test-suite.log
tests/.dirstamp
tests/test-parse-xml2
tests/test-middle-ram
tests/test-middle-pgsql
tests/test-middle-flat
tests/test-pgsql-escape
tests/test-parse-options
tests/test-output-multi-tags
tests/test-output-multi-line
tests/test-output-multi-line-storage
tests/test-output-multi-point
tests/test-output-multi-point-multi-table
tests/test-output-multi-polygon
tests/test-output-multi-poly-trivial
tests/test-output-pgsql
tests/test-output-pgsql-tablespace
tests/test-output-pgsql-z_order
tests/test-expire-tiles
tests/*.log
tests/*.trs
tests/*.flat.nodes.bin
.libs/
*.lo
libosm2pgsql.la
docs/html
docs/latex
language: cpp
sudo: false
addons:
apt:
sources:
- boost-latest
- ubuntu-toolchain-r-test
packages:
- libtool
- libxml2-dev
- libgeos-dev
- libgeos++-dev
- g++-4.8
- libexpat1-dev
- libpq-dev
- libbz2-dev
- libproj-dev
- protobuf-c-compiler
- libprotobuf-c0-dev
- lua5.2
- liblua5.2-dev
- libluajit-5.1-dev
- libboost1.55-dev
- libboost-system1.55-dev
- libboost-filesystem1.55-dev
matrix:
include:
#basic tests of with/without lua and old boost versions, with both clang and gc
- os: linux
compiler: clang
env: USE_LUA=true
- os: linux
compiler: clang
env: USE_LUA=true BOOST_PPA=1.55
- os: linux
compiler: clang
env: USE_LUA=false BOOST_PPA=1.55
env: CXXFLAGS="-pedantic -Werror" LUAJIT_OPTION="OFF"
- os: linux
compiler: gcc
env: USE_LUA=true
env: RUNTEST="-L NoDB" CXXFLAGS="-pedantic -Werror -fsanitize=address" LUAJIT_OPTION="OFF"
- os: linux
compiler: gcc
env: USE_LUA=true BOOST_PPA=1.55
compiler: clang
env: CXXFLAGS="-pedantic -Werror" LUAJIT_OPTION="ON"
- os: linux
compiler: gcc
env: USE_LUA=false BOOST_PPA=1.55
# additional tests
- os: linux
env: RUNTEST="-L NoDB" CXXFLAGS="-pedantic -Werror -fsanitize=address" LUAJIT_OPTION="ON"
- os: osx
compiler: clang
env: USE_LUA=true BOOST_PPA=1.54
env: RUNTEST="-L NoDB" CXXFLAGS="-pedantic -Werror -fsanitize=address" LUAJIT_OPTION="OFF"
before_install:
# BOOST_PPA is only set on linux
- if [ -z ${BOOST_PPA+x} ]; then
echo "Using system Boost";
else
echo "Using Boost PPA";
sudo add-apt-repository -y ppa:boost-latest/ppa;
fi
- if [[ $(uname -s) == 'Linux' ]]; then
sudo apt-get update -qq;
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
brew install lua;
fi
# update versions
install:
- if [[ $(uname -s) == 'Linux' ]]; then
if [ -z ${BOOST_PPA+x} ]; then
sudo apt-get install -y -qq libboost1.48-all-dev;
else
sudo apt-get install -y -qq "boost${BOOST_PPA}";
fi;
if [[ "${USE_LUA}" = "true" ]]; then
sudo apt-get install -y -qq lua5.2 liblua5.2-dev;
fi;
fi;
- if [[ $CC == 'gcc' ]]; then
export CC=gcc-4.8;
fi
- if [[ $CXX == 'g++' ]]; then
export CXX=g++-4.8;
fi
before_script:
- $CXX --version
- xml2-config --version
- geos-config --version
- proj | head -n1
- if [ "${USE_LUA}" = "true" ]; then
lua -v;
fi;
- lua -v
script:
./autogen.sh && ./configure && make -j2
- mkdir build && cd build
- cmake .. -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DWITH_LUAJIT=$LUAJIT_OPTION
- make -j2
- echo "Running tests that does not require PostgreSQL server"
- if [[ $RUNTEST ]]; then ctest -VV $RUNTEST; fi
after_failure:
- cat config.log
- # rerun make, but verbosely
make VERBOSE=1
INSERT INTO spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text)VALUES (900913,'EPSG',900913,'PROJCS["WGS84 / Simple Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS_1984", 6378137.0, 298.257223563]],PRIMEM["Greenwich", 0.0],UNIT["degree", 0.017453292519943295],AXIS["Longitude", EAST],AXIS["Latitude", NORTH]],PROJECTION["Mercator_1SP_Google"],PARAMETER["latitude_of_origin", 0.0],PARAMETER["central_meridian", 0.0],PARAMETER["scale_factor", 1.0],PARAMETER["false_easting", 0.0],PARAMETER["false_northing", 0.0],UNIT["m", 1.0],AXIS["x", EAST],AXIS["y", NORTH],AUTHORITY["EPSG","900913"]]','+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs');
set(PACKAGE osm2pgsql)
set(PACKAGE_NAME osm2pgsql)
set(PACKAGE_VERSION 0.96.0-RC1)
cmake_minimum_required(VERSION 2.8.7)
project(osm2pgsql)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if (WIN32)
set(DEFAULT_STYLE "default.style" CACHE STRING "Default style used unless one is given on the command line")
else()
set(DEFAULT_STYLE "${CMAKE_INSTALL_PREFIX}/share/osm2pgsql/default.style" CACHE STRING "Default style used unless one is given on the command line")
endif()
option(BUILD_TESTS "Build test suite" OFF)
option(WITH_LUA "Build with Lua support" ON)
option(WITH_LUAJIT "Build with LuaJIT support" OFF)
if (NOT TESTING_TIMEOUT)
set(TESTING_TIMEOUT 1200)
endif()
if (NOT WIN32 AND NOT APPLE)
# No need for this path, just a workaround to make cmake check pass on all systems
set(PostgreSQL_TYPE_INCLUDE_DIR /usr/include)
endif()
# Just in case user installed RPMs from http://yum.postgresql.org/
list(APPEND CMAKE_PREFIX_PATH /usr/pgsql-9.3 /usr/pgsql-9.4 /usr/pgsql-9.5 /usr/pgsql-9.6)
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed, please use a separate build directory like `mkdir build && cd build && cmake ..`")
endif()
message(STATUS "Building osm2pgsql ${PACKAGE_VERSION}")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_EXTENSIONS Off)
set (CMAKE_CXX_STANDARD_REQUIRED TRUE)
if ( MSVC )
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -wd4996)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099 /STACK:30000000")
else()
add_definitions(-Wall)
add_definitions(-DBOOST_TEST_DYN_LINK)
if (CMAKE_VERSION VERSION_LESS 3.1)
add_definitions(-std=c++11)
endif ()
endif()
option(EXTERNAL_LIBOSMIUM "Do not use the bundled libosmium" OFF)
option(EXTERNAL_PROTOZERO "Do not use the bundled protozero" OFF)
#############################################################
# Detect available headers and set global compiler options
#############################################################
include (CheckIncludeFiles)
include (CheckFunctionExists)
include (CheckTypeSize)
add_definitions( -DDEFAULT_STYLE=\"${DEFAULT_STYLE}\" )
add_definitions( -DFIXED_POINT )
CHECK_INCLUDE_FILES (termios.h HAVE_TERMIOS_H)
CHECK_INCLUDE_FILES (libgen.h HAVE_LIBGEN_H)
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
if (WIN32)
set(HAVE_LIBGEN_H FALSE)
endif()
#############################################################
# Find necessary libraries
#############################################################
if (NOT EXTERNAL_LIBOSMIUM)
set(OSMIUM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/contrib/libosmium")
endif()
if (NOT EXTERNAL_PROTOZERO)
set(PROTOZERO_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/contrib/protozero/include")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
find_package(Osmium 2.14 REQUIRED COMPONENTS io proj)
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS} ${PROTOZERO_INCLUDE_DIR})
if (WITH_LUA)
if (WITH_LUAJIT)
find_package(LuaJIT REQUIRED)
include_directories(${LUAJIT_INCLUDE_DIR})
set(HAVE_LUAJIT 1)
else()
find_package(Lua REQUIRED)
include_directories(${LUA_INCLUDE_DIR})
endif()
set(HAVE_LUA 1)
endif()
if (NOT Boost_ADDITIONAL_VERSIONS)
set(Boost_ADDITIONAL_VERSIONS "1.55;1.56;1.57;1.58;1.59;1.60;1.61")
endif()
# first try to find the version
find_package(Boost 1.50 REQUIRED COMPONENTS system filesystem ${BOOST_EXTRA})
include_directories(${Boost_INCLUDE_DIR})
find_package(PostgreSQL REQUIRED)
include_directories(${PostgreSQL_INCLUDE_DIRS})
find_package(Threads)
############### Libraries are found now ########################
set (LIBS ${Boost_LIBRARIES} ${PostgreSQL_LIBRARY} ${OSMIUM_LIBRARIES})
if (LUAJIT_FOUND)
list(APPEND LIBS ${LUAJIT_LIBRARIES})
elseif(LUA_FOUND)
list(APPEND LIBS ${LUA_LIBRARIES})
endif()
if (WIN32)
list(APPEND LIBS ws2_32)
if (MSVC)
find_path(GETOPT_INCLUDE_DIR getopt.h)
find_library(GETOPT_LIBRARY NAMES wingetopt getopt )
if (GETOPT_INCLUDE_DIR AND GETOPT_LIBRARY)
include_directories(${GETOPT_INCLUDE_DIR})
list(APPEND LIBS ${GETOPT_LIBRARY})
else()
message(ERROR "Can not find getopt library for Windows. Please get it from https://github.com/alex85k/wingetopt or alternative source.")
endif()
endif()
endif()
message("Libraries used to build: " ${LIBS})
list(APPEND LIBS ${CMAKE_DL_LIBS})
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_IN_RT)
if (HAVE_CLOCK_GETTIME_IN_RT)
list(APPEND LIBS rt)
endif()
endif ()
message("Active compiler flags:" ${CMAKE_CXX_FLAGS})
#############################################################
# Build the library and executable file
#############################################################
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
if (NOT HAVE_UNISTD_H AND NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/unistd.h)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/unistd.h "// empty header\n")
endif()
set(osm2pgsql_lib_SOURCES
expire-tiles.cpp
geometry-processor.cpp
id-tracker.cpp
middle-pgsql.cpp
middle-ram.cpp
middle.cpp
node-persistent-cache.cpp
node-ram-cache.cpp
options.cpp
osmdata.cpp
osmium-builder.cpp
output-gazetteer.cpp
output-multi.cpp
output-null.cpp
output-pgsql.cpp
output.cpp
parse-osmium.cpp
pgsql.cpp
processor-line.cpp
processor-point.cpp
processor-polygon.cpp
reprojection.cpp
sprompt.cpp
table.cpp
taginfo.cpp
tagtransform.cpp
tagtransform-c.cpp
util.cpp
wildcmp.cpp
expire-tiles.hpp
geometry-processor.hpp
id-tracker.hpp
middle-pgsql.hpp
middle-ram.hpp
middle.hpp
node-persistent-cache.hpp
node-ram-cache.hpp
options.hpp
osmdata.hpp
osmium-builder.hpp
osmtypes.hpp
output-gazetteer.hpp
output-multi.hpp
output-null.hpp
output-pgsql.hpp
output.hpp
parse-osmium.hpp
pgsql.hpp
processor-line.hpp
processor-point.hpp
processor-polygon.hpp
reprojection.hpp
sprompt.hpp
table.hpp
taginfo.hpp
taginfo_impl.hpp
tagtransform.hpp
util.hpp
wildcmp.hpp
wkb.hpp
)
if (LUA_FOUND OR LUAJIT_FOUND)
list(APPEND osm2pgsql_lib_SOURCES tagtransform-lua.cpp)
endif()
add_library(osm2pgsql_lib STATIC ${osm2pgsql_lib_SOURCES})
set_target_properties(osm2pgsql_lib PROPERTIES OUTPUT_NAME osm2pgsql)
add_executable(osm2pgsql osm2pgsql.cpp)
target_link_libraries(osm2pgsql_lib ${LIBS})
target_link_libraries(osm2pgsql osm2pgsql_lib ${LIBS})
#############################################################
# Build tests
#############################################################
enable_testing()
include(CTest)
if (BUILD_TESTS)
add_subdirectory(tests)
else()
add_subdirectory(tests EXCLUDE_FROM_ALL)
endif()
#############################################################
# Install
#############################################################
install(TARGETS osm2pgsql DESTINATION bin)
install(FILES docs/osm2pgsql.1 DESTINATION share/man/man1)
install(FILES default.style empty.style DESTINATION share/osm2pgsql)
......@@ -27,37 +27,38 @@ Osm2pgsql uses a X.Y.Z version number, where Y tells you if you are on a stable
or development series. Like the Linux Kernel, even numbers are stable and
development versions are odd.
Old branches and versions are not generally maintained.
Bugs and known issues are fixed on the main branch only. Exceptions may be made
for easy bug fixes, or if a patch backporting a fix is provided.
## Code style
The current codebase is a mix of styles, but new code should be written in the
Code must be written in the
[K&R 1TBS style](https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS) with
4 spaces indentation. Tabs should never be used in the C++ code.
4 spaces indentation. Tabs should never be used in the C++ code. Braces must
always be used for code blocks, even one-liners.
e.g.
Names should use underscores, not camel case, with class/struct names ending in `_t`.
Template parameters must use all upper case.
```
int main(int argc, char *argv[])
{
...
while (x == y) {
something();
somethingelse();
if (some_error) {
do_correct();
} else {
continue_as_usual();
}
}
finalthing();
...
}
```
Headers should be included in the order `config.h`, C++ standard library headers,
C library headers, Boost headers, and last osm2pgsql files.
Names should use underscores, not camel case, with class/struct names ending in `_t`.
There is a .clang-format configuration avialable and all code must be run through
clang-format before submitting. You can use git-clang-format after staging all
your changes:
git-clang-format --style=file *pp tests/*pp
clang-format 3.8 or later is required.
## Documentation
User documentation is stored in `docs/`. Pages on the OpenStreetMap wiki are
known to be unreliable and outdated.
There is some documentation in Doxygen-formatted comments. The documentation can
be generated with ``doxygen docs/Doxyfile``. It is not yet hooked into the build
scripts as most functions are not yet documented.
## Platforms targeted
......@@ -67,7 +68,13 @@ actively tested on Debian, Ubuntu and FreeBSD by the maintainers.
## Testing
The code also comes with a suite of tests which can be run by
executing ``make check``.
executing ``ctest``.
Regression tests require python and psycopg to be installed. On Ubuntu run:
```sh
sudo apt-get install python-psycopg2
```
Most of these tests depend on being able to set up a database and run osm2pgsql
against it. You need to ensure that PostgreSQL is running and that your user is
......
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = osm2pgsql nodecachefilereader
noinst_LTLIBRARIES = libosm2pgsql.la
osm2pgsql_SOURCES = osm2pgsql.cpp
osm2pgsql_LDADD = libosm2pgsql.la
libosm2pgsql_la_SOURCES = \
UTF8sanitizer.cpp \
expire-tiles.cpp \
geometry-builder.cpp \
geometry-processor.cpp \
id-tracker.cpp \
input.cpp \
middle.cpp \
middle-pgsql.cpp \
middle-ram.cpp \
node-persistent-cache.cpp \
node-ram-cache.cpp \
options.cpp \
osmdata.cpp \
output.cpp \
output-gazetteer.cpp \
output-multi.cpp \
output-null.cpp \
output-pgsql.cpp \
parse.cpp \
parse-o5m.cpp \
parse-pbf.cpp \
parse-xml2.cpp \
pgsql.cpp \
processor-line.cpp \
processor-point.cpp \
processor-polygon.cpp \
reprojection.cpp \
sprompt.cpp \
table.cpp \
taginfo.cpp \
tagtransform.cpp \
util.cpp \
wildcmp.cpp
nodecachefilereader_SOURCES = node-persistent-cache-reader.cpp
nodecachefilereader_LDADD = libosm2pgsql.la
check_PROGRAMS = \
tests/test-parse-xml2 \
tests/test-middle-ram \
tests/test-middle-pgsql \
tests/test-middle-flat \
tests/test-output-multi-tags \
tests/test-output-multi-line \
tests/test-output-multi-line-storage \
tests/test-output-multi-point \
tests/test-output-multi-point-multi-table \
tests/test-output-multi-polygon \
tests/test-output-multi-poly-trivial \
tests/test-output-pgsql \
tests/test-output-pgsql-z_order \
tests/test-output-pgsql-tablespace \
tests/test-pgsql-escape \
tests/test-parse-options \
tests/test-expire-tiles
tests_test_parse_xml2_SOURCES = tests/test-parse-xml2.cpp
tests_test_parse_xml2_LDADD = libosm2pgsql.la
tests_test_middle_ram_SOURCES = tests/test-middle-ram.cpp tests/middle-tests.cpp
tests_test_middle_ram_LDADD = libosm2pgsql.la
tests_test_middle_pgsql_SOURCES = tests/test-middle-pgsql.cpp tests/middle-tests.cpp tests/common-pg.cpp
tests_test_middle_pgsql_LDADD = libosm2pgsql.la
tests_test_middle_flat_SOURCES = tests/test-middle-flat.cpp tests/middle-tests.cpp tests/common-pg.cpp
tests_test_middle_flat_LDADD = libosm2pgsql.la
tests_test_output_multi_tags_SOURCES = tests/test-output-multi-tags.cpp tests/common-pg.cpp
tests_test_output_multi_tags_LDADD = libosm2pgsql.la
tests_test_output_multi_line_SOURCES = tests/test-output-multi-line.cpp tests/common-pg.cpp
tests_test_output_multi_line_LDADD = libosm2pgsql.la
tests_test_output_multi_line_storage_SOURCES = tests/test-output-multi-line-storage.cpp tests/common-pg.cpp
tests_test_output_multi_line_storage_LDADD = libosm2pgsql.la
tests_test_output_multi_point_SOURCES = tests/test-output-multi-point.cpp tests/common-pg.cpp
tests_test_output_multi_point_LDADD = libosm2pgsql.la
tests_test_output_multi_point_multi_table_SOURCES = tests/test-output-multi-point-multi-table.cpp tests/common-pg.cpp
tests_test_output_multi_point_multi_table_LDADD = libosm2pgsql.la
tests_test_output_multi_polygon_SOURCES = tests/test-output-multi-polygon.cpp tests/common-pg.cpp
tests_test_output_multi_polygon_LDADD = libosm2pgsql.la
tests_test_output_multi_poly_trivial_SOURCES = tests/test-output-multi-poly-trivial.cpp tests/common-pg.cpp
tests_test_output_multi_poly_trivial_LDADD = libosm2pgsql.la
tests_test_output_pgsql_SOURCES = tests/test-output-pgsql.cpp tests/common-pg.cpp
tests_test_output_pgsql_LDADD = libosm2pgsql.la
tests_test_output_pgsql_tablespace_SOURCES = tests/test-output-pgsql-tablespace.cpp tests/common-pg.cpp
tests_test_output_pgsql_tablespace_LDADD = libosm2pgsql.la
tests_test_output_pgsql_z_order_SOURCES = tests/test-output-pgsql-z_order.cpp tests/common-pg.cpp
tests_test_output_pgsql_z_order_LDADD = libosm2pgsql.la
tests_test_pgsql_escape_SOURCES = tests/test-pgsql-escape.cpp
tests_test_pgsql_escape_LDADD = libosm2pgsql.la
tests_test_parse_options_SOURCES = tests/test-parse-options.cpp
tests_test_parse_options_LDADD = libosm2pgsql.la
tests_test_expire_tiles_SOURCES = tests/test-expire-tiles.cpp
tests_test_expire_tiles_LDADD = libosm2pgsql.la
MOSTLYCLEANFILES = tests/test_middle_flat.flat.nodes.bin tests/test_output_pgsql_area_way.flat.nodes.bin
TESTS = $(check_PROGRAMS) tests/regression-test.sh
TEST_EXTENSIONS = .sh
SH_LOG_COMPILER = sh
if READER_PBF
osm2pgsql_SOURCES += parse-pbf.hpp fileformat.pb-c.h osmformat.pb-c.h
libosm2pgsql_la_SOURCES += parse-pbf.cpp fileformat.pb-c.c osmformat.pb-c.c
fileformat.pb-c.c: protobuf/fileformat.proto
$(AM_V_GEN) $(PROTOC_C) --proto_path=protobuf --c_out=. $<
fileformat.pb-c.h: fileformat.pb-c.c
@if test ! -f $@; then \
rm -f $<; \
$(MAKE) $(AM_MAKEFLAGS) $<; \
else :; fi
osmformat.pb-c.c: protobuf/osmformat.proto
$(AM_V_GEN) $(PROTOC_C) --proto_path=protobuf --c_out=. $<
osmformat.pb-c.h: osmformat.pb-c.c
@if test ! -f $@; then \
rm -f $<; \
$(MAKE) $(AM_MAKEFLAGS) $<; \
else :; fi
BUILT_SOURCES = \
fileformat.pb-c.c fileformat.pb-c.h \
osmformat.pb-c.c osmformat.pb-c.h
CLEANFILES = \
fileformat.pb-c.c fileformat.pb-c.h \
osmformat.pb-c.c osmformat.pb-c.h
endif
osm2pgsqldir = $(datadir)/osm2pgsql
AM_CFLAGS = @PTHREAD_CFLAGS@ @LFS_CFLAGS@ @POSTGRESQL_CPPFLAGS@ @XML2_CFLAGS@ @BZIP2_CFLAGS@ @GEOS_CFLAGS@ @PROJ_CFLAGS@ @PROTOBUF_C_CFLAGS@ @ZLIB_CFLAGS@ -DOSM2PGSQL_DATADIR='"$(osm2pgsqldir)"' -DVERSION='"@PACKAGE_VERSION@"' @LUA_INCLUDE@
AM_CPPFLAGS = @PTHREAD_CFLAGS@ @POSTGRESQL_CPPFLAGS@ @XML2_CFLAGS@ @BZIP2_CFLAGS@ @GEOS_CFLAGS@ @PROJ_CFLAGS@ -DOSM2PGSQL_DATADIR='"$(osm2pgsqldir)"' -Igeos-fallback @LUA_INCLUDE@ @BOOST_CPPFLAGS@
GLOBAL_LDFLAGS = @PTHREAD_CFLAGS@ @ZLIB_LDFLAGS@ @ZLIB_LIBS@ @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ @XML2_LDFLAGS@ @BZIP2_LDFLAGS@ @BZIP2_LIBS@ @GEOS_LDFLAGS@ @GEOS_LIBS@ @PROJ_LDFLAGS@ @PROJ_LIBS@ @PROTOBUF_C_LDFLAGS@ @PROTOBUF_C_LIBS@ -L/usr/lib/x86_64-linux-gnu @LUA_LIB@ @BOOST_LDFLAGS@ @BOOST_FILESYSTEM_LIB@ @BOOST_SYSTEM_LIB@ @BOOST_THREAD_LIB@
osm2pgsql_LDADD += $(GLOBAL_LDFLAGS)
tests_test_parse_xml2_LDADD += $(GLOBAL_LDFLAGS)
tests_test_middle_ram_LDADD += $(GLOBAL_LDFLAGS)
tests_test_middle_pgsql_LDADD += $(GLOBAL_LDFLAGS)
tests_test_middle_flat_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_multi_tags_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_multi_line_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_multi_line_storage_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_multi_point_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_multi_point_multi_table_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_multi_polygon_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_multi_poly_trivial_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_pgsql_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_pgsql_tablespace_LDADD += $(GLOBAL_LDFLAGS)
tests_test_output_pgsql_z_order_LDADD += $(GLOBAL_LDFLAGS)
tests_test_pgsql_escape_LDADD += $(GLOBAL_LDFLAGS)
tests_test_parse_options_LDADD += $(GLOBAL_LDFLAGS)
tests_test_expire_tiles_LDADD += $(GLOBAL_LDFLAGS)
nodecachefilereader_LDADD += $(GLOBAL_LDFLAGS)
osm2pgsql_DATA = default.style 900913.sql
man1_MANS = docs/osm2pgsql.1 docs/nodecachefilereader.1
EXTRA_DIST = osm2pgsql.spec.in \
osm2pgsql.spec \
protobuf/fileformat.proto \
protobuf/osmformat.proto \
debian \
$(osm2pgsql_DATA)
$(PACKAGE).spec: $(PACKAGE).spec.in
sed -e "s/@""PACKAGE""@/$(PACKAGE)/g; s/@""VERSION""@/$(VERSION)/g; s/@""SVN""@/`svnversion`/g;" $^ > $@
rpm: dist-gzip
rpmbuild -ta $(distdir).tar.gz
distclean-local:
@rm -f $(PACKAGE).spec
@rm -f config.nice
test: check
== 2010-11-06 Version 0.70.5 ==
* missing libraries are now already detected by 'configure'
instead of only breaking the build at compile time later
* the existing 'libxml2' and experimental 'primitive' XML
readers and a new 'pbf' reader for the Protobuf based
format are now all available in the main binary,
selectable using the new -r|--input-reader command line
option
\ No newline at end of file
......@@ -18,73 +18,104 @@ Nominatim, or general analysis.
## Installing ##
The latest source code is available in the OSM git repository on github
Most Linux distributions include osm2pgsql. It is also available on macOS with [Homebrew](http://brew.sh/).
Unoffical builds for Windows are available from [AppVeyor](https://ci.appveyor.com/project/openstreetmap/osm2pgsql/history) but you need to find the right build artifacts.
For the latest release 0.94.1, you may download a
[32bit version](https://ci.appveyor.com/api/projects/openstreetmap/osm2pgsql/artifacts/osm2pgsql_Release_x86.zip?tag=0.94.1&job=Environment%3A%20arch%3Dx86) or [64bit version](https://ci.appveyor.com/api/projects/openstreetmap/osm2pgsql/artifacts/osm2pgsql_Release_x64.zip?tag=0.94.1&job=Environment%3A%20arch%3Dx64).
## Building ##
The latest source code is available in the osm2pgsql git repository on GitHub
and can be downloaded as follows:
```sh
$ git clone git://github.com/openstreetmap/osm2pgsql.git
```
## Building ##
Osm2pgsql uses the [GNU Build System](http://www.gnu.org/software/automake/manual/html_node/GNU-Build-System.html)
Osm2pgsql uses the cross-platform [CMake build system](https://cmake.org/)
to configure and build itself and requires
* [libxml2](http://xmlsoft.org/)
* [geos](http://geos.osgeo.org/)
Required libraries are
* [expat](http://www.libexpat.org/)
* [proj](http://proj.osgeo.org/)
* [bzip2](http://www.bzip.org/)
* [zlib](http://www.zlib.net/)
* [Protocol Buffers](https://developers.google.com/protocol-buffers/)
* [Boost libraries](http://www.boost.org/), including system and filesystem
* [PostgreSQL](http://www.postgresql.org/) client libraries
* [Lua](http://www.lua.org/) (Optional, used for [Lua tag transforms](docs/lua.md))
* [Python](https://python.org/) (only for running tests)
* [Psycopg](http://initd.org/psycopg/) (only for running tests)
It also requires access to a database server running
[PostgreSQL](http://www.postgresql.org/) and [PostGIS](http://www.postgis.net/).
[PostgreSQL](http://www.postgresql.org/) 9.1+ and [PostGIS](http://www.postgis.net/) 2.0+.
Make sure you have installed the development packages for the libraries
mentioned in the requirements section and a C++ compiler which supports C++11.
Both GCC 4.8 and Clang 3.4 meet this requirement.
First install the dependencies.
On a Debian or Ubuntu system, this can be done with:
```sh
sudo apt-get install make cmake g++ libboost-dev libboost-system-dev \
libboost-filesystem-dev libexpat1-dev zlib1g-dev \
libbz2-dev libpq-dev libproj-dev lua5.2 liblua5.2-dev
```
On a Fedora system, use
Make sure you have installed the development packages for the
libraries mentioned in the requirements section and a C and C++
compiler.
```sh
sudo dnf install cmake make gcc-c++ boost-devel expat-devel zlib-devel \
bzip2-devel postgresql-devel proj-devel proj-epsg lua-devel
```
To install on a Debian or Ubuntu system, first install the prerequisites:
On RedHat / CentOS first run `sudo yum install epel-release` then install
dependencies with:
```sh
sudo apt-get install autoconf automake libtool make g++ libboost-dev \
libboost-system-dev libboost-filesystem-dev libboost-thread-dev libxml2-dev \
libgeos-dev libgeos++-dev libpq-dev libbz2-dev libproj-dev \
protobuf-c-compiler libprotobuf-c0-dev lua5.2 liblua5.2-dev
sudo yum install cmake make gcc-c++ boost-devel expat-devel zlib-devel \
bzip2-devel postgresql-devel proj-devel proj-epsg lua-devel
```
To install on a Fedora system, use
On a FreeBSD system, use
```sh
sudo yum install gcc-c++ automake libtool boost-devel libxml2-devel \
bzip2-devel postgresql-devel geos-devel proj-devel lua-devel \
protobuf-c-devel
pkg install devel/cmake devel/boost-libs textproc/expat2 \
databases/postgresql94-client graphics/proj lang/lua52
```
To install on a FreeBSD system, use
Once dependencies are installed, use CMake to build the Makefiles in a separate folder
```sh
pkg install devel/git devel/autoconf devel/automake devel/gmake devel/libtool \
textproc/libxml2 graphics/geos graphics/proj databases/postgresql94-client \
devel/boost-libs devel/protobuf-c lang/lua52 devel/pkgconf
mkdir build && cd build
cmake ..
```
Then you should be able to bootstrap the build system:
If some installed dependencies are not found by CMake, more options may need
to be set. Typically, setting `CMAKE_PREFIX_PATH` to a list of appropriate
paths is sufficient.
./autogen.sh
When the Makefiles have been successfully built, compile with
And then run the standard GNU build install:
```sh
make
```
./configure && make && make install
The compiled files can be installed with
Please see `./configure --help` for more options on how to control the build
process.
```sh
sudo make install
```
On FreeBSD instead bootstrap and then run
By default, the Release build with debug info is created and no tests are compiled.
You can change that behavior by using additional options like following:
LUA_LIB=`pkg-config --libs lua-5.2` ./configure && gmake && gmake install
```sh
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON
```
## Usage ##
......@@ -92,7 +123,7 @@ Osm2pgsql has one program, the executable itself, which has **43** command line
options.
Before loading into a database, the database must be created and the PostGIS
and optionally hstore extensions must be loaded. A full guide to PostgreSQL
and optional hstore extensions must be loaded. A full guide to PostgreSQL
setup is beyond the scope of this readme, but with reasonably recent versions
of PostgreSQL and PostGIS this can be done with
......@@ -118,14 +149,15 @@ osm2pgsql -c -d gis --slim -C <cache size> \
--flat-nodes <flat nodes> planet-latest.osm.pbf
```
where
* ``<cache size>`` is 24000 on machines with 32GiB or more RAM
or about 75% of memory in MiB on machines with less
* ``<flat nodes>`` is a location where a 24GiB file can be saved.
* ``<cache size>`` is about 75% of memory in MiB, to a maximum of about 30000. Additional RAM will not be used.
* ``<flat nodes>`` is a location where a 36GiB+ file can be saved.
Many different data files (e.g., .pbf) can be found at [planet.osm.org](http://planet.osm.org/).
The databases from either of these commands can be used immediately by
[Mapnik](http://mapnik.org/) for rendering maps with standard tools like
[renderd/mod_tile](https://github.com/openstreetmap/mod_tile),
[TileMill](https://www.mapbox.com/tilemill/), [Nik4](https://github.com/Zverik/Nik4),
[TileMill](https://tilemill-project.github.io/tilemill/), [Nik4](https://github.com/Zverik/Nik4),
among others. It can also be used for [spatial analysis](docs/analysis.md) or
[shapefile exports](docs/export.md).
......@@ -137,11 +169,8 @@ In addition to the standard [pgsql](docs/pgsql.md) backend designed for
rendering there is also the [gazetteer](docs/gazetteer.md) database for
geocoding, principally with [Nominatim](http://www.nominatim.org/), and the
null backend for testing. For flexibility a new [multi](docs/multi.md)
backend is also avialable which allows the configuration of custom
postgres tables instead of those provided in the pgsql backend.
Any questions should be directed at the osm dev list
http://wiki.openstreetmap.org/index.php/Mailing_lists
backend is also available which allows the configuration of custom
PostgreSQL tables instead of those provided in the pgsql backend.
## Contributing ##
......
== osm2pgsql ==
* there is still room for code cleanups
** the postgres specific files also contain some general functions
that could/should be moved out to separate files so that they
may be shared by other middle and output backends in the future
* in the long run it may make sense to go for C++ all the way
** the C++ interface to Google ProtoBuffers is much more mature than
its C counterpart
** inheriting input, middle, and output plugin implementations from
abstract C++ base clases would provide a cleaner and more readable
interface than the current C99 struct based implementation IMHO
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include "sanitizer.hpp"
#include "input.hpp"
int sanitizerClose(void *context);
int sanitizerProcess(void *context, char *buffer, int len);
/* UTF8sanitizer algorithm has some nasty edge cases when trying to operate
* in a 'block at a time' mode. For example, in the following scenario:
*
* INPUT sequence is 2 buffers with a 6 byte char starting at X1
*
* [ len = 5 ] [len = 1]
* X1 X2 X3 X4 X5 X6
*
* OUTPUT: nothing is generated for first buffer
* This will itself cause caller to assume EOF (hopefully normal reader will read >> 5 bytes).
* subsequent read of len=1 whille return all 6 bytes potentially causing output buffer overflow (and overwriting input data)
*
* The solution is to provice a small output buffer to hold anything bigger than a single byte
*
*/
struct Context {
long long line;
long long chars1, chars2, chars3, chars4, chars5, chars6;
int state, current_size;
int long_char[6];
int out_char[10];
int pend;
int verbose;
Input *file;
};
int sanitizerClose(void *context)
{
struct Context *ctx = (struct Context *)context;
int r = inputClose(ctx->file);
if (ctx->verbose) {
fprintf(stderr, "Summary:\n");
fprintf(stderr, "chars1: %lld\n", ctx->chars1);
fprintf(stderr, "chars2: %lld\n", ctx->chars2);
fprintf(stderr, "chars3: %lld\n", ctx->chars3);
fprintf(stderr, "chars4: %lld\n", ctx->chars4);
fprintf(stderr, "chars5: %lld\n", ctx->chars5);
fprintf(stderr, "chars6: %lld\n", ctx->chars6);
fprintf(stderr, "lines : %lld\n", ctx->line);
}
free(ctx);
return r;
}
xmlTextReaderPtr sanitizerOpen(const char *name)
{
struct Context *ctx = (struct Context *)malloc(sizeof(*ctx));
if (!ctx)
return NULL;
memset(ctx, 0, sizeof(*ctx));
ctx->verbose = 0;
ctx->state = 1;
ctx->pend = 0;
ctx->file = inputOpen(name);
if (!ctx->file) {
fprintf(stderr, "Input reader create failed\n");
free(ctx);
return NULL;
}
return xmlReaderForIO(sanitizerProcess, sanitizerClose, (void *)ctx, NULL, NULL, 0);
}
int sanitizerProcess(void *context, char *buffer, int len)
{
struct Context *ctx = (struct Context *)context;
int current_char, i, out = 0;
while (out < len) {
if (ctx->pend) {
buffer[out++] = ctx->out_char[--ctx->pend];
continue;
}
current_char=inputGetChar(ctx->file);
if (inputEof(ctx->file))
break;
if ((current_char & 128) == 0) {
/* Handle_ASCII_char(); */
if (current_char == '\n')
ctx->line++;
else
ctx->chars1++;
if (ctx->state != 1) {
if (ctx->verbose)
fprintf(stderr, "Error at line %lld\n", ctx->line);
buffer[out++] = '_';
ctx->state = 1;
}
/* buffer[out++] = current_char; */
ctx->out_char[ctx->pend++] = current_char;
} else if ((current_char & (128+64)) == 128) {
/* Handle_continue_char(); */
if(ctx->state > 1) {
ctx->state--;
if(ctx->state==1) {
ctx->out_char[ctx->pend++] = current_char;
for(i=ctx->current_size-1; i>0; i--) {
ctx->out_char[ctx->pend++] = ctx->long_char[i-1];
}
}
} else {
if (ctx->verbose)
fprintf(stderr, "Error at line %lld\n", ctx->line);
buffer[out++] = '_';
ctx->state=1;
}
} else if ((current_char & (128+64+32)) == (128+64)) {
/* Handle_two_bytes(); */
ctx->state=2;
ctx->chars2++;
ctx->current_size=2;
} else if ((current_char & (128+64+32+16)) == (128+64+32)) {
/* Handle_three_bytes(); */
ctx->state=3;
ctx->chars3++;
ctx->current_size=3;
} else if ((current_char & (128+64+32+16+8)) == (128+64+32+16)) {
/* Handle_four_bytes(); */
ctx->state=4;
ctx->chars4++;
ctx->current_size=4;
} else if ((current_char & (128+64+32+16+8+4)) == (128+64+32+16+8)) {
/* Handle_five_bytes(); */
ctx->state=5;
ctx->chars5++;
ctx->current_size=5;
} else if ((current_char & (128+64+32+16+8+4+2)) == (128+64+32+16+8+4)) {
/* Handle_six_bytes(); */
ctx->state=6;
ctx->chars6++;
ctx->current_size=6;
}
if(ctx->state>1) {
ctx->long_char[ctx->current_size-ctx->state]=current_char;
}
}
return out;
}
environment:
global:
BZIP2_VER: 1.0.6
EXPAT_VER: 2.2.5
PROJ4_VER: 4.9.3
ZLIB_VER: 1.2.11
LUA_VER: 5.3.4
LUA_INCLUDE_DIR: C:\lua\include
LUA_LIBRARIES: C:\lua\lua53.lib
LUA_DLL: C:\lua\lua53.dll
WINGETOPT_VER: v0.95
GETOPT_INCLUDE_DIR: C:\wingetopt\src
GETOPT_LIBRARY: C:\wingetopt\build\wingetopt.lib
BOOST_PATH: C:\Libraries\boost_1_63_0
POSTGRESQL_VER: 9.6.6
TESTS_POSTGRESQL_ROOT: C:\Progra~1\PostgreSQL\9.6
POSTGIS_VER: 2.4.3
POSTGIS_URL: "https://lonvia.dev.openstreetmap.org/osm2pgsql-winbuild/postgis-bundle-pg96-2.4.3x64.zip"
PGUSER: postgres
PGPASSWORD: Password12!
matrix:
- arch: x86
- arch: x64
os: Visual Studio 2015
services:
- postgresql96
clone_folder: c:\osm2pgsql
clone_depth: 1
init:
- git config --global core.autocrlf input
- if "%arch%"=="x86" (
set vcvarsall_arg=x86&&
set conda_path=C:\Miniconda36\Scripts&&
set conda_library_path=C:\Miniconda36\envs\osm2pgsql\Library&&
set lua_url=https://lonvia.dev.openstreetmap.org/osm2pgsql-winbuild/lua_x86.zip&&
set build_type=Release)
- if "%arch%"=="x64" (
set vcvarsall_arg=amd64&&
set conda_path=C:\Miniconda36-x64\Scripts&&
set conda_library_path=C:\Miniconda36-x64\envs\osm2pgsql\Library&&
set lua_url=https://lonvia.dev.openstreetmap.org/osm2pgsql-winbuild/lua_x64.zip&&
set build_type=Release)
- '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall" %vcvarsall_arg%'
install:
- set PATH=%TESTS_POSTGRESQL_ROOt%\bin;%PATH%;%conda_path%
- cd c:\
- conda config --set always_yes yes
- conda create --name osm2pgsql
- activate osm2pgsql
- conda install bzip2=%BZIP2_VER% expat=%EXPAT_VER% proj4=%PROJ4_VER% zlib=%ZLIB_VER% postgresql=%POSTGRESQL_VER%
- ps: if (!(Test-Path "C:\lua_$env:arch.zip")){(new-object net.webclient).DownloadFile($env:lua_url, "C:\lua_$env:arch.zip")}
- 7z x -y C:\lua_%arch%.zip -oC:\lua
- ps: if (!(Test-Path "C:\postgis.zip")){(new-object net.webclient).DownloadFile($env:POSTGIS_URL, "C:\postgis.zip")}
- 7z x C:\postgis.zip -oC:\postgis
- xcopy /e /y /q C:\postgis\postgis-bundle-pg96-2.4.3x64 %TESTS_POSTGRESQL_ROOT%
- git clone https://github.com/alex85k/wingetopt -b %WINGETOPT_VER% C:\wingetopt
- python -V
- pip install psycopg2
before_build:
- cd C:\wingetopt
- mkdir build
- cd build
- cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%build_type%
- nmake
build_script:
- mkdir c:\osm2pgsql\build
- cd c:\osm2pgsql\build
- >
cmake .. -LA -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%build_type% -DBUILD_TESTS=ON
-DLUA_INCLUDE_DIR=%LUA_INCLUDE_DIR% -DLUA_LIBRARIES=%LUA_LIBRARIES%
-DGETOPT_INCLUDE_DIR=%GETOPT_INCLUDE_DIR% -DGETOPT_LIBRARY=%GETOPT_LIBRARY%
-DBOOST_ROOT=%BOOST_PATH% -DBoost_USE_STATIC_LIBS=ON
- nmake
after_build:
- mkdir osm2pgsql-bin
- copy /y *.exe osm2pgsql-bin
- copy /y ..\*.style osm2pgsql-bin
- copy /y ..\*.lua osm2pgsql-bin
- copy /y %conda_library_path%\bin\libpq.dll osm2pgsql-bin
- copy /y %conda_library_path%\bin\libeay32.dll osm2pgsql-bin
- copy /y %conda_library_path%\bin\ssleay32.dll osm2pgsql-bin
- copy /y %conda_library_path%\bin\zlib.dll osm2pgsql-bin
- copy /y %conda_library_path%\bin\expat.dll osm2pgsql-bin
- copy /y %conda_library_path%\bin\libbz2.dll osm2pgsql-bin
- copy /y %LUA_DLL% osm2pgsql-bin
- 7z a c:\osm2pgsql\osm2pgsql_%build_type%_%arch%.zip osm2pgsql-bin -tzip
before_test:
- cd c:\
- mkdir temp
- cacls temp /T /E /G Users:F
- cacls temp /T /E /G "Network Service":F
- |
psql -c "CREATE TABLESPACE tablespacetest LOCATION 'c:/temp'"
- set PATH=c:\osm2pgsql\build\osm2pgsql-bin;%PATH%
- set PROJ_LIB=%conda_library_path%\share
test_script:
- cd c:\osm2pgsql\build
#- ctest -VV -L NoDB
- ctest -VV -LE FlatNodes # enable when Postgis will be available
artifacts:
- path: osm2pgsql_%build_type%_%arch%.zip
cache:
- C:\lua_%arch%.zip -> appveyor.yml
- C:\postgis.zip -> appveyor.yml
#!/bin/sh
autoreconf -vfi
#.rst:
# FindLua
# -------
#
#
#
# Locate Lua library This module defines
#
# ::
#
# LUA_FOUND - if false, do not try to link to Lua
# LUA_LIBRARIES - both lua and lualib
# LUA_INCLUDE_DIR - where to find lua.h
# LUA_VERSION_STRING - the version of Lua found
# LUA_VERSION_MAJOR - the major version of Lua
# LUA_VERSION_MINOR - the minor version of Lua
# LUA_VERSION_PATCH - the patch version of Lua
#
#
#
# Note that the expected include convention is
#
# ::
#
# #include "lua.h"
#
# and not
#
# ::
#
# #include <lua/lua.h>
#
# This is because, the lua location is not standardized and may exist in
# locations other than lua/
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
# Copyright 2013 Rolf Eike Beer <eike@sf-mail.de>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
unset(_lua_include_subdirs)
unset(_lua_library_names)
# this is a function only to have all the variables inside go away automatically
function(set_lua_version_vars)
set(LUA_VERSIONS5 5.3 5.2 5.1 5.0)
if (Lua_FIND_VERSION_EXACT)
if (Lua_FIND_VERSION_COUNT GREATER 1)
set(lua_append_versions ${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR})
endif ()
elseif (Lua_FIND_VERSION)
# once there is a different major version supported this should become a loop
if (NOT Lua_FIND_VERSION_MAJOR GREATER 5)
if (Lua_FIND_VERSION_COUNT EQUAL 1)
set(lua_append_versions ${LUA_VERSIONS5})
else ()
foreach (subver IN LISTS LUA_VERSIONS5)
if (NOT subver VERSION_LESS ${Lua_FIND_VERSION})
list(APPEND lua_append_versions ${subver})
endif ()
endforeach ()
endif ()
endif ()
else ()
# once there is a different major version supported this should become a loop
set(lua_append_versions ${LUA_VERSIONS5})
endif ()
foreach (ver IN LISTS lua_append_versions)
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
list(APPEND _lua_include_subdirs
include/lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
include/lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
include/lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
)
list(APPEND _lua_library_names
lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
)
endforeach ()
set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE)
set(_lua_library_names "${_lua_library_names}" PARENT_SCOPE)
endfunction(set_lua_version_vars)
set_lua_version_vars()
find_path(LUA_INCLUDE_DIR lua.h
HINTS
ENV LUA_DIR
PATH_SUFFIXES ${_lua_include_subdirs} include/lua include
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
unset(_lua_include_subdirs)
find_library(LUA_LIBRARY
NAMES ${_lua_library_names} lua
HINTS
ENV LUA_DIR
PATH_SUFFIXES lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
)
unset(_lua_library_names)
if (LUA_LIBRARY)
# include the math library for Unix
if (UNIX AND NOT APPLE AND NOT BEOS)
find_library(LUA_MATH_LIBRARY m)
set(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
# For Windows and Mac, don't need to explicitly include the math library
else ()
set(LUA_LIBRARIES "${LUA_LIBRARY}")
endif ()
endif ()
if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
# At least 5.[012] have different ways to express the version
# so all of them need to be tested. Lua 5.2 defines LUA_VERSION
# and LUA_RELEASE as joined by the C preprocessor, so avoid those.
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_strings
REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*")
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MAJOR ";${lua_version_strings};")
if (LUA_VERSION_MAJOR MATCHES "^[0-9]+$")
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MINOR ";${lua_version_strings};")
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_PATCH ";${lua_version_strings};")
set(LUA_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
else ()
string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$")
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
endif ()
string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUA_VERSION_MINOR "${LUA_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_PATCH "${LUA_VERSION_STRING}")
endif ()
unset(lua_version_strings)
endif()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)
# Locate LuaJIT library
# This module defines
# LUAJIT_FOUND, if false, do not try to link to Lua
# LUAJIT_LIBRARIES
# LUAJIT_INCLUDE_DIR, where to find luajit.h
# LUAJIT_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
## Copied from default CMake FindLua51.cmake
find_path(LUAJIT_INCLUDE_DIR luajit.h
HINTS
ENV LUA_DIR
PATH_SUFFIXES include/luajit-2.0 include
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
find_library(LUAJIT_LIBRARY
NAMES luajit-5.1
HINTS
ENV LUA_DIR
PATH_SUFFIXES lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
)
if(LUAJIT_LIBRARY)
# include the math library for Unix
if(UNIX AND NOT APPLE)
find_library(LUA_MATH_LIBRARY m)
set( LUAJIT_LIBRARIES "${LUAJIT_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "LuaJIT Libraries")
# For Windows and Mac, don't need to explicitly include the math library
else()
set( LUAJIT_LIBRARIES "${LUAJIT_LIBRARY}" CACHE STRING "LuaJIT Libraries")
endif()
endif()
if(LUAJIT_INCLUDE_DIR AND EXISTS "${LUAJIT_INCLUDE_DIR}/luajit.h")
file(STRINGS "${LUAJIT_INCLUDE_DIR}/luajit.h" luajit_version_str REGEX "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT .+\"")
string(REGEX REPLACE "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUAJIT_VERSION_STRING "${luajit_version_str}")
unset(luajit_version_str)
endif()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT
REQUIRED_VARS LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR
VERSION_VAR LUAJIT_VERSION_STRING)
mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARIES LUAJIT_LIBRARY LUA_MATH_LIBRARY)
#----------------------------------------------------------------------
#
# FindOsmium.cmake
#
# Find the Libosmium headers and, optionally, several components needed
# for different Libosmium functions.
#
#----------------------------------------------------------------------
#
# Usage:
#
# Copy this file somewhere into your project directory, where cmake can
# find it. Usually this will be a directory called "cmake" which you can
# add to the CMake module search path with the following line in your
# CMakeLists.txt:
#
# list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#
# Then add the following in your CMakeLists.txt:
#
# find_package(Osmium [version] REQUIRED COMPONENTS <XXX>)
# include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS})
#
# The version number is optional. If it is not set, any version of
# libosmium will do.
#
# For the <XXX> substitute a space separated list of one or more of the
# following components:
#
# pbf - include libraries needed for PBF input and output
# xml - include libraries needed for XML input and output
# io - include libraries needed for any type of input/output
# geos - include if you want to use any of the GEOS functions
# gdal - include if you want to use any of the OGR functions
# proj - include if you want to use any of the Proj.4 functions
# sparsehash - include if you use the sparsehash index
#
# You can check for success with something like this:
#
# if(NOT OSMIUM_FOUND)
# message(WARNING "Libosmium not found!\n")
# endif()
#
#----------------------------------------------------------------------
#
# Variables:
#
# OSMIUM_FOUND - True if Osmium found.
# OSMIUM_INCLUDE_DIRS - Where to find include files.
# OSMIUM_XML_LIBRARIES - Libraries needed for XML I/O.
# OSMIUM_PBF_LIBRARIES - Libraries needed for PBF I/O.
# OSMIUM_IO_LIBRARIES - Libraries needed for XML or PBF I/O.
# OSMIUM_LIBRARIES - All libraries Osmium uses somewhere.
#
#----------------------------------------------------------------------
# This is the list of directories where we look for osmium includes.
set(_osmium_include_path
../libosmium
~/Library/Frameworks
/Library/Frameworks
/opt/local # DarwinPorts
/opt
)
# Look for the header file.
find_path(OSMIUM_INCLUDE_DIR osmium/version.hpp
PATH_SUFFIXES include
PATHS ${_osmium_include_path}
)
# Check libosmium version number
if(Osmium_FIND_VERSION)
file(STRINGS "${OSMIUM_INCLUDE_DIR}/osmium/version.hpp" _libosmium_version_define REGEX "#define LIBOSMIUM_VERSION_STRING")
if("${_libosmium_version_define}" MATCHES "#define LIBOSMIUM_VERSION_STRING \"([0-9.]+)\"")
set(_libosmium_version "${CMAKE_MATCH_1}")
else()
set(_libosmium_version "unknown")
endif()
endif()
set(OSMIUM_INCLUDE_DIRS "${OSMIUM_INCLUDE_DIR}")
#----------------------------------------------------------------------
#
# Check for optional components
#
#----------------------------------------------------------------------
if(Osmium_FIND_COMPONENTS)
foreach(_component ${Osmium_FIND_COMPONENTS})
string(TOUPPER ${_component} _component_uppercase)
set(Osmium_USE_${_component_uppercase} TRUE)
endforeach()
endif()
#----------------------------------------------------------------------
# Component 'io' is an alias for 'pbf' and 'xml'
if(Osmium_USE_IO)
set(Osmium_USE_PBF TRUE)
set(Osmium_USE_XML TRUE)
endif()
#----------------------------------------------------------------------
# Component 'ogr' is an alias for 'gdal'
if(Osmium_USE_OGR)
set(Osmium_USE_GDAL TRUE)
endif()
#----------------------------------------------------------------------
# Component 'pbf'
if(Osmium_USE_PBF)
find_package(ZLIB)
find_package(Threads)
find_package(Protozero 1.5.1)
list(APPEND OSMIUM_EXTRA_FIND_VARS ZLIB_FOUND Threads_FOUND PROTOZERO_INCLUDE_DIR)
if(ZLIB_FOUND AND Threads_FOUND AND PROTOZERO_FOUND)
list(APPEND OSMIUM_PBF_LIBRARIES
${ZLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
list(APPEND OSMIUM_INCLUDE_DIRS
${ZLIB_INCLUDE_DIR}
${PROTOZERO_INCLUDE_DIR}
)
else()
message(WARNING "Osmium: Can not find some libraries for PBF input/output, please install them or configure the paths.")
endif()
endif()
#----------------------------------------------------------------------
# Component 'xml'
if(Osmium_USE_XML)
find_package(EXPAT)
find_package(BZip2)
find_package(ZLIB)
find_package(Threads)
list(APPEND OSMIUM_EXTRA_FIND_VARS EXPAT_FOUND BZIP2_FOUND ZLIB_FOUND Threads_FOUND)
if(EXPAT_FOUND AND BZIP2_FOUND AND ZLIB_FOUND AND Threads_FOUND)
list(APPEND OSMIUM_XML_LIBRARIES
${EXPAT_LIBRARIES}
${BZIP2_LIBRARIES}
${ZLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
list(APPEND OSMIUM_INCLUDE_DIRS
${EXPAT_INCLUDE_DIR}
${BZIP2_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
)
else()
message(WARNING "Osmium: Can not find some libraries for XML input/output, please install them or configure the paths.")
endif()
endif()
#----------------------------------------------------------------------
list(APPEND OSMIUM_IO_LIBRARIES
${OSMIUM_PBF_LIBRARIES}
${OSMIUM_XML_LIBRARIES}
)
list(APPEND OSMIUM_LIBRARIES
${OSMIUM_IO_LIBRARIES}
)
#----------------------------------------------------------------------
# Component 'geos'
if(Osmium_USE_GEOS)
find_path(GEOS_INCLUDE_DIR geos/geom.h)
find_library(GEOS_LIBRARY NAMES geos)
list(APPEND OSMIUM_EXTRA_FIND_VARS GEOS_INCLUDE_DIR GEOS_LIBRARY)
if(GEOS_INCLUDE_DIR AND GEOS_LIBRARY)
SET(GEOS_FOUND 1)
list(APPEND OSMIUM_LIBRARIES ${GEOS_LIBRARY})
list(APPEND OSMIUM_INCLUDE_DIRS ${GEOS_INCLUDE_DIR})
else()
message(WARNING "Osmium: GEOS library is required but not found, please install it or configure the paths.")
endif()
endif()
#----------------------------------------------------------------------
# Component 'gdal' (alias 'ogr')
if(Osmium_USE_GDAL)
find_package(GDAL)
list(APPEND OSMIUM_EXTRA_FIND_VARS GDAL_FOUND)
if(GDAL_FOUND)
list(APPEND OSMIUM_LIBRARIES ${GDAL_LIBRARIES})
list(APPEND OSMIUM_INCLUDE_DIRS ${GDAL_INCLUDE_DIRS})
else()
message(WARNING "Osmium: GDAL library is required but not found, please install it or configure the paths.")
endif()
endif()
#----------------------------------------------------------------------
# Component 'proj'
if(Osmium_USE_PROJ)
find_path(PROJ_INCLUDE_DIR proj_api.h)
find_library(PROJ_LIBRARY NAMES proj)
list(APPEND OSMIUM_EXTRA_FIND_VARS PROJ_INCLUDE_DIR PROJ_LIBRARY)
if(PROJ_INCLUDE_DIR AND PROJ_LIBRARY)
set(PROJ_FOUND 1)
list(APPEND OSMIUM_LIBRARIES ${PROJ_LIBRARY})
list(APPEND OSMIUM_INCLUDE_DIRS ${PROJ_INCLUDE_DIR})
else()
message(WARNING "Osmium: PROJ.4 library is required but not found, please install it or configure the paths.")
endif()
endif()
#----------------------------------------------------------------------
# Component 'sparsehash'
if(Osmium_USE_SPARSEHASH)
find_path(SPARSEHASH_INCLUDE_DIR google/sparsetable)
list(APPEND OSMIUM_EXTRA_FIND_VARS SPARSEHASH_INCLUDE_DIR)
if(SPARSEHASH_INCLUDE_DIR)
# Find size of sparsetable::size_type. This does not work on older
# CMake versions because they can do this check only in C, not in C++.
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
include(CheckTypeSize)
set(CMAKE_REQUIRED_INCLUDES ${SPARSEHASH_INCLUDE_DIR})
set(CMAKE_EXTRA_INCLUDE_FILES "google/sparsetable")
check_type_size("google::sparsetable<int>::size_type" SPARSETABLE_SIZE_TYPE LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES)
set(CMAKE_REQUIRED_INCLUDES)
else()
set(SPARSETABLE_SIZE_TYPE ${CMAKE_SIZEOF_VOID_P})
endif()
# Sparsetable::size_type must be at least 8 bytes (64bit), otherwise
# OSM object IDs will not fit.
if(SPARSETABLE_SIZE_TYPE GREATER 7)
set(SPARSEHASH_FOUND 1)
add_definitions(-DOSMIUM_WITH_SPARSEHASH=${SPARSEHASH_FOUND})
list(APPEND OSMIUM_INCLUDE_DIRS ${SPARSEHASH_INCLUDE_DIR})
else()
message(WARNING "Osmium: Disabled Google SparseHash library on 32bit system (size_type=${SPARSETABLE_SIZE_TYPE}).")
endif()
else()
message(WARNING "Osmium: Google SparseHash library is required but not found, please install it or configure the paths.")
endif()
endif()
#----------------------------------------------------------------------
list(REMOVE_DUPLICATES OSMIUM_INCLUDE_DIRS)
if(OSMIUM_XML_LIBRARIES)
list(REMOVE_DUPLICATES OSMIUM_XML_LIBRARIES)
endif()
if(OSMIUM_PBF_LIBRARIES)
list(REMOVE_DUPLICATES OSMIUM_PBF_LIBRARIES)
endif()
if(OSMIUM_IO_LIBRARIES)
list(REMOVE_DUPLICATES OSMIUM_IO_LIBRARIES)
endif()
if(OSMIUM_LIBRARIES)
list(REMOVE_DUPLICATES OSMIUM_LIBRARIES)
endif()
#----------------------------------------------------------------------
#
# Check that all required libraries are available
#
#----------------------------------------------------------------------
if(OSMIUM_EXTRA_FIND_VARS)
list(REMOVE_DUPLICATES OSMIUM_EXTRA_FIND_VARS)
endif()
# Handle the QUIETLY and REQUIRED arguments and the optional version check
# and set OSMIUM_FOUND to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Osmium
REQUIRED_VARS OSMIUM_INCLUDE_DIR ${OSMIUM_EXTRA_FIND_VARS}
VERSION_VAR _libosmium_version)
unset(OSMIUM_EXTRA_FIND_VARS)
#----------------------------------------------------------------------
#
# A function for setting the -pthread option in compilers/linkers
#
#----------------------------------------------------------------------
function(set_pthread_on_target _target)
if(NOT MSVC)
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "-pthread")
if(NOT APPLE)
set_target_properties(${_target} PROPERTIES LINK_FLAGS "-pthread")
endif()
endif()
endfunction()
#----------------------------------------------------------------------
#
# Add compiler flags
#
#----------------------------------------------------------------------
add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
if(MSVC)
add_definitions(-wd4996)
# Disable warning C4068: "unknown pragma" because we want it to ignore
# pragmas for other compilers.
add_definitions(-wd4068)
# Disable warning C4715: "not all control paths return a value" because
# it generates too many false positives.
add_definitions(-wd4715)
# Disable warning C4351: new behavior: elements of array '...' will be
# default initialized. The new behaviour is correct and we don't support
# old compilers anyway.
add_definitions(-wd4351)
# Disable warning C4503: "decorated name length exceeded, name was truncated"
# there are more than 150 of generated names in libosmium longer than 4096 symbols supported in MSVC
add_definitions(-wd4503)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
endif()
if(APPLE)
# following only available from cmake 2.8.12:
# add_compile_options(-stdlib=libc++)
# so using this instead:
add_definitions(-stdlib=libc++)
set(LDFLAGS ${LDFLAGS} -stdlib=libc++)
endif()
#----------------------------------------------------------------------
# This is a set of recommended warning options that can be added when compiling
# libosmium code.
if(MSVC)
set(OSMIUM_WARNING_OPTIONS "/W3 /wd4514" CACHE STRING "Recommended warning options for libosmium")
else()
set(OSMIUM_WARNING_OPTIONS "-Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wold-style-cast" CACHE STRING "Recommended warning options for libosmium")
endif()
set(OSMIUM_DRACONIC_CLANG_OPTIONS "-Wdocumentation -Wunused-exception-parameter -Wmissing-declarations -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-exit-time-destructors -Wno-global-constructors -Wno-padded -Wno-switch-enum -Wno-missing-prototypes -Wno-weak-vtables -Wno-cast-align -Wno-float-equal")
if(Osmium_DEBUG)
message(STATUS "OSMIUM_XML_LIBRARIES=${OSMIUM_XML_LIBRARIES}")
message(STATUS "OSMIUM_PBF_LIBRARIES=${OSMIUM_PBF_LIBRARIES}")
message(STATUS "OSMIUM_IO_LIBRARIES=${OSMIUM_IO_LIBRARIES}")
message(STATUS "OSMIUM_LIBRARIES=${OSMIUM_LIBRARIES}")
message(STATUS "OSMIUM_INCLUDE_DIRS=${OSMIUM_INCLUDE_DIRS}")
endif()
#----------------------------------------------------------------------
#
# FindProtozero.cmake
#
# Find the protozero headers.
#
#----------------------------------------------------------------------
#
# Usage:
#
# Copy this file somewhere into your project directory, where cmake can
# find it. Usually this will be a directory called "cmake" which you can
# add to the CMake module search path with the following line in your
# CMakeLists.txt:
#
# list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#
# Then add the following in your CMakeLists.txt:
#
# find_package(Protozero [version] [REQUIRED])
# include_directories(SYSTEM ${PROTOZERO_INCLUDE_DIR})
#
# The version number is optional. If it is not set, any version of
# protozero will do.
#
# if(NOT PROTOZERO_FOUND)
# message(WARNING "Protozero not found!\n")
# endif()
#
#----------------------------------------------------------------------
#
# Variables:
#
# PROTOZERO_FOUND - True if Protozero was found.
# PROTOZERO_INCLUDE_DIR - Where to find include files.
#
#----------------------------------------------------------------------
# find include path
find_path(PROTOZERO_INCLUDE_DIR protozero/version.hpp
PATH_SUFFIXES include
PATHS ${CMAKE_SOURCE_DIR}/../protozero
)
# Check version number
if(Protozero_FIND_VERSION)
file(STRINGS "${PROTOZERO_INCLUDE_DIR}/protozero/version.hpp" _version_define REGEX "#define PROTOZERO_VERSION_STRING")
if("${_version_define}" MATCHES "#define PROTOZERO_VERSION_STRING \"([0-9.]+)\"")
set(_version "${CMAKE_MATCH_1}")
else()
set(_version "unknown")
endif()
endif()
#set(PROTOZERO_INCLUDE_DIRS "${PROTOZERO_INCLUDE_DIR}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Protozero
REQUIRED_VARS PROTOZERO_INCLUDE_DIR
VERSION_VAR _version)
#----------------------------------------------------------------------
#cmakedefine HAVE_LSEEK64 1
#cmakedefine HAVE_LUA 1
#cmakedefine HAVE_POSIX_FADVISE 1
#cmakedefine HAVE_POSIX_FALLOCATE 1
#cmakedefine HAVE_SYNC_FILE_RANGE 1
#cmakedefine HAVE_TERMIOS_H 1
#cmakedefine HAVE_LIBGEN_H 1
#cmakedefine SIZEOF_OFF_T ${SIZEOF_OFF_T}
#ifdef _MSC_VER
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
#define VERSION "@PACKAGE_VERSION@"
dnl Process this file with autoconf to produce a configure script.
AC_INIT(osm2pgsql, 0.88.0-RC1)
dnl Required autoconf version
AC_PREREQ(2.61)
AX_CONFIG_NICE
dnl Allow maintainer mode to be disabled (debian build scripts do this)
AM_MAINTAINER_MODE([enable])
dnl use automake to generate standard Makefiles
AM_INIT_AUTOMAKE([1.9.6 dist-bzip2 std-options check-news])
dnl use 'silent' make rules by default (disabled for now)
dnl AM_INIT_AUTOMAKE([1.11 dist-bzip2 silent-rules])
dnl AM_SILENT_RULES([yes])
dnl Additional macro definitions are in here
AC_CONFIG_MACRO_DIR([m4])
dnl Generate configuration header file
AC_CONFIG_HEADER(config.h)
AC_GNU_SOURCE
AC_HEADER_SYS_WAIT
AC_FUNC_MMAP
dnl Find C compiler
dnl AC_PROG_CC_C99
dnl Find C++ compiler
AC_PROG_CXX
AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
if test "$HAVE_CXX" = "no"
then
AC_MSG_ERROR([Could not find a c++ compiler]);
fi
AX_CFLAGS_WARN_ALL
AX_CXXFLAGS_WARN_ALL
dnl Make sure we have libtool installed
AM_PROG_LIBTOOL
LFS_CFLAGS=`getconf LFS_CFLAGS`
AC_SUBST(LFS_CFLAGS)
AC_CHECK_FUNC(lseek64,[AC_DEFINE(HAVE_LSEEK64, [1], [lseek64 is present])],[AX_COMPILE_CHECK_SIZEOF(off_t)])
AC_CHECK_FUNCS([posix_fallocate posix_fadvise sync_file_range fork])
dnl Check for libxml2 library
AX_LIB_XML2
if test "$HAVE_XML2" = "no"
then
AC_MSG_ERROR([required library not found]);
fi
dnl check for zlib library
AX_LIB_ZLIB
if test "$HAVE_ZLIB" = "no"
then
AC_MSG_ERROR([required library not found]);
fi
dnl Check for bzip2 library
AX_LIB_BZIP2
if test "$HAVE_BZIP2" = "no"
then
AC_MSG_ERROR([required library not found]);
fi
dnl Check for Geos library
AX_LIB_GEOS([3.1])
dnl Check for Proj library
AX_LIB_PROJ
if test "$HAVE_PROJ" = "no"
then
AC_MSG_ERROR([required library not found]);
fi
dnl Check for protobuf-c library and protoc-c binary
AX_LIB_PROTOBUF_C([0.14])
dnl Decide whether to include PBF import support
BUILD_READER_PBF=no
if test "$HAVE_PROTOBUF_C" = "yes"
then
if test "$PROTOC_C" != "false"
then
BUILD_READER_PBF=yes
AC_DEFINE([BUILD_READER_PBF], [1], [Requirements for building the PBF reader are met])
fi
fi
AM_CONDITIONAL([READER_PBF], [test "$BUILD_READER_PBF" = "yes"])
dnl Check for PostgresSQL client library
AX_LIB_POSTGRESQL
if test "x$POSTGRESQL_VERSION" = "x"
then
AC_MSG_ERROR([postgresql client library not found])
fi
dnl Check for pthread library
AX_PTHREAD(,[AC_MSG_ERROR([no])])
dnl Check for Boost libraries
AX_BOOST_BASE([1.48], , [AC_MSG_ERROR([cannot find Boost libraries, which are are required for building osm2pgsql. Please install libboost-dev.])])
AX_BOOST_SYSTEM
AX_BOOST_FILESYSTEM
AX_BOOST_THREAD
if test "x$BOOST_SYSTEM_LIB" = "x" -o "x$BOOST_FILESYSTEM_LIB" = "x" -o "x$BOOST_THREAD_LIB" = "x"
then
AC_MSG_ERROR([One or more of the mandatory Boost libraries not found.])
fi
dnl Boost json parser in 1.49 has a bug when compiled with C++11
dnl see https://svn.boost.org/trac/boost/ticket/6785
AC_ARG_WITH([cxx11],
[AS_HELP_STRING([--without-cxx11],
[do not check for C++11-capable compiler (for testing only)])],
[],
[with_cxx11=yes])
if test "x$with_cxx11" = "xyes"; then
AX_BOOST_BASE([1.50], [ AX_CXX_COMPILE_STDCXX_11(,optional) ], [])
fi
dnl Check for Lua libraries and headers
AX_PROG_LUA([5.0],[],[
AX_LUA_HEADERS([
AX_LUA_LIBS([
AC_DEFINE([HAVE_LUA], [1], [Requirements for lua are met])
HAVE_LUA=yes
],[AC_MSG_WARN([cannot find Lua libs])])
],[AC_MSG_WARN([cannot find Lua includes])])
],[AC_MSG_WARN([cannot find Lua interpreter])])
dnl Enable fixed point
AC_ARG_WITH([fixed-point],
[AS_HELP_STRING([--without-fixed-point],
[use double instead of fixed point floats for coordinates])],
[],
[AC_DEFINE([FIXED_POINT], [1], [Store +-20,000km Mercator co-ordinates as fixed point 32bit number with maximum precision])])
dnl Generate Makefile
AC_OUTPUT(Makefile)
if test "$BUILD_READER_PBF" != "yes"
then
AC_MSG_WARN([
protobuf libraries not found. You will NOT be able to import PBF files.
To enable PBF support, the protobuf library and compiler are required.
Look for packages named: libprotobuf-c0-dev protobuf-c-compiler
])
fi
if test "$HAVE_LUA" != "yes"
then
AC_MSG_WARN([
lua libraries not found. You will NOT be able to use lua scripts for tag transform.
To enable lua support, the lua interpreter and libraries are required.
Look for packages named: lua5.2 liblua5.2-dev
])
fi
#!/bin/bash
#
# Author: Jason Huntley
# Email: onepremise@gmail.com
# Description: Cygwin Package script
#
# Change Log
#
# Date Description Initials
#-------------------------------------------------------------
# 04-11-13 Initial Coding JAH
#=============================================================
if [ ! -e "cygwin-package" ]; then
mkdir cygwin-package
fi
echo
echo Copying Executable...
echo
cp -rfv default.style cygwin-package || { stat=$?; echo "Packaging failed, aborting" >&2; exit $stat; }
cp -rfv 900913.sql cygwin-package || { stat=$?; echo "Packaging failed, aborting" >&2; exit $stat; }
cp -rfv README cygwin-package || { stat=$?; echo "Packaging failed, aborting" >&2; exit $stat; }
cp -rfv .libs/osm2pgsql.exe cygwin-package || { stat=$?; echo "Packaging failed, aborting" >&2; exit $stat; }
echo
echo Copying Dependent Libraries...
echo
cp -rfv /bin/cygcrypt*.dll cygwin-package
cp -rfv /bin/cyggcc*.dll cygwin-package
cp -rfv /usr/local/bin/cyggeos*.dll cygwin-package
cp -rfv /bin/cygiconv*.dll cygwin-package
cp -rfv /bin/cygintl*.dll cygwin-package
cp -rfv /bin/cyglber*.dll cygwin-package
cp -rfv /bin/cygldap*.dll cygwin-package
cp -rfv /bin/cyglzma*.dll cygwin-package
cp -rfv /bin/cygpq*.dll cygwin-package
cp -rfv /usr/local/bin/cygproj*.dll cygwin-package
cp -rfv /usr/local/bin/cygproto*.dll cygwin-package
cp -rfv /bin/cygsasl*.dll cygwin-package
cp -rfv /bin/cygssl*.dll cygwin-package
cp -rfv /bin/cygstdc++**.dll cygwin-package
cp -rfv /bin/cygwin*.dll cygwin-package
cp -rfv /bin/cygxml2*.dll cygwin-package
cp -rfv /bin/cygz*.dll cygwin-package
echo
echo Creating Archive...
echo
zip -r9 cygwin-package.zip cygwin-package
echo
echo Packaging Complete.
echo
exit 0