summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2017-03-07 13:02:37 +0000
committerReuben Thomas <rrt@sc3d.org>2017-04-04 22:33:33 +0100
commita8e771a58a996d210dc9d12a3896d04b27465cc1 (patch)
tree8775efa8a44f8472050706571e82d588f4a183ad
parent75d31e7c59cb10c269b30f9c9ff500a39e9d6fd5 (diff)
downloadenchant-a8e771a58a996d210dc9d12a3896d04b27465cc1.tar.gz
Make library relocatable using gnulib’s relocatable-lib-lgpl module
This adds a new API enchant_set_prefix_dir, which necessitated changing the C++ API so that rather than constructing a broker instance statically, which would pre-empt any setting of the prefix dir, the Broker object must now be explicitly created. This also gives an easier way to have multiple Brokers, if desired.
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am1
-rwxr-xr-xautogen.sh2
-rw-r--r--bootstrap.conf4
-rw-r--r--configure.ac12
-rw-r--r--m4/.gitignore11
-rw-r--r--m4/gnulib-cache.m44
-rw-r--r--src/Makefile.am5
-rw-r--r--src/enchant++.h33
-rw-r--r--src/enchant.h3
-rw-r--r--src/lib.c89
-rw-r--r--tests/Makefile.am31
-rw-r--r--tests/enchant.test.c27
-rw-r--r--tests/enchantxx.test.cpp6
-rw-r--r--unittests/EnchantBrokerTestFixture.h6
-rw-r--r--unittests/EnchantTestFixture.h8
-rw-r--r--unittests/Makefile.am25
-rw-r--r--unittests/mock_provider/Makefile.am15
18 files changed, 161 insertions, 122 deletions
diff --git a/.gitignore b/.gitignore
index 3adc1d7..62435c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@ Makefile.in
/configure
/config.*
/depcomp
+/doc
/enchant.pc
/gnulib
/install-sh
diff --git a/Makefile.am b/Makefile.am
index 360e890..33a931c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,5 @@
ACLOCAL_AMFLAGS = -I m4
+AM_DISTCHECK_CONFIGURE_FLAGS = --enable-relocatable
SUBDIRS = lib src providers tests unittests
diff --git a/autogen.sh b/autogen.sh
index 0645bee..6dba0e9 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -12,7 +12,7 @@ test -z "$srcdir" && srcdir=.
./bootstrap || exit 1
if [ "$NOCONFIGURE" = "" ]; then
- $srcdir/configure "$@" || exit 1
+ $srcdir/configure --enable-relocatable "$@" || exit 1
if [ "$1" = "--help" ]; then exit 0 else
echo "Now type \`make\' to compile" || exit 1
diff --git a/bootstrap.conf b/bootstrap.conf
index 487d51f..1e08354 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -1,4 +1,4 @@
-# bootstrap.conf (GNU zile) version 2017-03-03
+# bootstrap.conf (GNU zile) version 2017-03-20
# Written by Gary V. Vaughan, 2010
# Copyright (C) 2010 Free Software Foundation, Inc.
@@ -47,8 +47,10 @@ gnulib_tool_options='
gnulib_modules='
alloca
bootstrap
+ configmake
flock
manywarnings
+ relocatable-lib-lgpl
snippet/unused-parameter
strdup-posix
'
diff --git a/configure.ac b/configure.ac
index 0f2a292..324ca3c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,6 +43,7 @@ AX_CXX_COMPILE_STDCXX(11)
AC_PROG_OBJCXX
AC_PROG_INSTALL
AC_PROG_LN_S
+AC_PROG_MKDIR_P
AC_HEADER_STDC
LT_INIT([win32-dll])
LT_LANG([Windows Resource])
@@ -50,6 +51,10 @@ gl_INIT
AC_SUBST([objdir])
LT_SYS_MODULE_EXT
AC_SUBST([shlibext], [$libltdl_cv_shlibext])
+AC_CONFIG_LIBOBJ_DIR([lib])
+if test $RELOCATABLE != yes; then
+ AC_MSG_ERROR([Enchant must be built with --enable-relocatable])
+fi
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.6 gmodule-2.0])
@@ -107,11 +112,12 @@ else
fi
AC_SUBST([ISYSTEM])
+libdir_subdir=`echo "$libdir" | sed -e 's|^${exec_prefix}/||'`
+AC_SUBST([libdir_subdir])
+
+# FIXME: Use just GLIB_CFLAGS, GLIB_LIBS
ENCHANT_CFLAGS=$GLIB_CFLAGS
ENCHANT_LIBS=$GLIB_LIBS
-if test "x$prefix" != "xNONE"; then
- ENCHANT_CFLAGS="$ENCHANT_CFLAGS -DENCHANT_PREFIX_DIR='\"$prefix\"'"
-fi
AC_SUBST(ENCHANT_CFLAGS)
AC_SUBST(ENCHANT_LIBS)
diff --git a/m4/.gitignore b/m4/.gitignore
index f5ac187..484f97f 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -40,3 +40,14 @@
/malloc.m4
/strdup.m4
/string_h.m4
+/dirname.m4
+/double-slash-root.m4
+/errno_h.m4
+/error.m4
+/getprogname.m4
+/relocatable-lib.m4
+/stdbool.m4
+/stdio_h.m4
+/strerror.m4
+/sys_socket_h.m4
+/configmake.m4
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index e8e2c5b..5c74794 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -27,15 +27,17 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --local-dir=gl --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=gl alloca bootstrap flock manywarnings snippet/unused-parameter strdup-posix
+# gnulib-tool --import --local-dir=gl --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=gl alloca bootstrap configmake flock manywarnings relocatable-lib-lgpl snippet/unused-parameter strdup-posix
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([gl])
gl_MODULES([
alloca
bootstrap
+ configmake
flock
manywarnings
+ relocatable-lib-lgpl
snippet/unused-parameter
strdup-posix
])
diff --git a/src/Makefile.am b/src/Makefile.am
index f21fb8a..4e1f4fb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,10 @@
AM_CPPFLAGS = -I$(top_srcdir) $(ISYSTEM)$(top_builddir)/lib $(ISYSTEM)$(top_srcdir)/lib $(ENCHANT_CFLAGS) $(WARN_CFLAGS)
+DEFS = -DENABLE_COSTLY_RELOCATABLE -DIN_LIBRARY -DINSTALLDIR=\"$(libdir)\"
lib_LTLIBRARIES = libenchant.la
-libenchant_la_CPPFLAGS = $(AM_CPPFLAGS) -DENCHANT_SYSTEM_ORDERING=\"$(sysconfdir)/enchant\" -DPKGLIBDIR=\"$(pkglibdir)\" -D_ENCHANT_BUILD=1 -DENCHANT_VERSION_STRING=\"@ENCHANT_MAJOR_VERSION@.@ENCHANT_MINOR_VERSION@.@ENCHANT_MICRO_VERSION@\"
-libenchant_la_LIBADD = $(top_builddir)/lib/libgnu.la $(ENCHANT_LIBS)
+libenchant_la_CPPFLAGS = $(AM_CPPFLAGS) -D_ENCHANT_BUILD=1 -DENCHANT_VERSION_STRING=\"@ENCHANT_MAJOR_VERSION@.@ENCHANT_MINOR_VERSION@.@ENCHANT_MICRO_VERSION@\"
+libenchant_la_LIBADD = $(top_builddir)/lib/libgnu.la $(ENCHANT_LIBS) $(LTLIBOBJS)
libenchant_la_LDFLAGS = -no-undefined -export-symbols-regex '^enchant_.*'
if OS_WIN32
diff --git a/src/enchant++.h b/src/enchant++.h
index 741c9db..089a90c 100644
--- a/src/enchant++.h
+++ b/src/enchant++.h
@@ -37,6 +37,10 @@
namespace enchant
{
+ void set_prefix_dir (const std::string prefix) {
+ enchant_set_prefix_dir (prefix.c_str ());
+ }
+
class Broker;
class Exception : public std::exception
@@ -205,10 +209,15 @@ namespace enchant
public:
- static Broker * instance () {
- return &m_instance;
+ Broker ()
+ : m_broker (enchant_broker_init ())
+ {
+ }
+
+ ~Broker () {
+ enchant_broker_free (m_broker);
}
-
+
Dict * request_dict (const std::string & lang) {
EnchantDict * dict = enchant_broker_request_dict (m_broker, lang.c_str());
@@ -251,30 +260,12 @@ namespace enchant
private:
- // space reserved for API/ABI expansion
- void * _private[5];
-
- Broker ()
- : m_broker (enchant_broker_init ())
- {
- }
-
- ~Broker () {
- enchant_broker_free (m_broker);
- }
-
// not implemented
Broker (const Broker & rhs);
Broker& operator=(const Broker & rhs);
- static Broker m_instance;
-
EnchantBroker * m_broker;
}; // class enchant::Broker
-
- // define the broker instance
- Broker Broker::m_instance;
-
} // enchant namespace
#endif /* ENCHANT_PLUS_PLUS_H */
diff --git a/src/enchant.h b/src/enchant.h
index fa41799..ef517a7 100644
--- a/src/enchant.h
+++ b/src/enchant.h
@@ -154,6 +154,9 @@ ENCHANT_MODULE_EXPORT (void)
EnchantDictDescribeFn fn,
void * user_data);
+ENCHANT_MODULE_EXPORT(void)
+ enchant_set_prefix_dir(const char *);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/lib.c b/src/lib.c
index 1278178..ef90b37 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -43,6 +43,8 @@
#include "enchant-provider.h"
#include "pwl.h"
#include "unused-parameter.h"
+#include "relocatable.h"
+#include "configmake.h"
/********************************************************************************/
@@ -85,6 +87,16 @@ typedef void (*EnchantPreConfigureFunc) (EnchantProvider * provider,
/********************************************************************************/
/********************************************************************************/
+/* Relocate a path and ensure the result is allocated on the heap */
+static char *
+enchant_relocate (const char *path)
+{
+ char *newpath = (char *) relocate (path);
+ if (path == newpath)
+ newpath = strdup (newpath);
+ return newpath;
+}
+
static void
enchant_ensure_dir_exists (const char* dir)
{
@@ -110,16 +122,12 @@ enchant_get_conf_dirs (void)
{
GSList *conf_dirs = NULL;
- char *prefix = enchant_get_prefix_dir ();
- if (prefix)
- {
- conf_dirs = g_slist_append (conf_dirs, g_build_filename (prefix, "share", "enchant", NULL));
- g_free (prefix);
- }
+ conf_dirs = g_slist_append (conf_dirs, enchant_relocate (PKGDATADIR));
-#if defined(ENCHANT_SYSTEM_ORDERING)
- conf_dirs = g_slist_append (conf_dirs, strdup (ENCHANT_SYSTEM_ORDERING));
-#endif
+ char *sysconfdir = enchant_relocate (SYSCONFDIR);
+ char *pkgconfdir = g_build_filename (sysconfdir, "enchant", NULL);
+ conf_dirs = g_slist_append (conf_dirs, pkgconfdir);
+ free (sysconfdir);
conf_dirs = g_slist_append (conf_dirs, enchant_get_user_config_dir ());
@@ -1117,43 +1125,30 @@ enchant_load_providers_in_dir (EnchantBroker * broker, const char *dir_name)
static void
enchant_load_providers (EnchantBroker * broker)
{
- char *prefix = enchant_get_prefix_dir ();
- const char *pkglibdir = PKGLIBDIR;
-
- enchant_load_providers_in_dir (broker, pkglibdir);
-
- if (prefix)
- {
- char *module_dir = g_build_filename (prefix, "lib", "enchant", NULL);
- if (strcmp (module_dir, pkglibdir) != 0)
- enchant_load_providers_in_dir (broker, module_dir);
- g_free (module_dir);
- g_free (prefix);
- }
+ char *module_dir = enchant_relocate (PKGLIBDIR);
+ enchant_load_providers_in_dir (broker, module_dir);
+ free (module_dir);
}
static void
enchant_load_ordering_from_file (EnchantBroker * broker, const char * file)
{
- char line [1024];
- char * tag, * ordering;
+ char line[1024];
- size_t i, len;
-
- FILE * f;
-
- f = g_fopen (file, "r");
+ FILE * f = g_fopen (file, "r");
if (!f)
return;
while (NULL != fgets (line, sizeof(line), f)) {
+ size_t i, len;
+
for (i = 0, len = strlen(line); i < len && line[i] != ':'; i++)
;
if (i < len)
{
- tag = g_strndup (line, i);
- ordering = g_strndup (line+(i+1), len - i);
+ char * tag = g_strndup (line, i);
+ char * ordering = g_strndup (line + (i + 1), len - i);
enchant_broker_set_ordering (broker, tag, ordering);
@@ -1873,7 +1868,7 @@ enchant_get_user_language(void)
* compiled, except it is determined at runtime based on the location
* of the enchant library.
*
- * Returns: the prefix dir if it can be determined, or %null otherwise. Must be g_free'd.
+ * Returns: the prefix dir. Must be free'd.
*
* This API is private to the providers.
*
@@ -1881,23 +1876,21 @@ enchant_get_user_language(void)
ENCHANT_MODULE_EXPORT (char *)
enchant_get_prefix_dir(void)
{
- char * prefix = NULL;
-
- {
- /* Use ENCHANT_PREFIX_DIR env var */
- const gchar* env = g_getenv("ENCHANT_PREFIX_DIR");
- if (env) {
- prefix = g_filename_to_utf8(env, -1, NULL, NULL, NULL);
- }
- }
-
-#if defined(ENCHANT_PREFIX_DIR)
- if (!prefix) {
- prefix = g_strdup (ENCHANT_PREFIX_DIR);
- }
-#endif
+ return enchant_relocate (INSTALLPREFIX);
+}
- return prefix;
+/**
+ * enchant_set_prefix_dir
+ *
+ * Set the prefix dir. This overrides any auto-detected value,
+ * and can also be used on systems or installations where
+ * auto-detection does not work.
+ *
+ */
+ENCHANT_MODULE_EXPORT (void)
+enchant_set_prefix_dir(const char *new_prefix)
+{
+ set_relocation_prefix (INSTALLPREFIX, new_prefix);
}
ENCHANT_MODULE_EXPORT(const char *) _GL_ATTRIBUTE_CONST
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8341520..a8e052b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,21 +1,34 @@
AM_CPPFLAGS = -I$(top_srcdir)/src $(ENCHANT_CFLAGS)
+ENCHANT_CONFIG_DIR = config
+
AM_TESTS_ENVIRONMENT = \
- ENCHANT_PREFIX_DIR=""; \
- export ENCHANT_PREFIX_DIR; \
- ENCHANT_CONFIG_DIR="config"; \
- export ENCHANT_CONFIG_DIR; \
- rm -f test.pwl lib; \
- mkdir -p lib/enchant; \
- cp $(top_builddir)/providers/@objdir@/*@shlibext@ lib/enchant || :;
+ export ENCHANT_CONFIG_DIR=$(ENCHANT_CONFIG_DIR); \
+ rm -rf test.pwl $(libdir_subdir); \
+ mkdir -p $(libdir_subdir)/enchant; \
+ cp -r $(top_builddir)/src/@objdir@ $(libdir_subdir)/; \
+ cp $(top_builddir)/src/libenchant.la $(libdir_subdir)/; \
+ cp $(top_builddir)/providers/@objdir@/*@shlibext@ $(libdir_subdir)/enchant || :; \
cp $(srcdir)/test.pwl.orig $(builddir)/test.pwl; \
chmod +w $(builddir)/test.pwl;
-DISTCLEANFILES = test.pwl lib/enchant/*@shlibext@ config/*
+DISTCLEANFILES = test.pwl
+
+distclean-local:
+ rm -rf $(libdir_subdir) $(ENCHANT_CONFIG_DIR)
EXTRA_DIST = test.pwl.orig
-LDADD = $(top_builddir)/src/libenchant.la $(ENCHANT_LIBS)
+# FIXME: Remove this duplicate stanza when build system is made non-recursive
+LIBENCHANT_COPY = $(builddir)/$(libdir_subdir)/libenchant.la
+$(LIBENCHANT_COPY): $(top_builddir)/src/libenchant.la
+ rm -rf $(libdir_subdir)/
+ $(MKDIR_P) $(libdir_subdir)/enchant
+ cp -r $(top_builddir)/src/@objdir@ $(libdir_subdir)/
+ cp $(top_builddir)/src/libenchant.la $(libdir_subdir)/
+
+LDADD = $(LIBENCHANT_COPY) $(ENCHANT_LIBS)
+DEPS = $(LIBENCHANT_COPY)
check_PROGRAMS = enchant.test enchantxx.test
diff --git a/tests/enchant.test.c b/tests/enchant.test.c
index 216f9be..29dce66 100644
--- a/tests/enchant.test.c
+++ b/tests/enchant.test.c
@@ -110,14 +110,13 @@ run_dict_tests (EnchantDict * dict)
int
main (int argc, char **argv)
{
- EnchantBroker *broker;
- EnchantDict *dict;
+ enchant_set_prefix_dir (".");
+
const char * err;
-
- broker = enchant_broker_init ();
+ EnchantBroker *broker = enchant_broker_init ();
+ EnchantDict *dict;
dict = enchant_broker_request_dict (broker, "en_US");
-
if (!dict)
{
err = enchant_broker_get_error (broker);
@@ -127,12 +126,9 @@ main (int argc, char **argv)
fprintf (stderr, "Couldn't create dictionary for en_US\n");
return 1;
}
- else
- {
- enchant_dict_describe (dict, describe_dict_fn, NULL);
- run_dict_tests (dict);
- enchant_broker_free_dict (broker, dict);
- }
+ enchant_dict_describe (dict, describe_dict_fn, NULL);
+ run_dict_tests (dict);
+ enchant_broker_free_dict (broker, dict);
dict = enchant_broker_request_pwl_dict (broker, "test.pwl");
if (!dict)
@@ -144,12 +140,9 @@ main (int argc, char **argv)
fprintf (stderr, "Couldn't create personal wordlist dictionary\n");
return 1;
}
- else
- {
- enchant_dict_describe (dict, describe_dict_fn, NULL);
- run_dict_tests (dict);
- enchant_broker_free_dict (broker, dict);
- }
+ enchant_dict_describe (dict, describe_dict_fn, NULL);
+ run_dict_tests (dict);
+ enchant_broker_free_dict (broker, dict);
enchant_broker_describe (broker, enumerate_providers_fn, NULL);
enchant_broker_free (broker);
diff --git a/tests/enchantxx.test.cpp b/tests/enchantxx.test.cpp
index b3e3ea3..052dc33 100644
--- a/tests/enchantxx.test.cpp
+++ b/tests/enchantxx.test.cpp
@@ -95,11 +95,11 @@ run_dict_tests (enchant::Dict * dict)
int
main (int argc, char **argv)
{
- enchant::Broker *broker;
+ enchant::set_prefix_dir (".");
+
+ enchant::Broker *broker = new enchant::Broker();
enchant::Dict *dict;
- broker = enchant::Broker::instance ();
-
try {
dict = broker->request_dict ("en_US");
describe_dict (dict);
diff --git a/unittests/EnchantBrokerTestFixture.h b/unittests/EnchantBrokerTestFixture.h
index 015b7f6..a52b50b 100644
--- a/unittests/EnchantBrokerTestFixture.h
+++ b/unittests/EnchantBrokerTestFixture.h
@@ -126,7 +126,7 @@ struct EnchantBrokerTestFixture : EnchantTestFixture
userMockProvider2Configuration = user2Configuration;
CopyProvider("enchant_mock_provider", "enchant_mock_provider");
- hModule = g_module_open("lib/enchant/enchant_mock_provider", (GModuleFlags) 0);
+ hModule = g_module_open(LIBDIR_SUBDIR "/enchant/enchant_mock_provider", (GModuleFlags) 0);
if(hModule!=NULL){
SET_CONFIGURE sc;
assert(g_module_symbol(hModule, "set_configure", (gpointer *)&sc));
@@ -136,7 +136,7 @@ struct EnchantBrokerTestFixture : EnchantTestFixture
hModule2 = NULL;
if(user2Configuration != NULL){
CopyProvider("enchant_mock_provider2", "enchant_mock_provider2");
- hModule2 = g_module_open("lib/enchant/enchant_mock_provider2", (GModuleFlags) 0);
+ hModule2 = g_module_open(LIBDIR_SUBDIR "/enchant/enchant_mock_provider2", (GModuleFlags) 0);
if(hModule2!=NULL){
SET_CONFIGURE sc;
assert(g_module_symbol(hModule2, "set_configure", (gpointer *)&sc));
@@ -193,7 +193,7 @@ struct EnchantBrokerTestFixture : EnchantTestFixture
std::string sourceName = prefix + sourceProviderName + "." + G_MODULE_SUFFIX;
std::string destinationName = destinationProviderName + "." + G_MODULE_SUFFIX;
- std::string destinationDir = AddToPath(AddToPath(GetDirectoryOfThisModule(), "lib"),"enchant");
+ std::string destinationDir = AddToPath(AddToPath(GetDirectoryOfThisModule(), LIBDIR_SUBDIR), "enchant");
CreateDirectory(destinationDir);
diff --git a/unittests/EnchantTestFixture.h b/unittests/EnchantTestFixture.h
index fdca471..b28bba6 100644
--- a/unittests/EnchantTestFixture.h
+++ b/unittests/EnchantTestFixture.h
@@ -45,11 +45,14 @@
#include <locale>
#include <codecvt>
+#include "enchant.h"
+
struct EnchantTestFixture
{
//Setup
EnchantTestFixture()
{
+ enchant_set_prefix_dir(GetDirectoryOfThisModule().c_str());
CleanUpFiles(); //just in case we stopped the process in the middle.
CreateDirectory(GetTempUserEnchantDir());
}
@@ -60,9 +63,8 @@ struct EnchantTestFixture
}
void CleanUpFiles()
{
- //clean up personal dictionaries from home dir
DeleteDirAndFiles(GetTempUserEnchantDir());
- DeleteDirAndFiles(AddToPath(GetDirectoryOfThisModule(), "lib"));
+ DeleteDirAndFiles(AddToPath(AddToPath(GetDirectoryOfThisModule(), LIBDIR_SUBDIR), "enchant"));
DeleteDirAndFiles(AddToPath(GetDirectoryOfThisModule(), "share"));
}
@@ -144,7 +146,7 @@ struct EnchantTestFixture
std::string GetDirectoryOfThisModule()
{
- std::string result;
+ std::string result = ".";
#if defined(_WIN32)
// should be in the same directory as our test fixture
WCHAR szFilename[MAX_PATH];
diff --git a/unittests/Makefile.am b/unittests/Makefile.am
index b63821e..06f42bd 100644
--- a/unittests/Makefile.am
+++ b/unittests/Makefile.am
@@ -1,17 +1,23 @@
SUBDIRS = enchant_providers mock_provider
-AM_CPPFLAGS = -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(UNITTESTPP_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(UNITTESTPP_CFLAGS) -DLIBDIR_SUBDIR=\"$(libdir_subdir)\"
+
+ENCHANT_CONFIG_DIR="config"
AM_TESTS_ENVIRONMENT = \
- ENCHANT_PREFIX_DIR=""; \
- export ENCHANT_PREFIX_DIR; \
- ENCHANT_CONFIG_DIR="config"; \
- export ENCHANT_CONFIG_DIR; \
+ export ENCHANT_CONFIG_DIR=$(ENCHANT_CONFIG_DIR); \
cp $(builddir)/mock_provider/@objdir@/*@shlibext@ .;
check_PROGRAMS = main
TESTS = main
+LIBENCHANT_COPY = $(builddir)/$(libdir_subdir)/libenchant.la
+$(LIBENCHANT_COPY): $(top_builddir)/src/libenchant.la
+ rm -rf $(libdir_subdir)/
+ $(MKDIR_P) $(libdir_subdir)/enchant
+ cp -r $(top_builddir)/src/@objdir@ $(libdir_subdir)/
+ cp $(top_builddir)/src/libenchant.la $(libdir_subdir)/
+
main_SOURCES = main.cpp \
EnchantBrokerTestFixture.h \
EnchantDictionaryTestFixture.h \
@@ -47,7 +53,10 @@ main_SOURCES = main.cpp \
provider/enchant_provider_get_user_config_dirs_tests.cpp \
provider/enchant_provider_get_user_language_tests.cpp \
$(NULL)
-main_DEPENDENCIES = $(top_builddir)/src/libenchant.la
-main_LDADD = $(top_builddir)/src/libenchant.la $(ENCHANT_LIBS) $(UNITTESTPP_LIBS)
+main_DEPENDENCIES = $(LIBENCHANT_COPY)
+main_LDADD = $(LIBENCHANT_COPY) $(ENCHANT_LIBS) $(UNITTESTPP_LIBS)
+
+DISTCLEANFILES = *@shlibext@ $(libdir_subdir)/enchant/*@shlibext@ config/
-DISTCLEANFILES = libenchant_*.so *enchant*.dll
+distclean-local:
+ rm -rf $(libdir_subdir) $(ENCHANT_CONFIG_DIR)
diff --git a/unittests/mock_provider/Makefile.am b/unittests/mock_provider/Makefile.am
index f3c52cd..610080c 100644
--- a/unittests/mock_provider/Makefile.am
+++ b/unittests/mock_provider/Makefile.am
@@ -11,8 +11,19 @@ check_LTLIBRARIES = \
libenchant_null_identify.la \
libenchant_null_describe.la
-# Adding -rpath to LDFLAGS causes the .so to be built even though the lib is noinst_
-AM_LDFLAGS = -module -avoid-version -no-undefined -rpath /foo $(ENCHANT_LIBS) $(top_builddir)/src/libenchant.la
+# FIXME: This stanza from unittests/Makefile.am because for testing to work this directory must be built first,
+# but the test copy is required in the directory above.
+# When the build system is made non-recursive, this copy of the stanza can be removed.
+LIBENCHANT_COPY = $(builddir)/../$(libdir_subdir)/libenchant.la
+$(LIBENCHANT_COPY): $(top_builddir)/src/libenchant.la
+ rm -rf ../$(libdir_subdir)/
+ $(MKDIR_P) ../$(libdir_subdir)/enchant
+ cp -r $(abs_top_builddir)/src/@objdir@ ../$(libdir_subdir)/
+ cp $(abs_top_builddir)/src/libenchant.la ../$(libdir_subdir)/
+
+# Adding -rpath to LDFLAGS causes the .so to be built even though the lib is not to be installed
+AM_LDFLAGS = -module -avoid-version -no-undefined -rpath /foo $(ENCHANT_LIBS)
+LIBADD = $(LIBENCHANT_COPY)
libenchant_mock_provider_la_SOURCES = mock_provider.cpp
# Build distinct libraries rather than copying a single one, to avoid being