source: trunk/configure.ac @ 1495

Last change on this file since 1495 was 1495, checked in by Peter Johansson, 11 years ago

merge patch release 0.9.6 into trunk

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