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