refactor: change engine installation path

Use `pkglibdir` instead of `libdir` as engine library installation
path, since they are considered modules for `arify`.
This commit is contained in:
CismonX 2023-08-08 17:35:49 +08:00
parent c6cd759a8c
commit 98ce348274
Signed by: cismonx
GPG Key ID: 3094873E29A482FB
6 changed files with 30 additions and 23 deletions

View File

@ -242,7 +242,7 @@ If the two names match the following pattern, a @code{$@{short_name@}} can be
used instead of the full name:
@example
lib$@{short_name@}$@{shlib_suffix@}:arif_$@{short_name@}_engine
$@{libdir@}/arif/$@{short_name@}$@{shlib_suffix@}:arif_$@{short_name@}_engine
@end example
Where @code{$@{shlib_suffix@}} is the common name suffix for shared library

View File

@ -6,22 +6,22 @@
# this notice are preserved. This file is offered as-is, without any warranty.
#
include_HEADERS =
noinst_HEADERS =
lib_LTLIBRARIES =
dist_man3_MANS =
include_HEADERS =
noinst_HEADERS =
pkglib_LTLIBRARIES =
dist_man3_MANS =
if BUILD_ARIF_RIME
include_HEADERS += arif_rime.h
noinst_HEADERS += arif_rime_workaround.h
lib_LTLIBRARIES += libarifrime.la
dist_man3_MANS += arif_rime.3
include_HEADERS += arif_rime.h
noinst_HEADERS += arif_rime_workaround.h
pkglib_LTLIBRARIES += rime.la
dist_man3_MANS += arif_rime.3
libarifrime_la_CPPFLAGS = $(RIME_CFLAGS) -I$(top_srcdir)/include
libarifrime_la_LDFLAGS = -module
libarifrime_la_LIBADD = $(RIME_LIBS)
libarifrime_la_SOURCES = arif_rime.c arif_rime_workaround.cc
rime_la_CPPFLAGS = $(RIME_CFLAGS) -I$(top_srcdir)/include
rime_la_LDFLAGS = -module
rime_la_LIBADD = $(RIME_LIBS)
rime_la_SOURCES = arif_rime.c arif_rime_workaround.cc
endif # BUILD_ARIF_RIME

View File

@ -46,3 +46,7 @@
#else
# define ARIF_DEBUG_ASSERT(expr) if (!(expr)) { ARIF_UNREACHABLE(); }
#endif
#ifndef ARIF_LIBDIR
# define ARIF_LIBDIR /usr/local/lib
#endif

View File

@ -9,7 +9,7 @@
bin_PROGRAMS =
lib_LTLIBRARIES = libarif.la
ARIF_CPPFLAGS_ = -I$(top_srcdir)/include
ARIF_CPPFLAGS_ = -I$(top_srcdir)/include -DARIF_LIBDIR=$(libdir)
libarif_la_CPPFLAGS = $(READLINE_CFLAGS) $(ARIF_CPPFLAGS_)
libarif_la_LIBADD = $(READLINE_LIBS)
@ -27,7 +27,7 @@ if BUILD_ARIFY
bin_PROGRAMS += arify
lib_LTLIBRARIES += libarify.la
arify_CPPFLAGS = $(ARIF_CPPFLAGS_) -DARIFY_LIBDIR=$(libdir)
arify_CPPFLAGS = $(ARIF_CPPFLAGS_)
arify_SOURCES = arify_cli.c
libarify_la_CPPFLAGS = $(READLINE_CFLAGS) $(ARIF_CPPFLAGS_)

View File

@ -59,6 +59,11 @@
# error "__attribute__((destructor)) not supported"
#endif
#define ARIFY_ENGINE_PATH_(libdir, engine) \
#libdir "/arif/" engine ARIF_SHLIB_SUFFIX
#define ARIFY_ENGINE_PATH(libdir, engine) ARIFY_ENGINE_PATH_(libdir, engine)
#define ARIFY_ENGINE_SYM(engine) "arif_" engine "_engine"
#ifndef ARIFY_MAX_PAGE_SIZE
# define ARIFY_MAX_PAGE_SIZE 99
#endif
@ -308,15 +313,16 @@ load_engine (
char *var_tmp = NULL;
if (var_name == NULL) {
size_t lib_name_len = 7 + strlen(lib_name) + sizeof ARIF_SHLIB_SUFFIX;
size_t lib_name_len
= sizeof ARIFY_ENGINE_PATH(ARIF_LIBDIR, "") + strlen(lib_name);
lib_tmp = malloc(sizeof(char) * lib_name_len);
assert(lib_tmp != NULL);
sprintf(lib_tmp, "libarif%s" ARIF_SHLIB_SUFFIX, lib_name);
sprintf(lib_tmp, ARIFY_ENGINE_PATH(ARIF_LIBDIR, "%s"), lib_name);
size_t var_name_len = 12 + strlen(lib_name) + 1;
size_t var_name_len = sizeof ARIFY_ENGINE_SYM("") + strlen(lib_name);
var_tmp = malloc(sizeof(char) * var_name_len);
assert(var_tmp != NULL);
sprintf(var_tmp, "arif_%s_engine", lib_name);
sprintf(var_tmp, ARIFY_ENGINE_SYM("%s"), lib_name);
lib_name = lib_tmp;
var_name = var_tmp;

View File

@ -36,9 +36,6 @@
#include "arif.h"
#include "arif_defs.h"
#ifndef ARIFY_LIBDIR
#define ARIFY_LIBDIR /usr/local/lib
#endif
#define ARIFY_PRELOAD_LIB_(libdir) #libdir "/libarify" ARIF_SHLIB_SUFFIX
#define ARIFY_PRELOAD_LIB(libdir) ARIFY_PRELOAD_LIB_(libdir)
@ -176,7 +173,7 @@ main (
assert(program != NULL);
struct options opts = {
.preload = ARIFY_PRELOAD_LIB(ARIFY_LIBDIR),
.preload = ARIFY_PRELOAD_LIB(ARIF_LIBDIR),
};
argv += parse_options(argc, argv, &opts);
set_envs(&opts);