refactor: cleaner way to hard-code libdir
This commit is contained in:
parent
6bdc2578ef
commit
5526a0bc77
|
@ -48,5 +48,5 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ARIF_LIBDIR
|
#ifndef ARIF_LIBDIR
|
||||||
# define ARIF_LIBDIR /usr/local/lib
|
# define ARIF_LIBDIR "/usr/local/lib"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
bin_PROGRAMS =
|
bin_PROGRAMS =
|
||||||
lib_LTLIBRARIES = libarif.la
|
lib_LTLIBRARIES = libarif.la
|
||||||
|
|
||||||
ARIF_CPPFLAGS_ = -I$(top_srcdir)/include -DARIF_LIBDIR=$(libdir)
|
ARIF_CPPFLAGS_ = -I$(top_srcdir)/include -DARIF_LIBDIR="\"$(libdir)\""
|
||||||
|
|
||||||
libarif_la_CPPFLAGS = $(READLINE_CFLAGS) $(ARIF_CPPFLAGS_)
|
libarif_la_CPPFLAGS = $(READLINE_CFLAGS) $(ARIF_CPPFLAGS_)
|
||||||
libarif_la_LIBADD = $(READLINE_LIBS)
|
libarif_la_LIBADD = $(READLINE_LIBS)
|
||||||
|
|
12
src/arify.c
12
src/arify.c
|
@ -59,10 +59,9 @@
|
||||||
# error "__attribute__((destructor)) not supported"
|
# error "__attribute__((destructor)) not supported"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ARIFY_ENGINE_PATH_(libdir, engine) \
|
#define ARIFY_ENGINE_LIB(engine) \
|
||||||
#libdir "/arif/" engine ARIF_SHLIB_SUFFIX
|
ARIF_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"
|
||||||
#define ARIFY_ENGINE_SYM(engine) "arif_" engine "_engine"
|
|
||||||
|
|
||||||
#ifndef ARIFY_MAX_PAGE_SIZE
|
#ifndef ARIFY_MAX_PAGE_SIZE
|
||||||
# define ARIFY_MAX_PAGE_SIZE 99
|
# define ARIFY_MAX_PAGE_SIZE 99
|
||||||
|
@ -313,11 +312,10 @@ load_engine (
|
||||||
char *var_tmp = NULL;
|
char *var_tmp = NULL;
|
||||||
|
|
||||||
if (var_name == NULL) {
|
if (var_name == NULL) {
|
||||||
size_t lib_name_len
|
size_t lib_name_len = sizeof ARIFY_ENGINE_LIB("") + strlen(lib_name);
|
||||||
= sizeof ARIFY_ENGINE_PATH(ARIF_LIBDIR, "") + strlen(lib_name);
|
|
||||||
lib_tmp = malloc(sizeof(char) * lib_name_len);
|
lib_tmp = malloc(sizeof(char) * lib_name_len);
|
||||||
assert(lib_tmp != NULL);
|
assert(lib_tmp != NULL);
|
||||||
sprintf(lib_tmp, ARIFY_ENGINE_PATH(ARIF_LIBDIR, "%s"), lib_name);
|
sprintf(lib_tmp, ARIFY_ENGINE_LIB("%s"), lib_name);
|
||||||
|
|
||||||
size_t var_name_len = sizeof ARIFY_ENGINE_SYM("") + strlen(lib_name);
|
size_t var_name_len = sizeof ARIFY_ENGINE_SYM("") + strlen(lib_name);
|
||||||
var_tmp = malloc(sizeof(char) * var_name_len);
|
var_tmp = malloc(sizeof(char) * var_name_len);
|
||||||
|
|
|
@ -35,8 +35,7 @@
|
||||||
#include "arif.h"
|
#include "arif.h"
|
||||||
#include "arif_defs.h"
|
#include "arif_defs.h"
|
||||||
|
|
||||||
#define ARIFY_PRELOAD_LIB_(libdir) #libdir "/libarify" ARIF_SHLIB_SUFFIX
|
#define ARIFY_PRELOAD_LIB ARIF_LIBDIR "/libarify" ARIF_SHLIB_SUFFIX
|
||||||
#define ARIFY_PRELOAD_LIB(libdir) ARIFY_PRELOAD_LIB_(libdir)
|
|
||||||
|
|
||||||
struct options {
|
struct options {
|
||||||
char *frontend;
|
char *frontend;
|
||||||
|
@ -172,7 +171,7 @@ main (
|
||||||
assert(program != NULL);
|
assert(program != NULL);
|
||||||
|
|
||||||
struct options opts = {
|
struct options opts = {
|
||||||
.preload = ARIFY_PRELOAD_LIB(ARIF_LIBDIR),
|
.preload = ARIFY_PRELOAD_LIB,
|
||||||
};
|
};
|
||||||
argv += parse_options(argc, argv, &opts);
|
argv += parse_options(argc, argv, &opts);
|
||||||
set_envs(&opts);
|
set_envs(&opts);
|
||||||
|
|
Loading…
Reference in New Issue