From 436ce68ecd41ad66e7a0605b47b5814582db8538 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 24 Apr 2020 12:29:49 -0400 Subject: Consolidate platform detection preprocessor checks --- lib/config_global.c | 6 +++--- lib/error_handler.c | 1 + lib/extern/url.c | 2 +- lib/internal_cmd.c | 4 ++-- lib/mime.c | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/config_global.c b/lib/config_global.c index 52589d4..95302c3 100644 --- a/lib/config_global.c +++ b/lib/config_global.c @@ -129,11 +129,11 @@ void check_runtime_environment(void) { int bad_rt = 0; char *required[] = { "file", -#if defined(__linux) || defined(__linux__) +#if OS_LINUX "patchelf", -#elif defined(__APPLE__) && defined(__MACH__) +#elif OS_DARWIN "install_name_tool", -#elif defined(__WIN32__) +#elif OS_WINDOWS // TODO: Does windows provide some kind of equivalent? #endif "objdump", diff --git a/lib/error_handler.c b/lib/error_handler.c index cb2ef51..aa48274 100644 --- a/lib/error_handler.c +++ b/lib/error_handler.c @@ -13,6 +13,7 @@ const char *SPM_ERR_STRING[] = { "Failed to fetch package", "Manifest has no header", "Manifest has no data", + "Parsing error", NULL, }; diff --git a/lib/extern/url.c b/lib/extern/url.c index fe54db2..c39b314 100644 --- a/lib/extern/url.c +++ b/lib/extern/url.c @@ -137,7 +137,7 @@ static int fill_buffer(URL_FILE *file, size_t want) { curl_multi_fdset() doc. */ if (maxfd == -1) { -#ifdef _WIN32 +#ifdef _WIN32 // OS_WINDOWS not available at this level Sleep(100); rc = 0; #else diff --git a/lib/internal_cmd.c b/lib/internal_cmd.c index e5f875f..6f6b1c6 100644 --- a/lib/internal_cmd.c +++ b/lib/internal_cmd.c @@ -237,9 +237,9 @@ int mkruntime_interface(int argc, char **argv) { } runtime_set(rt, "CFLAGS", "-I$SPM_INCLUDE $CFLAGS"); -#if defined(__APPLE__) && defined (__MACH__) +#if OS_DARWIN runtime_set(rt, "LDFLAGS", "-rpath $SPM_LIB:$SPM_LIB64 -L$SPM_LIB -L$SPM_LIB64 $LDFLAGS"); -#elif defined(__linux) || defined (__linux__) +#elif OS_LINUX runtime_set(rt, "LDFLAGS", "-Wl,-rpath=$SPM_LIB:$SPM_LIB64 -L$SPM_LIB -L$SPM_LIB64 $LDFLAGS"); #else // TODO: Windows? diff --git a/lib/mime.c b/lib/mime.c index 9e4bdce..9d0205c 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -14,7 +14,7 @@ Process *file_command(const char *_filename) { Process *proc_info = NULL; char sh_cmd[PATH_MAX]; sh_cmd[0] = '\0'; -#ifdef __APPLE__ +#if OS_DARWIN const char *fmt_cmd = "file -I \"%s\" 2>&1"; #else // GNU const char *fmt_cmd = "file -i \"%s\" 2>&1"; -- cgit