configure.ac 5.03 KB
Newer Older
jfuser's avatar
jfuser committed
1
2
dnl #################################################################
dnl File: ./configure.ac
jfuser's avatar
jfuser committed
3
dnl Package: landsepi
jfuser's avatar
jfuser committed
4
5
6
7
8
9
10
11
12
dnl Description:
dnl   + autoconf file
dnl
dnl Process this file with autoconf to produce a configure script.
dnl #################################################################

dnl -----------------------------------------------
dnl Package name and version number (user defined)
dnl -----------------------------------------------
Loup Rimbaud's avatar
Loup Rimbaud committed
13
define([THE_PACKAGE_NAME],    [landsepi])
jfuser's avatar
jfuser committed
14
define([THE_PACKAGE_VERSION], [0.0.7])
jfuser's avatar
jfuser committed
15
16
17
18
19
20
21
22
23
24
25
26
define([THE_PACKAGE_MAINTAINER],  [jean-francois.rey@inra.fr])

dnl --------------------------------
dnl Initialization macros.
dnl --------------------------------
AC_INIT(THE_PACKAGE_NAME, THE_PACKAGE_VERSION, THE_PACKAGE_MAINTAINER)

dnl -----------------------------------------------
dnl Checks for programs.
dnl -----------------------------------------------

dnl check R
jfuser's avatar
jfuser committed
27
: ${R_HOME=`R RHOME`}
jfuser's avatar
jfuser committed
28
29
30
if test -z "${R_HOME}"; then
  AC_MSG_ERROR(["could not determine R_HOME, is R installed ?"])
fi
jfuser's avatar
jfuser committed
31
AC_MSG_NOTICE([${R_HOME}])
jfuser's avatar
jfuser committed
32
33
#CXX1X=`"${R_HOME}/bin/R" CMD config CXX1X`
#CXX1XSTD=`"${R_HOME}/bin/R" CMD config CXX1XSTD`
34
35
#CXX="${CXX1X} ${CXX1XSTD}"
CXX=`"${R_HOME}/bin/R" CMD config CXX`
36
#CPP=`"${R_HOME}/bin/R" CMD config CPP`
37
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
jfuser's avatar
jfuser committed
38
#CXX1XFLAGS=`"${R_HOME}/bin/R" CMD config CXX1XFLAGS`
jfuser's avatar
jfuser committed
39
40
41
42
43
44
45
46
47
48
49
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS`

AC_LANG(C++)

## debug mode for compiler code 
AC_MSG_CHECKING([whether to build debug version])
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [build debug version (default=no)]))

if test "$enable_debug" != "yes" && test "$DEBUG" != TRUE ; then
  AC_MSG_RESULT(no)
jfuser's avatar
jfuser committed
50
  CXXFLAGS="${CXXFLAGS} -w"
jfuser's avatar
jfuser committed
51
52
else
  AC_MSG_RESULT(yes)
jfuser's avatar
jfuser committed
53
54
  CXXFLAGS="${CXXFLAGS} -Wall -Wextra -g -ggdb -Wconversion -O0 -fno-inline"
  CPPFLAGS="${CPPFLAGS} -DDEBUG "
jfuser's avatar
jfuser committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
fi

# check Rcpp
AC_MSG_NOTICE([${R_HOME}])
AC_MSG_CHECKING([for Rcpp package])
PKG_RCPP_LIBS=`${R_HOME}/bin/Rscript -e "Rcpp:::LdFlags()"`
PKG_RCPP_CXXFLAGS=`${R_HOME}/bin/Rscript -e "Rcpp:::CxxFlags()"`
AC_MSG_RESULT(yes)
AC_SUBST(PKG_RCPP_LIBS)
AC_SUBST(PKG_RCPP_CXXFLAGS)

# GSL librarie 
AC_CHECK_LIB([m],[cos])
AC_CHECK_LIB([gslcblas],[cblas_dgemm])
AC_CHECK_LIB([gsl],[gsl_blas_dgemm])

LDFLAGS="${LDFLAGS} ${LIBS}"

# GDAL librarie
GDAL_CONFIG="gdal-config"

AC_MSG_CHECKING(gdal-config usability)
if test `${GDAL_CONFIG} --version`;
then
jfuser's avatar
jfuser committed
79
  GDAL_CFLAGS=`${GDAL_CONFIG} --cflags`
jfuser's avatar
jfuser committed
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
  GDAL_LIBS=`${GDAL_CONFIG} --libs`
  GDAL_VERSION=`${GDAL_CONFIG} --version`
  GDAL_DEP_LIBS=`${GDAL_CONFIG} --dep-libs`
  GDAL_DATADIR=`${GDAL_CONFIG} --datadir`
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  echo "Error: gdal-config not found"
  echo "The gdal-config script distributed with GDAL could not be found."
  echo "If you have not installed the GDAL libraries, you can"
  echo "download the source from  http://www.gdal.org/"
  echo "If you have installed the GDAL libraries, then make sure that"
  echo "gdal-config is in your path. Try typing gdal-config at a"
  echo "shell prompt and see if it runs. If not, use:"
  echo " --configure-args='--with-gdal-config=/usr/local/bin/gdal-config'"
  echo "with appropriate values for your installation."
  echo ""
  exit 1

fi

AC_MSG_NOTICE([GDAL: ${GDAL_VERSION}])
AC_MSG_CHECKING([GDAL version >= 1.11.0])
GDAL_VER_MAX=`echo $GDAL_VERSION | cut -d'.' -f1`
GDAL_VER_MED=`echo $GDAL_VERSION | cut -d'.' -f1`
if test ${GDAL_VER_MAX} -lt 1 && test ${GDAL_VER_MED} -lt 11; then
  AC_MSG_RESULT(no)
  AC_MSG_ERROR([upgrade GDAL to 1.11.0 or later])
else
  AC_MSG_RESULT(yes)
  CPPFLAGS="${CPPFLAGS} -DGDAL_VERSION=${GDAL_VER_MAX}"
jfuser's avatar
jfuser committed
111
  CXXFLAGS="${CXXFLAGS} ${GDAL_CFLAGS}"
jfuser's avatar
jfuser committed
112
113
fi

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
151
152
153
154
155
156
157
158
159
160
161
162
163
# test if need dep libs ( script from rgdal)
[cat > gdal_test.cc <<_EOCONF
#include <gdal.h>
#ifdef __cplusplus
extern "C" {
#endif
int main() {
GDALAllRegister();
}
#ifdef __cplusplus
}
#endif
_EOCONF]

LIBS="${LDFLAGS} ${GDAL_LIBS}"
AC_MSG_CHECKING(gdal: linking with --libs only)
${CXX} ${CPPFLAGS} ${CXXFLAGS} -o gdal_test gdal_test.cc ${LIBS} 2> errors.txt
if test `echo $?` -ne 0 ; then
  gdalok=no
  AC_MSG_RESULT(no)
else
  AC_MSG_RESULT(yes)
fi

if test "${gdalok}" = no; then
  AC_MSG_CHECKING(gdal: linking with --libs and --dep-libs)
  LIBS="${LIBS} ${GDAL_DEP_LIBS}"
  gdalok=yes
  ${CXX} ${CPPFLAGS} ${CXXFLAGS} -o gdal_test gdal_test.cc ${LIBS} 2>> errors.txt
  if test `echo $?` -ne 0 ; then
    gdalok=no
  fi
  if test "${gdalok}" = yes; then
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
fi

if test "${gdalok}" = no; then
  cat errors.txt
  AC_MSG_NOTICE([Install failure: compilation and/or linkage problems.])
  AC_MSG_ERROR([GDALAllRegister not found in libgdal.])
fi

rm -f gdal_test errors.txt gdal_test.cc

## /end rgdal script

LDFLAGS="${LIBS}"
jfuser's avatar
jfuser committed
164

jfuser's avatar
jfuser committed
165
CXXFLAGS="${CXXFLAGS}"
jfuser's avatar
jfuser committed
166
167
168
169
170
171

dnl -----------------------------------------------
dnl Generates Makefile's, configuration files and scripts
dnl -----------------------------------------------
# R mode
AC_SUBST(CXX)
jfuser's avatar
jfuser committed
172
#AC_SUBST(CXX11)
jfuser's avatar
jfuser committed
173
AC_SUBST(CXXFLAGS)
jfuser's avatar
jfuser committed
174
#AC_SUBST(CXX1XFLAGS)
jfuser's avatar
jfuser committed
175
176
177
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)

jfuser's avatar
jfuser committed
178
AC_CONFIG_FILES([src/Makevars])
jfuser's avatar
jfuser committed
179
180

AC_OUTPUT