aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/error_handler.h1
-rw-r--r--include/shlib.h8
-rw-r--r--include/spm.h22
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