diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2020-04-24 15:29:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 15:29:05 -0400 |
commit | 338abde356efcae6cf0a000b71b781d21c8733b6 (patch) | |
tree | b275d303c93662ea4879fdca4597aa21e1c9421c /include | |
parent | d78903961ee95376bccde7c1313be5b583911ab7 (diff) | |
parent | 24992f1f426111f0ce05df341087a55486ae48db (diff) | |
download | spmc-338abde356efcae6cf0a000b71b781d21c8733b6.tar.gz |
Merge pull request #30 from jhunkeler/shlib-macos
Shlib macos
Diffstat (limited to 'include')
-rw-r--r-- | include/error_handler.h | 1 | ||||
-rw-r--r-- | include/shlib.h | 8 | ||||
-rw-r--r-- | include/spm.h | 22 |
3 files changed, 24 insertions, 7 deletions
diff --git a/include/error_handler.h b/include/error_handler.h index 92705fe..e58698e 100644 --- a/include/error_handler.h +++ b/include/error_handler.h @@ -16,6 +16,7 @@ #define SPM_ERR_PKG_FETCH _SPM_ERR(6) // failed to download package #define SPM_ERR_MANIFEST_INVALID _SPM_ERR(7) // manifest file is invalid (no header) #define SPM_ERR_MANIFEST_EMPTY _SPM_ERR(8) // manifest file has no data +#define SPM_ERR_PARSE _SPM_ERR(9) // general parsing error extern int spmerrno; extern const char *SPM_ERR_STRING[]; diff --git a/include/shlib.h b/include/shlib.h index e0ccb5b..68b8487 100644 --- a/include/shlib.h +++ b/include/shlib.h @@ -4,13 +4,13 @@ #ifndef SPM_SHLIB_H #define SPM_SHLIB_H -#if defined(_MSC_VER) +#if OS_WINDOWS && defined(_MSC_VER) #define SPM_SHLIB_EXEC "dumpbin" #define SPM_SHLIB_EXEC_ARGS "/dependents" #define SPM_SHLIB_EXTENSION ".dll" -#elif defined(__APPLE__) && defined(__MACH__) -#define SPM_SHLIB_EXEC "/usr/bin/otool" -#define SPM_SHLIB_EXEC_ARGS "-l" +#elif OS_APPLE +#define SPM_SHLIB_EXEC "/usr/bin/objdump" +#define SPM_SHLIB_EXEC_ARGS "-macho -p" #define SPM_SHLIB_EXTENSION ".dylib" #else // linux (hopefully) #define SPM_SHLIB_EXEC "/usr/bin/objdump" diff --git a/include/spm.h b/include/spm.h index f9b2201..5382378 100644 --- a/include/spm.h +++ b/include/spm.h @@ -4,6 +4,22 @@ #ifndef SPM_SPM_H #define SPM_SPM_H +// Define some platform detection shortcuts +#define OS_DARWIN 0 +#define OS_WINDOWS 0 +#define OS_LINUX 0 + +#if defined(__APPLE__) && defined(__MACH__) +#undef OS_DARWIN +#define OS_DARWIN 1 +#elif defined(_WIN32) +#undef OS_WINDOWS +#define OS_WINDOWS 1 +#elif defined(__linux) || defined(__linux__) +#undef OS_LINUX +#define OS_LINUX 1 +#endif + #include <ctype.h> #include <dirent.h> #include <errno.h> @@ -19,7 +35,7 @@ #include <openssl/md5.h> #include <openssl/sha.h> -#if !defined(_WIN32) +#if !OS_WINDOWS #include <fts.h> #include <glob.h> #include <unistd.h> @@ -65,7 +81,7 @@ extern spm_vars SPM_GLOBAL; #define DIRSEPS_UNIX "/" #define PATHSEP_UNIX ';' #define PATHSEPS_UNIX ";" -#if defined(_WIN32) +#if OS_WINDOWS #define DIRSEP DIRSEP_WIN32 #define DIRSEPS DIRSEPS_WIN32 #define NOT_DIRSEP DIRSEP_UNIX @@ -98,7 +114,7 @@ _1________________________________________________" // GLOBALS -#ifdef __APPLE__ +#if OS_DARWIN extern char **environ; #define __environ environ #endif |