Skip to content

Commit

Permalink
Switch from basic Makefile to autotools.
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliopaci committed Nov 17, 2010
1 parent f132ee3 commit 3569de1
Show file tree
Hide file tree
Showing 8 changed files with 377 additions and 0 deletions.
Empty file added AUTHORS
Empty file.
File renamed without changes.
Empty file added ChangeLog
Empty file.
117 changes: 117 additions & 0 deletions Makefile.am
@@ -0,0 +1,117 @@
## Process this file with automake to produce Makefile.in

SUBDIRS =

EXTRA_DIST = autogen.sh \
debian/changelog \
debian/control \
debian/docs \
debian/libmitlm-dev.install \
debian/mitlm.install \
debian/compat \
debian/copyright \
debian/info \
debian/libmitlm.install \
debian/rules


INCLUDES = \
-Isrc

# Enable building files in subdirectories.
AUTOMAKE_OPTIONS = subdir-objects

lib_LTLIBRARIES = libmitlm.la

mitlmincdir = $(includedir)/mitlm
mitlmoptimizeincdir = $(includedir)/mitlm/optimize
mitlmutilincdir = $(includedir)/mitlm/util
mitlmvectorincdir = $(includedir)/mitlm/vector

mitlmoptimizeinc_HEADERS= \
src/optimize/Optimization.h \
src/optimize/LBFGS.h \
src/optimize/Powell.h \
src/optimize/LBFGSB.h

mitlmutilinc_HEADERS= \
src/util/FastIO.h \
src/util/RefCounter.h \
src/util/CommandOptions.h \
src/util/ZFile.h \
src/util/Logger.h \
src/util/SharedPtr.h \
src/util/BitOps.h \
src/util/FastHash.h

mitlmvectorinc_HEADERS= \
src/vector/Range.h \
src/vector/Operations.h \
src/vector/VectorClosures.h \
src/vector/Traits.h \
src/vector/VectorBuilder.h \
src/vector/VectorOps.h \
src/vector/Scalar.h \
src/vector/Vector.h \
src/vector/DenseVector.h \
src/vector/DenseVector.tcc

mitlminc_HEADERS= \
src/MaxLikelihoodSmoothing.h \
src/Smoothing.h \
src/Vocab.h \
src/Mask.h \
src/KneserNeySmoothing.h \
src/PerplexityOptimizer.h \
src/NgramVector.h \
src/Lattice.h \
src/WordErrorRateOptimizer.h \
src/InterpolatedNgramLM.h \
src/NgramLM.h \
src/NgramModel.h \
src/Types.h



libmitlm_la_SOURCES = \
src/util/CommandOptions.cpp \
src/util/RefCounter.cpp \
src/util/Logger.cpp \
src/NgramLM.cpp \
src/Vocab.cpp \
src/PerplexityOptimizer.cpp \
src/Lattice.cpp \
src/Smoothing.cpp \
src/NgramModel.cpp \
src/NgramVector.cpp \
src/MaxLikelihoodSmoothing.cpp \
src/KneserNeySmoothing.cpp \
src/InterpolatedNgramLM.cpp \
src/optimize/lbfgs.f \
src/optimize/lbfgsb.f \
src/WordErrorRateOptimizer.cpp

libmitlm_la_LIBADD = $(FLIBS)


# Programs:

bin_PROGRAMS = evaluate-ngram estimate-ngram interpolate-ngram

evaluate_ngram_SOURCES = \
src/evaluate-ngram.cpp

evaluate_ngram_LDADD = libmitlm.la $(FLIBS)
evaluate_ngram_CFLAGS =

estimate_ngram_SOURCES = \
src/estimate-ngram.cpp

estimate_ngram_LDADD = libmitlm.la $(FLIBS)
estimate_ngram_CFLAGS =

interpolate_ngram_SOURCES = \
src/interpolate-ngram.cpp

interpolate_ngram_LDADD = libmitlm.la $(FLIBS)
interpolate_ngram_CFLAGS =
49 changes: 49 additions & 0 deletions Makefile.example
@@ -0,0 +1,49 @@
INC = -Isrc
CXXFLAGS = -g -Wall -fPIC -fmessage-length=0 $(INC)
LDFLAGS = -L. -lg2c -lmitlm
FFLAGS = -g -fPIC -fmessage-length=0

ifdef GPROF
CXXFLAGS += -pg
LDFLAGS += -pg
endif

ifdef DEBUG
CXXFLAGS += -O0 -fno-inline
else
CXXFLAGS += -O3 -DNDEBUG -funroll-loops
FFLAGS += -O3 -DNDEBUG -funroll-loops
LDFLAGS += -O3 -funroll-loops
endif

UTIL_SOURCES = src/util/RefCounter.cpp src/util/Logger.cpp src/util/CommandOptions.cpp
SOURCES = $(UTIL_SOURCES) src/Vocab.cpp src/NgramVector.cpp \
src/NgramModel.cpp src/NgramLM.cpp src/InterpolatedNgramLM.cpp \
src/Smoothing.cpp src/MaxLikelihoodSmoothing.cpp src/KneserNeySmoothing.cpp \
src/PerplexityOptimizer.cpp src/WordErrorRateOptimizer.cpp \
src/Lattice.cpp
UTIL_OBJECTS = $(UTIL_SOURCES:.cpp=.o)
OBJECTS = $(SOURCES:.cpp=.o) src/optimize/lbfgsb.o src/optimize/lbfgs.o

# Core MITLM utilities
all: estimate-ngram interpolate-ngram evaluate-ngram

libmitlm.a: $(OBJECTS)
ar rcs $@ $(OBJECTS)

estimate-ngram: libmitlm.a src/estimate-ngram.o
$(CXX) src/estimate-ngram.o -o $@ $(LDFLAGS)

interpolate-ngram: libmitlm.a src/interpolate-ngram.o
$(CXX) src/interpolate-ngram.o -o $@ $(LDFLAGS)

evaluate-ngram: libmitlm.a src/evaluate-ngram.o
$(CXX) src/evaluate-ngram.o -o $@ $(LDFLAGS)

# Build scripts
clean:
rm -f $(OBJECTS) src/*.o test/*.o mitlm.tgz
rm -f estimate-ngram interpolate-ngram evaluate-ngram libmitlm.a

dist: clean
cd ..; tar czvf mitlm.tgz --exclude=".*" mitlm/; cd mitlm; mv ../mitlm.tgz .
Empty file added NEWS
Empty file.
162 changes: 162 additions & 0 deletions autogen.sh
@@ -0,0 +1,162 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.

srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.

DIE=0

if [ -n "$GNOME2_DIR" ]; then
ACLOCAL_FLAGS="-I $GNOME2_DIR/share/aclocal $ACLOCAL_FLAGS"
LD_LIBRARY_PATH="$GNOME2_DIR/lib:$LD_LIBRARY_PATH"
PATH="$GNOME2_DIR/bin:$PATH"
export PATH
export LD_LIBRARY_PATH
fi

(test -f $srcdir/configure.ac) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level package directory"
exit 1
}

(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`autoconf' installed."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}

(grep "^AC_PROG_INTLTOOL" $srcdir/configure.ac >/dev/null) && {
(intltoolize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`intltool' installed."
echo "You can get it from:"
echo " ftp://ftp.gnome.org/pub/GNOME/"
DIE=1
}
}

(grep "^AM_PROG_XML_I18N_TOOLS" $srcdir/configure.ac >/dev/null) && {
(xml-i18n-toolize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`xml-i18n-toolize' installed."
echo "You can get it from:"
echo " ftp://ftp.gnome.org/pub/GNOME/"
DIE=1
}
}

(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && {
(libtool --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`libtool' installed."
echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
}

(grep "^AM_GLIB_GNU_GETTEXT" $srcdir/configure.ac >/dev/null) && {
(grep "sed.*POTFILES" $srcdir/configure.ac) > /dev/null || \
(glib-gettextize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`glib' installed."
echo "You can get it from: ftp://ftp.gtk.org/pub/gtk"
DIE=1
}
}

(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`automake' installed."
echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
DIE=1
NO_AUTOMAKE=yes
}


# if no automake, don't bother testing for aclocal
test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: Missing \`aclocal'. The version of \`automake'"
echo "installed doesn't appear recent enough."
echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}

if test "$DIE" -eq 1; then
exit 1
fi

if test -z "$*"; then
echo "**Warning**: I am going to run \`configure' with no arguments."
echo "If you wish to pass any to it, please specify them on the"
echo \`$0\'" command line."
echo
fi

case $CC in
xlc )
am_opt=--include-deps;;
esac

for coin in `find $srcdir -name configure.ac -print`
do
dr=`dirname $coin`
if test -f $dr/NO-AUTO-GEN; then
echo skipping $dr -- flagged as no auto-gen
else
echo processing $dr
( cd $dr

aclocalinclude="$ACLOCAL_FLAGS"
if test -d /mingw/share/aclocal ; then
aclocalinclude="$aclocalinclude -I /mingw/share/aclocal"
fi

if grep "^AM_GLIB_GNU_GETTEXT" configure.ac >/dev/null; then
echo "Creating $dr/aclocal.m4 ..."
test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
echo "Running glib-gettextize... Ignore non-fatal messages."
echo "no" | glib-gettextize --force --copy
echo "Making $dr/aclocal.m4 writable ..."
test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
fi
if grep "^AC_PROG_INTLTOOL" configure.ac >/dev/null; then
echo "Running intltoolize..."
intltoolize --copy --force --automake
fi
if grep "^AM_PROG_XML_I18N_TOOLS" configure.ac >/dev/null; then
echo "Running xml-i18n-toolize..."
xml-i18n-toolize --copy --force --automake
fi
if grep "^AC_PROG_LIBTOOL" configure.ac >/dev/null; then
if test -z "$NO_LIBTOOLIZE" ; then
echo "Running libtoolize..."
libtoolize --force --copy
fi
fi
echo "Running aclocal $aclocalinclude ..."
aclocal $aclocalinclude
if grep "^AM_CONFIG_HEADER" configure.ac >/dev/null; then
echo "Running autoheader..."
autoheader
fi
echo "Running automake --gnu $am_opt ..."
automake --add-missing --gnu $am_opt
echo "Running autoconf ..."
autoconf
)
fi
done

conf_flags="--enable-maintainer-mode"

if test x$NOCONFIGURE = x; then
echo Running $srcdir/configure $conf_flags "$@" ...
$srcdir/configure $conf_flags "$@" \
&& echo Now type \`make\' to compile. || exit 1
else
echo Skipping configure process.
fi
49 changes: 49 additions & 0 deletions configure.ac
@@ -0,0 +1,49 @@
dnl Process this file with autoconf to produce a configure script.

dnl AC_INIT(package, version, bug-report-address)
AC_INIT([MIT Language Modeling Toolkit], 0.4, [giuliopaci@interfree.it], mitlm)
dnl This file (configure.ac) revision.
AC_REVISION([$Revision$])
dnl The base directory (srcdir) must contain configure.ac.
AC_CONFIG_SRCDIR(configure.ac)
dnl Use ./ to store scripts and files used by configure.
AC_CONFIG_AUX_DIR(.)

AM_INIT_AUTOMAKE

AM_MAINTAINER_MODE

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_F77

AC_F77_LIBRARY_LDFLAGS

AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

dnl Checks for header files.
AC_CHECK_HEADERS(string.h math.h)
AC_HEADER_STDC

dnl Checks for types.

dnl Checks for structures.

dnl Checks for compiler characteristics.
AC_C_INLINE
AM_PROG_CC_C_O

dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_MALLOC
AC_FUNC_REALLOC
dnl Checks for system services.

dnl Output.
AC_CONFIG_FILES([
Makefile
])

AC_OUTPUT([])

0 comments on commit 3569de1

Please sign in to comment.