Lower the AC_PREREQ version 2.59
[bbkeys.git] / configure.ac
blob55ee07fb481c2ad4c9e38a13a1c36c5d60d2122e
1 dnl Process this file with autoconf to produce a configure script.
2 dnl Minimum Autoconf version required.
3 AC_INIT([bbkeys], [1.0.0git], [http://bbkeys.sourceforge.net])
4 AC_PREREQ(2.59)
5 AC_CONFIG_SRCDIR([src/main.cpp])
6 AM_INIT_AUTOMAKE
7 AM_MAINTAINER_MODE
8 AC_PREFIX_DEFAULT([/usr/local])
10 AC_CHECK_PROGS(regex_cmd, sed)
11 if test x$regex_cmd = "x"; then
12  AC_MSG_ERROR([error. sed is required to build the default bbtoolsrc file.])
15 dnl get the debug values right
16 AC_DEFUN([AC_SET_DEBUG],
18   _CFLAGS="-g -Wall -DDEBUG"
19   _CXXFLAGS="-g -Wall -DDEBUG"
20   _LDFLAGS=""
21   case $host_os in
22   [*solaris*)]
23     dnl On solaris, we get a ton of multiply-defined errors if we don't include
24     dnl this parameter
25     _LDFLAGS="$_LDFLAGS -z muldefs"
26     ;;
27   esac
28   test "$CFLAGS" = "" && CFLAGS=$_CFLAGS
29   test "$CXXFLAGS" = "" && CXXFLAGS=$_CXXFLAGS
30   test "$LDFLAGS" = "" && LDFLAGS=$_LDFLAGS
33 AC_DEFUN([AC_SET_NODEBUG],
35   _CFLAGS="-DNDEBUG"
36   _CXXFLAGS="-DNDEBUG"
37   _LDFLAGS=""
38   case $host_os in
39   [*solaris*)]
40      _CFLAGS="$_CFLAGS -O"
41      _CXXFLAGS="$_CXXFLAGS -O"
42      dnl On solaris, we get a ton of multiply-defined errors if we don't include
43      dnl this parameter
44      _LDFLAGS="$_LDFLAGS -z muldefs"
45      ;;
46   [*)]
47      _CFLAGS="$_CFLAGS -O2"
48      _CXXFLAGS="$_CXXFLAGS -O2"
49      ;;
50   esac
51   test "$CFLAGS" = "" && CFLAGS=$_CFLAGS
52   test "$CXXFLAGS" = "" && CXXFLAGS=$_CXXFLAGS
53   test "$LDFLAGS" = "" && LDFLAGS=$_LDFLAGS
56 AC_ARG_ENABLE([debug],
57               [AS_HELP_STRING([--enable-debug],
58                               [create debugging code @<:@default=no@:>@])],
59         [
60         if test $enableval = "no";
61          then AC_SET_NODEBUG
62          else AC_SET_DEBUG
63         fi
64         ],
65         [AC_SET_NODEBUG])
67 dnl Checks for programs.
68 AC_PROG_CC
69 AC_PROG_CXX
70 AC_PROG_CPP
71 AC_PROG_AWK
72 AC_PROG_INSTALL
73 AC_PROG_LN_S
74 AC_PROG_MAKE_SET
76 dnl minimum version we can live with
77 PERL_VERSION=5.004
78 dnl check for perl for our command-line configurator
79 AC_PATH_PROGS(PERL, $PERL perl5 perl )
80 if test -z "$PERL" || test "$PERL" = ":"; then
81     AC_MSG_ERROR([perl not found in \$PATH])
84 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
85 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
86 _perl_res=$?
87 AC_MSG_RESULT([$_perl_version])
89 if test "$_perl_res" != 0; then
90     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
93 AC_MSG_CHECKING([for full perl installation])
94 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
95 _perl_res=$?
96 if test "$_perl_res" != 0; then
97     AC_MSG_RESULT([no])
98     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
99 else
100     AC_MSG_RESULT([yes])
104 # Checks for header files.
105 AC_PATH_XTRA
106 AC_HEADER_STDC
107 AC_HEADER_SYS_WAIT
108 AC_CHECK_HEADERS(ctype.h strings.h fcntl.h libgen.h locale.h process.h signal.h stdio.h time.h errno.h unistd.h sys/signal.h sys/param.h sys/select.h sys/stat.h sys/time.h sys/types.h sys/wait.h stdlib.h string.h malloc.h)
110 # Checks for typedefs, structures, and compiler characteristics.
111 AC_C_CONST
112 AC_C_INLINE
113 AC_HEADER_TIME
114 AC_STRUCT_TM
116 # Checks for library functions.
117 dnl AC_FUNC_FORK
118 dnl AC_FUNC_MALLOC
119 AC_TYPE_SIGNAL
120 dnl AC_FUNC_STAT
121 AC_CHECK_FUNCS(setlocale sigaction strftime gettimeofday memset strcasecmp strchr strcspn strdup strncasecmp select strstr)
123 dnl these have to be here for X tests...
124 CFLAGS="$CFLAGS $X_CFLAGS"
125 CXXFLAGS="$CXXFLAGS $X_CFLAGS"
126 LDFLAGS="$LDFLAGS $X_LIBS $X_PRE_LIBS"
129 dnl Checks for X libraries.
130 AC_CHECK_LIB(X11, XOpenDisplay, LIBS="-lX11",
131              AC_MSG_ERROR(XOpenDisplay not found in -lX11))
133 dnl Checks for Xextension
134 AC_CHECK_LIB(Xext, XMissingExtension, LIBS="$LIBS -lXext",
135              AC_MSG_ERROR(XMissingExtension not found in -lXext))
137 dnl pkgconfig checks for blackbox library
138 PKG_CHECK_MODULES(LIBBT, libbt)
139 CXXFLAGS="$CXXFLAGS $LIBBT_CFLAGS"
140 LIBS="$LIBS $LIBBT_LIBS"
142 dnl generate the config header
143 AC_CONFIG_HEADERS([config.h])
145 dnl Output files
146 AC_CONFIG_FILES([
147 version.h
148 Makefile
149 src/Makefile
150 doc/Makefile
151 data/Makefile
152 doc/bbkeys.1
153 rpm/Makefile
154 rpm/bbkeys.spec
156 AC_OUTPUT
158 dnl Print results
159 AC_MSG_RESULT([])
160 AC_MSG_RESULT([ $PACKAGE version $VERSION configured successfully.])
161 AC_MSG_RESULT([])
162 AC_MSG_RESULT([Using '$prefix' for installation.])
163 AC_MSG_RESULT([Using '$CXX' for C++ compiler.])
164 AC_MSG_RESULT([Building with '$CXXFLAGS' for C++ compiler flags.])
165 AC_MSG_RESULT([Building with '$LDFLAGS' for linker flags.])
166 AC_MSG_RESULT([Building with '$LIBS' libraries.])
167 AC_MSG_RESULT([])