source: trunk/configure.ac @ 1405

Last change on this file since 1405 was 1405, checked in by Peter Johansson, 12 years ago

merged patch release 0.9.4 to trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.0 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 1405 2011-10-22 16:47:34Z peter $
4##
5## If you grabbed the source from subversion you should, at top-level,
6## execute:
7##          ./bootstrap
8## To push subsequent changes of this file into the build scripts you
9## must issue:
10##          autoreconf
11
12# Copyright (C) 2005 Jari Häkkinen, Peter Johansson
13# Copyright (C) 2006 Jari Häkkinen
14# Copyright (C) 2007, 2008, 2009, 2010 Jari Häkkinen, Peter Johansson
15# Copyright (C) 2011 Peter Johansson
16#
17# This file is part of svndigest, http://dev.thep.lu.se/svndigest
18#
19# svndigest is free software; you can redistribute it and/or modify it
20# under the terms of the GNU General Public License as published by
21# the Free Software Foundation; either version 3 of the License, or
22# (at your option) any later version.
23#
24# svndigest is distributed in the hope that it will be useful, but
25# WITHOUT ANY WARRANTY; without even the implied warranty of
26# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27# General Public License for more details.
28#
29# You should have received a copy of the GNU General Public License
30# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
31
32AC_PREREQ([2.63])
33
34m4_include([m4/version.m4])
35AC_INIT([svndigest], m4_defn([SVNDIGEST_VERSION]),
36        [svndigest-users@lists.sourceforge.net],,
37        [http://dev.thep.lu.se/svndigest])
38AC_CONFIG_SRCDIR([lib/File.h])
39AC_CONFIG_AUX_DIR([autotools])
40dnl arg below should be the same as in Makefile.am
41AC_CONFIG_MACRO_DIR([m4])
42AC_PREFIX_DEFAULT([/usr/local])
43
44dnl FIXME remove when we assume autoconf 2.64
45m4_ifndef([AC_PACKAGE_URL],
46          [AC_DEFINE([PACKAGE_URL], ["http://dev.thep.lu.se/svndigest"],
47                     [Define to home page for this package])
48           AC_SUBST([PACKAGE_URL], ["http://dev.thep.lu.se/svndigest"])])
49
50AC_SUBST([SVNDIGEST_MAJOR_VERSION], [MAJOR_VERSION])
51AC_SUBST([SVNDIGEST_MINOR_VERSION], [MINOR_VERSION])
52AC_SUBST([SVNDIGEST_PATCH_VERSION], [PATCH_VERSION])
53
54AC_DEFINE([DEV_BUILD],[SVNDIGEST_DEV_BUILD],
55          [true if dev build (version ends with pre)])
56AC_DEFINE([SVNDIGEST_MAJOR_VERSION], [MAJOR_VERSION],
57                    [Define to the svndigest major version])
58AC_DEFINE([SVNDIGEST_MINOR_VERSION], [MINOR_VERSION],
59                    [Define to the svndigest minor version])
60AC_DEFINE([SVNDIGEST_PATCH_VERSION], [PATCH_VERSION],
61                    [Define to the svndigest patch version])
62
63AC_CONFIG_HEADERS([config.h])
64AM_INIT_AUTOMAKE([1.11 color-tests std-options parallel-tests])
65
66# Set default programming language
67AC_LANG([C++])
68
69# propagate selected configure variables to DISTCHECK_CONFIGURE_FLAGS
70for var in CPPFLAGS CXX CXXFLAGS CXXCPP LDFLAGS LIBS; do
71  eval isset=\${$var+set}
72  if test "$isset" = 'set' ; then
73    eval val=$`echo $var`
74    DISTCHECK_CONFIGURE_FLAGS="${DISTCHECK_CONFIGURE_FLAGS}'${var}=${val}' "
75  fi
76done
77AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
78
79# Let user overide default CXXFLAGS
80if test "${CXXFLAGS+set}" != set; then
81  CXXFLAGS=""  # Setting CXXFLAGS here to prevent expansion in AC_PROG_CXX
82fi
83
84# Checks for programs.
85AC_PROG_CXXCPP
86AC_PROG_CXX
87AC_PROG_RANLIB
88AC_PROG_SED
89AM_MISSING_PROG([HELP2MAN], [help2man])
90# look for pkg-config
91PKG_PROG_PKG_CONFIG([0.23])
92
93# Save FLAGS
94APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
95APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
96
97# -Wno-long-long is needed to suppress compiler diagnostics regarding
98# using extension beyond the C++ standard (usage of non C++ standard
99# 'long long' types).
100YAT_CXX_ADD_FLAG([CXXFLAGS],[-Wno-long-long])
101AC_TYPE_LONG_LONG_INT
102AS_IF([test x$ac_cv_type_long_long_int = xno],
103      [AC_MSG_ERROR([compiler does not support long long int])]
104     )
105
106AC_ARG_ENABLE([debug],
107  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
108
109AS_IF([test x$enable_debug = xyes],
110  [YAT_CXX_ADD_FLAG([CXXFLAGS],[-pedantic -g -O])],
111  [YAT_CPP_ADD_FLAG([CPPFLAGS],[-DNDEBUG])
112   YAT_CXX_ADD_FLAG([CXXFLAGS],[-O3])])
113
114AC_MSG_CHECKING([g++ deprecation attribute])
115AC_COMPILE_IFELSE(
116  [AC_LANG_PROGRAM([[void f() __attribute__ ((deprecated));]],)], 
117  [AC_DEFINE([YAT_HAVE_GCC_DEPRECATED], [1],
118             [Define if compiler supports deprecated attribute, as in g++ 4.0])
119   AC_MSG_RESULT([yes])],
120  [AC_MSG_RESULT([no])] )
121
122# Apache Portable Runtime (APR) API checks
123APR_FIND_APR(,,[1],[1 0])
124AS_IF([test "${with_apr+set}" = set],
125    [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-apr=$with_apr"]
126)
127if test "$apr_found" = "yes" ; then
128    APR_LIBS="`$apr_config --libs`"
129    apr_link_ld="`$apr_config --link-ld`"
130    for i in $apr_link_ld; do
131      AS_IF([AS_ECHO([$i]) | grep '^-l' > /dev/null],[APR_LIBS="$i $APR_LIBS"],
132            [YAT_LD_ADD_FLAG([LDFLAGS], [$i])])
133    done
134    YAT_CPP_ADD_FLAG([CPPFLAGS],[`$apr_config --includes --cppflags`])
135    AC_CHECK_HEADER([apr_allocator.h],,[apr_found="no"])
136fi
137AC_SUBST([APR_LIBS])
138
139# Subversion API checks
140svn_found="yes"
141AC_ARG_WITH([svn],
142  [AS_HELP_STRING([--with-svn=DIR],[prefix for svn developer files [[PREFIX]]])],
143  [ AS_CASE([$withval], [yes|no],
144            [AC_MSG_ERROR([--with-svn requires a directory to be provided])])
145    AS_IF([test -d $with_svn], [],
146          [AC_MSG_ERROR([$with_svn: no such directory])])
147    # transform argument to absolute path
148    with_svn=`cd $with_svn && pwd`
149    DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-svn=$with_svn"
150    YAT_LD_ADD_FLAG([LDFLAGS], [-L$with_svn/lib])
151    YAT_CPP_ADD_FLAG([CPPFLAGS], [-I$with_svn/include])
152  ])
153# svn needs needs apr headers
154AC_CHECK_HEADER([subversion-1/svn_types.h],,[svn_found="no"])
155
156save_LIBS=$LIBS
157tmp_LIBS="$APR_LIBS $save_LIBS"
158LIBS=""
159AC_SEARCH_LIBS([svn_cmdline_setup_auth_baton],[svn_subr-1],
160               [], [svn_found="no"], [$tmp_LIBS])
161AC_SEARCH_LIBS([svn_ra_initialize],[svn_ra-1], [], [svn_found="no"],[$tmp_LIBS])
162AC_SEARCH_LIBS([svn_wc_adm_open3],[svn_wc-1], [], [svn_found="no"], [$tmp_LIBS])
163AC_SEARCH_LIBS([svn_diff_file_options_create],[svn_diff-1],[],
164               [svn_found="no"], [$tmp_LIBS])
165AC_SEARCH_LIBS([svn_client_log3],[svn_client-1],,[svn_found="no"], [$tmp_LIBS])
166SVN_LIBS=$LIBS
167LIBS=$save_LIBS
168AC_SUBST([SVN_LIBS])
169
170# PLplot API checks
171# plplot_found can get values: skip, noheader, old, or nolib if an
172# error is detected.
173plplot_found="yes"
174plplot_version=5.9.6
175save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
176AC_ARG_WITH([plplot],
177  [AS_HELP_STRING([--with-plplot=DIR],[prefix for plplot developer files])],
178  [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-plplot=$withval"
179   AS_IF([test "x$withval" = "xno"], [ dnl
180     plplot_found=skip;
181   ], [ dnl
182     AS_IF([test -d $with_plplot], [],
183           [AC_MSG_ERROR([$with_plplot: no such directory])])
184     with_plplot=`cd $with_plplot && pwd`
185     # help pkg-config find .pc file
186     PKG_CONFIG_PATH=$with_plplot/lib/pkgconfig$PATH_SEPARATOR$PKG_CONFIG_PATH
187     export PKG_CONFIG_PATH
188   ])
189  ])
190
191use_plplot_pc="no"
192AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
193  AC_MSG_CHECKING([for plplotd-c++.pc])
194  AS_IF([$PKG_CONFIG --exists plplotd-c++], [
195    AC_MSG_RESULT([yes])
196    use_plplot_pc="yes"
197  ],[
198    AC_MSG_RESULT([no])
199    AC_MSG_WARN([cannot find plplotd-c++;
200      please use --with-plplot with appropriate argument to get more accurate
201      configuration.])
202  ])
203])
204
205AS_IF([test "x$plplot_found" = "xyes"], [
206  # copy flags if we have found pc file
207  AS_IF([test "$use_plplot_pc" = "yes"], [
208    # plplot typically returns <prefix>/include/plplot because plplot
209    # people assumes users include header files as <foo.h>. We prefer
210    # including files as <plplot/foo.h> and therefore need to trim off
211    # trailing '/plplot'. Space is included in sed expression to avoid
212    # substituting potential '/plplot' in PREFIX.
213    YAT_CPP_ADD_FLAG([CPPFLAGS],
214             [`$PKG_CONFIG plplotd-c++ --cflags-only-I | sed 's|/plplot | |g'`])
215    YAT_LD_ADD_FLAG([LDFLAGS], [`$PKG_CONFIG plplotd-c++ --libs-only-L`])
216    PLPLOT_LIBS="`$PKG_CONFIG plplotd-c++ --libs-only-l --libs-only-other`"
217  ],[
218    # otherwise guess
219    PLPLOT_LIBS="-lplplotcxxd -lplplotd";
220    AS_IF([test -n "$with_plplot" && test "x$with_plplot" != "xyes"], [
221      YAT_LD_ADD_FLAG([LDFLAGS], [-L$with_plplot/lib])
222      YAT_CPP_ADD_FLAG([CPPFLAGS], [-I$with_plplot/include])
223    ])
224  ])
225])
226                 
227AS_IF([test "x$plplot_found" = "xyes"], [
228  AC_CHECK_HEADER([plplot/plstream.h], [], [plplot_found="noheader"])
229])
230
231AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
232  AC_MSG_CHECKING([plplot version >= $plplot_version])
233  AS_IF([$PKG_CONFIG --atleast-version=$plplot_version plplotd-c++], [
234    AC_MSG_RESULT([yes])
235  ],[
236    have_plplot_version=`$PKG_CONFIG --modversion plplotd-c++`
237    AC_MSG_RESULT([$have_plplot_version])
238    plplot_found="old"
239  ])
240])
241
242AS_IF([test "x$plplot_found" = "xyes"], [
243  save_LIBS=$LIBS
244  LIBS="$PLPLOT_LIBS $LIBS"
245  AC_MSG_CHECKING([for library containing plstream])
246  AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <plplot/plstream.h>],
247                                  [plstream pls(1,1,"svg", "conftest.svg");
248                                   pls.scolbga(255, 255, 255, 0);
249                                  ])],
250                 [AC_MSG_RESULT([yes]);
251                  AC_DEFINE([HAVE_PLPLOT], [1],
252                            [Define to 1 if you have plplot])],
253                 [AC_MSG_RESULT([no])
254                  plplot_found=nolib;])
255  LIBS=$save_LIBS
256])
257# restore variable
258export PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
259AC_SUBST(PLPLOT_LIBS)
260
261# checking if we have test repo
262test_repo_filename=$srcdir/test/repo;
263AS_IF([test -r $test_repo_filename],
264              [AC_DEFINE([HAVE_TEST_REPO],[1],[define if test repo is available])
265               test_repo_found="yes"],
266              [test_repo_found="no"])
267AC_SUBST([test_repo_found])
268AS_IF([test "x$test_repo_found" = xyes],
269      [abs_test_repo=`cd $test_repo_filename && pwd`;
270       AC_SUBST(abs_test_repo)]
271     )
272AC_CONFIG_FILES([test/init.sh])
273AC_CONFIG_FILES([test/svn_update.sh], [chmod +x test/svn_update.sh])
274
275dnl maintainer make rules from yat project
276YAT_SVN_RELEASE
277YAT_SVN_REVISION
278YAT_REVISION_HEADER
279YAT_SVN_RELEASE_YEAR
280
281
282# Restore FLAGS
283APR_RESTORE_THE_ENVIRONMENT([CPPFLAGS], [SVNDIGEST_])
284APR_RESTORE_THE_ENVIRONMENT([CXXFLAGS], [SVNDIGEST_])
285APR_RESTORE_THE_ENVIRONMENT([LDFLAGS], [SVNDIGEST_])
286
287AC_CONFIG_FILES([Makefile
288                bin/Makefile
289                lib/Makefile
290                yat/Makefile
291                man/Makefile
292                test/environment.h
293                test/Makefile])
294
295AC_CONFIG_HEADER([yat/config_public.h])
296
297# Print failure status information about selected items, and exit if
298# fatal errors were encountered. No output will be created if
299# configure is halted prematurely.
300
301# used to trigger exit before creation of output
302all_reqs_ok="true"
303
304AS_VAR_IF([have_svn_wc], [yes], [
305   AC_MSG_CHECKING([help2man])
306   # redirecting potential error msg to log file
307   AS_IF([help2man --version >/dev/null 2>&AS_MESSAGE_LOG_FD],
308         [AC_MSG_RESULT([yes])],
309         [AC_MSG_RESULT([no])
310     AC_MSG_WARN(m4_text_wrap(m4_normalize([
311       `help2man' is missing on your system.  You will not be
312       able to create the man page. A sound man page should be
313       included in a distribution, and since you will not able
314       to create a complete distribution `make dist' will fail.
315       ]),[                   ],
316          [                             ], 79))
317   ])
318   if (test "$test_repo_found" = "no"); then
319      all_reqs_ok="false";
320      AC_MSG_WARN([dnl
321Cannot find test repository (test_repo_filename), which should be
322available when building from a subversion working copy. Try svn
323update in top directory.]);
324   fi
325])
326
327# Non-existing APR is fatal -- sub-sequent compilation will fail.
328if (test "$apr_found" = "no") ; then
329  AC_MSG_WARN([APR not found. The Apache Portable Runtime
330  (APR) library cannot be found. Please make sure APR is installed
331  and supply the appropriate --with-apr option to 'configure'.])
332  all_reqs_ok="false"
333fi
334
335# Non-existing subversion API is fatal -- sub-sequent compilation will fail.
336if (test "$svn_found" = "no") ; then
337  svn_msg="Subversion API not found. Subversion API libraries cannot
338  be found. Make sure the APIs are installed and supply the
339  appropriate --with-svn option to 'configure'."
340  if (test "$apr_found" = "no") ; then
341    svn_msg="$svn_msg
342    Note, APR was not found. Failure to locate APR affects the search
343    of the subversion API. Please fix the APR problem before trying
344    to resolve the subversion related issues."
345  fi
346  AC_MSG_WARN([$svn_msg])
347  all_reqs_ok="false"
348fi
349
350# Non-existing PLplot API is fatal -- sub-sequent compilation will fail.
351AS_CASE([$plplot_found],
352  [noheader],
353    [AC_MSG_WARN([
354    PLplot developer files cannot be found. Make sure PLplot is installed.])
355    all_reqs_ok="false"],
356  [old],
357    [AC_MSG_WARN([
358    PLplot developer files found but not required API version.
359    Version at least $plplot_version is required. Please upgrade PLplot.])
360    all_reqs_ok="false"],
361  [nolib],
362    [AC_MSG_WARN([
363    PLplot developer files found but linking against plplot library failed.])
364    all_reqs_ok="false"])
365
366if test $ac_cv_type_long_long_int != yes ; then
367  AC_MSG_WARN([Compiler $CXX does not support `long long'.
368  svndigest must be compiled with a compiler that supports `long long'.])
369  all_reqs_ok="false"
370fi
371
372if (test "$all_reqs_ok" = "false") ; then
373  AC_MSG_ERROR([Some pre-requisites were not fulfilled, aborting
374  configure. Please consult the 'README' file for more information
375  about what is needed to compile svndigest and refer to above
376  warning messages. Needed files were NOT created.])
377fi
378
379# Create output.
380AC_OUTPUT
381
382# Some more messages.
383AC_MSG_NOTICE([
384Ready to compile the executables of svndigest $VERSION
385The following flags and libs will be used:
386+++++++++++++++++++++++++++++++++++++++++++++++
387  Compiler:           $CXX
388  Preprocessor flags:
389    CPPFLAGS:           $CPPFLAGS
390    SVNDIGEST_CPPFLAGS: $SVNDIGEST_CPPFLAGS
391  C++ flags:
392    CXXFLAGS:           $CXXFLAGS
393    SVNDIGEST_CXXFLAGS: $SVNDIGEST_CXXFLAGS
394  Linker flags:
395    LDFLAGS:            $LDFLAGS
396    SVNDIGEST_LDFLAGS:  $SVNDIGEST_LDFLAGS
397  Libraries:         
398    LIBS                $LIBS
399    APR_LIBS            $APR_LIBS
400    SVN_LIBS            $SVN_LIBS
401    PLPLOT_LIBS         $PLPLOT_LIBS
402+++++++++++++++++++++++++++++++++++++++++++++++]dnl
403)
404
405AC_MSG_NOTICE([Now type 'make all check'.])
Note: See TracBrowser for help on using the repository browser.