[WIP] Move hardcoded paths to r_userconf.h (#9959)

* Move hardcoded paths to r_userconf.h

* Add R2_HOME_* macros

* Some cleanup
This commit is contained in:
Paul I 2018-04-28 11:02:55 +03:00 committed by radare
parent d53dcde2f3
commit cc90ec6be5
54 changed files with 286 additions and 193 deletions

View File

@ -574,7 +574,7 @@ int main(int argc, char **argv) {
bin = core.bin;
if (!(tmp = r_sys_getenv ("RABIN2_NOPLUGINS"))) {
char *homeplugindir = r_str_home (R2_HOMEDIR "/plugins");
char *homeplugindir = r_str_home (R2_HOME_PLUGINS);
l = r_lib_new ("radare_plugin");
r_lib_add_handler (l, R_LIB_TYPE_BIN, "bin plugins",
&__lib_bin_cb, &__lib_bin_dt, NULL);

View File

@ -174,22 +174,22 @@ static int main_help(int line) {
" -z, -zz do not load strings or load them even in raw\n");
}
if (line == 2) {
char *homedir = r_str_home (R2_HOMEDIR);
char *homedir = r_str_home (R2_HOME_CONFIGDIR);
printf (
"Scripts:\n"
" system ${R2_PREFIX}/share/radare2/radare2rc\n"
" user ~/.radare2rc ${RHOMEDIR}/radare2/radare2rc (and radare2rc.d/)\n"
" user ~/.radare2rc " R_JOIN_2_PATHS("~", R2_HOME_RC) " (and " R_JOIN_3_PATHS("~", R2_HOME_RC_DIR,"") ")\n"
" file ${filename}.r2\n"
"Plugins:\n"
" binrc ~/.config/radare2/rc.d/bin-<format>/ (elf, elf64, mach0, ..)\n"
" binrc " R_JOIN_4_PATHS("~", R2_HOME_BINRC, "bin-<format>", "") " (elf, elf64, mach0, ..)\n"
" plugins "R2_PREFIX"/lib/radare2/last\n"
" USER_PLUGINS ~/.config/radare2/plugins\n"
" USER_PLUGINS " R_JOIN_2_PATHS("~", R2_HOME_PLUGINS)"\n"
" LIBR_PLUGINS "R2_PREFIX"/lib/radare2/"R2_VERSION"\n"
" USER_ZIGNS ~/.config/radare2/zigns\n"
" USER_ZIGNS " R_JOIN_2_PATHS("~", R2_HOME_ZIGNS) "\n"
"Environment:\n"
" RHOMEDIR %s\n" // TODO: rename to RHOME R2HOME?
" RCFILE ~/.radare2rc (user preferences, batch script)\n" // TOO GENERIC
" MAGICPATH "R_MAGIC_PATH"\n"
" MAGICPATH "R2_SDB_MAGIC"\n"
" R_DEBUG if defined, show error messages and crash signal\n"
" VAPIDIR path to extra vapi directory\n"
" R2_NOPLUGINS do not load r2 shared plugins\n"
@ -206,15 +206,15 @@ static int main_help(int line) {
static int main_print_var(const char *var_name) {
int i = 0;
char *homedir = r_str_home (R2_HOMEDIR);
char *homeplugs = r_str_newf ("%s" R_SYS_DIR "plugins", homedir);
char *homezigns = r_str_newf ("%s" R_SYS_DIR "zigns", homedir);
char *homedir = r_str_home (R2_HOME_CONFIGDIR);
char *homeplugs = r_str_home (R2_HOME_PLUGINS);
char *homezigns = r_str_home (R2_HOME_ZIGNS);
struct radare2_var_t {
const char *name;
const char *value;
} r2_vars[] = {
{ "R2_PREFIX", R2_PREFIX },
{ "MAGICPATH", R_MAGIC_PATH },
{ "MAGICPATH", R2_SDB_MAGIC },
{ "PREFIX", R2_PREFIX },
{ "INCDIR", R2_INCDIR },
{ "LIBDIR", R2_LIBDIR },
@ -297,7 +297,7 @@ static void radare2_rc(RCore *r) {
r_core_cmd_file (r, homerc);
}
free (homerc);
homerc = r_str_home (".config/radare2/radare2rc");
homerc = r_str_home (R2_HOME_RC);
if (homerc && r_file_is_regular (homerc)) {
if (has_debug) {
eprintf ("USER CONFIG loaded from %s\n", homerc);
@ -305,7 +305,7 @@ static void radare2_rc(RCore *r) {
r_core_cmd_file (r, homerc);
}
free (homerc);
homerc = r_str_home (".config/radare2/radare2rc.d");
homerc = r_str_home (R2_HOME_RC_DIR);
if (homerc) {
if (r_file_is_directory (homerc)) {
char *file;
@ -1427,7 +1427,7 @@ int main(int argc, char **argv, char **envp) {
}
if (mustSaveHistory(r.config)) {
r_line_hist_save (R2_HOMEDIR"/history");
r_line_hist_save (R2_HOME_HISTORY);
}
// TODO: kill thread

View File

@ -446,7 +446,7 @@ int main (int argc, char *argv[]) {
r_lib_opendir (l, path);
if (1) {
char *homeplugindir = r_str_home (R2_HOMEDIR "/plugins");
char *homeplugindir = r_str_home (R2_HOME_PLUGINS);
// eprintf ("OPENDIR (%s)\n", homeplugindir);
r_lib_opendir (l, homeplugindir);
free (homeplugindir);

View File

@ -229,14 +229,13 @@ R_API bool r_anal_set_reg_profile(RAnal *anal) {
}
R_API bool r_anal_set_fcnsign(RAnal *anal, const char *name) {
#define FCNSIGNPATH "share/radare2/" R2_VERSION "/fcnsign"
const char *dirPrefix = r_sys_prefix (NULL);
char *file = NULL;
const char *arch = (anal->cur && anal->cur->arch) ? anal->cur->arch : R_SYS_ARCH;
if (name && *name) {
file = sdb_fmt ("%s/%s/%s.sdb", dirPrefix, FCNSIGNPATH, name);
file = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "%s.sdb"), dirPrefix, name);
} else {
file = sdb_fmt ("%s/%s/%s-%s-%d.sdb", dirPrefix, FCNSIGNPATH,
file = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "%s-%s-%d.sdb"), dirPrefix,
anal->os, arch, anal->bits);
}
if (r_file_exists (file)) {

View File

@ -35,6 +35,6 @@ foreach file : sdb_files
build_by_default: true,
build_always: false,
install: true,
install_dir: join_paths(get_option('datadir'), 'radare2', r2version, 'fcnsign')
install_dir: join_paths(get_option('datadir'), 'radare2', r2_version, 'fcnsign')
)
endforeach

View File

@ -113,13 +113,13 @@ r_anal = library('r_anal', files,
],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_anal],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_anal',
filebase: 'r_anal',
requires: [

View File

@ -1171,7 +1171,7 @@ R_API char *r_sign_path(RAnal *a, const char *file) {
}
free (abs);
} else {
char *home = r_str_home (".config/radare2/zigns/");
char *home = r_str_home (R2_HOME_ZIGNS);
abs = r_str_newf ("%s%s%s", home, R_SYS_DIR, file);
free (home);
if (r_file_is_regular (abs)) {
@ -1180,9 +1180,7 @@ R_API char *r_sign_path(RAnal *a, const char *file) {
free (abs);
}
/// XXX mixed / and R_SYS_DIR
const char *pfx = "/share/radare2/" R2_VERSION "/zigns";
abs = r_str_newf ("%s%s%s%s", r_sys_prefix (NULL), pfx, R_SYS_DIR, file);
abs = r_str_newf (R_JOIN_3_PATHS("%s", R2_ZIGNS, "%s"), r_sys_prefix (NULL), file);
if (r_file_is_regular (abs)) {
return abs;
}

View File

@ -8,8 +8,6 @@
#include <spp/spp.h>
#include <config.h>
#define R_ASM_OPCODES_PATH "/share/radare2/" R2_VERSION "/opcodes"
R_LIB_VERSION (r_asm);
char *directives[] = {
@ -315,7 +313,8 @@ R_API int r_asm_use(RAsm *a, const char *name) {
if (!a->cur || (a->cur && strcmp (a->cur->arch, h->arch))) {
//const char *dop = r_config_get (core->config, "dir.opcodes");
// TODO: allow configurable path for sdb files
snprintf (file, sizeof (file), "%s/"R_ASM_OPCODES_PATH"/%s.sdb", dirPrefix, h->arch);
snprintf (file, sizeof (file), R_JOIN_3_PATHS("%s", R2_SDB_OPCODES, "%s.sdb"),
dirPrefix, h->arch);
sdb_free (a->pair);
r_asm_set_cpu (a, NULL);
a->pair = sdb_new (NULL, file, 0);

View File

@ -38,6 +38,6 @@ foreach file : sdb_files
build_by_default: true,
build_always: false,
install: true,
install_dir: join_paths(get_option('datadir'), 'radare2', r2version, 'opcodes')
install_dir: join_paths(get_option('datadir'), 'radare2', r2_version, 'opcodes')
)
endforeach

View File

@ -168,13 +168,13 @@ r_asm = library('r_asm', files,
],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_asm],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_asm',
filebase: 'r_asm',
requires: [

View File

@ -55,7 +55,7 @@ foreach file : sdb_files
build_by_default: true,
build_always: false,
install: true,
install_dir: join_paths(get_option('datadir'), 'radare2', r2version, 'format/dll')
install_dir: join_paths(get_option('datadir'), 'radare2', r2_version, 'format/dll')
)
endforeach
@ -70,5 +70,5 @@ format_files = [
]
install_data(format_files,
install_dir: join_paths(get_option('datadir'), 'radare2', r2version, 'format')
install_dir: join_paths(get_option('datadir'), 'radare2', r2_version, 'format')
)

View File

@ -433,17 +433,9 @@ static int bin_pe_parse_imports(struct PE_(r_bin_pe_obj_t)* bin,
if (r_file_exists (filename)) {
db = sdb_new (NULL, filename, 0);
} else {
#if __WINDOWS__
char invoke_dir[MAX_PATH];
if (r_sys_get_src_dir_w32 (invoke_dir)) {
filename = sdb_fmt ("%s\\share\\radare2\\"R2_VERSION "\\format\\dll\\%s.sdb", invoke_dir, symdllname);
} else {
filename = sdb_fmt ("share/radare2/"R2_VERSION "/format/dll/%s.sdb", symdllname);
}
#else
const char *dirPrefix = r_sys_prefix (NULL);
filename = sdb_fmt ("%s/share/radare2/" R2_VERSION "/format/dll/%s.sdb", dirPrefix, symdllname);
#endif
filename = sdb_fmt (R_JOIN_4_PATHS("%s", R2_SDB_FORMAT, "dll", "%s.sdb"),
dirPrefix, symdllname);
if (r_file_exists (filename)) {
db = sdb_new (NULL, filename, 0);
}

View File

@ -123,13 +123,13 @@ r_bin = library('r_bin', files,
link_with: [r_util, r_io, r_socket, r_magic, libr_shlr],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_bin],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_bin',
filebase: 'r_bin',
requires: [

View File

@ -19,8 +19,8 @@ static char *get_filetype(RBinFile *bf) {
if (ck && bf && bf->buf) {
const char *tmp = NULL;
// TODO: dir.magic not honored here
char *pfx = r_str_newf ("%s/%s", r_sys_prefix (NULL), R_MAGIC_PATH);
r_magic_load (ck, R_MAGIC_PATH);
char *pfx = r_str_newf (R_JOIN_2_PATHS("%s", R2_SDB_MAGIC), r_sys_prefix (NULL));
r_magic_load (ck, R2_SDB_MAGIC);
r_buf_read_at (bf->buf, 0, buf, sizeof (buf));
tmp = r_magic_buffer (ck, buf, sizeof (buf));
if (tmp) {

View File

@ -18,13 +18,13 @@ r_bp = library('r_bp', files,
link_with: [r_util],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_bp],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_bp',
filebase: 'r_bp',
requires: [

View File

@ -8,13 +8,13 @@ r_config = library('r_config', files,
link_with: [r_util, libr_shlr],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_config],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_config',
filebase: 'r_config',
requires: [

View File

@ -1,4 +1,4 @@
install_subdir('.',
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'radare2', r2version, 'cons'),
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'radare2', r2_version, 'cons'),
exclude_files: ['Makefile', 'meson.build']
)

View File

@ -22,13 +22,13 @@ r_cons = library('r_cons', files,
link_with: [r_util, libr_shlr],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_cons],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_cons',
filebase: 'r_cons',
requires: [

View File

@ -3,7 +3,6 @@
#include <r_core.h>
#include "r_util.h"
#define DBSPATH "/share/radare2/" R2_VERSION "/fcnsign"
#define is_in_range(at, from, sz) ((at) >= (from) && (at) < ((from) + (sz)))
#define VA_FALSE 0
@ -497,35 +496,42 @@ R_API void r_core_anal_type_init(RCore *core) {
anal_arch = r_config_get (core->config, "anal.arch");
os = r_config_get (core->config, "asm.os");
// spaguetti ahead
dbpath = sdb_fmt ("%s/"DBSPATH"/types.sdb", dir_prefix);
dbpath = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "types.sdb"), dir_prefix);
if (r_file_exists (dbpath)) {
sdb_concat_by_path (types, dbpath);
}
dbpath = sdb_fmt ("%s/"DBSPATH"/types-%s.sdb", dir_prefix, anal_arch);
dbpath = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "types-%s.sdb"),
dir_prefix, anal_arch);
if (r_file_exists (dbpath)) {
sdb_concat_by_path (types, dbpath);
}
dbpath = sdb_fmt ("%s/"DBSPATH"/types-%s.sdb", dir_prefix, os);
dbpath = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "types-%s.sdb"),
dir_prefix, os);
if (r_file_exists (dbpath)) {
sdb_concat_by_path (types, dbpath);
}
dbpath = sdb_fmt ("%s/"DBSPATH"/types-%d.sdb", dir_prefix, bits);
dbpath = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "types-%d.sdb"),
dir_prefix, bits);
if (r_file_exists (dbpath)) {
sdb_concat_by_path (types, dbpath);
}
dbpath = sdb_fmt ("%s/"DBSPATH"/types-%s-%d.sdb", dir_prefix, os, bits);
dbpath = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "types-%s-%d.sdb"),
dir_prefix, os, bits);
if (r_file_exists (dbpath)) {
sdb_concat_by_path (types, dbpath);
}
dbpath = sdb_fmt ("%s/"DBSPATH"/types-%s-%d.sdb", dir_prefix, anal_arch, bits);
dbpath = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "types-%s-%d.sdb"),
dir_prefix, anal_arch, bits);
if (r_file_exists (dbpath)) {
sdb_concat_by_path (types, dbpath);
}
dbpath = sdb_fmt ("%s/"DBSPATH"/types-%s-%s.sdb", dir_prefix, anal_arch, os);
dbpath = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "types-%s-%s.sdb"),
dir_prefix, anal_arch, os);
if (r_file_exists (dbpath)) {
sdb_concat_by_path (types, dbpath);
}
dbpath = sdb_fmt ("%s/"DBSPATH"/types-%s-%s-%d.sdb", dir_prefix, anal_arch, os, bits);
dbpath = sdb_fmt (R_JOIN_3_PATHS("%s", R2_SDB_FCNSIGN, "types-%s-%s-%d.sdb"),
dir_prefix, anal_arch, os, bits);
if (r_file_exists (dbpath)) {
sdb_concat_by_path (types, dbpath);
}
@ -562,7 +568,7 @@ R_API void r_core_anal_cc_init(RCore *core) {
bits = 32;
}
char *dbpath = sdb_fmt ("%s/"DBSPATH"/cc-%s-%d.sdb", dir_prefix, anal_arch, bits);
char *dbpath = sdb_fmt ("%s/"R2_SDB_FCNSIGN"/cc-%s-%d.sdb", dir_prefix, anal_arch, bits);
if (r_file_exists (dbpath)) {
sdb_concat_by_path (core->anal->sdb_cc, dbpath);
}
@ -583,7 +589,6 @@ R_API void r_core_anal_cc_init(RCore *core) {
sdb_close (sdbs[0]);
sdb_free (sdbs[0]);
}
#undef DBSPATH
static int bin_info(RCore *r, int mode) {
int i, j, v;
@ -1242,24 +1247,11 @@ static void set_bin_relocs(RCore *r, RBinReloc *reloc, ut64 addr, Sdb **db, char
if (r_file_exists (filename)) {
*db = sdb_new (NULL, filename, 0);
} else {
// XXX. we have dir.prefix, windows shouldnt work different
filename = sdb_fmt ("%s/share/radare2/" R2_VERSION"/format/dll/%s.sdb", r_config_get (r->config, "dir.prefix"), module);
const char *dirPrefix = r_sys_prefix (NULL);
filename = sdb_fmt (R_JOIN_4_PATHS("%s", R2_SDB_FORMAT, "dll", "%s.sdb"),
dirPrefix, module);
if (r_file_exists (filename)) {
*db = sdb_new (NULL, filename, 0);
#if __WINDOWS__
} else {
char invoke_dir[MAX_PATH];
if (r_sys_get_src_dir_w32 (invoke_dir)) {
filename = sdb_fmt ("%s/share/radare2/"R2_VERSION "/format/dll/%s.sdb", invoke_dir, module);
} else {
filename = sdb_fmt ("share/radare2/"R2_VERSION"/format/dll/%s.sdb", module);
}
#else
filename = sdb_fmt ("%s/share/radare2/" R2_VERSION"/format/dll/%s.sdb", r_config_get (r->config, "dir.prefix"), module);
if (r_file_exists (filename)) {
*db = sdb_new (NULL, filename, 0);
}
#endif
}
}
}

View File

@ -2295,7 +2295,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("pdb.useragent", "Microsoft-Symbol-Server/6.11.0001.402", "User agent for Microsoft symbol server");
SETPREF ("pdb.server", "https://msdl.microsoft.com/download/symbols", "Base URL for Microsoft symbol server");
{
char *pdb_path = r_str_home(R2_HOMEDIR R_SYS_DIR "pdb");
char *pdb_path = r_str_home(R2_HOME_PDB);
SETPREF("pdb.symstore", pdb_path, "Path to downstream symbol store");
R_FREE(pdb_path);
}
@ -2591,7 +2591,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("zign.bytes", "true", "Use bytes patterns for matching");
SETPREF ("zign.offset", "true", "Use original offset for matching");
SETPREF ("zign.refs", "true", "Use references for matching");
SETPREF ("zign.autoload", "false", "Autoload all zignatures located in ~/.config/radare2/zigns");
SETPREF ("zign.autoload", "false", "Autoload all zignatures located in " R_JOIN_2_PATHS("~", R2_HOME_ZIGNS));
/* diff */
SETCB ("diff.sort", "addr", &cb_diff_sort, "Specify function diff sorting column see (e diff.sort=?)");
@ -2603,7 +2603,7 @@ R_API int r_core_config_init(RCore *core) {
/* dir */
SETCB ("dir.dbgsnap", ".", &cb_dbgsnap, "Path to session dump files");
{
char *path = r_str_newf ("%s/" R_MAGIC_PATH, r_config_get (core->config, "dir.prefix"));
char *path = r_str_newf (R_JOIN_2_PATHS("%s", R2_SDB_MAGIC), r_config_get (core->config, "dir.prefix"));
SETPREF ("dir.magic", path, "Path to r_magic files");
free (path);
}
@ -2616,12 +2616,10 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("dir.types", "/usr/include", "Default path to look for cparse type files");
#if __ANDROID__
SETPREF ("dir.projects", "/data/data/org.radare.radare2installer/radare2/projects", "Default path for projects");
#elif __WINDOWS__
SETPREF ("dir.projects", "~\\"R2_HOMEDIR"\\projects", "Default path for projects");
#else
SETPREF ("dir.projects", "~/"R2_HOMEDIR"/projects", "Default path for projects");
SETPREF ("dir.projects", R_JOIN_2_PATHS("~", R2_HOME_PROJECTS), "Default path for projects");
#endif
SETCB ("dir.zigns", "~/"R2_HOMEDIR"/zigns", &cb_dirzigns, "Default path for zignatures (see zo command)");
SETCB ("dir.zigns", R_JOIN_2_PATHS("~", R2_HOME_ZIGNS), &cb_dirzigns, "Default path for zignatures (see zo command)");
SETPREF ("stack.bytes", "true", "Show bytes instead of words in stack");
SETPREF ("stack.anotated", "false", "Show anotated hexdump in visual debug");
SETI ("stack.size", 64, "Size in bytes of stack hexdump in visual debug");
@ -2776,11 +2774,9 @@ R_API int r_core_config_init(RCore *core) {
#endif
SETI ("http.maxsize", 0, "Maximum file size for upload");
SETPREF ("http.bind", "localhost", "Server address");
SETPREF ("http.homeroot", "~/.config/radare2/www", "http home root directory");
SETPREF ("http.homeroot", R_JOIN_2_PATHS("~", R2_HOME_WWWROOT), "http home root directory");
#if __ANDROID__
SETPREF ("http.root", "/data/data/org.radare.radare2installer/www", "http root directory");
#elif __WINDOWS__
SETPREF ("http.root", "www", "http root directory");
#else
SETPREF ("http.root", R2_WWWROOT, "http root directory");
#endif

View File

@ -1410,7 +1410,7 @@ static int cmd_system(void *data, const char *input) {
case '-':
if (input[1]) {
r_line_hist_free();
r_line_hist_save (R2_HOMEDIR"/history");
r_line_hist_save (R2_HOME_HISTORY);
} else {
r_line_hist_free();
}
@ -1442,8 +1442,8 @@ static int cmd_system(void *data, const char *input) {
free (cmd);
} //else eprintf ("Error setting up system environment\n");
} else {
eprintf ("History saved to "R2_HOMEDIR"/history\n");
r_line_hist_save (R2_HOMEDIR"/history");
eprintf ("History saved to "R2_HOME_HISTORY"\n");
r_line_hist_save (R2_HOME_HISTORY);
}
break;
case '\0':

View File

@ -46,7 +46,7 @@ static const char *help_msg_ec[] = {
"", " ", "",
"colors:", "", "rgb:000, red, green, blue, #ff0000, ...",
"e scr.color", "=0", "use more colors (0: no color 1: ansi 16, 2: 256, 3: 16M)",
"$DATADIR/radare2/cons", "", "~/.config/radare2/cons ./",
"$DATADIR/radare2/cons", "", R_JOIN_2_PATHS("~", R2_HOME_THEMES) " ./",
NULL
};
@ -118,13 +118,13 @@ R_API RList *r_core_list_themes(RCore *core) {
RList *list = r_list_newf (free);
getNext = false;
char *path = r_str_home (".config/radare2/cons/");
char *path = r_str_home (R2_HOME_THEMES R_SYS_DIR);
if (path) {
list_themes_in_path (list, path);
R_FREE (path);
}
path = r_str_r2_prefix ("share/radare2/"R2_VERSION"/cons/");
path = r_str_r2_prefix (R2_THEMES R_SYS_DIR);
if (path) {
list_themes_in_path (list, path);
R_FREE (path);
@ -139,7 +139,7 @@ static void nextpal(RCore *core, int mode) {
RListIter *iter;
const char *fn;
int ctr = 0;
char *home = r_str_home (".config/radare2/cons/");
char *home = r_str_home (R2_HOME_THEMES R_SYS_DIR);
getNext = false;
if (mode == 'j') {
@ -179,7 +179,7 @@ static void nextpal(RCore *core, int mode) {
R_FREE (home);
}
char *path = r_str_r2_prefix ("share/radare2/"R2_VERSION"/cons/");
char *path = r_str_r2_prefix (R2_THEMES R_SYS_DIR);
if (path) {
files = r_sys_dir (path);
r_list_foreach (files, iter, fn) {
@ -310,11 +310,11 @@ static int cmd_eval(void *data, const char *input) {
bool failed = false;
char *home, *path, *tmp;
tmp = r_str_newf (".config/radare2/cons/%s", input + 3);
tmp = r_str_newf (R_JOIN_2_PATHS(R2_HOME_THEMES, "%s"), input + 3);
home = tmp ? r_str_home (tmp) : NULL;
free (tmp);
tmp = r_str_newf ("share/radare2/"R2_VERSION"/cons/%s", input + 3);
tmp = r_str_newf (R_JOIN_2_PATHS(R2_THEMES, "%s"), input + 3);
path = tmp ? r_str_r2_prefix (tmp) : NULL;
free (tmp);
@ -339,7 +339,8 @@ static int cmd_eval(void *data, const char *input) {
eprintf ("Something went wrong\n");
}
} else if (input[2] == '?') {
eprintf ("Usage: eco [themename] ;load theme from %s/share/radare2/"R2_VERSION"/cons/ (see dir.prefix)\n",
eprintf ("Usage: eco [themename] ;load theme from "
R_JOIN_3_PATHS("%s", R2_THEMES, "") " (see dir.prefix)\n",
r_sys_prefix (NULL));
} else {

View File

@ -880,14 +880,15 @@ static void cmd_print_format(RCore *core, const char *_input, const ut8* block,
if (input[1] == 'o') { // "pfo"
if (input[2] == '?') {
eprintf ("|Usage: pfo [format-file]\n"
" ~/.config/radare2/format\n"
" %s/radare2/"R2_VERSION "/format/\n",
" " R_JOIN_3_PATHS("~", R2_HOME_SDB_FORMAT, "") "\n"
" " R_JOIN_3_PATHS("%s", R2_SDB_FORMAT, "") "\n",
r_sys_prefix (NULL));
} else if (input[2] == ' ') {
char *home, *path, tmp[512];
snprintf (tmp, sizeof (tmp), ".config/radare2/format/%s", input + 3);
snprintf (tmp, sizeof (tmp),
R_JOIN_2_PATHS(R2_HOME_SDB_FORMAT, "%s"), input + 3);
home = r_str_home (tmp);
snprintf (tmp, sizeof (tmp), "share/radare2/"R2_VERSION"/format/%s", input + 3);
snprintf (tmp, sizeof (tmp), R_JOIN_2_PATHS(R2_SDB_FORMAT, "%s"), input + 3);
path = r_str_r2_prefix (tmp);
if (!r_core_cmd_file (core, home) && !r_core_cmd_file (core, path)) {
if (!r_core_cmd_file (core, input + 3)) {
@ -900,7 +901,7 @@ static void cmd_print_format(RCore *core, const char *_input, const ut8* block,
RList *files;
RListIter *iter;
const char *fn;
char *home = r_str_home (".config/radare2/format/");
char *home = r_str_home (R2_HOME_SDB_FORMAT R_SYS_DIR);
if (home) {
files = r_sys_dir (home);
r_list_foreach (files, iter, fn) {
@ -911,7 +912,7 @@ static void cmd_print_format(RCore *core, const char *_input, const ut8* block,
r_list_free (files);
free (home);
}
char *path = r_str_r2_prefix ("share/radare2/"R2_VERSION"/format/");
char *path = r_str_r2_prefix (R2_SDB_FORMAT R_SYS_DIR);
if (path) {
files = r_sys_dir (path);
r_list_foreach (files, iter, fn) {
@ -4664,7 +4665,7 @@ static int cmd_print(void *data, const char *input) {
"| foo@0x40 # use 'foo' magic file on address 0x40\n"
"| @0x40 # use current magic file on address 0x40\n"
"| \\n # append newline\n"
"| e dir.magic # defaults to "R_MAGIC_PATH "\n"
"| e dir.magic # defaults to "R2_SDB_MAGIC "\n"
"| /m # search for magic signatures\n"
);
} else {

View File

@ -18,7 +18,7 @@ static const char *help_msg_P[] = {
"PS", " [file]", "save script file",
"P-", " [file]", "delete project (alias for Pd)",
"NOTE:", "", "See 'e??prj.'",
"NOTE:", "", "project are stored in ~/.config/radare2/projects",
"NOTE:", "", "project are stored in " R_JOIN_2_PATHS("~", R2_HOME_PROJECTS),
NULL
};

View File

@ -1710,11 +1710,7 @@ R_API const char *r_core_anal_optype_colorfor(RCore *core, ut64 addr, bool verbo
static void r_core_setenv (RCore *core) {
char *e = r_sys_getenv ("PATH");
#if __WINDOWS__ && !__CYGWIN__
char *h = r_str_home (".config\\radare2\\prefix\\bin;");
#else
char *h = r_str_home (".config/radare2/prefix/bin:");
#endif
char *h = r_str_home (R2_HOME_BIN R_SYS_ENVSEP);
char *n = r_str_newf ("%s%s", h, e);
r_sys_setenv ("PATH", n);
free (n);
@ -1825,7 +1821,7 @@ R_API bool r_core_init(RCore *core) {
core->cons->user_fgets = (void *)r_core_fgets;
#endif
//r_line_singleton()->user = (void *)core;
r_line_hist_load (R2_HOMEDIR"/history");
r_line_hist_load (R2_HOME_HISTORY);
}
core->print->cons = core->cons;
r_cons_bind (&core->print->consbind);

View File

@ -502,7 +502,7 @@ static void load_scripts_for(RCore *core, const char *name) {
// TODO:
char *file;
RListIter *iter;
char *hdir = r_str_newf (R2_HOMEDIR "/rc.d/bin-%s", name);
char *hdir = r_str_newf (R_JOIN_2_PATHS(R2_HOME_BINRC, "bin-%s"), name);
char *path = r_str_home (hdir);
RList *files = r_sys_dir (path);
if (!r_list_empty (files)) {

View File

@ -5,8 +5,8 @@ static const char *fortunes[] = {
};
static char *getFortuneFile(RCore *core, const char *type) {
return r_str_newf ("%s/share/doc/radare2/fortunes.%s",
r_config_get (core->config, "dir.prefix"), type);
return r_str_newf (R_JOIN_3_PATHS("%s", R2_FORTUNES, "fortunes.%s"),
r_sys_prefix (NULL), type);
}
R_API void r_core_fortune_list_types(void) {

View File

@ -86,7 +86,7 @@ R_API int r_core_loadlibs(RCore *core, int where, const char *path) {
free (p);
}
if (where & R_CORE_LOADLIBS_HOME) {
char *homeplugindir = r_str_home (R2_HOMEDIR "/plugins");
char *homeplugindir = r_str_home (R2_HOME_PLUGINS);
// eprintf ("OPENDIR (%s)\n", homeplugindir);
r_lib_opendir (core->lib, homeplugindir);
free (homeplugindir);
@ -103,7 +103,7 @@ R_API int r_core_loadlibs(RCore *core, int where, const char *path) {
}
#endif
// load script plugins
char *homeplugindir = r_str_home (R2_HOMEDIR "/plugins");
char *homeplugindir = r_str_home (R2_HOME_PLUGINS);
RList *files = r_sys_dir (homeplugindir);
RListIter *iter;
char *file;

View File

@ -80,13 +80,13 @@ r_core = library('r_core', files,
dependencies: [platform_deps],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_core],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_core',
filebase: 'r_core',
requires: [

View File

@ -198,10 +198,10 @@ static int zoom = 0;
R_API int r_core_visual_hud(RCore *core) {
const char *c = r_config_get (core->config, "hud.path");
char *f = r_str_newf ("%s/share/radare2/" R2_VERSION "/hud/main",
r_config_get (core->config, "dir.prefix"));
char *f = r_str_newf (R_JOIN_3_PATHS("%s", R2_HUD, "main"),
r_sys_prefix (NULL));
int use_color = core->print->flags & R_PRINT_FLAGS_COLOR;
char *homehud = r_str_home (R2_HOMEDIR "/hud");
char *homehud = r_str_home (R2_HOME_HUD);
char *res = NULL;
char *p = 0;
r_cons_singleton ()->color = use_color;

View File

@ -26,13 +26,13 @@ r_crypto = library('r_crypto', files,
c_args: ['-DCORELIB=1'],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkg = import('pkgconfig')
pkg.generate(libraries: [r_crypto],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_crypto',
filebase: 'r_crypto',
requires: [

View File

@ -70,13 +70,13 @@ r_debug = library('r_debug', files,
],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_debug],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_debug',
filebase: 'r_debug',
requires: [

View File

@ -21,13 +21,13 @@ r_egg = library('r_egg', files,
link_with: [r_util, r_asm, r_syscall, libr_shlr],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_egg],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_egg',
filebase: 'r_egg',
requires: [

View File

@ -10,13 +10,13 @@ r_flag = library('r_flag', files,
link_with: [r_util, libr_shlr],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_flag],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_flag',
filebase: 'r_flag',
requires: [

View File

@ -35,13 +35,13 @@ r_fs = library('r_fs', files,
link_with: [r_util, libr_shlr],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_fs],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_fs',
filebase: 'r_fs',
requires: [

View File

@ -20,13 +20,13 @@ r_hash = library('r_hash', files,
link_with: [r_util],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_hash],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_hash',
filebase: 'r_hash',
requires: [

View File

@ -15,8 +15,6 @@ R_LIB_VERSION_HEADER(r_magic);
#define MAGICFILE "/etc/magic"
#endif
#define R_MAGIC_PATH "/share/radare2/" R2_VERSION "/magic"
#if USE_LIB_MAGIC
#include <magic.h>

View File

@ -181,15 +181,20 @@ extern "C" {
#if __WINDOWS__
#define FS "\\"
#define R_SYS_DIR "\\"
#define R_SYS_ENVSEP ";"
#define R_SYS_HOME "USERPROFILE"
#define R2_HOMEDIR ".config\\radare2"
#else
#define FS "/"
#define R_SYS_DIR "/"
#define R_SYS_ENVSEP ":"
#define R_SYS_HOME "HOME"
#define R2_HOMEDIR ".config/radare2"
#endif
#define R_JOIN_2_PATHS(p1, p2) p1 R_SYS_DIR p2
#define R_JOIN_3_PATHS(p1, p2, p3) p1 R_SYS_DIR p2 R_SYS_DIR p3
#define R_JOIN_4_PATHS(p1, p2, p3, p4) p1 R_SYS_DIR p2 R_SYS_DIR p3 R_SYS_DIR p4
#define R_JOIN_5_PATHS(p1, p2, p3, p4, p5) p1 R_SYS_DIR p2 R_SYS_DIR p3 R_SYS_DIR p4 R_SYS_DIR p5
#ifndef __packed
#define __packed __attribute__((__packed__))
#endif

View File

@ -8,16 +8,49 @@
#if __WINDOWS__ || __CYGWIN__ || MINGW32 || _MSC_VER || CUTTER
#define R2_PREFIX "."
#define R2_LIBDIR "./lib"
#define R2_INCDIR "./include/libr"
#define R2_DATDIR "./share"
#define R2_LIBDIR "lib"
#define R2_INCDIR "include\\libr"
#define R2_DATDIR "share"
#define R2_WWWROOT "www"
#else
#define R2_PREFIX "@PREFIX@"
#define R2_LIBDIR "@LIBDIR@"
#define R2_INCDIR "@INCLUDEDIR@/libr"
#define R2_DATDIR "@DATADIR@"
#define R2_WWWROOT R2_DATDIR "/radare2/" R2_VERSION "/www"
#endif
#define R2_SDB R_JOIN_3_PATHS("share", "radare2", R2_VERSION)
#define R2_ZIGNS R_JOIN_4_PATHS("share", "radare2", R2_VERSION, "zigns")
#define R2_THEMES R_JOIN_4_PATHS("share", "radare2", R2_VERSION, "cons")
#define R2_FORTUNES R_JOIN_3_PATHS("share", "doc", "radare2")
#define R2_HUD R_JOIN_4_PATHS("share", "radare2", R2_VERSION, "hud")
#define R2_SDB_FCNSIGN R_JOIN_2_PATHS(R2_SDB, "fcnsign")
#define R2_SDB_OPCODES R_JOIN_2_PATHS(R2_SDB, "opcodes")
#define R2_SDB_MAGIC R_JOIN_2_PATHS(R2_SDB, "magic")
#define R2_SDB_FORMAT R_JOIN_2_PATHS(R2_SDB, "format")
#define R2_HOME_CONFIGDIR R_JOIN_2_PATHS(".config", "radare2")
#define R2_HOME_DATADIR R_JOIN_3_PATHS(".local", "share", "radare2")
#define R2_HOME_CACHEDIR R_JOIN_2_PATHS(".cache", "radare2")
#define R2_HOME_THEMES R_JOIN_2_PATHS(R2_HOME_DATADIR, "cons")
#define R2_HOME_PLUGINS R_JOIN_2_PATHS(R2_HOME_DATADIR, "plugins")
#define R2_HOME_ZIGNS R_JOIN_2_PATHS(R2_HOME_DATADIR, "zigns")
#define R2_HOME_PDB R_JOIN_2_PATHS(R2_HOME_DATADIR, "pdb")
#define R2_HOME_PROJECTS R_JOIN_2_PATHS(R2_HOME_DATADIR, "projects")
#define R2_HOME_WWWROOT R_JOIN_2_PATHS(R2_HOME_DATADIR, "www")
#define R2_HOME_SDB_FORMAT R_JOIN_2_PATHS(R2_HOME_DATADIR, "format")
#define R2_HOME_HUD R_JOIN_2_PATHS(R2_HOME_DATADIR, "hud")
#define R2_HOME_BINRC R_JOIN_2_PATHS(R2_HOME_DATADIR, "rc.d")
#define R2_HOME_BIN R_JOIN_3_PATHS(R2_HOME_DATADIR, "prefix", "bin")
#define R2_HOME_RC R_JOIN_2_PATHS(R2_HOME_CONFIGDIR, "radare2rc")
#define R2_HOME_RC_DIR R_JOIN_2_PATHS(R2_HOME_CONFIGDIR, "radare2rc.d")
#define R2_HOME_HISTORY R_JOIN_2_PATHS(R2_HOME_CACHEDIR, "history")
#define HAVE_LIB_MAGIC @HAVE_LIB_MAGIC@
#define USE_LIB_MAGIC @USE_LIB_MAGIC@
#ifndef HAVE_LIB_SSL
@ -28,8 +61,6 @@
#define WITH_GPL @WITH_GPL@
#define R2_WWWROOT R2_DATDIR "/radare2/" R2_VERSION "/www"
#if __APPLE__ && __POWERPC__
#define HAVE_JEMALLOC 0
#else

View File

@ -6,17 +6,42 @@
#define DEBUGGER @DEBUGGER@
#define HAVE_DECL_ADDR_NO_RANDOMIZE @HAVE_DECL_ADDR_NO_RANDOMIZE@
#if __WINDOWS__ || __CYGWIN__ || MINGW32 || _MSC_VER || CUTTER
#define R2_PREFIX "."
#define R2_LIBDIR "./lib"
#define R2_INCDIR "./include/libr"
#define R2_DATDIR "./share"
#else
#define R2_PREFIX "@PREFIX@"
#define R2_LIBDIR "@LIBDIR@"
#define R2_INCDIR "@INCLUDEDIR@/libr"
#define R2_INCDIR "@INCLUDEDIR@"
#define R2_DATDIR "@DATADIR@"
#endif
#define R2_WWWROOT "@WWWROOT@"
#define R2_SDB "@SDB@"
#define R2_ZIGNS "@ZIGNS@"
#define R2_THEMES "@THEMES@"
#define R2_FORTUNES "@FORTUNES@"
#define R2_HUD "@HUD@"
#define R2_SDB_FCNSIGN R_JOIN_2_PATHS(R2_SDB, "fcnsign")
#define R2_SDB_OPCODES R_JOIN_2_PATHS(R2_SDB, "opcodes")
#define R2_SDB_MAGIC R_JOIN_2_PATHS(R2_SDB, "magic")
#define R2_SDB_FORMAT R_JOIN_2_PATHS(R2_SDB, "format")
#define R2_HOME_CONFIGDIR R_JOIN_2_PATHS(".config", "radare2")
#define R2_HOME_DATADIR R_JOIN_3_PATHS(".local", "share", "radare2")
#define R2_HOME_CACHEDIR R_JOIN_2_PATHS(".cache", "radare2")
#define R2_HOME_THEMES R_JOIN_2_PATHS(R2_HOME_DATADIR, "cons")
#define R2_HOME_PLUGINS R_JOIN_2_PATHS(R2_HOME_DATADIR, "plugins")
#define R2_HOME_ZIGNS R_JOIN_2_PATHS(R2_HOME_DATADIR, "zigns")
#define R2_HOME_PDB R_JOIN_2_PATHS(R2_HOME_DATADIR, "pdb")
#define R2_HOME_PROJECTS R_JOIN_2_PATHS(R2_HOME_DATADIR, "projects")
#define R2_HOME_WWWROOT R_JOIN_2_PATHS(R2_HOME_DATADIR, "www")
#define R2_HOME_SDB_FORMAT R_JOIN_2_PATHS(R2_HOME_DATADIR, "format")
#define R2_HOME_HUD R_JOIN_2_PATHS(R2_HOME_DATADIR, "hud")
#define R2_HOME_BINRC R_JOIN_2_PATHS(R2_HOME_DATADIR, "rc.d")
#define R2_HOME_BIN R_JOIN_3_PATHS(R2_HOME_DATADIR, "prefix", "bin")
#define R2_HOME_RC R_JOIN_2_PATHS(R2_HOME_CONFIGDIR, "radare2rc")
#define R2_HOME_RC_DIR R_JOIN_2_PATHS(R2_HOME_CONFIGDIR, "radare2rc.d")
#define R2_HOME_HISTORY R_JOIN_2_PATHS(R2_HOME_CACHEDIR, "history")
#define HAVE_LIB_MAGIC @HAVE_LIB_MAGIC@
#define USE_LIB_MAGIC @USE_LIB_MAGIC@
@ -28,8 +53,6 @@
#define WITH_GPL @WITH_GPL@
#define R2_WWWROOT R2_DATDIR "/radare2/" R2_VERSION "/www"
#define HAVE_JEMALLOC @HAVE_JEMALLOC@
#endif

View File

@ -73,13 +73,13 @@ r_io = library('r_io', files,
c_args: ['-DCORELIB=1'],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_io],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_io',
filebase: 'r_io',
requires: [

View File

@ -14,13 +14,13 @@ r_lang = library('r_lang', files,
link_with: [r_util, r_cons],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_lang],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_lang',
filebase: 'r_lang',
requires: [

View File

@ -1,4 +1,4 @@
install_subdir('default',
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'radare2', r2version, 'magic'),
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'radare2', r2_version, 'magic'),
strip_directory: true
)

View File

@ -15,13 +15,13 @@ r_magic = library('r_magic', files,
link_with: [r_util],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_magic],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_magic',
filebase: 'r_magic',
requires: [

View File

@ -28,13 +28,13 @@ r_parse = library('r_parse', files,
link_with: [r_util, r_flag, r_syscall, r_reg, libr_shlr],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_parse],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_parse',
filebase: 'r_parse',
requires: [

View File

@ -12,13 +12,13 @@ r_reg = library('r_reg', files,
link_with: [r_util],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_reg],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_reg',
filebase: 'r_reg',
requires: [

View File

@ -15,13 +15,13 @@ r_search = library('r_search', files,
link_with: [r_util],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_search],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_search',
filebase: 'r_search',
requires: [

View File

@ -16,13 +16,13 @@ r_socket = library('r_socket', files,
c_args: ['-DCORELIB=1'],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_socket],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_socket',
filebase: 'r_socket',
requires: [

View File

@ -31,6 +31,6 @@ foreach file : sdb_files
build_by_default: true,
build_always: false,
install: true,
install_dir: join_paths(get_option('datadir'), 'radare2', r2version, 'syscall')
install_dir: join_paths(get_option('datadir'), 'radare2', r2_version, 'syscall')
)
endforeach

View File

@ -8,12 +8,12 @@ r_syscall = library('r_syscall', files,
link_with: [r_util, libr_shlr],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(libraries: [r_syscall],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_syscall',
filebase: 'r_syscall',
requires: [

View File

@ -91,13 +91,13 @@ r_util = library('r_util', files,
link_with: [libr_shlr],
install: true,
implicit_include_directories: false,
soversion: r2libversion
soversion: r2_libversion
)
pkgconfig_mod.generate(
libraries: [r_util],
subdirs: 'libr',
version: r2version,
version: r2_version,
name: 'r_util',
filebase: 'r_util',
description: 'radare foundation libraries'

View File

@ -12,7 +12,7 @@ static bool disabled = false;
static bool inHomeWww(const char *path) {
bool ret = false;
char *homeWww = r_str_home (".config/radare2/www/");
char *homeWww = r_str_home (R2_HOME_WWWROOT R_SYS_DIR);
if (homeWww) {
if (!strncmp (path, homeWww, strlen (homeWww))) {
ret = true;

View File

@ -6,11 +6,11 @@ pkgconfig_mod = import('pkgconfig')
glob_cmd = [py3_exe, '-c', 'from sys import argv; print(";".join(__import__("glob").glob(argv[1])))']
# Get r2 version
r2version = run_command(py3_exe, 'sys/version.py')
if r2version.returncode() != 0
r2version = 'unknown-error'
r2_version = run_command(py3_exe, 'sys/version.py')
if r2_version.returncode() != 0
r2_version = 'unknown-error'
else
r2version = r2version.stdout().strip()
r2_version = r2_version.stdout().strip()
endif
repo = '.'
@ -62,7 +62,7 @@ else
r2birth = r2birth.stdout().strip()
endif
r2libversion = host_machine.system() == 'windows' ? '' : r2version
r2_libversion = host_machine.system() == 'windows' ? '' : r2_version
# system dependencies
cc = meson.get_compiler('c')
@ -86,6 +86,53 @@ if get_option('static_runtime')
endif
endif
if host_machine.system() == 'windows'
r2_prefix = '.'
r2_libdir = 'lib'
r2_incdir = 'include/libr'
r2_datdir = 'share'
opts1 = ['r2_libdir', 'r2_incdir', 'r2_datdir']
foreach opt : opts1
val = get_option(opt)
if val != ''
set_variable(opt, val)
endif
endforeach
r2_wwwroot = join_paths(r2_datdir, 'radare2', r2_version, 'www')
r2_sdb = join_paths(r2_datdir, 'radare2', r2_version)
r2_zigns = join_paths(r2_datdir, 'radare2', r2_version, 'zigns')
r2_themes = join_paths(r2_datdir, 'radare2', r2_version, 'cons')
r2_fortunes = join_paths(r2_datdir, 'doc/radare2')
r2_hud = join_paths(r2_datdir, 'radare2', r2_version, 'hud')
opts2 = ['r2_wwwroot', 'r2_sdb', 'r2_zigns', 'r2_themes', 'r2_fortunes', 'r2_hud']
foreach opt : opts2
val = get_option(opt)
if val != ''
set_variable(opt, val)
endif
endforeach
foreach opt : opts1 + opts2
val = get_variable(opt)
val = '\\\\'.join(val.split('/'))
set_variable(opt, val)
endforeach
else
r2_prefix = get_option('prefix')
r2_libdir = join_paths(r2_prefix, get_option('libdir'))
r2_incdir = join_paths(r2_prefix, get_option('includedir'), 'libr')
r2_datdir = join_paths(r2_prefix, get_option('datadir'))
r2_wwwroot = join_paths(r2_datdir, 'radare2', r2_version, 'www')
r2_sdb = join_paths(get_option('datadir'), 'radare2', r2_version)
r2_zigns = join_paths(get_option('datadir'), 'radare2', r2_version, 'zigns')
r2_themes = join_paths(get_option('datadir'), 'radare2', r2_version, 'cons')
r2_fortunes = join_paths(get_option('datadir'), 'doc/radare2')
r2_hud = join_paths(get_option('datadir'), 'radare2', r2_version, 'hud')
endif
# load plugin configuration
subdir('libr')
@ -110,10 +157,16 @@ config_h = configure_file(
userconf = configuration_data()
userconf.set('DEBUGGER', 1)
userconf.set('PREFIX', get_option('prefix'))
userconf.set('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
userconf.set('INCLUDEDIR', join_paths(get_option('prefix'), get_option('includedir')))
userconf.set('DATADIR', join_paths(get_option('prefix'), get_option('datadir')))
userconf.set('PREFIX', r2_prefix)
userconf.set('LIBDIR', r2_libdir)
userconf.set('INCLUDEDIR', r2_incdir)
userconf.set('DATADIR', r2_datdir)
userconf.set('WWWROOT', r2_wwwroot)
userconf.set('SDB', r2_sdb)
userconf.set('ZIGNS', r2_zigns)
userconf.set('THEMES', r2_themes)
userconf.set('FORTUNES', r2_fortunes)
userconf.set('HUD', r2_hud)
userconf.set('HAVE_LIB_MAGIC', 0)
userconf.set('USE_LIB_MAGIC', 0)
userconf.set('HAVE_OPENSSL', 0)
@ -138,7 +191,7 @@ r_userconf_h = configure_file(
versionconf = configuration_data()
versionconf.set('VERSIONCOMMIT', version_commit)
versionconf.set('R2_VERSION', r2version)
versionconf.set('R2_VERSION', r2_version)
versionconf.set('R2_GITTAP', gittap)
versionconf.set('R2_GITTIP', gittip)
versionconf.set('R2_BIRTH', r2birth)
@ -155,7 +208,7 @@ run_command(py3_exe, '-c', '__import__("shutil").copyfile("shlr/spp/config.def.h
pcconf = configuration_data()
pcconf.set('PREFIX', get_option('prefix'))
pcconf.set('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
pcconf.set('VERSION', r2version)
pcconf.set('VERSION', r2_version)
libr_pc = configure_file(
input: 'libr/libr.pc.acr',
output: 'libr.pc',
@ -218,12 +271,12 @@ else
libr2_dep = declare_dependency(
link_with: libr2_lib,
include_directories: libr2_inc,
version: r2version
version: r2_version
)
endif
install_subdir('shlr/www',
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'radare2', r2version)
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'radare2', r2_version)
)
fortunes_files = run_command(glob_cmd + ['doc/fortunes.*']).stdout().strip().split(';')
@ -242,6 +295,6 @@ install_data(man7_files,
)
install_data('doc/hud',
install_dir: join_paths(get_option('datadir'), 'radare2', r2version, 'hud'),
install_dir: join_paths(get_option('datadir'), 'radare2', r2_version, 'hud'),
rename: 'main'
)

View File

@ -1 +1,10 @@
option('static_runtime', type: 'boolean', value: false)
option('static_runtime', type: 'boolean', value: false)
option('r2_libdir', type: 'string', value: '')
option('r2_incdir', type: 'string', value: '')
option('r2_datdir', type: 'string', value: '')
option('r2_wwwroot', type: 'string', value: '')
option('r2_sdb', type: 'string', value: '')
option('r2_zigns', type: 'string', value: '')
option('r2_themes', type: 'string', value: '')
option('r2_fortunes', type: 'string', value: '')
option('r2_hud', type: 'string', value: '')