Add first cut at autoconf

Rename 'core' directory
This commit is contained in:
Paul Ramsey 2013-01-14 16:46:13 -08:00
parent 4a655883a9
commit 4626d99aa1
24 changed files with 329 additions and 3 deletions

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
*.o
*.a
*.so
autom4te.cache
configure
config.log
confdefs.h

View File

@ -1,10 +1,10 @@
all install uninstall noop clean distclean:
$(MAKE) -C core $@
$(MAKE) -C libpc $@
$(MAKE) -C postgis $@
check:
$(MAKE) -C core $@
$(MAKE) -C libpc $@
astyle:
find . \

280
configure.ac Normal file
View File

@ -0,0 +1,280 @@
dnl **********************************************************************
dnl * configure.ac
dnl *
dnl * Pointclound buildb configuration.
dnl *
dnl * Copyright (c) 2012, OpenGeo
dnl *
dnl ***********************************************************************/
AC_INIT()
dnl AC_CONFIG_HEADERS([postgis_config.h])
AC_CONFIG_MACRO_DIR([macros])
dnl
dnl Compilers
dnl
AC_PROG_CC
dnl
dnl Define executable suffix for use with the loader Makefiles
dnl
EXESUFFIX="$ac_cv_exeext"
AC_SUBST([EXESUFFIX])
dnl
dnl Search for flex/bison to build the parser
dnl
AC_PROG_LEX
AC_PROG_YACC
AC_SUBST([LEX])
AC_SUBST([YACC])
dnl ===========================================================================
dnl Detect CUnit if it is installed (used for unit testing)
dnl
dnl Note that we pass any specified CPPFLAGS and LDFLAGS into the Makefile
dnl as CUnit is the only compile-time dependency that cannot obtain any
dnl specialised flags using a --with-X parameter, and so we allow this
dnl information to be passed in if required.
dnl ===========================================================================
CUNIT_LDFLAGS=""
AC_CHECK_HEADER([CUnit/CUnit.h], [
CUNIT_CPPFLAGS="$CPPFLAGS"
AC_CHECK_LIB([cunit], [CU_initialize_registry], [CUNIT_LDFLAGS="$LDFLAGS -lcunit"], [AC_MSG_WARN([could not locate CUnit required for unit tests])])
],
[
AC_MSG_WARN([could not locate CUnit required for unit tests])
])
AC_SUBST([CUNIT_CPPFLAGS])
AC_SUBST([CUNIT_LDFLAGS])
dnl ===========================================================================
dnl Detect the version of PostgreSQL installed on the system
dnl ===========================================================================
AC_ARG_WITH([pgconfig],
[AS_HELP_STRING([--with-pgconfig=FILE], [specify an alternative pg_config file])],
[PGCONFIG="$withval"], [PGCONFIG=""])
if test "x$PGCONFIG" = "x"; then
dnl PGCONFIG was not specified, so search within the current path
AC_PATH_PROG([PGCONFIG], [pg_config])
dnl If we couldn't find pg_config, display an error
if test "x$PGCONFIG" = "x"; then
AC_MSG_ERROR([could not find pg_config within the current path. You may need to try re-running configure with a --with-pgconfig parameter.])
fi
else
dnl PGCONFIG was specified; display a message to the user
if test "x$PGCONFIG" = "xyes"; then
AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pg_config])
else
if test -f $PGCONFIG; then
AC_MSG_RESULT([Using user-specified pg_config file: $PGCONFIG])
else
AC_MSG_ERROR([the user-specified pg_config file $PGCONFIG does not exist])
fi
fi
fi
dnl ===========================================================================
dnl Ensure that $PG_CONFIG --pgxs points to a valid file. This is because some
dnl distributions such as Debian also include pg_config as part of libpq-dev
dnl packages, but don't install the Makefile it points to unless
dnl the postgresql-server-dev packages are installed :)
dnl ===========================================================================
PGXS=`$PGCONFIG --pgxs`
if test ! -f $PGXS; then
AC_MSG_ERROR([the PGXS Makefile $PGXS cannot be found. Please install the PostgreSQL server development packages and re-run configure.])
fi
AC_SUBST([PGXS])
dnl Extract the version information from pg_config
dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give
dnl the final version. This is to guard against user error...
PGSQL_MAJOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f1 | sed 's/[[^0-9]]//g'`
PGSQL_MINOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f2 | sed 's/[[^0-9]]//g'`
PGSQL_FULL_VERSION=`$PGCONFIG --version`
PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION"
PGSQL_PKGLIBDIR=`$PGCONFIG --pkglibdir`
PGSQL_LIBDIR=`$PGCONFIG --libdir`
PGSQL_SHAREDIR=`$PGCONFIG --sharedir`
AC_MSG_RESULT([checking PostgreSQL version... $PGSQL_FULL_VERSION])
dnl Ensure that we are using PostgreSQL >= 9.0
if test ! "$PGSQL_MAJOR_VERSION" -ge 9; then
AC_MSG_ERROR([PointCloud requires PostgreSQL >= 9.0])
fi
dnl Extract the linker and include flags for the frontend (for programs that use libpq)
PGSQL_FE_LDFLAGS=-L`$PGCONFIG --libdir`" -lpq"
PGSQL_FE_CPPFLAGS=-I`$PGCONFIG --includedir`
AC_SUBST([PGSQL_FE_LDFLAGS])
AC_SUBST([PGSQL_FE_CPPFLAGS])
dnl Ensure that we can parse libpq-fe.h
CPPFLAGS_SAVE="$CPPFLAGS"
CPPFLAGS="$PGSQL_FE_CPPFLAGS"
AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([could not find libpq-fe.h])])
CPPFLAGS="$CPPFLAGS_SAVE"
dnl Ensure we can link against libpq
LIBS_SAVE="$LIBS"
LIBS="$PGSQL_FE_LDFLAGS"
AC_CHECK_LIB([pq], [PQserverVersion],
[],
[AC_MSG_ERROR([could not find libpq])],
[])
LIBS="$LIBS_SAVE"
AC_DEFINE_UNQUOTED([PGSQL_VERSION], [$PGSQL_VERSION], [PostgreSQL server version])
AC_SUBST([PGSQL_VERSION])
dnl ===========================================================================
dnl Detect LibXML2
dnl ===========================================================================
AC_ARG_WITH([xml2config],
[AS_HELP_STRING([--with-xml2config=FILE], [specify an alternative xml2-config file])],
[XML2CONFIG="$withval"], [XML2CONFIG=""])
if test "x$XML2CONFIG" = "x"; then
dnl XML2CONFIG was not specified, so search within the current path
AC_PATH_PROG([XML2CONFIG], [xml2-config])
dnl If we couldn't find xml2-config, display a warning
if test "x$XML2CONFIG" = "x"; then
AC_MSG_ERROR([could not find xml2-config from libxml2 within the current path. You may need to try re-running configure with a --with-xml2config parameter.])
fi
else
dnl XML2CONFIG was specified; display a message to the user
if test "x$XML2CONFIG" = "xyes"; then
AC_MSG_ERROR([you must specify a parameter to --with-xml2config, e.g. --with-xml2config=/path/to/xml2-config])
else
if test -f $XML2CONFIG; then
AC_MSG_RESULT([Using user-specified xml2-config file: $XML2CONFIG])
else
AC_MSG_ERROR([the user-specified xml2-config file $XML2CONFIG does not exist])
fi
fi
fi
dnl Extract the linker and include flags
XML2_LDFLAGS=`$XML2CONFIG --libs`
XML2_CPPFLAGS=`$XML2CONFIG --cflags`
dnl Extract the version
LIBXML2_VERSION=`$XML2CONFIG --version`
dnl Check headers file
CPPFLAGS_SAVE="$CPPFLAGS"
CPPFLAGS="$XML2_CPPFLAGS"
AC_CHECK_HEADERS([libxml/tree.h libxml/parser.h libxml/xpath.h libxml/xpathInternals.h],
[], [AC_MSG_ERROR([could not find headers include related to libxml2])])
CPPFLAGS="$CPPFLAGS_SAVE"
dnl Ensure we can link against libxml2
LIBS_SAVE="$LIBS"
LIBS="$XML2_LDFLAGS"
AC_CHECK_LIB([xml2], [xmlInitParser], [], [AC_MSG_ERROR([could not find libxml2])], [])
LIBS="$LIBS_SAVE"
AC_DEFINE_UNQUOTED([LIBXML2_VERSION], ["$LIBXML2_VERSION"], [PointCloud libxml2 version])
AC_SUBST([LIBXML2_VERSION])
dnl ===========================================================================
dnl Detect the version of PROJ.4 installed
dnl ===========================================================================
AC_ARG_WITH([projdir],
[AS_HELP_STRING([--with-projdir=PATH], [specify the PROJ.4 installation directory])],
[PROJDIR="$withval"], [PROJDIR=""])
if test ! "x$PROJDIR" = "x"; then
dnl Make sure that the directory exists
if test "x$PROJDIR" = "xyes"; then
AC_MSG_ERROR([you must specify a parameter to --with-projdir, e.g. --with-projdir=/path/to])
else
if test -d "$PROJDIR"; then
AC_MSG_RESULT([Using user-specified proj directory: $PROJDIR])
dnl Add the include directory to PROJ_CPPFLAGS
PROJ_CPPFLAGS="-I$PROJDIR/include"
PROJ_LDFLAGS="-L$PROJDIR/lib"
else
AC_MSG_ERROR([the --with-projdir directory "$PROJDIR" cannot be found])
fi
fi
fi
dnl Check that we can find the proj_api.h header file
CPPFLAGS_SAVE="$CPPFLAGS"
CPPFLAGS="$PROJ_CPPFLAGS"
AC_CHECK_HEADER([proj_api.h], [], [AC_MSG_ERROR([could not find proj_api.h - you may need to specify the directory of a PROJ.4 installation using --with-projdir])])
dnl Return the PROJ.4 version number
AC_PROJ_VERSION([PROJ_VERSION])
AC_DEFINE_UNQUOTED([PROJ_VERSION], [$PROJ_VERSION], [PROJ library version])
AC_SUBST([PROJ_VERSION])
CPPFLAGS="$CPPFLAGS_SAVE"
AC_SUBST([PROJ_CPPFLAGS])
AC_SUBST([PROJ_LDFLAGS])
dnl Ensure that we are using PROJ >= 4.6.0 (requires pj_set_searchpath)
if test ! "$PROJ_VERSION" -ge 46; then
AC_MSG_ERROR([PointCloud requires PROJ >= 4.6.0])
fi
dnl Ensure we can link against libproj
LIBS_SAVE="$LIBS"
LIBS="$PROJ_LDFLAGS"
AC_CHECK_LIB([proj], [pj_get_release],
[],
[AC_MSG_ERROR([could not find libproj - you may need to specify the directory of a PROJ.4 installation using --with-projdir])],
[])
LIBS="$LIBS_SAVE"
dnl ===========================================================================
dnl Output the relevant files
dnl ===========================================================================
AC_OUTPUT([
core/Makefile
core/cunit/Makefile
])
dnl ===========================================================================
dnl Display the configuration status information
dnl ===========================================================================
AC_MSG_RESULT()
AC_MSG_RESULT([ PointCloud is now configured for ${host}])
AC_MSG_RESULT()
AC_MSG_RESULT([ -------------- Compiler Info ------------- ])
AC_MSG_RESULT([ C compiler: ${CC} ${CFLAGS}])
AC_MSG_RESULT()
AC_MSG_RESULT([ -------------- Dependencies -------------- ])
AC_MSG_RESULT([ PostgreSQL config: ${PGCONFIG}])
AC_MSG_RESULT([ PostgreSQL version: ${PGSQL_FULL_VERSION}])
AC_MSG_RESULT([ PROJ4 version: ${PROJ_VERSION}])
AC_MSG_RESULT([ Libxml2 config: ${XML2CONFIG}])
AC_MSG_RESULT([ Libxml2 version: ${LIBXML2_VERSION}])
AC_MSG_RESULT()

View File

@ -0,0 +1,42 @@
dnl **********************************************************************
dnl * $Id: ac_proj4_version.m4 2797 2008-05-31 09:56:44Z mcayland $
dnl *
dnl * PostGIS - Spatial Types for PostgreSQL
dnl * http://postgis.refractions.net
dnl * Copyright 2008 Mark Cave-Ayland
dnl *
dnl * This is free software; you can redistribute and/or modify it under
dnl * the terms of the GNU General Public Licence. See the COPYING file.
dnl *
dnl **********************************************************************
dnl
dnl Return the PROJ.4 version number
dnl
AC_DEFUN([AC_PROJ_VERSION], [
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([
#ifdef HAVE_STDINT_H
#include <stdio.h>
#endif
#include "proj_api.h"
],
[
FILE *fp;
fp = fopen("conftest.out", "w");
fprintf(fp, "%d\n", PJ_VERSION);
fclose(fp)])
],
[
dnl The program ran successfully, so return the version number in the form MAJORMINOR
$1=`cat conftest.out | sed 's/\([[0-9]]\)\([[0-9]]\)\([[0-9]]\)/\1\2/'`
],
[
dnl The program failed so return an empty variable
$1=""
]
)
])

View File

@ -9,7 +9,7 @@ DATA = pointcloud--1.0.sql
REGRESS = pointcloud
SHLIB_LINK += $(filter -lm, $(LIBS)) ../core/libpc.a
SHLIB_LINK += $(filter -lm, $(LIBS)) ../libpc/libpc.a
# We are going to use PGXS for sure
PG_CONFIG = pg_config