source: trunk/configure.ac @ 1337

Last change on this file since 1337 was 1337, checked in by Peter Johansson, 10 years ago

using macros from yat to create files .release and .release_year

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