From c709ee7c1067978d5286861c33108befdffeefae Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 23 Aug 2019 20:55:50 +0200 Subject: [PATCH] rework PREFIX for future make install --- client/fileutils.c | 8 ++++---- client/scripting.c | 10 +++++----- .../Mac-OS-X-Homebrew-Installation-Instructions.md | 7 +------ include/common.h | 10 +++++++--- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/client/fileutils.c b/client/fileutils.c index 7500ea8dd..6556a9a1b 100644 --- a/client/fileutils.c +++ b/client/fileutils.c @@ -654,8 +654,8 @@ int searchAndList(const char *pm3dir, const char *ext) { filelist(script_directory_path, ext, false); } { - char script_directory_path[strlen(PM3_SYSTEM_DIRECTORY) + strlen(pm3dir) + 1]; - strcpy(script_directory_path, PM3_SYSTEM_DIRECTORY); + char script_directory_path[strlen(PM3_SHARE_PATH) + strlen(pm3dir) + 1]; + strcpy(script_directory_path, PM3_SHARE_PATH); strcat(script_directory_path, pm3dir); filelist(script_directory_path, ext, true); } @@ -711,8 +711,8 @@ char *searchFile(const char *pm3dir, const char *ext, const char *filename) { } // try pm3 dirs in pm3 installation dir (install mode) { - char *path = malloc(strlen(PM3_SYSTEM_DIRECTORY) + strlen(pm3dir) + strlen(filename) + strlen(suffix) + 1); - strcpy(path, PM3_SYSTEM_DIRECTORY); + char *path = malloc(strlen(PM3_SHARE_PATH) + strlen(pm3dir) + strlen(filename) + strlen(suffix) + 1); + strcpy(path, PM3_SHARE_PATH); strcat(path, pm3dir); strcat(path, filename); strcat(path, suffix); diff --git a/client/scripting.c b/client/scripting.c index 596b535fa..664b0080f 100644 --- a/client/scripting.c +++ b/client/scripting.c @@ -1167,16 +1167,16 @@ int set_pm3_libraries(lua_State *L) { setLuaPath(L, libraries_path); } - if (strlen(PM3_SYSTEM_DIRECTORY) != 0 || strlen(LUA_SCRIPTS_DIRECTORY) != 0 || strlen(LUA_LIBRARIES_WILDCARD) != 0 ) { + if (strlen(PM3_SHARE_PATH) != 0 || strlen(LUA_SCRIPTS_DIRECTORY) != 0 || strlen(LUA_LIBRARIES_WILDCARD) != 0 ) { // from the /usr/local/share/proxmark3/luascripts/ directory - char scripts_path[strlen(PM3_SYSTEM_DIRECTORY) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1]; - strcpy(scripts_path, PM3_SYSTEM_DIRECTORY); + char scripts_path[strlen(PM3_SHARE_PATH) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1]; + strcpy(scripts_path, PM3_SHARE_PATH); strcat(scripts_path, LUA_SCRIPTS_DIRECTORY); strcat(scripts_path, LUA_LIBRARIES_WILDCARD); setLuaPath(L, scripts_path); // from the /usr/local/share/proxmark3/lualib/ directory - char libraries_path[strlen(PM3_SYSTEM_DIRECTORY) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1]; - strcpy(libraries_path, PM3_SYSTEM_DIRECTORY); + char libraries_path[strlen(PM3_SHARE_PATH) + strlen(LUA_LIBRARIES_DIRECTORY) + strlen(LUA_LIBRARIES_WILDCARD) + 1]; + strcpy(libraries_path, PM3_SHARE_PATH); strcat(libraries_path, LUA_LIBRARIES_DIRECTORY); strcat(libraries_path, LUA_LIBRARIES_WILDCARD); setLuaPath(L, libraries_path); diff --git a/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md b/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md index 22868121c..fd336104d 100644 --- a/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Mac-OS-X-Homebrew-Installation-Instructions.md @@ -64,12 +64,7 @@ These instructions will show how to setup the environment on OSX to the point wh 2. Install dependencies: ``` -brew install readline -brew install p7zip -brew install libusb-compat -brew install perl -brew install qt5 -brew install wget +brew install readline p7zip libusb-compat perl qt5 wget brew install RfidResearchGroup/proxmark3/arm-none-eabi-gcc ``` diff --git a/include/common.h b/include/common.h index d70bc484f..fc1d688f0 100644 --- a/include/common.h +++ b/include/common.h @@ -16,10 +16,14 @@ #include #include -#ifndef PREFIX -# define PREFIX "/usr/local/" +// brew prefixes are a bit weird so we've to split bin & share to be prepared: +#ifndef PM3_BIN_PATH +# define PM3_BIN_PATH "/usr/local/bin/" #endif -#define PM3_SYSTEM_DIRECTORY PREFIX "share/proxmark3/" +#ifndef PM3_SHARE_PATH +# define PM3_SHARE_PATH "/usr/local/share/proxmark3/" +#endif +// PM3_USER_DIRECTORY will be expanded as if with a "~" upfront, e.g. ~/.proxmark3/ #define PM3_USER_DIRECTORY "/.proxmark3/" #define PACKED __attribute__((packed))