source: trunk/configure.ac @ 1415

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

indentation

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