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