source: branches/0.10-stable/configure.ac @ 1591

Last change on this file since 1591 was 1591, checked in by Jari Häkkinen, 6 years ago

Addresses #530. Allow build of svndigest but fail for 'make dist'.

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