From e3f9581a69031d8f114d30ab599bbe73af183807 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 27 Feb 2016 17:10:05 +0100 Subject: [PATCH 1/7] move from autotools to cmake and update osm2pgsql --- .gitignore | 26 +------ Makefile.am | 27 ------- autogen.sh | 2 - configure.ac | 67 ---------------- contrib/openlayers.cfg | 36 --------- m4/ax_lib_postgresql_svr.m4 | 125 ------------------------------ m4/ax_lib_xml2.m4 | 150 ------------------------------------ module/Makefile.in | 10 --- nominatim/Makefile.am | 9 --- nominatim/nominatim.c | 2 +- osm2pgsql | 2 +- 11 files changed, 4 insertions(+), 452 deletions(-) delete mode 100644 Makefile.am delete mode 100755 autogen.sh delete mode 100644 configure.ac delete mode 100644 contrib/openlayers.cfg delete mode 100644 m4/ax_lib_postgresql_svr.m4 delete mode 100644 m4/ax_lib_xml2.m4 delete mode 100644 module/Makefile.in delete mode 100644 nominatim/Makefile.am diff --git a/.gitignore b/.gitignore index b6625912..23fb34a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,33 +1,11 @@ *.log *.pyc -nominatim/*.d -nominatim/*.o -nominatim/nominatim -module/nominatim.so -module/nominatim.o -settings/configuration.txt -settings/download.lock -settings/state.txt +build settings/local.php -.deps/ -autom4te.cache/ -config.* -configure -Makefile -!tests/scenes/bin/Makefile -Makefile.in -stamp-h1 -missing -INSTALL -aclocal.m4 -depcomp -install-sh -compile - data/wiki_import.sql data/wiki_specialphrases.sql data/osmosischange.osc -.vagrant \ No newline at end of file +.vagrant diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 2ade09a5..00000000 --- a/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -ACLOCAL_AMFLAGS = -I osm2pgsql/m4 -AUTOMAKE_OPTIONS = -Wno-portability - -SUBDIRS = osm2pgsql module nominatim - -NOMINATIM_SERVER ?= $(shell echo a | php -F lib/init.php -E 'echo CONST_Website_BaseURL."\n";') -NOMINATIM_DATABASE ?= $(shell echo a | php -F lib/init.php -E 'echo DB::parseDSN(CONST_Database_DSN)["database"];') - -install: - @echo Nominatim needs to be executed directly from this directory. No install necessary. - -test: - cd tests; NOMINATIM_SERVER=${NOMINATIM_SERVER} lettuce -t -Fail -t -poldi-only - -test-fast: - cd tests; NOMINATIM_SERVER=${NOMINATIM_SERVER} NOMINATIM_REUSE_TEMPLATE=1 lettuce -t -Fail -t -poldi-only - -test-db: - cd tests; NOMINATIM_SERVER=${NOMINATIM_SERVER} lettuce -t -Fail -t -poldi-only features/db - -test-db-fast: - cd tests; NOMINATIM_SERVER=${NOMINATIM_SERVER} NOMINATIM_REUSE_TEMPLATE=1 lettuce -t -Fail -t -poldi-only features/db - -test-api: - cd tests; NOMINATIM_SERVER=${NOMINATIM_SERVER} lettuce -t -Fail -t -poldi-only features/api - -.PHONY: test test-fast test-db test-db-fast test-api diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 68341a59..00000000 --- a/autogen.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -autoreconf -vfi diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 53a8e871..00000000 --- a/configure.ac +++ /dev/null @@ -1,67 +0,0 @@ -AC_INIT(Nominatim,2.5) -if git rev-parse HEAD 2>/dev/null >/dev/null; then - AC_SUBST([PACKAGE_VERSION], [$PACKAGE_VERSION-git-`git rev-parse --short HEAD`]) -fi - -dnl Required autoconf version -AC_PREREQ(2.61) - -AM_INIT_AUTOMAKE([1.9.6 dist-bzip2 std-options check-news]) - -dnl Additional macro definitions are in here -m4_include([m4/ax_lib_postgresql_svr.m4]) -AC_CONFIG_MACRO_DIR([osm2pgsql/m4]) - -dnl Generate configuration header file -AC_CONFIG_HEADER(nominatim/config.h) - - -dnl Find C compiler -AC_PROG_CC - -dnl Find C++ compiler -AC_PROG_CXX - -dnl pthread -AX_PTHREAD([], [AC_MSG_ERROR([pthread library required])]) - -dnl Check for Geos library -AX_LIB_GEOS -if test "x$GEOS_VERSION" = "x" -then - AC_MSG_ERROR([required library not found]); -fi - -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 PostgresSQL client library -AX_LIB_POSTGRESQL(9.0) -if test "x$POSTGRESQL_VERSION" = "x" -then - AC_MSG_ERROR([postgresql client library not found]) -fi -AX_LIB_POSTGRESQL_SVR(9.0) -if test ! -f "$POSTGRESQL_PGXS" -then - AC_MSG_ERROR([postgresql server development 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 libxml2 library -AM_PATH_XML2 - -AC_CONFIG_SUBDIRS([osm2pgsql]) - -AC_OUTPUT(Makefile nominatim/Makefile module/Makefile) diff --git a/contrib/openlayers.cfg b/contrib/openlayers.cfg deleted file mode 100644 index 61dc4fc5..00000000 --- a/contrib/openlayers.cfg +++ /dev/null @@ -1,36 +0,0 @@ -# This file includes a small subset of OpenLayers code, designed to be -# integrated into another application. It includes only the Layer types -# neccesary to create tiled or untiled WMS, and does not include any Controls. -# This is the result of what was at the time called "Webmap.js" at the FOSS4G -# Web Mapping BOF. - -[first] - -[last] - -[include] -OpenLayers/Map.js -OpenLayers/Kinetic.js -OpenLayers/Geometry/MultiLineString.js -OpenLayers/Geometry/MultiPolygon.js -OpenLayers/Format/WKT.js -OpenLayers/Layer/OSM.js -OpenLayers/Layer/Vector.js -OpenLayers/Layer/SphericalMercator.js -OpenLayers/Control/Attribution.js -OpenLayers/Control/KeyboardDefaults.js -OpenLayers/Control/Navigation.js -OpenLayers/Control/MousePosition.js -OpenLayers/Control/PanZoomBar.js -OpenLayers/Control/Permalink.js -OpenLayers/Control/TouchNavigation.js -OpenLayers/Style.js -OpenLayers/Protocol/HTTP.js -OpenLayers/Projection.js -OpenLayers/Renderer/SVG.js -OpenLayers/Renderer/VML.js -OpenLayers/Renderer/Canvas.js - -[exclude] - - diff --git a/m4/ax_lib_postgresql_svr.m4 b/m4/ax_lib_postgresql_svr.m4 deleted file mode 100644 index 56ecb5b4..00000000 --- a/m4/ax_lib_postgresql_svr.m4 +++ /dev/null @@ -1,125 +0,0 @@ -# SYNOPSIS -# -# AX_LIB_POSTGRESQL_SVR([MINIMUM-VERSION]) -# -# DESCRIPTION -# -# This macro provides tests of availability of PostgreSQL server library -# -# This macro calls: -# -# AC_SUBST(POSTGRESQL_PGXS) -# AC_SUBST(POSTGRESQL_SERVER_CFLAGS) -# -# LICENSE -# -# Copyright (c) 2008 Mateusz Loskot -# Copyright (c) 2015 Sarah Hoffmann -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. - -AC_DEFUN([AX_LIB_POSTGRESQL_SVR], -[ - AC_ARG_WITH([postgresql], - AC_HELP_STRING([--with-postgresql-svr=@<:@ARG@:>@], - [use PostgreSQL server library @<:@default=yes@:>@, optionally specify path to pg_config] - ), - [ - if test "$withval" = "no"; then - want_postgresql="no" - elif test "$withval" = "yes"; then - want_postgresql="yes" - else - want_postgresql="yes" - PG_CONFIG="$withval" - fi - ], - [want_postgresql="yes"] - ) - - dnl - dnl Check PostgreSQL server libraries - dnl - - if test "$want_postgresql" = "yes"; then - - if test -z "$PG_CONFIG" -o test; then - AC_PATH_PROG([PG_CONFIG], [pg_config], []) - fi - - if test ! -x "$PG_CONFIG"; then - AC_MSG_ERROR([$PG_CONFIG does not exist or it is not an exectuable file]) - PG_CONFIG="no" - found_postgresql="no" - fi - - if test "$PG_CONFIG" != "no"; then - AC_MSG_CHECKING([for PostgreSQL server libraries]) - - POSTGRESQL_SERVER_CFLAGS="-I`$PG_CONFIG --includedir-server`" - - POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` - - POSTGRESQL_PGXS=`$PG_CONFIG --pgxs` - if test -f "$POSTGRESQL_PGXS" - then - found_postgresql="yes" - AC_MSG_RESULT([yes]) - fi - else - found_postgresql="no" - AC_MSG_RESULT([no]) - fi - fi - - dnl - dnl Check if required version of PostgreSQL is available - dnl - - - postgresql_version_req=ifelse([$1], [], [], [$1]) - - if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then - - AC_MSG_CHECKING([if PostgreSQL version is >= $postgresql_version_req]) - - dnl Decompose required version string of PostgreSQL - dnl and calculate its number representation - postgresql_version_req_major=`expr $postgresql_version_req : '\([[0-9]]*\)'` - postgresql_version_req_minor=`expr $postgresql_version_req : '[[0-9]]*\.\([[0-9]]*\)'` - postgresql_version_req_micro=`expr $postgresql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$postgresql_version_req_micro" = "x"; then - postgresql_version_req_micro="0" - fi - - postgresql_version_req_number=`expr $postgresql_version_req_major \* 1000000 \ - \+ $postgresql_version_req_minor \* 1000 \ - \+ $postgresql_version_req_micro` - - dnl Decompose version string of installed PostgreSQL - dnl and calculate its number representation - postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'` - postgresql_version_minor=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'` - postgresql_version_micro=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$postgresql_version_micro" = "x"; then - postgresql_version_micro="0" - fi - - postgresql_version_number=`expr $postgresql_version_major \* 1000000 \ - \+ $postgresql_version_minor \* 1000 \ - \+ $postgresql_version_micro` - - postgresql_version_check=`expr $postgresql_version_number \>\= $postgresql_version_req_number` - if test "$postgresql_version_check" = "1"; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - fi - - AC_SUBST([POSTGRESQL_PGXS]) - AC_SUBST([POSTGRESQL_SERVER_CFLAGS]) -]) - diff --git a/m4/ax_lib_xml2.m4 b/m4/ax_lib_xml2.m4 deleted file mode 100644 index d0cd2cb5..00000000 --- a/m4/ax_lib_xml2.m4 +++ /dev/null @@ -1,150 +0,0 @@ -# SYNOPSIS -# -# AX_LIB_XML2([MINIMUM-VERSION]) -# -# DESCRIPTION -# -# This macro provides tests of availability of xml2 'libxml2' library -# of particular version or newer. -# -# AX_LIB_LIBXML2 macro takes only one argument which is optional. If -# there is no required version passed, then macro does not run version -# test. -# -# The --with-libxml2 option takes one of three possible values: -# -# no - do not check for xml2 library -# -# yes - do check for xml2 library in standard locations (xml2-config -# should be in the PATH) -# -# path - complete path to xml2-config utility, use this option if xml2-config -# can't be found in the PATH -# -# This macro calls: -# -# AC_SUBST(XML2_CFLAGS) -# AC_SUBST(XML2_LDFLAGS) -# AC_SUBST(XML2_VERSION) -# -# And sets: -# -# HAVE_XML2 -# -# LICENSE -# -# Copyright (c) 2009 Hartmut Holzgraefe -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. - -AC_DEFUN([AX_LIB_XML2], -[ - AC_ARG_WITH([libxml2], - AC_HELP_STRING([--with-libxml2=@<:@ARG@:>@], - [use libxml2 library @<:@default=yes@:>@, optionally specify path to xml2-config] - ), - [ - if test "$withval" = "no"; then - want_libxml2="no" - elif test "$withval" = "yes"; then - want_libxml2="yes" - else - want_libxml2="yes" - XML2_CONFIG="$withval" - fi - ], - [want_libxml2="yes"] - ) - - XML2_CFLAGS="" - XML2_LDFLAGS="" - XML2_VERSION="" - - dnl - dnl Check xml2 libraries (libxml2) - dnl - - if test "$want_libxml2" = "yes"; then - - if test -z "$XML2_CONFIG" -o test; then - AC_PATH_PROG([XML2_CONFIG], [xml2-config], []) - fi - - if test ! -x "$XML2_CONFIG"; then - AC_MSG_ERROR([$XML2_CONFIG does not exist or it is not an exectuable file]) - XML2_CONFIG="no" - found_libxml2="no" - fi - - if test "$XML2_CONFIG" != "no"; then - AC_MSG_CHECKING([for xml2 libraries]) - - XML2_CFLAGS="`$XML2_CONFIG --cflags`" - XML2_LDFLAGS="`$XML2_CONFIG --libs`" - - XML2_VERSION=`$XML2_CONFIG --version` - - AC_DEFINE([HAVE_XML2], [1], - [Define to 1 if xml2 libraries are available]) - - found_libxml2="yes" - AC_MSG_RESULT([yes]) - else - found_libxml2="no" - AC_MSG_RESULT([no]) - fi - fi - - dnl - dnl Check if required version of xml2 is available - dnl - - - libxml2_version_req=ifelse([$1], [], [], [$1]) - - - if test "$found_libxml2" = "yes" -a -n "$libxml2_version_req"; then - - AC_MSG_CHECKING([if libxml2 version is >= $libxml2_version_req]) - - dnl Decompose required version string of libxml2 - dnl and calculate its number representation - libxml2_version_req_major=`expr $libxml2_version_req : '\([[0-9]]*\)'` - libxml2_version_req_minor=`expr $libxml2_version_req : '[[0-9]]*\.\([[0-9]]*\)'` - libxml2_version_req_micro=`expr $libxml2_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$libxml2_version_req_micro" = "x"; then - libxml2_version_req_micro="0" - fi - - libxml2_version_req_number=`expr $libxml2_version_req_major \* 1000000 \ - \+ $libxml2_version_req_minor \* 1000 \ - \+ $libxml2_version_req_micro` - - dnl Decompose version string of installed PostgreSQL - dnl and calculate its number representation - libxml2_version_major=`expr $XML2_VERSION : '\([[0-9]]*\)'` - libxml2_version_minor=`expr $XML2_VERSION : '[[0-9]]*\.\([[0-9]]*\)'` - libxml2_version_micro=`expr $XML2_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$libxml2_version_micro" = "x"; then - libxml2_version_micro="0" - fi - - libxml2_version_number=`expr $libxml2_version_major \* 1000000 \ - \+ $libxml2_version_minor \* 1000 \ - \+ $libxml2_version_micro` - - libxml2_version_check=`expr $libxml2_version_number \>\= $libxml2_version_req_number` - if test "$libxml2_version_check" = "1"; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - fi - - AC_SUBST([XML2_VERSION]) - AC_SUBST([XML2_CFLAGS]) - AC_SUBST([XML2_LDFLAGS]) -]) - diff --git a/module/Makefile.in b/module/Makefile.in deleted file mode 100644 index fcaa41fa..00000000 --- a/module/Makefile.in +++ /dev/null @@ -1,10 +0,0 @@ -MODULES = nominatim -PGXS := @POSTGRESQL_PGXS@ -PG_CONFIG := @PG_CONFIG@ -include $(PGXS) - -all: - chmod 755 nominatim.so - -install: - @echo Library does not need to be installed. diff --git a/nominatim/Makefile.am b/nominatim/Makefile.am deleted file mode 100644 index d27ae554..00000000 --- a/nominatim/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -bin_PROGRAMS = nominatim - -nominatim_SOURCES = export.c geometry.cpp import.c index.c input.c nominatim.c postgresql.c sprompt.c - -AM_CFLAGS = @PTHREAD_CFLAGS@ @POSTGRESQL_CPPFLAGS@ @XML_CPPFLAGS@ @BZIP2_CFLAGS@ @GEOS_CFLAGS@ @PROJ_CFLAGS@ -DVERSION='"@PACKAGE_VERSION@"' -AM_CPPFLAGS = @PTHREAD_CFLAGS@ @POSTGRESQL_CPPFLAGS@ @XML_CPPFLAGS@ @BZIP2_CFLAGS@ @GEOS_CFLAGS@ @PROJ_CFLAGS@ - -nominatim_LDADD = @PTHREAD_CFLAGS@ @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ @XML_LIBS@ @BZIP2_LDFLAGS@ @BZIP2_LIBS@ @GEOS_LDFLAGS@ @GEOS_LIBS@ @PROJ_LDFLAGS@ @PROJ_LIBS@ -lz - diff --git a/nominatim/nominatim.c b/nominatim/nominatim.c index 7a9e6e9e..1771be2e 100644 --- a/nominatim/nominatim.c +++ b/nominatim/nominatim.c @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) PGconn *conn; - fprintf(stderr, "nominatim version %s\n\n", VERSION); + fprintf(stderr, "nominatim version %s\n\n", NOMINATIM_VERSION); while (1) { diff --git a/osm2pgsql b/osm2pgsql index 8179cdb6..fa6a8102 160000 --- a/osm2pgsql +++ b/osm2pgsql @@ -1 +1 @@ -Subproject commit 8179cdb67e70d7fb5605ab6ddedfd0bd3347db47 +Subproject commit fa6a8102e7ee98d011be12fa7549eb3e9e9248c0 From c96e71a3d711722cef00cc983ef7f3c9f011d70d Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 27 Feb 2016 19:06:32 +0100 Subject: [PATCH 2/7] add actual cmake file --- CMakeLists.txt | 61 ++++++++++++++++++++++++++++++++++++++++ module/CMakeLists.txt | 10 +++++++ nominatim/CMakeLists.txt | 4 +++ 3 files changed, 75 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 module/CMakeLists.txt create mode 100644 nominatim/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..e5587741 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,61 @@ +#----------------------------------------------------------------------------- +# +# CMake Config +# +# Nominatim +# +#----------------------------------------------------------------------------- + +cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") + + +#----------------------------------------------------------------------------- +# +# Project version +# +#----------------------------------------------------------------------------- + +project(nominatim) + +set(NOMINATIM_VERSION_MAJOR 2) +set(NOMINATIM_VERSION_MINOR 5) + +set(NOMINATIM_VERSION "${NOMINATIM_VERSION_MAJOR}.${NOMINATIM_VERSION_MINOR}") + +add_definitions(-DNOMINATIM_VERSION="${NOMINATIM_VERSION}") + + +#----------------------------------------------------------------------------- +# +# Find external dependencies +# +#----------------------------------------------------------------------------- + +add_subdirectory(osm2pgsql) + +find_package(Threads REQUIRED) + +unset(PostgreSQL_TYPE_INCLUDE_DIR CACHE) +set(PostgreSQL_TYPE_INCLUDE_DIR "/usr/include/") +find_package(PostgreSQL REQUIRED) +include_directories(${PostgreSQL_INCLUDE_DIRS}) + +find_program(PG_CONFIG pg_config) +execute_process(COMMAND ${PG_CONFIG} --pgxs + OUTPUT_VARIABLE PGXS + OUTPUT_STRIP_TRAILING_WHITESPACE) + +find_package(ZLIB REQUIRED) + +find_package(BZip2 REQUIRED) + +find_package(LibXml2 REQUIRED) +include_directories(${LIBXML2_INCLUDE_DIR}) + +#----------------------------------------------------------------------------- + +add_subdirectory(module) +add_subdirectory(nominatim) + +#----------------------------------------------------------------------------- diff --git a/module/CMakeLists.txt b/module/CMakeLists.txt new file mode 100644 index 00000000..5e507a9e --- /dev/null +++ b/module/CMakeLists.txt @@ -0,0 +1,10 @@ +# just use the pgxs makefile +ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/dummy + COMMAND PGXS=${PGXS} PG_CONFIG=${PG_CONFIG} make -f ${CMAKE_CURRENT_SOURCE_DIR}/Makefile + COMMENT "Running external makefile ${PGXS}" + ) + +ADD_CUSTOM_TARGET( nominatim_lib ALL + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dummy + ) + diff --git a/nominatim/CMakeLists.txt b/nominatim/CMakeLists.txt new file mode 100644 index 00000000..53b5073b --- /dev/null +++ b/nominatim/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(nominatim export.c geometry.cpp import.c index.c input.c nominatim.c postgresql.c sprompt.c) + +target_link_libraries(nominatim ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PostgreSQL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + From 5d7bd37ab22be5e9aa37509e905ce43bd48500a3 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 28 Feb 2016 16:42:24 +0100 Subject: [PATCH 3/7] introduce InstallPath, so that stuff can be executed from build dir --- CMakeLists.txt | 20 ++++++++++++++++++++ lib/init.php | 2 +- settings/settings.php | 5 +++-- utils/country_languages.php | 2 +- utils/setup.php | 18 +++++++++--------- utils/specialphrases.php | 2 +- utils/update.php | 13 +++++-------- 7 files changed, 40 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5587741..ceffb6fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,26 @@ find_package(BZip2 REQUIRED) find_package(LibXml2 REQUIRED) include_directories(${LIBXML2_INCLUDE_DIR}) +#----------------------------------------------------------------------------- +# +# Setup settings and paths +# +#----------------------------------------------------------------------------- + +configure_file( + ${PROJECT_SOURCE_DIR}/settings/settings.php + ${PROJECT_BINARY_DIR}/settings/settings.php +) + +configure_file( + ${PROJECT_SOURCE_DIR}/settings/phrase_settings.php + ${PROJECT_BINARY_DIR}/settings/phrase_settings.php +) + +execute_process( + COMMAND ln -s -t ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/utils +) + #----------------------------------------------------------------------------- add_subdirectory(module) diff --git a/lib/init.php b/lib/init.php index 67efdbfd..db984ef8 100644 --- a/lib/init.php +++ b/lib/init.php @@ -2,7 +2,7 @@ @define('CONST_BasePath', dirname(dirname(__FILE__))); - require_once(CONST_BasePath.'/settings/settings.php'); + require_once('settings/settings.php'); require_once(CONST_BasePath.'/lib/lib.php'); require_once(CONST_BasePath.'/lib/leakybucket.php'); require_once(CONST_BasePath.'/lib/db.php'); diff --git a/settings/settings.php b/settings/settings.php index 04ffe162..93d3a9d5 100644 --- a/settings/settings.php +++ b/settings/settings.php @@ -1,5 +1,6 @@ 1000) fail("unable to obtain state file"); - file_put_contents(CONST_BasePath.'/settings/state.txt', $sStateFile); + file_put_contents(CONST_InstallPath.'/settings/state.txt', $sStateFile); echo "Updating DB status\n"; pg_query($oDB->connection, 'TRUNCATE import_status'); $sSQL = "INSERT INTO import_status VALUES('".$aRepMatch[2]."')"; @@ -657,7 +657,7 @@ $bDidSomething = true; $sOutputFile = ''; if (isset($aCMDResult['index-output'])) $sOutputFile = ' -F '.$aCMDResult['index-output']; - $sBaseCmd = CONST_BasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$iInstances.$sOutputFile; + $sBaseCmd = CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$iInstances.$sOutputFile; passthruCheckReturn($sBaseCmd.' -R 4'); if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE'); passthruCheckReturn($sBaseCmd.' -r 5 -R 25'); diff --git a/utils/specialphrases.php b/utils/specialphrases.php index 97b60dde..020f5f80 100755 --- a/utils/specialphrases.php +++ b/utils/specialphrases.php @@ -15,7 +15,7 @@ ); getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true); - include(CONST_BasePath.'/settings/phrase_settings.php'); + include(CONST_InstallPath.'/settings/phrase_settings.php'); if ($aCMDResult['countries']) { diff --git a/utils/update.php b/utils/update.php index cc275463..a91eb30e 100755 --- a/utils/update.php +++ b/utils/update.php @@ -64,9 +64,6 @@ } */ - // Assume osm2pgsql is in the folder above - $sBasePath = dirname(dirname(__FILE__)); - date_default_timezone_set('Etc/UTC'); $oDB =& getDB(); @@ -349,7 +346,7 @@ if ($aResult['index']) { - passthru(CONST_BasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'].' -r '.$aResult['index-rank']); + passthru(CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'].' -r '.$aResult['index-rank']); } if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) @@ -361,11 +358,11 @@ $sImportFile = CONST_BasePath.'/data/osmosischange.osc'; $sOsmosisCMD = CONST_Osmosis_Binary; - $sOsmosisConfigDirectory = CONST_BasePath.'/settings'; + $sOsmosisConfigDirectory = CONST_InstallPath.'/settings'; $sCMDDownload = $sOsmosisCMD.' --read-replication-interval workingDirectory='.$sOsmosisConfigDirectory.' --simplify-change --write-xml-change '.$sImportFile; $sCMDCheckReplicationLag = $sOsmosisCMD.' -q --read-replication-lag workingDirectory='.$sOsmosisConfigDirectory; $sCMDImport = $sOsm2pgsqlCmd.' '.$sImportFile; - $sCMDIndex = $sBasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances']; + $sCMDIndex = $sInstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances']; if (!$aResult['no-npi']) { $sCMDIndex .= '-F '; } @@ -542,8 +539,8 @@ var_dump($iNPIID); exit(1); } - $sConfigDirectory = CONST_BasePath.'/settings'; - $sCMDImportTemplate = $sBasePath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.$sBasePath.'/nominatim/partitionedtags.def -F '; + $sConfigDirectory = CONST_InstallPath.'/settings'; + $sCMDImportTemplate = $sBasePath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.CONST_BasePath.'/nominatim/partitionedtags.def -F '; while(true) { $fStartTime = time(); From 314a9e52e924395a24755a753a2daf3c9957b9c8 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Mon, 29 Feb 2016 21:46:24 +0100 Subject: [PATCH 4/7] use external makefile for pgxs with cmake --- module/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 module/Makefile diff --git a/module/Makefile b/module/Makefile new file mode 100644 index 00000000..783a6602 --- /dev/null +++ b/module/Makefile @@ -0,0 +1,8 @@ +MODULES = nominatim +include $(PGXS) + +all: + chmod 755 nominatim.so + +install: + @echo Library does not need to be installed. From 6450126933988d8881606748bce0c2ad358f7373 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Mon, 29 Feb 2016 22:26:22 +0100 Subject: [PATCH 5/7] adapt README and vagrant scripts to cmake --- README | 8 +++----- vagrant/centos-7-provision.sh | 9 +++++---- vagrant/ubuntu-trusty-provision.sh | 10 +++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/README b/README index 224b6569..7a760ff6 100644 --- a/README +++ b/README @@ -29,13 +29,11 @@ is cloned as well by running `git submodule update --init`. Installation steps: -0. If checking out from git run: - - ./autogen.sh - 1. Compile Nominatim: - ./configure + mkdir build + cd build + cmake .. make 2. Get OSM data and import: diff --git a/vagrant/centos-7-provision.sh b/vagrant/centos-7-provision.sh index 93139a23..db9d1b4f 100644 --- a/vagrant/centos-7-provision.sh +++ b/vagrant/centos-7-provision.sh @@ -15,7 +15,7 @@ yum update -y yum install -y epel-release yum install -y postgresql-server postgresql-contrib postgresql-devel postgis postgis-utils \ - make automake gcc gcc-c++ libtool policycoreutils-python \ + make cmake gcc gcc-c++ libtool policycoreutils-python \ php-pgsql php php-pear php-pear-DB libpqxx-devel proj-epsg \ bzip2-devel proj-devel geos-devel libxml2-devel boost-devel \ expat-devel zlib-devel @@ -70,13 +70,14 @@ cd /home/$USERNAME # If the Nominatim source is not being shared with the host, check out source. if [ ! -d "Nominatim" ]; then yum install -y git - sudo -u $USERNAME git clone --recursive https://github.com/twain47/Nominatim.git + sudo -H -u $USERNAME git clone --recursive https://github.com/twain47/Nominatim.git fi # Configure and compile the source. cd Nominatim -sudo -u $USERNAME ./autogen.sh -sudo -u $USERNAME ./configure +sudu -u $USERNAME mkdir build-vagrant +cd build-vagrant +sudo -u $USERNAME cmake .. sudo -u $USERNAME make # Make sure that postgres has access to the nominatim library. diff --git a/vagrant/ubuntu-trusty-provision.sh b/vagrant/ubuntu-trusty-provision.sh index 84e98e23..ed58d2e0 100755 --- a/vagrant/ubuntu-trusty-provision.sh +++ b/vagrant/ubuntu-trusty-provision.sh @@ -36,7 +36,7 @@ USERNAME=vagrant sudo apt-get update -qq sudo apt-get upgrade -y sudo apt-get install -y build-essential libgeos-dev libpq-dev libbz2-dev \ - libtool automake libproj-dev libboost-dev libboost-system-dev \ + libtool cmake libproj-dev libboost-dev libboost-system-dev \ libboost-filesystem-dev libboost-thread-dev libexpat-dev sudo apt-get autoremove -y @@ -89,13 +89,13 @@ cd /home/$USERNAME # If the Nominatim source is not being shared with the host, check out source. if [ ! -d "Nominatim" ]; then sudo apt-get install -y git - sudo -u $USERNAME git clone --recursive https://github.com/twain47/Nominatim.git + sudo -H -u $USERNAME git clone --recursive https://github.com/twain47/Nominatim.git fi cd Nominatim - -sudo -u $USERNAME ./autogen.sh -sudo -u $USERNAME ./configure +sudo -u $USERNAME mkdir build-vagrant +cd build-vagrant +sudo -u $USERNAME cmake .. sudo -u $USERNAME make chmod +x ./ chmod +x ./module From b24ef60b33da99938d864b3ff1b9399282dd253a Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Mon, 29 Feb 2016 23:45:30 +0100 Subject: [PATCH 6/7] enable test execution using ctest --- CMakeLists.txt | 23 +++++++++++++++++++++++ tests/steps/db_results.py | 1 - tests/steps/db_setup.py | 3 ++- tests/steps/osm2pgsql_setup.py | 6 ++++-- tests/steps/terrain.py | 10 ++++++---- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ceffb6fc..a561e020 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ add_definitions(-DNOMINATIM_VERSION="${NOMINATIM_VERSION}") # #----------------------------------------------------------------------------- +set(BUILD_TESTS on) add_subdirectory(osm2pgsql) find_package(Threads REQUIRED) @@ -73,6 +74,28 @@ execute_process( COMMAND ln -s -t ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/utils ) +#----------------------------------------------------------------------------- +# +# Tests +# +#----------------------------------------------------------------------------- + +include(CTest) + +set(TEST_BDD db osm2pgsql api) + +foreach (test ${TEST_BDD}) + add_test(NAME bdd_${test} + COMMAND lettuce features/${test} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests) + set_tests_properties(bdd_${test} + PROPERTIES ENVIRONMENT "NOMINATIM_DIR=${PROJECT_BINARY_DIR}") +endforeach() + +add_test(NAME php + COMMAND phpunit ./ + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests-php) + #----------------------------------------------------------------------------- add_subdirectory(module) diff --git a/tests/steps/db_results.py b/tests/steps/db_results.py index c3ac9445..71a30927 100644 --- a/tests/steps/db_results.py +++ b/tests/steps/db_results.py @@ -11,7 +11,6 @@ import psycopg2 import psycopg2.extensions import psycopg2.extras import os -import subprocess import random import json import re diff --git a/tests/steps/db_setup.py b/tests/steps/db_setup.py index e1315ed9..8041c6cc 100644 --- a/tests/steps/db_setup.py +++ b/tests/steps/db_setup.py @@ -266,7 +266,8 @@ def query_cmd(step, query, with_dups): '--search', query] if with_dups is not None: cmd.append('--nodedupe') - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc = subprocess.Popen(cmd, cwd=world.config.source_dir, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) (outp, err) = proc.communicate() assert (proc.returncode == 0), "query.php failed with message: %s" % err world.page = outp diff --git a/tests/steps/osm2pgsql_setup.py b/tests/steps/osm2pgsql_setup.py index eaa14573..4b03b1ea 100644 --- a/tests/steps/osm2pgsql_setup.py +++ b/tests/steps/osm2pgsql_setup.py @@ -155,7 +155,8 @@ def osm2pgsql_load_place(step): cmd = [os.path.join(world.config.source_dir, 'utils', 'setup.php')] cmd.extend(['--osm-file', fname, '--import-data','--osm2pgsql-cache', '300']) - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc = subprocess.Popen(cmd, cwd=world.config.source_dir, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) (outp, outerr) = proc.communicate() assert (proc.returncode == 0), "OSM data import failed:\n%s\n%s\n" % (outp, outerr) @@ -204,7 +205,8 @@ def osm2pgsql_update_place(step): cmd = [os.path.join(world.config.source_dir, 'utils', 'update.php')] cmd.extend(['--import-diff', fname]) - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc = subprocess.Popen(cmd, cwd=world.config.source_dir, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) (outp, outerr) = proc.communicate() assert (proc.returncode == 0), "OSM data update failed:\n%s\n%s\n" % (outp, outerr) diff --git a/tests/steps/terrain.py b/tests/steps/terrain.py index e9561d1a..349deafe 100644 --- a/tests/steps/terrain.py +++ b/tests/steps/terrain.py @@ -23,7 +23,7 @@ class NominatimConfig: logging.basicConfig(level=loglevel) # Nominatim test setup self.base_url = os.environ.get('NOMINATIM_SERVER', 'http://localhost/nominatim') - self.source_dir = os.path.abspath(os.environ.get('NOMINATIM_DIR', '..')) + self.source_dir = os.path.abspath(os.environ.get('NOMINATIM_DIR', '../build')) self.template_db = os.environ.get('TEMPLATE_DB', 'test_template_nominatim') self.test_db = os.environ.get('TEST_DB', 'test_nominatim') self.local_settings_file = os.environ.get('NOMINATIM_SETTINGS', '/tmp/nominatim_settings.php') @@ -52,7 +52,8 @@ def write_nominatim_config(dbname): def run_nominatim_script(script, *args): cmd = [os.path.join(world.config.source_dir, 'utils', '%s.php' % script)] cmd.extend(['--%s' % x for x in args]) - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc = subprocess.Popen(cmd, cwd=world.config.source_dir, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) (outp, outerr) = proc.communicate() assert (proc.returncode == 0), "Script '%s' failed:\n%s\n%s\n" % (script, outp, outerr) @@ -176,8 +177,9 @@ def db_template_setup(): conn.close() # execute osm2pgsql on an empty file to get the right tables osm2pgsql = os.path.join(world.config.source_dir, 'osm2pgsql', 'osm2pgsql') - proc = subprocess.Popen([osm2pgsql, '-lsc', '-O', 'gazetteer', '-d', world.config.template_db, '-'], - stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc = subprocess.Popen([osm2pgsql, '-lsc', '-r', 'xml', '-O', 'gazetteer', '-d', world.config.template_db, '-'], + cwd=world.config.source_dir, stdin=subprocess.PIPE, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) [outstr, errstr] = proc.communicate(input='') world.run_nominatim_script('setup', 'create-functions', 'create-tables', 'create-partition-tables', 'create-partition-functions', 'load-data', 'create-search-indices') From 5ccb499a6f389913fe8c8c745a31dff40907b98c Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 9 Mar 2016 00:07:46 +0100 Subject: [PATCH 7/7] install executables and call settings.php explicitly Executables (including websites) need to be installed in the build directory, so that they can find the right settings.php. settings now defines build and source dir. --- CMakeLists.txt | 45 ++++++++++++++++++++++++++++--------- lib/init.php | 3 --- settings/settings.php | 3 ++- utils/blocks.php | 5 +++-- utils/country_languages.php | 4 +++- utils/importWikipedia.php | 3 ++- utils/imports.php | 3 ++- utils/query.php | 7 +++--- utils/setup.php | 3 ++- utils/specialphrases.php | 7 +++--- utils/update.php | 5 +++-- utils/warm.php | 5 +++-- website/deletable.php | 3 ++- website/details.php | 3 ++- website/hierarchy.php | 3 ++- website/lookup.php | 3 ++- website/polygons.php | 3 ++- website/reverse.php | 3 ++- website/search.php | 3 ++- website/status.php | 3 ++- 20 files changed, 78 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a561e020..dca35eca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ add_definitions(-DNOMINATIM_VERSION="${NOMINATIM_VERSION}") #----------------------------------------------------------------------------- set(BUILD_TESTS on) +set(WITH_LUA off) add_subdirectory(osm2pgsql) find_package(Threads REQUIRED) @@ -60,19 +61,41 @@ include_directories(${LIBXML2_INCLUDE_DIR}) # #----------------------------------------------------------------------------- -configure_file( - ${PROJECT_SOURCE_DIR}/settings/settings.php - ${PROJECT_BINARY_DIR}/settings/settings.php -) +set(CUSTOMFILES + settings/settings.php + settings/phrase_settings.php + website/deletable.php + website/details.php + website/hierarchy.php + website/lookup.php + website/polygons.php + website/reverse.php + website/search.php + website/status.php + utils/blocks.php + utils/country_languages.php + utils/imports.php + utils/importWikipedia.php + utils/query.php + utils/server_compare.php + utils/setup.php + utils/specialphrases.php + utils/update.php + utils/warm.php + ) -configure_file( - ${PROJECT_SOURCE_DIR}/settings/phrase_settings.php - ${PROJECT_BINARY_DIR}/settings/phrase_settings.php -) +foreach (cfile ${CUSTOMFILES}) + configure_file(${PROJECT_SOURCE_DIR}/${cfile} ${PROJECT_BINARY_DIR}/${cfile}) +endforeach() + +set(WEBPATHS css images js) + +foreach (wp ${WEBPATHS}) + execute_process( + COMMAND ln -sf ${PROJECT_SOURCE_DIR}/website/${wp} ${PROJECT_BINARY_DIR}/website/ + ) +endforeach() -execute_process( - COMMAND ln -s -t ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/utils -) #----------------------------------------------------------------------------- # diff --git a/lib/init.php b/lib/init.php index db984ef8..26952d05 100644 --- a/lib/init.php +++ b/lib/init.php @@ -1,8 +1,5 @@