1dnl Process this file with autoconf to produce a configure script.
2
3dnl check for one of the source files
4AC_INIT(refdb, 0.9.9-1)
5AC_CONFIG_SRCDIR(src/backend-ris.c)
6
7dnl Find out host type
8AC_CONFIG_AUX_DIR(./conf)
9AC_CANONICAL_HOST
10
11dnl Use automake (shut off warnings about GNU make)
12AM_INIT_AUTOMAKE([-Wno-portability])
13
14dnl switch on GNU extensions
15AC_DEFINE(_GNU_SOURCE)
16
17dnl see which compiler is available
18AC_PROG_CC
19
20dnl set some compile options (just a stub right now)
21if test -n "$GCC"; then
22   case $host in
23   *)
24	CFLAGS=$CFLAGS" -O2";;
25   esac
26fi
27
28dnl see where the libdbi lib is
29AC_ARG_WITH(libdbi-lib,
30	[  --with-libdbi-lib=DIR         Find libdbi lib in DIR],
31	[CFLAGS=$CFLAGS" -L$withval"])
32
33dnl see where expat lib is
34AC_ARG_WITH(expat-lib,
35	[  --with-expat-lib=DIR          Find expat lib in DIR],
36	[CFLAGS=$CFLAGS" -L$withval"])
37
38dnl see where btparse lib is
39AC_ARG_WITH(btparse-lib,
40	[  --with-btparse-lib=DIR        Find btparse lib in DIR],
41	[CFLAGS=$CFLAGS" -L$withval"])
42
43dnl need a sgml declaration
44AC_ARG_WITH(sgml-declaration,
45	[  --with-sgml-declaration=PATH  Use this file as SGML declaration],
46	[sgml_decl=$withval],
47	[sgml_decl="\$(pkgdatadir)/declarations/docbook.dcl"])
48
49dnl need a xml declaration
50AC_ARG_WITH(xml-declaration,
51	[  --with-xml-declaration=PATH   Use this file as XML declaration],
52	[xml_decl=$withval],
53	[xml_decl="\$(pkgdatadir)/declarations/xml.dcl"])
54
55dnl need the path to the docbook xsl stylesheets
56AC_ARG_WITH(docbook-xsl,
57	[  --with-docbook-xsl=PATH       Path to the DocBook XSL stylesheet root],
58	[docbk_xsl=$withval],
59	[docbk_xsl="http://docbook.sourceforge.net/release/xsl/current"])
60
61dnl need the path to the docbook namespaced xsl stylesheets
62AC_ARG_WITH(docbook-xsl-ns,
63	[  --with-docbook-xsl-ns=PATH     Path to the DocBook XSL NS stylesheet root],
64	[docbk_xsl_ns=$withval],
65	[docbk_xsl_ns="http://docbook.sourceforge.net/release/xsl-ns/current"])
66
67dnl need the path to the tei P4 xsl stylesheets
68AC_ARG_WITH(tei-xsl,
69	[  --with-tei-xsl=PATH           Path to the TEI XSL stylesheet root],
70	[tei_xsl=$withval],
71	[tei_xsl="http://www.tei-c.org/Stylesheets"])
72
73dnl need the path to the tei P5 xsl stylesheets
74AC_ARG_WITH(tei-xsl-ns,
75	[  --with-tei-xsl-ns=PATH        Path to the TEI XSL NS stylesheet root],
76	[tei_xsl_ns=$withval],
77	[tei_xsl_ns="http://www.tei-c.org/Stylesheets"])
78
79dnl need the path to the jars
80AC_ARG_WITH(classpath_root,
81	[  --with-classpath-root=PATH    Path to a Java class repository for XSL processors],
82	[classpath_root=$withval],
83	[classpath_root=""])
84
85dnl need a path to write a pid file
86AC_ARG_WITH(var_dir,
87	[  --with-var-dir=PATH           Path of a directory for PID files],
88	[var_dir=$withval],
89	[var_dir="\$(localstatedir)/run"])
90
91dnl need a path to write log files
92AC_ARG_WITH(log_dir,
93	[  --with-log-dir=PATH           Path of a directory for log files],
94	[log_dir=$withval],
95	[log_dir="\$(localstatedir)/log"])
96
97dnl the main database
98AC_ARG_WITH(main_db,
99	[  --with-main-db=name           The name of the RefDB system database],
100	[main_db=$withval],
101	[main_db="refdb"])
102
103dnl which directory will hold the databases? This does not only pertain
104dnl to SQLite, as the directory also holds the version file
105AC_ARG_WITH(db_dir,
106	[  --with-db-dir=PATH            Directory for database files],
107	[db_dir=$withval],
108	[db_dir="\$(localstatedir)/lib/refdb/db"],
109])
110
111dnl maintainers may need the trang jar
112AC_ARG_WITH(trang_jar,
113	[  --with-trang-jar=PATH         specify the full path to trang],
114	[trang_cmd="java -jar "$withval],
115	[trang_cmd="cp"])
116
117dnl see whether we should build the docs
118ac_docs="YES"
119AC_ARG_ENABLE(docs,
120	[  --disable-docs		  do not build and install the documentation.],
121	[  ac_docs="NO" ])
122
123if test "$ac_docs" = "YES"; then
124docs_subdirs="doc"
125else
126docs_subdirs=""
127fi
128
129dnl see whether we should build the man pages
130ac_manpages="YES"
131AC_ARG_ENABLE(manpages,
132	[  --disable-manpages		  do not build and install the man pages.],
133	[  ac_manpages="NO" ])
134
135if test "$ac_manpages" = "YES"; then
136man_subdirs="man"
137else
138man_subdirs=""
139fi
140
141dnl see whether we should build the server
142ac_server="YES"
143AC_ARG_ENABLE(server,
144	[  --disable-server		  Exclude server.],
145	[  ac_server="NO" ])
146
147if test "$ac_server" = "YES"; then
148server_subdirs="etc scripts src phpweb sru"
149server_bins="refdbd\$(EXEEXT)"
150server_scripts="refdbctl refdb-init refdbsru refdb-sruserver"
151server_etc_objects="refdbdrc.mysql.example refdbdrc.pgsql.example refdbdrc.sqlite.example refdbdrc.sqlite3.example refdbsrurc.example"
152server_etc_distobjects="refdbdrc refdbsrurc"
153server_mans="refdb.8 refdbd.1 refdb-init.8 refdbctl.1 refdbsru.1 refdb-sruserver.1"
154server8_mans="refdb.sh.8"
155else
156server_subdirs=""
157server_bins=""
158server_scripts=""
159server_etc_objects=""
160server_etc_distobjects=""
161server_mans=""
162server8_mans=""
163fi
164
165dnl see whether we should build the clients
166ac_client="YES"
167AC_ARG_ENABLE(clients,
168	[  --disable-clients		  Exclude clients.],
169	[  ac_client="NO" ])
170
171if test "$ac_client" = "YES" && test "$ac_server" = "YES"; then
172client_subdirs="declarations dsssl dtd examples styles xsl"
173client_bins="refdbib\$(EXEEXT) refdbc\$(EXEEXT) refdba\$(EXEEXT) refdbxp\$(EXEEXT) eenc\$(EXEEXT)"
174client_scripts="refdbjade runbib db2ris refdbxml marc2ris med2ris en2ris refdbnd refdb_dos2unix refdb-ms refdb-backup refdb-restore refdb_latex2utf8txt bib2ris-utf8"
175client_etc_objects="bib2risrc.example bib2riscgirc.example db2risrc.example refdbarc.example refdbcrc.example refdbcgirc.example refdbibrc.example med2risrc.example med2riscgirc.example marc2risrc.example refdbxmlrc.example refdbjaderc.example runbibrc.example"
176client_etc_distobjects="bib2risrc bib2riscgirc db2risrc refdbarc refdbcrc refdbcgirc refdbibrc med2risrc med2riscgirc marc2risrc refdbxmlrc refdbjaderc runbibrc"
177client_mans="RefDB.7 refdba.1 refdbc.1 refdbib.1 bib2ris.1 db2ris.1 en2ris.1 marc2ris.1 med2ris.1 eenc.1 refdb-backup.1 refdb-ms.1 refdb-restore.1 refdbjade.1 refdbnd.1 refdbxml.1 runbib.1 refdbxp.1 refdb-bug.1 refdb_dos2unix.1 refdb_latex2utf8txt.1"
178client1_mans="bib2ris-utf8.1"
179elif test "$ac_client" = "YES"; then
180client_subdirs="declarations dsssl dtd etc examples scripts src styles xsl"
181client_bins="refdbib\$(EXEEXT) refdbc\$(EXEEXT) refdba\$(EXEEXT) refdbxp\$(EXEEXT) eenc\$(EXEEXT)"
182client_scripts="refdbjade runbib db2ris refdb-bug refdbxml marc2ris med2ris en2ris refdbnd refdb_dos2unix refdb-ms refdb-backup refdb-restore refdb_latex2utf8txt bib2ris-utf8"
183client_etc_objects="bib2risrc.example bib2riscgirc.example db2risrc.example refdbarc.example refdbcrc.example refdbcgirc.example refdbibrc.example med2risrc.example med2riscgirc.example marc2risrc.example refdbxmlrc.example refdbjaderc.example runbibrc.example"
184client_etc_distobjects="bib2risrc bib2riscgirc db2risrc refdbarc refdbcrc refdbcgirc refdbibrc med2risrc med2riscgirc marc2risrc refdbxmlrc refdbjaderc runbibrc"
185client_mans="RefDB.7 refdba.1 refdbc.1 refdbib.1 bib2ris.1 db2ris.1 en2ris.1 marc2ris.1 med2ris.1 eenc.1 refdb-backup.1 refdb-ms.1 refdb-restore.1 refdbjade.1 refdbnd.1 refdbxml.1 runbib.1 refdbxp.1 refdb-bug.1 refdb_dos2unix.1 refdb_latex2utf8txt.1"
186client1_mans="bib2ris-utf8.1"
187else
188client_subdirs=""
189client_bins=""
190client_scripts=""
191client_etc_objects=""
192client_etc_distobjects=""
193client_mans=""
194client1_mans=""
195fi
196
197dnl Checks for programs.
198AC_PATH_PROGS(myshell, bash sh)
199
200if test "$ac_client" = "YES"; then
201AC_PATH_PROGS(myjade, openjade jade)
202AC_PATH_PROG(myperl, perl)
203AC_PATH_PROG(myxsltproc, xsltproc)
204AC_PATH_PROG(myxmlcatalog, xmlcatalog)
205fi
206
207if test "$ac_docs" = "YES"; then
208AC_PATH_PROG(mydtdparse, dtdparse)
209AC_PATH_PROG(mydtdformat, dtdformat)
210AC_PATH_PROG(mysgrep, sgrep)
211AC_PATH_PROG(mytidy, tidy)
212AC_PATH_PROG(mybatik, batik-rasterizer)
213fi
214
215dnl see whether subversion is installed
216AC_PATH_PROG(svnversioncommand, svnversion)
217
218dnl use svnversion to record the current repository revision only if
219dnl subversion is installed and we are in a working copy
220if test "X$svnversioncommand" = "X" || test `$svnversioncommand -n '.'` = "exported"; then
221mysvnversion="cat svn_dist_version"
222else
223mysvnversion="svnversion -n '.'"
224fi
225
226dnl this is for building docs only, but the conditional must not be defined
227dnl inside of an if block
228AM_CONDITIONAL(HAVEBATIK, test x$mybatik != "x")
229
230AM_CONDITIONAL(HAVESERVER, test "$ac_server" = "YES")
231
232dnl this is used to make sure we create the file svn_dist_version only if
233dnl we have svnversion and if we are in a svn working copy. In all other
234dnl cases the distributed copy of svn_dist_version should be used
235AM_CONDITIONAL(HAVESVNWC, test "X$svnversioncommand" != "X" && test `$svnversioncommand -n '.'` != "exported")
236
237dnl
238dnl Checks for libraries.
239dnl
240
241if test "$ac_client" = "YES"; then
242dnl libtermcap; libreadline needs either libtermcap or lib(n)curses, so
243dnl we have to check this first
244AC_CHECK_LIB(termcap, tputs, [
245rltestlib="-ltermcap"],
246[AC_CHECK_LIB(ncurses, tputs, [
247rltestlib="-lncurses"],
248[AC_CHECK_LIB(curses, tputs, [
249rltestlib="-lcurses"],
250[echo "Cannot build refdb without either libtermcap, libncurses, or libcurses"
251exit 1])])])
252
253dnl libreadline
254AC_CHECK_LIB(readline, readline, [
255refdba_LDADD=$refdba_LDADD" -lreadline "$rltestlib
256refdbc_LDADD=$refdbc_LDADD" -lreadline "$rltestlib], [
257echo "Cannot build refdb without libreadline"
258exit 1], $rltestlib)
259
260AC_MSG_CHECKING(for libreadline version)
261
262AC_TRY_RUN(
263#include <stdio.h>
264#include <readline/readline.h>
265char* rl_readline_name;
266int main(void) {
267exit(0);
268}
269, ac_cv_lib_readline=old, ac_cv_lib_readline=new, ac_cv_lib_readline=old)
270
271AC_MSG_RESULT($ac_cv_lib_readline)
272if test "$ac_cv_lib_readline" = "old" ; then
273  AC_DEFINE(READLINE41)
274else
275  AC_DEFINE(READLINE42)
276fi
277fi dnl end if build clients
278
279if test "$ac_server" = "YES"; then
280
281dnl see how to get iconv support
282AM_ICONV_LINK
283
284dnl linking with libdl is necessary on some systems
285AC_SEARCH_LIBS_VAR(dlopen, dl,,,,refdbd_LDADD)
286
287dnl linking with libltdl may be required by libdbi
288AC_SEARCH_LIBS_VAR(lt_dlopen, ltdl,,,,refdbd_LDADD)
289
290dnl libdbi - depends on libdl on some systems
291AC_CHECK_LIB(dbi, dbi_initialize, [
292refdbd_LDADD=$refdbd_LDADD" -ldbi"], [
293echo "Cannot build refdb without libdbi"
294exit 1])
295
296dnl compress is in glibc, but not in Cygwin newlib
297AC_SEARCH_LIBS_VAR(compress, z, , , , refdbd_LDADD)
298
299fi dnl end if build server
300
301dnl linking with libsocket may be necessary (Solaris?)
302AC_SEARCH_LIBS(setsockopt, socket,,)
303
304dnl in some cases Solaris seems to need libnsl too
305AC_SEARCH_LIBS(gethostbyname, nsl,,)
306
307dnl libexpat
308if test "$ac_server" = "YES"; then
309AC_CHECK_LIB(expat, XML_ParserCreate, [
310refdbd_LDADD=$refdbd_LDADD" -lexpat"], [
311echo "Cannot build refdb without libexpat"
312exit 1])
313fi
314
315dnl btparse
316if test "$ac_client" = "YES"; then
317AC_CHECK_LIB(btparse, bt_initialize, [
318bib2ris_LDADD=$bib2ris_LDADD" -lbtparse"
319BIB2RIS="bib2ris\$(EXEEXT)"], [
320echo "libbtparse not found; bib2ris import filter will not be built"])
321fi
322
323dnl check types that aren't really portable
324AC_CHECK_TYPES(socklen_t)
325
326dnl this is the dusty corner of configure and attempts to tackle the
327dnl following issues:
328dnl (1) printf uses non-standard conversion specifiers on some platforms
329dnl (2) ps uses different arguments on BSD/SysV style systems to list
330dnl     all running processes. Some ps'es accept both styles which makes
331dnl     the list a little less ugly
332case $host in
333    *-sun-solaris*)
334        ULLSPEC="%llu"
335	psarg="-e" ;;
336    *)
337        ULLSPEC="%llu"
338	psarg="ax" ;;
339esac
340
341AC_SUBST(refdba_LDADD)
342AC_SUBST(refdbc_LDADD)
343AC_SUBST(refdbd_LDADD)
344AC_SUBST(bib2ris_LDADD)
345AC_SUBST(BIB2RIS)
346AC_SUBST(myjade)
347AC_SUBST(myshell)
348AC_SUBST(myxsltproc)
349AC_SUBST(mysvnversion)
350AC_SUBST(sgml_decl)
351AC_SUBST(xml_decl)
352AC_SUBST(docbk_xsl)
353AC_SUBST(docbk_xsl_ns)
354AC_SUBST(tei_xsl)
355AC_SUBST(tei_xsl_ns)
356AC_SUBST(classpath_root)
357AC_SUBST(log_dir)
358AC_SUBST(var_dir)
359AC_SUBST(main_db)
360AC_SUBST(db_dir)
361AC_SUBST(ULLSPEC)
362AC_SUBST(psarg)
363AC_SUBST(trang_cmd)
364AC_SUBST(server_subdirs)
365AC_SUBST(client_subdirs)
366AC_SUBST(docs_subdirs)
367AC_SUBST(man_subdirs)
368AC_SUBST(server_bins)
369AC_SUBST(client_bins)
370AC_SUBST(server_scripts)
371AC_SUBST(client_scripts)
372AC_SUBST(server_etc_objects)
373AC_SUBST(client_etc_objects)
374AC_SUBST(server_etc_distobjects)
375AC_SUBST(client_etc_distobjects)
376AC_SUBST(server_mans)
377AC_SUBST(server8_mans)
378AC_SUBST(client_mans)
379AC_SUBST(client1_mans)
380
381dnl Checks for header files.
382AC_HEADER_STDC
383AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/time.h sys/ioctl.h syslog.h unistd.h)
384
385dnl Checks for typedefs, structures, and compiler characteristics.
386AC_C_CONST
387AC_TYPE_PID_T
388AC_TYPE_SIZE_T
389AC_HEADER_TIME
390AC_STRUCT_TM
391
392dnl Checks for library functions.
393AC_TYPE_SIGNAL
394AC_FUNC_STRFTIME
395AC_FUNC_MKFIFO
396AC_CHECK_FUNCS(gethostname select socket strcspn strstr strtoll atoll)
397
398dnl these checks are required only for clients
399if test "$ac_client" = "YES"; then
400
401dnl Check for XSL stylesheets
402AC_CHECK_FILE($docbk_xsl/fo/docbook.xsl,
403[echo "DocBook XSL stylesheets found"],
404[if test -n "$myxmlcatalog"; then
405REFDB_XML_FILE($myxmlcatalog,${docbk_xsl}/fo/docbook.xsl)
406else
407echo "cannot locate DocBook XSL stylesheets via XML catalog"
408fi])
409
410dnl Check for XSL NS stylesheets
411AC_CHECK_FILE($docbk_xsl_ns/fo/docbook.xsl,
412[echo "DocBook XSL NS stylesheets found"],
413[if test -n "$myxmlcatalog"; then
414REFDB_XML_FILE($myxmlcatalog,${docbk_xsl_ns}/fo/docbook.xsl)
415else
416echo "cannot locate DocBook XSL NS stylesheets via XML catalog"
417fi])
418
419AC_CHECK_FILE($tei_xsl/p4/fo/tei.xsl,
420[echo "TEI XSL stylesheets found"],
421[if test -n "$myxmlcatalog"; then
422REFDB_XML_FILE($myxmlcatalog,${tei_xsl}/p4/fo/tei.xsl)
423else
424echo "cannot locate TEI XSL stylesheets via XML catalog"
425fi])
426
427AC_CHECK_FILE($tei_xsl_ns/p5/fo/tei.xsl,
428[echo "TEI XSL NS stylesheets found"],
429[if test -n "$myxmlcatalog"; then
430REFDB_XML_FILE($myxmlcatalog,${tei_xsl_ns}/p5/fo/tei.xsl)
431else
432echo "cannot locate TEI XSL NS stylesheets via XML catalog"
433fi])
434
435dnl Check for Perl version and Perl modules
436changequote(<<,>>)dnl
437refdb_perl_command='print $]'
438changequote([,])dnl
439REFDB_PERL_VERSION($myperl, 5.006)
440REFDB_PERL_MODULE($myperl, Text::Iconv, refdb_iconv)
441REFDB_PERL_MODULE($myperl, Term::Clui, refdb_clui)
442REFDB_PERL_MODULE($myperl, RefDB::Makestyle, refdb_makestyle)
443REFDB_PERL_MODULE($myperl, RefDB::Prefs, refdb_prefs)
444REFDB_PERL_MODULE($myperl, RefDB::SRU, refdb_sru)
445REFDB_PERL_MODULE($myperl, RefDB::SRUserver, refdb_sruserver)
446REFDB_PERL_MODULE($myperl, XML::Parser, refdb_parser)
447REFDB_PERL_MODULE($myperl, MARC::Record, refdb_record)
448REFDB_PERL_MODULE($myperl, MARC::Charset, refdb_charset)
449REFDB_PERL_MODULE($myperl, CGI, refdb_cgi)
450
451fi dnl end if build clients
452
453AC_OUTPUT(src/Makefile scripts/Makefile etc/Makefile doc/Makefile dtd/Makefile declarations/Makefile examples/Makefile styles/Makefile phpweb/Makefile phpweb/css/Makefile phpweb/images/Makefile phpweb/includes/Makefile phpweb/xsl/Makefile sru/Makefile dsssl/Makefile dsssl/refdb/Makefile dsssl/refdb/html/Makefile dsssl/refdb/print/Makefile dsssl/refdb/lib/Makefile xsl/Makefile xsl/refdb/Makefile xsl/refdb/common-refdb/Makefile xsl/refdb/docbk-refdb-xsl/Makefile xsl/refdb/docbk-refdb-xsl/docbk-fo/Makefile xsl/refdb/docbk-refdb-xsl/docbk-html/Makefile xsl/refdb/docbk-refdb-xsl/docbk-xhtml/Makefile xsl/refdb/docbk-refdb-xsl/docbk-lib/Makefile xsl/refdb/tei-refdb-xsl/Makefile xsl/refdb/tei-refdb-xsl/tei-fo/Makefile xsl/refdb/tei-refdb-xsl/tei-html/Makefile xsl/refdb/tei-refdb-xsl/tei-lib/Makefile man/Makefile Makefile)
454
455echo
456
457if test "$ac_client" = "YES"; then
458if test -z "$refdb_makestyle" || test -z "$refdb_prefs" || test -z "$refdb_parser" || test -z "$refdb_record" || test -z "$refdb_charset" || test -z "$refdb_iconv" || test -z "$refdb_clui" || test -z "$refdb_sru" || test -z "$refdb_sruserver" || test -z "$refdb_cgi"; then
459echo "Your system seems to miss some of the recommended Perl modules. Please"
460echo "check the output above for details. It is safe to make and make install"
461echo "anyway, but some of the accessory Perl scripts will fail to run if the"
462echo " required modules are not installed. Please consult the manual where to"
463echo "get the missing modules from."
464echo
465fi
466fi
467
468echo "Configuration summary:"
469if test "$ac_client" = "YES"; then
470echo "will build clients"
471fi
472if test "$ac_server" = "YES"; then
473echo "will build server"
474fi
475if test "$ac_docs" = "YES"; then
476echo "will build docs"
477fi
478if test "$ac_manpages" = "YES"; then
479echo "will build man pages"
480fi
481
482echo ""
483echo "What you should do next:"
484echo "- run \"make\" to build RefDB."
485echo "- run \"make install\" as root to install everything."
486echo "- create the main database and the configuration files. Either run the"
487echo "  refdb-init shell script as root, or peruse the handbook if you"
488echo "  prefer a manual installation."
489echo ""
490