source: trunk/configure.ac @ 901

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

refs #401 fixes #408

Modifications of detection of plplot;

  • detection of plplot will not fail due to absent pkg-config
  • if pkg-config is available and it finds pc file for plplot, then we use it to retrieve compiler/linker flags, otherwise we guess.
  • new AC_DEFINE(HAVE_PLPLOT)
  • configure now accepts --without-plplot (or --with-plplot=no) and tests are skipped (following build will currently not work)
  • added a test linking against plplot library
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.9 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 901 2009-11-27 00:47:36Z 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 Jari Häkkinen, Peter Johansson
15#
16# This file is part of svndigest, http://dev.thep.lu.se/svndigest
17#
18# svndigest is free software; you can redistribute it and/or modify it
19# under the terms of the GNU General Public License as published by
20# the Free Software Foundation; either version 3 of the License, or
21# (at your option) any later version.
22#
23# svndigest is distributed in the hope that it will be useful, but
24# WITHOUT ANY WARRANTY; without even the implied warranty of
25# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26# General Public License for more details.
27#
28# You should have received a copy of the GNU General Public License
29# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
30
31AC_PREREQ(2.61)
32
33m4_include([m4/version.m4])
34AC_INIT([svndigest],[SVNDIGEST_VERSION],[jari@thep.lu.se],,
35        [http://dev.thep.lu.se/svndigest])
36AC_CONFIG_SRCDIR([lib/File.h])
37AC_CONFIG_AUX_DIR([autotools])
38dnl arg below should be the same as in Makefile.am
39AC_CONFIG_MACRO_DIR([m4])
40AC_PREFIX_DEFAULT([/usr/local])
41
42dnl FIXME remove when we assume autoconf 2.64
43m4_ifndef([AC_PACKAGE_URL],
44          [AC_DEFINE([PACKAGE_URL], ["http://dev.thep.lu.se/svndigest"],
45                     [Define to home page for this package])])
46
47AC_SUBST([SVNDIGEST_MAJOR_VERSION], [MAJOR_VERSION])
48AC_SUBST([SVNDIGEST_MINOR_VERSION], [MINOR_VERSION])
49AC_SUBST([SVNDIGEST_PATCH_VERSION], [PATCH_VERSION])
50
51AC_DEFINE([DEV_BUILD],[SVNDIGEST_DEV_BUILD],
52          [true if dev build (version ends with pre)])
53AC_DEFINE([SVNDIGEST_MAJOR_VERSION], [MAJOR_VERSION],
54                    [Define to the svndigest major version])
55AC_DEFINE([SVNDIGEST_MINOR_VERSION], [MINOR_VERSION],
56                    [Define to the svndigest minor version])
57AC_DEFINE([SVNDIGEST_PATCH_VERSION], [PATCH_VERSION],
58                    [Define to the svndigest patch version])
59
60AC_CONFIG_HEADER([config.h])
61AM_INIT_AUTOMAKE([1.10 std-options])
62
63# Set default programming language
64AC_LANG([C++])
65
66# propagate selected configure variables to DISTCHECK_CONFIGURE_FLAGS
67for var in CPPFLAGS CXX CXXFLAGS CXXCPP LDFLAGS LIBS; do
68  eval isset=\${$var+set}
69  if test "$isset" = 'set' ; then
70    eval val=$`echo $var`
71    DISTCHECK_CONFIGURE_FLAGS="${DISTCHECK_CONFIGURE_FLAGS}'${var}=${val}' "
72  fi
73done
74AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
75
76# Let user overide default CXXFLAGS
77if test "${CXXFLAGS+set}" != set; then
78  CXXFLAGS=""  # Setting CXXFLAGS here to prevent expansion in AC_PROG_CXX
79fi
80
81# Checks for programs.
82AC_PROG_CXXCPP
83AC_PROG_CXX
84AC_PROG_INSTALL
85AC_PROG_RANLIB
86AC_PROG_SED
87AC_PATH_PROG([HELP2MAN], [help2man], [no])
88AM_CONDITIONAL([HAVE_HELP2MAN], [test x$HELP2MAN != xno])
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
96# -Wno-long-long is needed to suppress compiler diagnostics regarding
97# using extension beyond the C++ standard (usage of non C++ standard
98# 'long long' types).
99YAT_CXX_ADD_FLAG([CXXFLAGS],[-pedantic -Wno-long-long])
100AC_TYPE_LONG_LONG_INT
101AS_IF([test x$ac_cv_type_long_long_int = xno],
102      [AC_MSG_ERROR([compiler does not support long long int])]
103     )
104
105AC_ARG_ENABLE([debug],
106  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
107
108AS_IF([test x$enable_debug = xyes],
109  [YAT_CXX_ADD_FLAG([CXXFLAGS],[-g -O])],
110  [YAT_CPP_ADD_FLAG([CPPFLAGS],[-DNDEBUG])
111   YAT_CXX_ADD_FLAG([CXXFLAGS],[-O3])])
112
113# Apache Portable Runtime (APR) API checks
114APR_FIND_APR(,,[1],[1 0])
115AS_IF([test "${with_apr+set}" = set],
116    [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-apr=$with_apr"]
117)
118if test "$apr_found" = "yes" ; then
119    APR_LIBS="`$apr_config --libs`"
120    apr_link_ld="`$apr_config --link-ld`"
121    for i in $apr_link_ld; do
122      AS_IF([test ${i:0:2} = "-l"],[APR_LIBS="$i $APR_LIBS"],
123            [YAT_LD_ADD_FLAG([APR_LDFLAGS], [$i])])
124    done
125    YAT_CPP_ADD_FLAG([APR_CPPFLAGS],[`$apr_config --includes --cppflags`])
126    save_CPPFLAGS=$CPPFLAGS
127    CPPFLAGS="$APR_CPPFLAGS $CPPFLAGS"
128    AC_CHECK_HEADER([apr_allocator.h],,[apr_found="no"])
129    CPPFLAGS=$save_CPPFLAGS
130fi
131AC_SUBST([APR_CPPFLAGS])
132AC_SUBST([APR_LDFLAGS])
133AC_SUBST([APR_LIBS])
134
135# Subversion API checks
136svn_found="yes"
137AC_ARG_WITH([svn],
138  [AS_HELP_STRING([--with-svn=DIR],[prefix for svn developer files [[PREFIX]]])],
139  [ DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-svn=$withval"
140    YAT_LD_ADD_FLAG([SVN_LDFLAGS], [-L$withval/lib])
141    YAT_CPP_ADD_FLAG([SVN_CPPFLAGS], [-I$withval/include])
142  ])
143# svn needs needs apr headers
144save_CPPFLAGS=$CPPFLAGS
145CPPFLAGS="$APR_CPPFLAGS $SVN_CPPFLAGS $CPPFLAGS"
146AC_CHECK_HEADER([subversion-1/svn_types.h],,[svn_found="no"])
147CPPFLAGS=$save_CPPFLAGS
148
149save_LDFLAGS=$LDFLAGS
150save_LIBS=$LIBS
151tmp_LIBS="$APR_LIBS $save_LIBS"
152LIBS=""
153LDFLAGS="$SVN_LDFLAGS $APR_LDFLAGS"
154AC_SEARCH_LIBS([svn_cmdline_setup_auth_baton],[svn_subr-1],
155               [], [svn_found="no"], [$tmp_LIBS])
156AC_SEARCH_LIBS([svn_ra_initialize],[svn_ra-1], [], [svn_found="no"],[$tmp_LIBS])
157AC_SEARCH_LIBS([svn_wc_adm_open3],[svn_wc-1], [], [svn_found="no"], [$tmp_LIBS])
158AC_SEARCH_LIBS([svn_diff_file_options_create],[svn_diff-1],[],
159               [svn_found="no"], [$tmp_LIBS])
160AC_SEARCH_LIBS([svn_client_log3],[svn_client-1],,[svn_found="no"], [$tmp_LIBS])
161SVN_LIBS=$LIBS
162LIBS=$save_LIBS
163LDFLAGS=$save_LDFLAGS
164AC_SUBST([SVN_CPPFLAGS])
165AC_SUBST([SVN_LDFLAGS])
166AC_SUBST([SVN_LIBS])
167
168
169# check if svnversion is installed
170AC_PATH_PROG([SVNVERSION], [svnversion], [no])
171
172# PLplot API checks
173# plplot_found can get values: skip, noheader, old, or nolib if an
174# error is detected.
175plplot_found="yes"
176plplot_version=5.9
177save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
178AC_ARG_WITH([plplot],
179  [AS_HELP_STRING([--with-plplot=DIR],[prefix for plplot developer files])],
180  [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-plplot=$withval"
181   AS_IF([test "x$withval" = "xno"], [ dnl
182     plplot_found=skip;
183   ], [ dnl
184     # help pkg-config find .pc file
185     PKG_CONFIG_PATH=${withval}/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    YAT_CPP_ADD_FLAG([PLPLOT_CPPFLAGS], [`$PKG_CONFIG plplotd-c++ --cflags`])
208    YAT_LD_ADD_FLAG([PLPLOT_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_CPP_ADD_FLAG([PLPLOT_CPPFLAGS], [$with_plplot/include])
215      YAT_LD_ADD_FLAG([PLPLOT_LDFLAGS], [$with_plplot/libs])
216    ])
217  ])
218])
219                 
220AS_IF([test "x$plplot_found" = "xyes"], [
221  save_CPPFLAGS=$CPPFLAGS
222  CPPFLAGS="$PLPLOT_CPPFLAGS $CPPFLAGS"
223  AC_CHECK_HEADER([plplot/plstream.h], [], [plplot_found="noheader"])
224  CPPFLAGS=$save_CPPFLAGS
225])
226
227
228AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
229  AC_MSG_CHECKING([plplot version >= $plplot_version])
230  AS_IF([$PKG_CONFIG --atleast-version=$plplot_version plplotd-c++], [
231    AC_MSG_RESULT([yes])
232  ],[
233    AC_MSG_RESULT([`$PKG_CONFIG --modversion= plplotd-c++`])
234    plplot_found="old"
235  ])
236])
237
238AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
239  save_LDFLAGS=$LDFLAGS
240  LDFLAGS="$PLPLOT_LDFLAGS $LDFLAGS"
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                 [AC_MSG_RESULT([yes]);
247                  AC_DEFINE([HAVE_PLPLOT], [1],
248                            [Define to 1 if you have plplot])],
249                 [AC_MSG_RESULT([no])
250                  plplot_found=nolib;])
251])
252# restore variable
253LDFLAGS=$save_LDFLAGS
254LIBS=$save_LIBS
255export PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
256AC_SUBST(PLPLOT_CPPFLAGS)
257AC_SUBST(PLPLOT_LDFLAGS)
258AC_SUBST(PLPLOT_LIBS)
259
260# checking if we build in a subversion WC
261AS_IF([test -d $srcdir/.svn], [wc_found="yes"], [wc_found="no"])
262AM_CONDITIONAL([HAVE_SVN_WC], [test "$wc_found" = "yes"])
263AC_SUBST([wc_found])
264
265# checking if we have test repo
266test_repo_filename=$srcdir/test/repo;
267AS_IF([test -r $test_repo_filename],
268              [AC_DEFINE([HAVE_TEST_REPO],[1],[define if test repo is available])
269               test_repo_found="yes"],
270              [test_repo_found="no"])
271AC_SUBST([test_repo_found])
272AS_IF([test "x$test_repo_found" = xyes],
273      [abs_test_repo=`cd $test_repo_filename && pwd`;
274       AC_SUBST(abs_test_repo)]
275     )
276AC_CONFIG_FILES([test/test_repo.sh], [chmod +x test/test_repo.sh])
277AC_CONFIG_FILES([test/svn_update.sh], [chmod +x test/svn_update.sh])
278AC_CONFIG_FILES([test/check_repo_status.sh],
279                [chmod +x test/check_repo_status.sh])   
280
281dnl maintainer make rukes from yat project
282YAT_SVN_RELEASE
283
284# Restore FLAGS
285APR_RESTORE_THE_ENVIRONMENT([CPPFLAGS], [DEFAULT_])
286APR_RESTORE_THE_ENVIRONMENT([CXXFLAGS], [DEFAULT_])
287
288AC_CONFIG_FILES([Makefile
289                bin/Makefile
290                lib/Makefile
291                lib/yat/Makefile
292                man/Makefile
293                test/environment.h
294                test/Makefile])
295
296AC_CONFIG_HEADER([lib/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
305if (test "$wc_found" = "yes"); then
306   if test x$HELP2MAN = xno; then
307     AC_MSG_WARN(m4_text_wrap(m4_normalize([
308       `help2man' is missing on your system.  You will not be
309       able to create the man page. A sound man page should be
310       included in a distribution, and since you will not able
311       to create a complete distribution `make dist' will fail.
312       ]),[                   ],
313          [                             ], 79))
314   fi
315   # svnversion is required when building from svn wc
316   if (test "$svnversion" = "no"); then
317      all_reqs_ok="false";
318      AC_MSG_WARN([dnl
319Cannot find svnversion, which is required when building from a
320subversion working copy. Please install svnversion and make sure it is
321in your search path.]);
322   fi
323   if (test "$test_repo_found" = "no"); then
324      all_reqs_ok="false";
325      AC_MSG_WARN([dnl
326Cannot find test repository (test_repo_filename), which should be
327available when building from a subversion working copy. Try svn
328update in top directory.]);
329   fi
330fi
331
332# Non-existing APR is fatal -- sub-sequent compilation will fail.
333if (test "$apr_found" = "no") ; then
334  AC_MSG_WARN([APR not found. The Apache Portable Runtime
335  (APR) library cannot be found. Please make sure APR is installed
336  and supply the appropriate --with-apr option to 'configure'.])
337  all_reqs_ok="false"
338fi
339
340# Non-existing subversion API is fatal -- sub-sequent compilation will fail.
341if (test "$svn_found" = "no") ; then
342  svn_msg="Subversion API not found. Subversion API libraries cannot
343  be found. Make sure the APIs are installed and supply the
344  appropriate --with-svn option to 'configure'."
345  if (test "$apr_found" = "no") ; then
346    svn_msg="$svn_msg
347    Note, APR was not found. Failure to locate APR affects the search
348    of the subversion API. Please fix the APR problem before trying
349    to resolve the subversion related issues."
350  fi
351  AC_MSG_WARN([$svn_msg])
352  all_reqs_ok="false"
353fi
354
355# Non-existing PLplot API is fatal -- sub-sequent compilation will fail.
356AS_CASE([$plplot],
357  [noheader],
358    [AC_MSG_WARN([
359    PLplot developer files cannot be found. Make sure PLplot is installed.])
360    all_reqs_ok="false"],
361  [old],
362    [AC_MSG_WARN([
363    PLplot developer files found but not required API version.
364    Version at least $plplot_version is required. Please upgrade PLplot.])
365    all_reqs_ok="false"],
366  [nolib],
367    [AC_MSG_WARN([
368    PLplot developer files found but linking against plplot library failed.])
369    all_reqs_ok="false"])
370
371if test $ac_cv_type_long_long_int != yes ; then
372  AC_MSG_WARN([Compiler $CXX does not support `long long'.
373  svndigest must be compiled with a compiler that supports `long long'.])
374  all_reqs_ok="false"
375fi
376
377if (test "$all_reqs_ok" = "false") ; then
378  AC_MSG_ERROR([Some pre-requisites were not fulfilled, aborting
379  configure. Please consult the 'README' file for more information
380  about what is needed to compile svndigest and refer to above
381  warning messages. Needed files were NOT created.])
382fi
383
384# Create output.
385AC_OUTPUT
386
387# Some more messages.
388AC_MSG_NOTICE([
389Ready to compile the executables of svndigest $VERSION
390The following flags and libs will be used:
391+++++++++++++++++++++++++++++++++++++++++++++++
392  Compiler:           $CXX
393  Preprocessor flags: $SD_CPPFLAGS $CPPFLAGS
394    CPPFLAGS:         $CPPFLAGS
395    DEFAULT_CPPFLAGS: $DEFAULT_CPPFLAGS
396    APR_CPPFLAGS:     $APR_CPPFLAGS
397    SVN_CPPFLAGS:     $SVN_CPPFLAGS
398    PLPLOT_CPPFLAGS:  $PLPLOT_CPPFLAGS
399  C++ flags:
400    CXXFLAGS:         $CXXFLAGS
401    DEFAULT_CXXFLAGS: $DEFAULT_CXXFLAGS
402  Linker flags:
403    LDFLAGS:          $LDFLAGS
404    APR_LDFLAGS:      $APR_LDFLAGS
405    SVN_LDFLAGS:      $SVN_LDFLAGS
406    PLPLOT_LDFLAGS:   $PLPLOT_LDFLAGS
407  Libraries:         
408    LIBS              $LIBS
409    APR_LIBS          $APR_LIBS
410    SVN_LIBS          $SVN_LIBS
411    PLPLOT_LIBS       $PLPLOT_LIBS
412+++++++++++++++++++++++++++++++++++++++++++++++]dnl
413)
414
415AC_MSG_NOTICE([Now type 'make all check'.])
Note: See TracBrowser for help on using the repository browser.