dnl -*- Mode: Autoconf -*- dnl Process this file with autoconf to produce a configure script. # NATools - Package with parallel corpora tools # Copyright (C) 2002-2011 Alberto Simões # # This package is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # Check one file from the soruce dir AC_INIT(src/corpus.c) # Say we need a configure file AM_CONFIG_HEADER(config.h) AC_ARG_WITH(perl-prefix, [ --with-perl-prefix=PATH Specify preffix for Perl modules]) if test "x$with_perl_prefix" = "x"; then PERLPREFIX=`perl -MConfig -e 'print $Config{siteprefixexp}'` PERLSITEARCH=`perl -MConfig -e 'print $Config{installsitearch}'` PERLSITELIB=`perl -MConfig -e 'print $Config{installsitelib}'` PERLMAN1DIR=`perl -MConfig -e 'print $Config{installsiteman1dir}'` PERLMAN3DIR=`perl -MConfig -e 'print $Config{installsiteman3dir}'` else archname=`perl -MConfig -e 'print $Config{archname}'` version=`perl -MConfig -e 'print $Config{version}'` PERLPREFIX="$with_perl_prefix" PERLSITEARCH=$PERLPREFIX/lib/perl5/$version/$archname PERLSITELIB=$PERLPREFIX/lib/perl5 PERLMAN1DIR=$PERLPREFIX/man/man1 PERLMAN3DIR=$PERLPREFIX/man/man3 fi AC_SUBST(PERLPREFIX) # some terminal codes ... boldface="`tput bold 2>/dev/null`" normal="`tput sgr0 2>/dev/null`" printbold() { echo "$boldface" echo "$@" echo "$normal" } printbold "Checking basic configuration..." # Define package name and version AM_INIT_AUTOMAKE(NATools, 0.5.10) AC_DEFINE(PKG_PREFIX, [nat], [Prefix for binaries]) AC_CONFIG_MACRO_DIR([m4]) # Check standards AC_ISC_POSIX AC_PROG_CC AM_PROG_CC_C_O AC_HEADER_STDC # Check libtool m4_define([_LT_AC_TAGCONFIG],[]) AC_PROG_LIBTOOL # Check some more specific functions on libc AC_FUNC_MALLOC # Check for standard math library functions printbold "Checking for math functions..." for func in log10 log exp sqrt; do AC_CHECK_LIB(m, ${func}, LIBS="$LIBS", [AC_MSG_ERROR([Sorry, libm (math library) is required])]) done LIBS="$LIBS -lm" # #--------------------------------------- # Check for standard zlib functions # printbold "Checking for zlib..." for func in gzopen gzread gzwrite gzclose ; do AC_CHECK_LIB(z, ${func}, LIBS="$LIBS", [AC_MSG_ERROR([Sorry, zlib (z library) is required])]) done LIBS="$LIBS -lz" # #--------------------------------------- # Check for glib-2.0 # printbold "Checking for glib 2.0, SQLite and Berkeley DB..." PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.8]) LIBS="$LIBS $GLIB_LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS" PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.5.0]) LIBS="$LIBS $SQLITE_LIBS" CFLAGS="$CFLAGS $SQLITE_CFLAGS" AC_CHECK_PROGS(SQLITE, sqlite3) if test "X$SQLITE" = "x"; then AC_MSG_ERROR([sqlite3 binary is needed]) fi AX_BERKELEY_DB(4.3, [], [AC_MSG_ERROR("Berkeley DB Version 4.3 or greater is required.")]) LIBS="$LIBS $DB_LIBS" CFLAGS="$CFLAGS $DB_CFLAGS" # #--------------------------------------- # PERL STUFF # printbold "Checking for Perl and modules..." AC_CHECK_PROGS(PERL, perl perl5) if test "x$PERL" = "x"; then AC_MSG_ERROR([Perl is needed]) fi AC_CHECK_PROGS(POD2MAN, pod2man) if test "x$POD2MAN" = "x"; then AC_MSG_ERROR([pod2man command is needed to produce documentation]) fi # Final variable setting # --- LIBS="$LIBS $PKG_DEPS_LIBS" # --- CFLAGS="-Wall $CFLAGS $PKG_DEPS_CFLAGS" AC_SUBST(LIBS) AC_SUBST(CFLAGS) # #--------------------------------------- # Go configure the perl module # # but before, write the NAT.pm file... printbold "Writing Perl specific files..." AC_CONFIG_FILES([NAT/scripts/nat-sentence-align], [chmod +x NAT/scripts/nat-sentence-align]) AC_OUTPUT(NAT/NAT.pm) printbold "Checking required Perl modules versions..." # Test if we got all the modules we need :) # (thanks krani1 and mpg for that) modules=`cat NAT/Makefile.PL | sed -e "s/'/#/g" | $PERL -e 'join("",<>)=~/#PREREQ_PM#\s*\=\>\s*\{\s*(.*?)\s*\}/s;$a=$1;while($a=~/#(.*)#.*#(.*)#/g){print "$1 $2\n" unless $1=~/#/}'` AC_PERL_MODULES_VERSION("$modules", , AC_MSG_ERROR(Use CPAN to get the missing module)) printbold "Running Perl module Makefile.PL..." test "x$prefix" = xNONE && prefix=$ac_default_prefix (cd NAT; $PERL Makefile.PL INSTALLSITEARCH=$PERLSITEARCH INSTALLSITELIB=$PERLSITELIB INSTALLSITEMAN1DIR=$PERLMAN1DIR INSTALLSITEMAN3DIR=$PERLMAN3DIR INSTALLSITEBIN=${prefix}/bin INSTALLSITESCRIPT=${prefix}/bin CC=$CC INC="${CFLAGS} -I../src" LIBS="${LIBS}") printbold "Writing makefiles..." AC_OUTPUT( Makefile src/Makefile src/server/Makefile pods/Makefile data/Makefile 3rdParty/Makefile NAT/Makefile t/Makefile t/input/Makefile ) echo "" echo "-----------------------------------------------------------------------------" echo "LIBS: $LIBS" echo "CFLAGS: $CFLAGS" echo "-----------------------------------------------------------------------------" printbold "Run 'make' to start compiling."