1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
# Process this file with autoconf to produce a configure script.
#
# Configure.in for RPostgreSQL
# Copyright (C) 2008 Dirk Eddelbuettel and licensed under GNU GPL
#
# This file draws heavily on configure.in files from littler, RMySQL, and RdbiPgSQL
# Set the name and version -- the version set here will propagate to other files from here
AC_INIT(RPostgreSQL, 0.5)
AC_CONFIG_AUX_DIR(src)
# Checks for common programs using default macros
AC_PROG_CC
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
case "${host_os}" in
darwin*)
R_OS_TYPE="darwin"
;;
esac
# Check for non-standard programs: pg_config(1) to configure PostgreSQL builds
AC_PATH_PROG([PG_CONFIG], [pg_config])
# By default, we will not use the accompanied libpq
ENABLE_LIBPQ=
# If pg_config was found, let's use it
if test "${PG_CONFIG}" != ""; then
# Use pg_config for header and linker arguments
PG_INCDIR=`${PG_CONFIG} --includedir`
PG_LIBDIR=`${PG_CONFIG} --libdir`
else
# let's look around -- code copied from RdbuiPgSQL but modified to use test -f
AC_MSG_NOTICE([checking for PostgreSQL header files])
if ! test $PG_INCDIR
then
for dir in \
/usr/include \
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include \
/usr/include/pgsql \
/usr/include/postgresql \
/usr/local/include \
/usr/local/include/pgsql \
/usr/local/include/postgresql \
/usr/local/pgsql/include \
/usr/local/postgresql/include \
/opt/include \
/opt/include/pgsql \
/opt/include/postgresql \
/opt/local/include \
/opt/local/include/postgresql \
/sw/include/postgresql
do
AC_MSG_NOTICE([Checking include ${dir}.])
if test -f ${dir}/libpq-fe.h
then
PG_INCDIR=${dir}
break
fi
done
fi
# likewise, let's look around for libpq.so
if ! test $PG_LIBDIR
then
for dir in \
/usr/lib \
/usr/lib/pgsql \
/usr/lib/postgresql \
/usr/local/lib \
/usr/local/lib/pgsql \
/usr/local/lib/postgresql \
/usr/local/pgsql/lib \
/usr/local/postgresql/lib \
/opt/lib \
/opt/lib/pgsql \
/opt/lib/postgresql \
/opt/local/lib \
/opt/local/lib/postgresql \
/sw/lib
do
AC_MSG_NOTICE([Checking lib ${dir}.])
if test -f ${dir}/libpq.so
then
PG_LIBDIR=${dir}
break
fi
if test -f ${dir}/libpq.dylib
then
PG_LIBDIR=${dir}
break
fi
done
fi
if test $PG_LIBDIR && test $PG_INCDIR
then
echo $PG_LIBDIR
echo $PG_INCDIR
else
if test "$R_OS_TYPE" = "darwin" ; then
# in case we cannot find any libpq library we will use the accompanied libpq
# This content would be written into src/Makevars at the end of this script
ENABLE_LIBPQ='
PKG_CPPFLAGS=-Ilibpq
PKG_LIBS=libpq/libpq.a
.PHONY: all
all: $(SHLIB)
$(SHLIB): libpq/libpq.5.dylib
libpq/libpq.5.dylib:
(cd libpq; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" -f Makefile.darwin pg_config.h pg_config_os.h all)
clean:
(cd libpq; $(MAKE) -f Makefile.darwin clean)
'
fi
fi
fi
# Expand into arguments
# make sure we use the included libpq-fe.h if it was not previously found
if ! test $PG_INCDIR ; then
AC_MSG_NOTICE([Using internal package libpq-fe.h])
PG_INCDIR="src/libpq"
fi
PKG_CPPFLAGS="-I${PG_INCDIR}"
PKG_LIBS="-L${PG_LIBDIR} -lpq"
# Test for sanity by looking for libpq-fe.h, no explicit action on found, error on failure
AC_CHECK_FILE(["${PG_INCDIR}/libpq-fe.h"],
,
AC_SUBST(R_OS_TYPE))
# Now substitute these two variable in src/Makevars.in to create src/Makevars
AC_SUBST(PKG_CPPFLAGS)
AC_SUBST(PKG_LIBS)
AC_SUBST(ENABLE_LIBPQ)
AC_OUTPUT(src/Makevars)
|