headers and automake cleanup
[transitory.git] / configure.ac
1 # Copyright (C) 2013 Equinox Software, Inc.
2 # Mike Rylander <miker@esilibrary.com>
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14
15 #---------------------------
16 # Init
17 #---------------------------
18
19 export PATH=${PATH}:/usr/sbin
20 AC_PREREQ(2.61)
21 AC_INIT(ShareStuff, master, miker@esilibrary.com)
22 AM_INIT_AUTOMAKE([ShareStuff], [master])
23 AC_REVISION($Revision: 0.1 $)
24 AC_CONFIG_SRCDIR([configure.ac])
25 AC_SUBST(prefix)
26 AC_SUBST([abs_top_builddir])
27 #-----------------------------------
28 # Checks for programs.
29 #-----------------------------------
30
31
32 AC_PROG_LIBTOOL
33 AC_PROG_CC
34 AC_PROG_INSTALL
35 AC_PROG_LN_S
36 AC_PROG_MAKE_SET
37 AC_PROG_MKDIR_P
38 AM_PROG_CC_C_O
39
40 #-----------------------------------
41 # Check for dependencies 
42 #-----------------------------------
43 AC_PATH_PROG([OSRF_CONFIG], [osrf_config])
44 if test "x$OSRF_CONFIG" == "x"; then
45     AC_MSG_ERROR([Could not find osrf_config.
46     Ensure OpenSRF is installed and that the PATH environment variable includes
47     the OpenSRF executables. For example: PATH=\$PATH:/openils/bin ./configure])
48 fi
49
50 AC_ARG_WITH([opensrf-headers],
51 [  --with-opensrf-headers=path location of the OpenSRF header files],
52 [OPENSRF_HEADERS=${withval}],
53 [OPENSRF_HEADERS=`$OSRF_CONFIG --includedir`])
54 AC_SUBST([OPENSRF_HEADERS])
55
56 # We need this for JavaScript
57 AC_ARG_WITH([opensrf-libs],
58 [  --with-opensrf-libs=path    location of the OpenSRF libraries],
59 [OPENSRF_LIBS=${withval}],
60 [OPENSRF_LIBS=`$OSRF_CONFIG --libdir`])
61 AC_SUBST([OPENSRF_LIBS])
62
63 AC_ARG_WITH([tmp],
64 [  --with-tmp=path             location of the ShareStuff temporary directory (default is /tmp) ],
65 [TMP=${withval}],
66 [TMP=/tmp])
67 AC_SUBST([TMP])
68
69 AC_ARG_WITH([libxml2],
70 [  --with-libxml2=path         location of the libxml2 headers (default is /usr/include/libxml2)],
71 [LIBXML2_HEADERS=${withval}],
72 [LIBXML2_HEADERS=/usr/include/libxml2/])
73 AC_SUBST([LIBXML2_HEADERS])
74
75 AC_ARG_WITH([dbi],
76 [  --with-dbi=path             location of the libdbi driver libraries (default is /usr/local/lib/dbd)],
77 [DBI_LIBS=${withval}],
78 [DBI_LIBS=/usr/local/lib/dbd/])
79
80 # If the passed in value doesn't work, fall back to reasonable defaults
81 # Distributions are starting to package a good version of libdbi / libdbd
82 if ! test -d "$DBI_LIBS"; then
83     for i in /usr/lib/dbd/ /usr/lib64/dbd /usr/local/lib/dbd/ ; do
84         if test -d "$i"; then
85             DBI_LIBS="$i"
86             break
87         fi
88     done
89 fi
90 AC_SUBST([DBI_LIBS])
91
92 if test "x$openils_core" = "xtrue"; then
93
94     AC_CHECK_PROG([MEMCACHED],memcached,yes,no)
95     if test $MEMCACHED = "no"; then
96         AC_MSG_ERROR([*** memcached not found, aborting])
97     fi
98
99     AC_CHECK_PROG([ASPELL],aspell,yes,no)
100     if test $ASPELL = "no"; then
101         AC_MSG_ERROR([*** aspell not found, aborting])
102     fi
103
104     AC_CHECK_PROG([CPAN],cpan,yes,no)
105     if test $CPAN = "no"; then
106         AC_MSG_ERROR([*** cpan not found, aborting])
107     fi
108
109     AC_CHECK_PROG([YAZ],yaz-config,yes,no)
110     if test $YAZ = "no"; then
111         AC_MSG_ERROR([*** yaz not found, aborting])
112     fi
113
114     AC_CHECK_PROG([PERL],perl,yes,no)
115     if test $PERL = "no"; then 
116         AC_MSG_ERROR([*** perl not found, aborting])
117     fi
118
119     #------------------------------------
120     # Checks for libraries. 
121     #------------------------------------
122
123     # Check for the rest of the libraries
124
125     #check for dynamic linking functions
126     AC_CHECK_LIB(dl,dlopen)
127
128     #check for the libdbi library
129     AC_CHECK_LIB(dbi,dbi_initialize)
130
131     #to check for the availability and function of a particular
132     #driver we need a runtime check (since the driver is loaded
133     #dynamically). This example checks for the mysql driver
134     AC_MSG_CHECKING([for libdbi pgsql driver (dynamic load)])
135     AC_RUN_IFELSE(
136       [AC_LANG_PROGRAM(,
137         [[dbi_initialize(0); return(dbi_conn_new("pgsql") ? 0 : 1);]])],
138       [AC_MSG_RESULT("yes")],
139       [AC_MSG_FAILURE("pgsql driver not installed?")])
140
141     AC_CHECK_LIB([expat], [main], [], AC_MSG_ERROR(*** ShareStuff requires libexpat))
142     AC_CHECK_LIB([ncurses], [main], [], AC_MSG_ERROR(*** ShareStuff requires libncurses))
143
144     # IF the OpenSRF libs are installed in a non-standard location, such as
145     # /openils/lib, the compilation test will fail. Support that case.
146     LDFLAGS="-L$OPENSRF_LIBS"
147
148     AC_CHECK_LIB([opensrf], [osrfMessageFree], [], AC_MSG_ERROR(*** ShareStuff requires libopensrf))
149     AC_CHECK_LIB([readline], [main], [], AC_MSG_ERROR(*** ShareStuff requires libreadline))
150     AC_CHECK_LIB([xml2], [main], [], AC_MSG_ERROR(*** ShareStuff requires libxml2))
151     AC_CHECK_LIB([xslt], [main], [], AC_MSG_ERROR(*** ShareStuff requires libxslt))
152     AC_CHECK_LIB([pq], [main], [], AC_MSG_ERROR(*** ShareStuff requires libpq))
153
154     #------------------------------------
155     # Checks for header files.
156     #------------------------------------
157
158     AC_HEADER_STDC
159     AC_CHECK_HEADERS([fcntl.h langinfo.h locale.h stdlib.h string.h unistd.h])
160
161     #-------------------------------------------------------------------
162     # Checks for typedefs, structures, and compiler characteristics.
163     #-------------------------------------------------------------------
164
165     AC_C_CONST
166     AC_TYPE_SIZE_T
167     AC_STRUCT_TM
168     AC_HEADER_STDBOOL
169
170     #-------------------------------------------------------------------
171     # Checks for library functions.
172     #-------------------------------------------------------------------
173
174     AC_FUNC_STRFTIME
175     AC_FUNC_STRTOD
176     AC_CHECK_FUNCS([localtime_r memset nl_langinfo setlocale strcasecmp strchr strdup strerror strncasecmp])
177
178     #----------------------------
179     # Create Makefiles/Output
180     #----------------------------
181
182     AC_CONFIG_FILES([src/c/Makefile])
183 fi
184
185 AC_CONFIG_FILES([Makefile
186          src/Makefile
187          src/perl/Makefile
188          ],
189         [
190         ])
191 AC_OUTPUT
192
193 #-------------------------------------------------
194 # OUTPUT STUFF 
195 #-------------------------------------------------
196
197 AC_MSG_RESULT([])
198 AC_MSG_RESULT([--------------------- Configuration options:  -----------------------])
199
200 AC_MSG_RESULT([])
201 AC_MSG_RESULT([-------- Installation Directories --------])
202 AC_MSG_RESULT(Installation directory prefix:            ${prefix})
203 AC_MSG_RESULT(Temporary directory:                      ${TMP})
204 AC_MSG_RESULT(libxml2 headers location:                 ${LIBXML2_HEADERS})
205 AC_MSG_RESULT(libdbi location:                          ${DBI_LIBS})
206 AC_MSG_RESULT(OpenSRF headers location:                 ${OPENSRF_HEADERS})
207 AC_MSG_RESULT(OpenSRF libraries location:               ${OPENSRF_LIBS})
208
209 AC_MSG_RESULT([----------------------------------------------------------------------])
210
211 # vim:et:ts=4:sw=4: