How OpenFst and dl libraries were added under HFST

(1) Make directories openfst and dlfcn under hfst3 root.

(2) Copy OpenFst win32 version source files under openfst, go to openfst and delete everything except Makefile.am and directory src.

(3) Add the line AUTOMAKE_OPTIONS=subdir-objects to Makefile.am.

(4) Go to directory src and rewrite Makefile.am as

AUTOMAKE_OPTIONS=subdir-objects
SUBDIRS=lib

(5) Delete everything except Makefile.am and directories include and lib.

(6) Go to directory lib, delete Makefile.in and rewrite Makefile.am as

AUTOMAKE_OPTIONS=subdir-objects
AM_CPPFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../dlfcn $(ICU_CPPFLAGS) \
        -DMSC_VER -DOPENFSTEXPORT

noinst_LTLIBRARIES = libfst.la
libfst_la_SOURCES = compat.cc flags.cc fst.cc properties.cc \
symbol-table.cc util.cc symbol-table-ops.cc

(7) Go to directory include and delete Makefile.in.

(8) Download the dlfcn library and copy the files dlfcn.c and dlfcn.h to directory dlfcn. Go to directory dlfcn and make the following changes to the file dlfcn.h: Find the lines

#ifndef DLFCN_H
#define DLFCN_H

and add there three lines so that it becomes

#ifndef DLFCN_H
#define DLFCN_H
#ifdef __cplusplus
extern "C" {
#endif

Find at the end of the file the line

#endif /* DLFCN_H */

and add there three lines so that it becomes

#ifdef __cplusplus
}
#endif
#endif /* DLFCN_H */

(9) Write Makefile.am as

AUTOMAKE_OPTIONS=subdir-objects

noinst_LTLIBRARIES = libdl.la
libdl_la_SOURCES = dlfcn.c

(10) Add dlfcn and openfst to SUBDIRS variable of top-level Makefile.am.

Also add ../../openfst/src/lib/libfst.la and ../../dlfcn/libdl.la to libhfst_la_LIBADD

(11) Make the following changes to configure.ac:

Comment or delete the following lines:

AC_ARG_WITH([openfst],
            [AS_HELP_STRING([--with-openfst],
                            [process weighted fsts with OpenFst @<:@default=yes@:>@])],
            [],
            [with_openfst=yes])
AS_IF([test "x$with_openfst" != xno], [AC_DEFINE([HAVE_OPENFST], [1],
                                              [Define to compile OpenFst support in HFST])])
AM_CONDITIONAL([WANT_OPENFST], [test x$with_openfst != xno])

and

AS_IF([test "x$with_openfst" != "xno"],
      [AC_CHECK_LIB([pthread], [main])]
      [AC_CHECK_LIB([dl], [main])]
      [AC_CHECK_LIB([fst], [main], [],
                 [AC_MSG_FAILURE([openfst test failed (--without-openfst to disable)])])]
      [AC_CHECK_LIB([m], [main])])

Add the following files to AC_CONFIG_FILES:

dlfcn/Makefile
openfst/Makefile
openfst/src/Makefile
openfst/src/lib/Makefile

-- ErikAxelson - 2012-08-22

Topic revision: r2 - 2014-02-24 - ErikAxelson
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback