source: trunk/configure.ac @ 973

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

change treatment of arguments of --with-svn and --with-plplot. Translate them to absolute path and barf if it is not a directory. Exception is that --with-plplot=no is still allowed.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.2 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 973 2009-12-11 04:25:32Z 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.63])
32
33m4_include([m4/version.m4])
34AC_INIT([svndigest], m4_defn([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           AC_SUBST([PACKAGE_URL], ["http://dev.thep.lu.se/svndigest"])])
47
48# propagate RELEASE_YEAR from file .release_year
49RELEASE_YEAR=`cat $srcdir/.release_year`
50AC_SUBST([RELEASE_YEAR])
51AC_DEFINE_UNQUOTED([RELEASE_YEAR], ["$RELEASE_YEAR"],
52                   [Define year package was last modified])
53AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/.release_year'])
54
55AC_SUBST([SVNDIGEST_MAJOR_VERSION], [MAJOR_VERSION])
56AC_SUBST([SVNDIGEST_MINOR_VERSION], [MINOR_VERSION])
57AC_SUBST([SVNDIGEST_PATCH_VERSION], [PATCH_VERSION])
58
59AC_DEFINE([DEV_BUILD],[SVNDIGEST_DEV_BUILD],
60          [true if dev build (version ends with pre)])
61AC_DEFINE([SVNDIGEST_MAJOR_VERSION], [MAJOR_VERSION],
62                    [Define to the svndigest major version])
63AC_DEFINE([SVNDIGEST_MINOR_VERSION], [MINOR_VERSION],
64                    [Define to the svndigest minor version])
65AC_DEFINE([SVNDIGEST_PATCH_VERSION], [PATCH_VERSION],
66                    [Define to the svndigest patch version])
67
68AC_CONFIG_HEADER([config.h])
69AM_INIT_AUTOMAKE([1.10 std-options])
70
71dnl create bin/svndigest-copy-cache.in at autoconf time and let
72dnl config.status create bin/svndigest-copy-cache from
73dnl bin/svndigest-copy-cache.in
74m4_pushdef([FILE], [svndigest-copy-cache])
75m4_pushdef([my_m4sh_options], [-m 0644])
76dnl me cd down in bin to have same output as when created from Makefile
77m4_syscmd([cd bin && autom4te -l M4sh -o ]FILE[.in ]my_m4sh_options FILE[.as])
78AC_CONFIG_FILES([bin/]FILE[], [chmod +x bin/]FILE[ && chmod a-w bin/]FILE[])
79dnl export options so we can use the same in Makefile
80AC_SUBST([M4SH_OPTIONS], ['my_m4sh_options'])
81m4_popdef([my_m4sh_options])
82m4_popdef([FILE])
83AM_MISSING_PROG([AUTOM4TE], [autom4te])
84
85# Set default programming language
86AC_LANG([C++])
87
88# propagate selected configure variables to DISTCHECK_CONFIGURE_FLAGS
89for var in CPPFLAGS CXX CXXFLAGS CXXCPP LDFLAGS LIBS; do
90  eval isset=\${$var+set}
91  if test "$isset" = 'set' ; then
92    eval val=$`echo $var`
93    DISTCHECK_CONFIGURE_FLAGS="${DISTCHECK_CONFIGURE_FLAGS}'${var}=${val}' "
94  fi
95done
96AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
97
98# Let user overide default CXXFLAGS
99if test "${CXXFLAGS+set}" != set; then
100  CXXFLAGS=""  # Setting CXXFLAGS here to prevent expansion in AC_PROG_CXX
101fi
102
103# Checks for programs.
104AC_PROG_CXXCPP
105AC_PROG_CXX
106AC_PROG_INSTALL
107AC_PROG_RANLIB
108AC_PROG_SED
109AC_PATH_PROG([HELP2MAN], [help2man], [no])
110AM_CONDITIONAL([HAVE_HELP2MAN], [test x$HELP2MAN != xno])
111# look for pkg-config
112PKG_PROG_PKG_CONFIG([0.23])
113
114# Save FLAGS
115APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
116APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
117
118# -Wno-long-long is needed to suppress compiler diagnostics regarding
119# using extension beyond the C++ standard (usage of non C++ standard
120# 'long long' types).
121YAT_CXX_ADD_FLAG([CXXFLAGS],[-pedantic -Wno-long-long])
122AC_TYPE_LONG_LONG_INT
123AS_IF([test x$ac_cv_type_long_long_int = xno],
124      [AC_MSG_ERROR([compiler does not support long long int])]
125     )
126
127AC_ARG_ENABLE([debug],
128  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
129
130AS_IF([test x$enable_debug = xyes],
131  [YAT_CXX_ADD_FLAG([CXXFLAGS],[-g -O])],
132  [YAT_CPP_ADD_FLAG([CPPFLAGS],[-DNDEBUG])
133   YAT_CXX_ADD_FLAG([CXXFLAGS],[-O3])])
134
135# Apache Portable Runtime (APR) API checks
136APR_FIND_APR(,,[1],[1 0])
137AS_IF([test "${with_apr+set}" = set],
138    [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-apr=$with_apr"]
139)
140if test "$apr_found" = "yes" ; then
141    APR_LIBS="`$apr_config --libs`"
142    apr_link_ld="`$apr_config --link-ld`"
143    for i in $apr_link_ld; do
144      AS_IF([test ${i:0:2} = "-l"],[APR_LIBS="$i $APR_LIBS"],
145            [YAT_LD_ADD_FLAG([APR_LDFLAGS], [$i])])
146    done
147    YAT_CPP_ADD_FLAG([APR_CPPFLAGS],[`$apr_config --includes --cppflags`])
148    save_CPPFLAGS=$CPPFLAGS
149    CPPFLAGS="$APR_CPPFLAGS $CPPFLAGS"
150    AC_CHECK_HEADER([apr_allocator.h],,[apr_found="no"])
151    CPPFLAGS=$save_CPPFLAGS
152fi
153AC_SUBST([APR_CPPFLAGS])
154AC_SUBST([APR_LDFLAGS])
155AC_SUBST([APR_LIBS])
156
157# Subversion API checks
158svn_found="yes"
159AC_ARG_WITH([svn],
160  [AS_HELP_STRING([--with-svn=DIR],[prefix for svn developer files [[PREFIX]]])],
161  [ AS_CASE([$withval], [yes|no],
162            [AC_MSG_ERROR([--with-svn requires a directory to be provided])])
163    AS_IF([test -d $with_svn], [],
164          [AC_MSG_ERROR([$with_svn: no such directory])])
165    # transform argument to absolute path
166    with_svn=`cd $with_svn && pwd`
167    DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-svn=$with_svn"
168    YAT_LD_ADD_FLAG([SVN_LDFLAGS], [-L$with_svn/lib])
169    YAT_CPP_ADD_FLAG([SVN_CPPFLAGS], [-I$with_svn/include])
170  ])
171# svn needs needs apr headers
172save_CPPFLAGS=$CPPFLAGS
173CPPFLAGS="$APR_CPPFLAGS $SVN_CPPFLAGS $CPPFLAGS"
174AC_CHECK_HEADER([subversion-1/svn_types.h],,[svn_found="no"])
175CPPFLAGS=$save_CPPFLAGS
176
177save_LDFLAGS=$LDFLAGS
178save_LIBS=$LIBS
179tmp_LIBS="$APR_LIBS $save_LIBS"
180LIBS=""
181LDFLAGS="$SVN_LDFLAGS $APR_LDFLAGS"
182AC_SEARCH_LIBS([svn_cmdline_setup_auth_baton],[svn_subr-1],
183               [], [svn_found="no"], [$tmp_LIBS])
184AC_SEARCH_LIBS([svn_ra_initialize],[svn_ra-1], [], [svn_found="no"],[$tmp_LIBS])
185AC_SEARCH_LIBS([svn_wc_adm_open3],[svn_wc-1], [], [svn_found="no"], [$tmp_LIBS])
186AC_SEARCH_LIBS([svn_diff_file_options_create],[svn_diff-1],[],
187               [svn_found="no"], [$tmp_LIBS])
188AC_SEARCH_LIBS([svn_client_log3],[svn_client-1],,[svn_found="no"], [$tmp_LIBS])
189SVN_LIBS=$LIBS
190LIBS=$save_LIBS
191LDFLAGS=$save_LDFLAGS
192AC_SUBST([SVN_CPPFLAGS])
193AC_SUBST([SVN_LDFLAGS])
194AC_SUBST([SVN_LIBS])
195
196
197# check if svnversion is installed
198AC_PATH_PROG([SVNVERSION], [svnversion], [no])
199
200# PLplot API checks
201# plplot_found can get values: skip, noheader, old, or nolib if an
202# error is detected.
203plplot_found="yes"
204plplot_version=5.9
205save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
206AC_ARG_WITH([plplot],
207  [AS_HELP_STRING([--with-plplot=DIR],[prefix for plplot developer files])],
208  [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-plplot=$withval"
209   AS_IF([test "x$withval" = "xno"], [ dnl
210     plplot_found=skip;
211   ], [ dnl
212     AS_IF([test -d $with_plplot], [],
213           [AC_MSG_ERROR([$with_plplot: no such directory])])
214     with_plplot=`cd $with_plplot && pwd`
215     # help pkg-config find .pc file
216     PKG_CONFIG_PATH=$with_plplot/lib/pkgconfig$PATH_SEPARATOR$PKG_CONFIG_PATH
217     export PKG_CONFIG_PATH
218   ])
219  ])
220
221use_plplot_pc="no"
222AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
223  AC_MSG_CHECKING([for plplotd-c++.pc])
224  AS_IF([$PKG_CONFIG --exists plplotd-c++], [
225    AC_MSG_RESULT([yes])
226    use_plplot_pc="yes"
227  ],[
228    AC_MSG_RESULT([no])
229    AC_MSG_WARN([cannot find plplotd-c++;
230      please use --with-plplot with appropriate argument to get more accurate
231      configuration.])
232  ])
233])
234
235AS_IF([test "x$plplot_found" = "xyes"], [
236  # copy flags if we have found pc file
237  AS_IF([test "$use_plplot_pc" = "yes"], [
238    YAT_CPP_ADD_FLAG([PLPLOT_CPPFLAGS], [`$PKG_CONFIG plplotd-c++ --cflags`])
239    YAT_LD_ADD_FLAG([PLPLOT_LDFLAGS], [`$PKG_CONFIG plplotd-c++ --libs-only-L`])
240    PLPLOT_LIBS="`$PKG_CONFIG plplotd-c++ --libs-only-l --libs-only-other`"
241  ],[
242    # otherwise guess
243    PLPLOT_LIBS="-lplplotcxxd -lplplotd";
244    AS_IF([test -n "$with_plplot" && test "x$with_plplot" != "xyes"], [
245      YAT_CPP_ADD_FLAG([PLPLOT_CPPFLAGS], [$with_plplot/include])
246      YAT_LD_ADD_FLAG([PLPLOT_LDFLAGS], [$with_plplot/libs])
247    ])
248  ])
249])
250                 
251AS_IF([test "x$plplot_found" = "xyes"], [
252  save_CPPFLAGS=$CPPFLAGS
253  CPPFLAGS="$PLPLOT_CPPFLAGS $CPPFLAGS"
254  AC_CHECK_HEADER([plplot/plstream.h], [], [plplot_found="noheader"])
255  CPPFLAGS=$save_CPPFLAGS
256])
257
258
259AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
260  AC_MSG_CHECKING([plplot version >= $plplot_version])
261  AS_IF([$PKG_CONFIG --atleast-version=$plplot_version plplotd-c++], [
262    AC_MSG_RESULT([yes])
263  ],[
264    AC_MSG_RESULT([`$PKG_CONFIG --modversion= plplotd-c++`])
265    plplot_found="old"
266  ])
267])
268
269AS_IF([test "x$plplot_found" = "xyes"], [
270  save_LDFLAGS=$LDFLAGS
271  LDFLAGS="$PLPLOT_LDFLAGS $LDFLAGS"
272  save_LIBS=$LIBS
273  LIBS="$PLPLOT_LIBS $LIBS"
274  AC_MSG_CHECKING([for library containing plstream])
275  AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <plplot/plstream.h>],
276                                  [plstream pls(1,1,"svg", "conftest.svg")])],
277                 [AC_MSG_RESULT([yes]);
278                  AC_DEFINE([HAVE_PLPLOT], [1],
279                            [Define to 1 if you have plplot])],
280                 [AC_MSG_RESULT([no])
281                  plplot_found=nolib;])
282])
283# restore variable
284LDFLAGS=$save_LDFLAGS
285LIBS=$save_LIBS
286export PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
287AC_SUBST(PLPLOT_CPPFLAGS)
288AC_SUBST(PLPLOT_LDFLAGS)
289AC_SUBST(PLPLOT_LIBS)
290
291# checking if we build in a subversion WC
292AS_IF([test -d $srcdir/.svn], [wc_found="yes"], [wc_found="no"])
293AM_CONDITIONAL([HAVE_SVN_WC], [test "$wc_found" = "yes"])
294AC_SUBST([wc_found])
295
296# checking if we have test repo
297test_repo_filename=$srcdir/test/repo;
298AS_IF([test -r $test_repo_filename],
299              [AC_DEFINE([HAVE_TEST_REPO],[1],[define if test repo is available])
300               test_repo_found="yes"],
301              [test_repo_found="no"])
302AC_SUBST([test_repo_found])
303AS_IF([test "x$test_repo_found" = xyes],
304      [abs_test_repo=`cd $test_repo_filename && pwd`;
305       AC_SUBST(abs_test_repo)]
306     )
307AC_CONFIG_FILES([test/init.sh])
308AC_CONFIG_FILES([test/svn_update.sh], [chmod +x test/svn_update.sh])
309
310dnl maintainer make rukes from yat project
311YAT_SVN_RELEASE
312
313# Restore FLAGS
314APR_RESTORE_THE_ENVIRONMENT([CPPFLAGS], [DEFAULT_])
315APR_RESTORE_THE_ENVIRONMENT([CXXFLAGS], [DEFAULT_])
316
317AC_CONFIG_FILES([Makefile
318                bin/Makefile
319                lib/Makefile
320                lib/yat/Makefile
321                man/Makefile
322                test/environment.h
323                test/Makefile])
324
325AC_CONFIG_HEADER([lib/yat/config_public.h])
326
327# Print failure status information about selected items, and exit if
328# fatal errors were encountered. No output will be created if
329# configure is halted prematurely.
330
331# used to trigger exit before creation of output
332all_reqs_ok="true"
333
334if (test "$wc_found" = "yes"); then
335   if test x$HELP2MAN = xno; then
336     AC_MSG_WARN(m4_text_wrap(m4_normalize([
337       `help2man' is missing on your system.  You will not be
338       able to create the man page. A sound man page should be
339       included in a distribution, and since you will not able
340       to create a complete distribution `make dist' will fail.
341       ]),[                   ],
342          [                             ], 79))
343   fi
344   # svnversion is required when building from svn wc
345   if (test "$svnversion" = "no"); then
346      all_reqs_ok="false";
347      AC_MSG_WARN([dnl
348Cannot find svnversion, which is required when building from a
349subversion working copy. Please install svnversion and make sure it is
350in your search path.]);
351   fi
352   if (test "$test_repo_found" = "no"); then
353      all_reqs_ok="false";
354      AC_MSG_WARN([dnl
355Cannot find test repository (test_repo_filename), which should be
356available when building from a subversion working copy. Try svn
357update in top directory.]);
358   fi
359fi
360
361# Non-existing APR is fatal -- sub-sequent compilation will fail.
362if (test "$apr_found" = "no") ; then
363  AC_MSG_WARN([APR not found. The Apache Portable Runtime
364  (APR) library cannot be found. Please make sure APR is installed
365  and supply the appropriate --with-apr option to 'configure'.])
366  all_reqs_ok="false"
367fi
368
369# Non-existing subversion API is fatal -- sub-sequent compilation will fail.
370if (test "$svn_found" = "no") ; then
371  svn_msg="Subversion API not found. Subversion API libraries cannot
372  be found. Make sure the APIs are installed and supply the
373  appropriate --with-svn option to 'configure'."
374  if (test "$apr_found" = "no") ; then
375    svn_msg="$svn_msg
376    Note, APR was not found. Failure to locate APR affects the search
377    of the subversion API. Please fix the APR problem before trying
378    to resolve the subversion related issues."
379  fi
380  AC_MSG_WARN([$svn_msg])
381  all_reqs_ok="false"
382fi
383
384# Non-existing PLplot API is fatal -- sub-sequent compilation will fail.
385AS_CASE([$plplot_found],
386  [noheader],
387    [AC_MSG_WARN([
388    PLplot developer files cannot be found. Make sure PLplot is installed.])
389    all_reqs_ok="false"],
390  [old],
391    [AC_MSG_WARN([
392    PLplot developer files found but not required API version.
393    Version at least $plplot_version is required. Please upgrade PLplot.])
394    all_reqs_ok="false"],
395  [nolib],
396    [AC_MSG_WARN([
397    PLplot developer files found but linking against plplot library failed.])
398    all_reqs_ok="false"])
399
400if test $ac_cv_type_long_long_int != yes ; then
401  AC_MSG_WARN([Compiler $CXX does not support `long long'.
402  svndigest must be compiled with a compiler that supports `long long'.])
403  all_reqs_ok="false"
404fi
405
406if (test "$all_reqs_ok" = "false") ; then
407  AC_MSG_ERROR([Some pre-requisites were not fulfilled, aborting
408  configure. Please consult the 'README' file for more information
409  about what is needed to compile svndigest and refer to above
410  warning messages. Needed files were NOT created.])
411fi
412
413# Create output.
414AC_OUTPUT
415
416# Some more messages.
417AC_MSG_NOTICE([
418Ready to compile the executables of svndigest $VERSION
419The following flags and libs will be used:
420+++++++++++++++++++++++++++++++++++++++++++++++
421  Compiler:           $CXX
422  Preprocessor flags: $SD_CPPFLAGS $CPPFLAGS
423    CPPFLAGS:         $CPPFLAGS
424    DEFAULT_CPPFLAGS: $DEFAULT_CPPFLAGS
425    APR_CPPFLAGS:     $APR_CPPFLAGS
426    SVN_CPPFLAGS:     $SVN_CPPFLAGS
427    PLPLOT_CPPFLAGS:  $PLPLOT_CPPFLAGS
428  C++ flags:
429    CXXFLAGS:         $CXXFLAGS
430    DEFAULT_CXXFLAGS: $DEFAULT_CXXFLAGS
431  Linker flags:
432    LDFLAGS:          $LDFLAGS
433    APR_LDFLAGS:      $APR_LDFLAGS
434    SVN_LDFLAGS:      $SVN_LDFLAGS
435    PLPLOT_LDFLAGS:   $PLPLOT_LDFLAGS
436  Libraries:         
437    LIBS              $LIBS
438    APR_LIBS          $APR_LIBS
439    SVN_LIBS          $SVN_LIBS
440    PLPLOT_LIBS       $PLPLOT_LIBS
441+++++++++++++++++++++++++++++++++++++++++++++++]dnl
442)
443
444AC_MSG_NOTICE([Now type 'make all check'.])
Note: See TracBrowser for help on using the repository browser.