source: trunk/configure.ac @ 690

Last change on this file since 690 was 690, checked in by Peter Johansson, 13 years ago

improved syntax for svnversion detection

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.8 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 690 2008-09-07 17:26:28Z 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 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 2 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 this program; if not, write to the Free Software
30# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
31# 02111-1307, USA.
32
33AC_PREREQ(2.60)
34
35
36m4_include([./build_support/version.m4])
37AC_INIT([svndigest],[SVNDIGEST_VERSION],[jari@thep.lu.se])
38AC_CONFIG_SRCDIR([lib/File.h])
39AC_CONFIG_AUX_DIR([autotools])
40AC_PREFIX_DEFAULT([/usr/local])
41test $prefix = NONE && prefix=/usr/local
42
43AC_SUBST([SVNDIGEST_MAJOR_VERSION], [MAJOR_VERSION])
44AC_SUBST([SVNDIGEST_MINOR_VERSION], [MINOR_VERSION])
45AC_SUBST([SVNDIGEST_PATCH_VERSION], [PATCH_VERSION])
46
47AC_DEFINE([DEV_BUILD],[SVNDIGEST_DEV_BUILD],
48          [true if dev build (version starts with pre)])
49AC_DEFINE([SVNDIGEST_MAJOR_VERSION], [MAJOR_VERSION],
50                    [Define to the svndigest major version])
51AC_DEFINE([SVNDIGEST_MINOR_VERSION], [MINOR_VERSION],
52                    [Define to the svndigest minor version])
53AC_DEFINE([SVNDIGEST_PATCH_VERSION], [PATCH_VERSION],
54                    [Define to the svndigest patch version])
55
56AC_CONFIG_HEADER([config.h])
57AM_INIT_AUTOMAKE([std-options check-news])
58
59# seems like these variables are not set with older autoconf(?)
60AC_SUBST([abs_srcdir], ["`cd $srcdir && pwd`"])
61AC_SUBST([abs_builddir], ["`pwd`"])
62
63# Set default programming language
64AC_LANG(C++)
65
66# Let user overide default CXXFLAGS
67if test "${CXXFLAGS+set}" != set; then
68  CXXFLAGS=""  # Setting CXXFLAGS here to prevent expansion in AC_PROG_CXX
69fi
70
71# Checks for programs.
72AC_PROG_CXXCPP
73AC_PROG_CXX
74AC_PROG_INSTALL
75AC_PROG_RANLIB
76AC_PROG_SED
77AC_CHECK_PROG([GNUPLOT],[gnuplot],[ok])
78
79# Save FLAGS
80SAVE_CPPFLAGS="$CPPFLAGS"
81SAVE_CXXFLAGS="$CXXFLAGS"
82SAVE_LDFLAGS="$LDFLAGS"
83SAVE_LIBS="$LIBS"
84
85# -Wno-long-long is needed to suppress compiler diagnostics regarding
86# using extension beyond the C++ standard (usage of non C++ standard
87# 'long long' types).
88SD_CXXFLAGS="$SD_CXXFLAGS-Wall -pedantic -Wno-long-long"
89AC_TYPE_LONG_LONG_INT()
90
91AC_ARG_ENABLE(debug,
92  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])],
93  [SD_CXXFLAGS="$SD_CXXFLAGS -g -O"],
94  [SD_CPPFLAGS="-DNDEBUG" SD_CXXFLAGS="$SD_CXXFLAGS -O3"])
95
96# Apache Portable Runtime (APR) API checks
97# The next three lines are not needed as long as APR_FIND_APR is used.
98# AC_ARG_WITH(apr,
99#  [  --with-apr=DIR          prefix for installed APR or path to APR build
100#                          tree [[PREFIX]]])
101# Include APR_FIND_APR macro distributed within the APR project. If
102# the usage of the APR macro is to be omitted then the construct for
103# setting the CXXFLAGS (header file location) and LDFLAGS (linking
104# informaion) for APR must be changed. The latter can be achieved with
105# AC_SEARCH_LIBS([apr_allocator_create],[apr-0],,apr_found="no") but
106# apr-0 must be prior knowledge.
107m4_sinclude(./build_support/find_apr.m4)
108APR_FIND_APR(,,1,[1 0])
109if test "$apr_found" = "yes" ; then
110    SD_LIBS="`$apr_config --libs` $SD_LIBS"
111    SD_LDFLAGS="`$apr_config --link-ld` $SD_LDFLAGS"
112    SD_CPPFLAGS="`$apr_config --includes --cppflags` $SD_CPPFLAGS"
113fi
114
115# Subversion API checks
116svn_found="yes"
117AC_ARG_WITH(svn,
118  [AS_HELP_STRING([--with-svn=DIR],[prefix for svn developer files [[PREFIX]]])],
119  [ SD_LDFLAGS="-L$withval/lib $SD_LDFLAGS"
120    SD_CPPFLAGS="-I$withval/include $SD_CPPFLAGS"])
121
122
123# Use SD_*FLAGS in tests
124CPPFLAGS="$SD_CPPFLAGS $CPPFLAGS"
125CXXFLAGS="$SD_CXXFLAGS $CXXFLAGS"
126LDFLAGS="$SD_LDFLAGS $LDFLAGS"
127LIBS="$SD_LIBS $LIBS"
128
129AC_CHECK_HEADER([apr_allocator.h],,apr_found="no")
130AC_CHECK_HEADER([subversion-1/svn_types.h],,svn_found="no")
131AC_SEARCH_LIBS([svn_cmdline_setup_auth_baton],[svn_subr-1],
132               [SD_LIBS="-lsvn_subr-1 $SD_LIBS"],svn_found="no")
133AC_SEARCH_LIBS([svn_ra_initialize],[svn_ra-1],
134               [SD_LIBS="-lsvn_ra-1 $SD_LIBS"],svn_found="no")
135AC_SEARCH_LIBS([svn_wc_adm_open3],[svn_wc-1],
136               [SD_LIBS="-lsvn_wc-1 $SD_LIBS"],svn_found="no")
137AC_SEARCH_LIBS([svn_diff_file_options_create],[svn_diff-1],
138               [SD_LIBS="-lsvn_diff-1 $SD_LIBS"],svn_found="no")
139AC_SEARCH_LIBS([svn_client_log3],[svn_client-1],
140               [SD_LIBS="-lsvn_client-1 $SD_LIBS"],svn_found="no")
141
142# Export flags
143AC_SUBST([SVNDIGEST_CPPFLAGS], $SD_CPPFLAGS)
144AC_SUBST([SVNDIGEST_CXXFLAGS], $SD_CXXFLAGS)
145AC_SUBST([SVNDIGEST_LDFLAGS], $SD_LDFLAGS)
146AC_SUBST([SVNDIGEST_LIBS], $SD_LIBS)
147
148# Reset FLAGS
149CPPFLAGS="$SAVE_CPPFLAGS"
150CXXFLAGS="$SAVE_CXXFLAGS"
151LDFLAGS="$SAVE_LDFLAGS"
152LIBS="$SAVE_LIBS"
153
154# check if svnversion is installed
155AC_PATH_PROG([SVNVERSION], [svnversion], [no])
156
157# checking if we build in a subversion WC
158wc_found="no";
159if (test "$SVNVERSION" != "no" &&
160  test `$SVNVERSION -n $srcdir` != "exported");
161then
162  wc_found="yes";
163fi
164AC_CHECK_FILE("$srcdir/lib/subversion_info.cc",info_found="yes",info_found="no")
165
166# checking that DEV_BUILD is set to false at time of release
167# Failure should be captured by distcheck
168if (test "$wc_found" = "no" && test "$SVNDIGEST_DEV_BUILD" = "true") ; then
169  AC_MSG_ERROR([Incorrect version:
170               [SVNDIGEST_DEV_BUILD] is set to SVNDIGEST_DEV_BUILD.
171         [SVNDIGEST_DEV_BUILD] should be set to false at time of release.
172               Please, update version.m4.])
173fi
174
175
176# devel version should have svn WC and SVNVERSION installed
177AM_CONDITIONAL(HAVE_SVN_WC, test "$wc_found" = "yes" )
178
179
180AC_CONFIG_FILES([Makefile
181                bin/Makefile
182                lib/Makefile
183                test/environment.h
184                test/Makefile])
185
186# Print failure status information about selected items, and exit if
187# fatal errors were encountered. No output will be created if
188# configure is halted prematurely.
189
190# used to trigger exit before creation of output
191all_reqs_ok="true"
192
193if (test "$wc_found" != "yes") ; then
194if (test "$info_found" = "no") ; then
195   AC_MSG_WARN([Cannot find sources (lib/subversion_info.cc).])
196   if (test "$svnversion" = "no") ; then
197     AC_MSG_WARN([If you grabbed the source from the subversion repository,
198     the file will be generated automatically. However, svnversion cannot
199     be found and therefore the file cannot be generated. Please install
200     svnversion and make sure it is in your search path.])
201   else
202     AC_MSG_WARN([If you grabbed the source from the subversion repository,
203     the file will be generated automatically. However, the output from
204     svnversion was incorrect. Either your installation of svnversion is
205     is not healthy or there is something wrong with the repository.])
206   fi
207   all_reqs_ok="false"
208fi
209else
210  dnl test repo is not distributed
211  AC_CONFIG_FILES([test/test_repo.sh], [chmod +x test/test_repo.sh])
212  AC_CONFIG_FILES([test/check_repo_status.sh], [chmod +x test/check_repo_status.sh])   
213fi
214
215# Non-existing APR is fatal -- sub-sequent compilation will fail.
216if (test "$apr_found" = "no") ; then
217  AC_MSG_WARN([APR not found. The Apache Portable Runtime
218  (APR) library cannot be found. Please make sure APR is installed
219  and supply the appropriate --with-apr option to 'configure'.])
220  all_reqs_ok="false"
221fi
222
223# Non-existing subversion API is fatal -- sub-sequent compilation will fail.
224if (test "$svn_found" = "no") ; then
225  svn_msg="Subversion API not found. Subversion API libraries cannot
226  be found. Make sure the APIs are installed and supply the
227  appropriate --with-svn option to 'configure'."
228  if (test "$apr_found" = "no") ; then
229    svn_msg="$svn_msg
230    Note, APR was not found. Failure to locate APR affects the search
231    of the subversion API. Please fix the APR problem before trying
232    to resolve the subversion related issues."
233  fi
234  AC_MSG_WARN([$svn_msg])
235  all_reqs_ok="false"
236fi
237
238if test $ac_cv_type_long_long_int != yes ; then
239  AC_MSG_WARN([Compiler $CXX does not support `long long'.
240  svndigest must be compiled with a compiler that supports `long long'.])
241  all_reqs_ok="false"
242fi
243
244if (test "$all_reqs_ok" = "false") ; then
245  AC_MSG_ERROR([Some pre-requisites were not fulfilled, aborting
246  configure. Please consult the 'README' file for more information
247  about what is needed to compile svndigest and refer to above
248  warning messages. Needed files were NOT created.])
249fi
250
251# Create output.
252AC_OUTPUT
253
254# Some more messages.
255AC_MSG_NOTICE([])
256AC_MSG_NOTICE([   Ready to compile the executables of svndigest $VERSION])
257AC_MSG_NOTICE([   The following flags and libs will be used:])
258AC_MSG_NOTICE([   +++++++++++++++++++++++++++++++++++++++++++++++])
259AC_MSG_NOTICE([    Compiler:           $CXX])
260AC_MSG_NOTICE([    Preprocessor flags: $SD_CPPFLAGS $CPPFLAGS])
261AC_MSG_NOTICE([    C++ flags:          $SD_CXXFLAGS $CXXFLAGS])
262AC_MSG_NOTICE([    Linker flags:       $SD_LDFLAGS $LDFLAGS])
263AC_MSG_NOTICE([    LIBS:               $SD_LIBS $LIBS])
264AC_MSG_NOTICE([   +++++++++++++++++++++++++++++++++++++++++++++++])
265AC_MSG_NOTICE([])
266
267# Failure to locate gnuplot is not considered fatal
268if (test "$GNUPLOT" != "ok") ; then
269  AC_MSG_WARN([Gnuplot was not found. svndigest will compile
270  without gnuplot but will throw an exception at run-time. Please
271  install gnuplot (available for a wide range of operating systems
272  at http://www.gnuplot.info).])
273  AC_MSG_NOTICE([])
274fi
275
276AC_MSG_NOTICE([Now type 'make ; make check'.])
Note: See TracBrowser for help on using the repository browser.