source: trunk/configure.ac @ 1407

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

reintroduce -Wall (in enable-debug mode) refs #488

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