* Skeleton build for 'ctdlsh' utility. Warning: this is extremely gnuuey, it's got...
[citadel.git] / ctdlsh / configure.ac
1 # Copyright (C) 2006 Free Software Foundation, Inc.
2 # This configure.ac script is free software; the Free Software Foundation
3 # gives unlimited permission to copy, distribute and modify it.
4
5 AC_INIT([ctdlsh], [1.0], [bug-automake@gnu.org])
6 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
7 AC_PROG_CC
8 AC_CONFIG_HEADERS([config.h])
9
10 ##########################################################################
11 # adding the readline library (e.g. with static name 'libreadline.a')
12 ##########################################################################
13
14 # adding the lib to the files to link
15 LIBS="-lreadline $LIBS"
16
17 # introduce the optional configure parameter for a non-standard install prefix of readline
18 AC_ARG_WITH([readline],
19     [AS_HELP_STRING([--with-readline=prefix],
20         [try this for a non-standard install prefix of the readline library])],
21     [readlinePATHSET=1],
22     [readlinePATHSET=0])
23         
24 # if optional parameter used, extend path flags for compliler and linker
25 if test $readlinePATHSET = 1 ; then
26     # extend the compiler and linker flags according to the path set
27     AM_CXXFLAGS="$AM_CXXFLAGS -I$with_readline/include"
28     AM_LDFLAGS="$AM_LDFLAGS -L$with_readline/lib"
29 fi
30
31 ##########################################################################
32
33
34 ##########################################################################
35 # check for readline library
36 ##########################################################################
37
38 # store current *FLAGS and merge with AM_*FLAGS for compilation and linker check   
39 OLD_CXXFLAGS=$CXXFLAGS;
40 OLD_LDFLAGS=$LDFLAGS;
41 CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
42 LDFLAGS="$AM_LDFLAGS $LDFLAGS"
43
44 # ensure the library to check for is covered by the LIBS variable
45 OLD_LIBS=$LIBS
46 LIBS="$LIBS -lreadline"
47
48 # check for readline library headers   
49 AC_MSG_CHECKING([for the readline library headers])
50 # try to compile a file that includes a header of the library readline
51 AC_COMPILE_IFELSE([[#include <readline/readline.h>]],
52     [AC_MSG_RESULT([found])
53         # try to link the function 'rl_initialize' out of library readline
54         AC_MSG_CHECKING([whether the readline library can be linked])
55         AC_LINK_IFELSE(
56             [AC_LANG_PROGRAM([[#include <readline/readline.h>]],
57                 [[rl_initialize();]])],
58             [AC_MSG_RESULT([yes])
59                 FOUND_readline=1;],
60             [AC_MSG_RESULT([no])
61                 LIBS=$OLD_LIBS; dnl reset to old value since readline was not found
62                 FOUND_readline=0;])],
63     [AC_MSG_RESULT([not found])
64         FOUND_readline=0;])
65
66 # reset original *FLAGS
67 CXXFLAGS=$OLD_CXXFLAGS
68 LDFLAGS=$OLD_LDFLAGS
69
70 # handle check results
71 if test $FOUND_readline != 1; then
72     AC_MSG_NOTICE([])
73     AC_MSG_NOTICE([The readline library was not found!])
74     if test  $readlinePATHSET = 1 ; then
75         AC_MSG_NOTICE([ The install prefix '$with_readline' for the readline library was set.])
76         AC_MSG_NOTICE([ --> Maybe wrong ???])
77     else
78         AC_MSG_NOTICE([ No non-standard install prefix was set.])
79         AC_MSG_NOTICE([ --> You might want to use '--with-readline=PREFIX' ?!?])
80     fi
81     AC_MSG_NOTICE([])
82     AC_MSG_ERROR([ readline library is an essential dependency : cannot build and stop here !])
83 fi
84
85 ##########################################################################
86
87
88
89
90
91 AC_CONFIG_FILES([
92  Makefile
93  src/Makefile
94 ])
95 AC_OUTPUT