source: trunk/configure.ac @ 1417

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

allow silent make rules (default turned off).

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