Initial revision
[bbkeys.git] / configure.ac
blobecf56ce96f3d3693fc1e8cdfc6792b1de17ed5a3
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(src/main.cpp)
3 AM_INIT_AUTOMAKE(bbkeys, 0.9.0pre)
4 AM_MAINTAINER_MODE
5 AC_PREFIX_DEFAULT(/usr/local)
7 AC_CHECK_PROGS(regex_cmd, sed)
8 if test x$regex_cmd = "x"; then
9  AC_MSG_ERROR([error. sed is required to build the default bbtoolsrc file.])
12 dnl get the debug values right
13 AC_DEFUN(AC_SET_DEBUG,
15   _CFLAGS="-g -Wall -DDEBUG"
16   _CXXFLAGS="-g -Wall -DDEBUG"
17   _LDFLAGS=""
18   case $host_os in
19   [*solaris*)]
20     dnl On solaris, we get a ton of multiply-defined errors if we don't include
21     dnl this parameter
22     _LDFLAGS="$_LDFLAGS -z muldefs"
23     ;;
24   esac
25   test "$CFLAGS" = "" && CFLAGS=$_CFLAGS
26   test "$CXXFLAGS" = "" && CXXFLAGS=$_CXXFLAGS
27   test "$LDFLAGS" = "" && LDFLAGS=$_LDFLAGS
30 AC_DEFUN(AC_SET_NODEBUG,
32   _CFLAGS="-DNDEBUG"
33   _CXXFLAGS="-DNDEBUG"
34   _LDFLAGS=""
35   case $host_os in
36   [*solaris*)]
37      _CFLAGS="$_CFLAGS -O"
38      _CXXFLAGS="$_CXXFLAGS -O"
39      dnl On solaris, we get a ton of multiply-defined errors if we don't include
40      dnl this parameter
41      _LDFLAGS="$_LDFLAGS -z muldefs"
42      ;;
43   [*)]
44      _CFLAGS="$_CFLAGS -O2"
45      _CXXFLAGS="$_CXXFLAGS -O2"
46      ;;
47   esac
48   test "$CFLAGS" = "" && CFLAGS=$_CFLAGS
49   test "$CXXFLAGS" = "" && CXXFLAGS=$_CXXFLAGS
50   test "$LDFLAGS" = "" && LDFLAGS=$_LDFLAGS
53 AC_ARG_ENABLE(debug,[  --enable-debug   create debugging code [default=no]],
55 if test $enableval = "no";
56  then AC_SET_NODEBUG
57  else AC_SET_DEBUG
60 AC_SET_NODEBUG)
62 dnl Checks for programs.
63 AC_PROG_CC
64 AC_PROG_CXX
65 AC_PROG_CPP
66 AC_PROG_AWK
67 AC_PROG_INSTALL
68 AC_PROG_LN_S
69 AC_PROG_MAKE_SET
70 AC_PROG_RANLIB
72 dnl minimum version we can live with
73 PERL_VERSION=5.004
74 dnl check for perl for our command-line configurator
75 AC_PATH_PROGS(PERL, $PERL perl5 perl )
76 if test -z "$PERL" || test "$PERL" = ":"; then
77     AC_MSG_ERROR([perl not found in \$PATH])
80 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
81 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
82 _perl_res=$?
83 AC_MSG_RESULT([$_perl_version])
85 if test "$_perl_res" != 0; then
86     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
89 AC_MSG_CHECKING([for full perl installation])
90 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
91 _perl_res=$?
92 if test "$_perl_res" != 0; then
93     AC_MSG_RESULT([no])
94     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
95 else
96     AC_MSG_RESULT([yes])    
100 # Checks for header files.
101 AC_PATH_X
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 check for blackbox library and headers
135 blackbox_inc=""
136 AC_MSG_CHECKING([for blackbox headers])
137 AC_ARG_WITH(bt-includes,
138         AC_HELP_STRING([--with-bt-includes], [blackbox library headers]),
139         ac_blackbox_inc=$withval, ac_blackbox_inc="")
141 # if the blackbox headers directory was specified, make sure we have it
142 for btdir in $ac_blackbox_inc /usr/local /usr/lib /usr; do
143     if test -f "$btdir/Application.hh"; then
144        blackbox_inc=$btdir
145        break
146     fi
147 done
149 if test -z "$blackbox_inc"; then
150    AC_MSG_RESULT([Not found])
151    echo 
152    echo "Couldn't find your blackbox library headers."
153    echo "Use --with-bt-includes=dir option to fix this."
154    echo 
155    exit 1
158 AC_MSG_RESULT([$blackbox_inc])
160 CXXFLAGS="$CXXFLAGS -I$blackbox_inc"
161 dnl for the time being, assume the lib is in the same spot as the headers
162 LIBS="$LIBS -L$blackbox_inc -lbt"
164 dnl generate the config header
165 AM_CONFIG_HEADER(config.h) 
167 dnl Print results
168 AC_MSG_RESULT([])
169 AC_MSG_RESULT([ $PACKAGE version $VERSION configured successfully.])
170 AC_MSG_RESULT([])
171 AC_MSG_RESULT([Using '$prefix' for installation.])
172 AC_MSG_RESULT([Using '$CXX' for C++ compiler.])
173 AC_MSG_RESULT([Building with '$CXXFLAGS' for C++ compiler flags.])
174 AC_MSG_RESULT([Building with '$LIBS' for linker flags.])
175 AC_MSG_RESULT([])
178 dnl Output files
179 AC_OUTPUT( \
180 version.h \
181 Makefile \
182 src/Makefile \
183 doc/Makefile \
184 data/Makefile \
185 doc/bbkeys.1 \