diff options
author | Kristaps Dz <kristaps@bsd.lv> | 2018-07-18 11:04:35 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-07-28 14:08:06 -0700 |
commit | 51066e5478d76824c5da53f37184e0e0d1f3e4af (patch) | |
tree | 63cf9ed3de3f2aa0c41b942069ba7fbfb3298062 | |
parent | 8da7ddc64badd09e309e39ed79f4b6821d84454e (diff) | |
download | subsurface-51066e5478d76824c5da53f37184e0e0d1f3e4af.tar.gz |
Build-system: add OpenBSD support
Rename linux.c to unix.c and add OpenBSD support as well. Conditionally compile based on OS.
Signed-off-by: Kristaps Dzonsons <kristaps@bsd.lv>
-rw-r--r-- | core/CMakeLists.txt | 4 | ||||
-rw-r--r-- | core/unix.c (renamed from core/linux.c) | 18 |
2 files changed, 17 insertions, 5 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 52470d414..dbaa3bbe5 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -4,7 +4,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(ANDROID) set(PLATFORM_SRC android.cpp) else() - set(PLATFORM_SRC linux.c) + set(PLATFORM_SRC unix.c) endif() elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") set(PLATFORM_SRC android.cpp) @@ -12,6 +12,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(PLATFORM_SRC macos.c) elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(PLATFORM_SRC windows.c) +elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") + set(PLATFORM_SRC unix.c) endif() if(FTDISUPPORT) diff --git a/core/linux.c b/core/unix.c index 07d178cb0..963d25ac5 100644 --- a/core/linux.c +++ b/core/unix.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -/* linux.c */ -/* implements Linux specific functions */ +/* unix.c */ +/* implements UNIX specific functions */ #include "ssrf.h" #include "dive.h" #include "subsurface-string.h" @@ -16,8 +16,8 @@ #include <pwd.h> // the DE should provide us with a default font and font size... -const char linux_system_divelist_default_font[] = "Sans"; -const char *system_divelist_default_font = linux_system_divelist_default_font; +const char unix_system_divelist_default_font[] = "Sans"; +const char *system_divelist_default_font = unix_system_divelist_default_font; double system_divelist_default_font_size = -1.0; void subsurface_OS_pref_setup(void) @@ -111,6 +111,13 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type) size_t len; if (dc_type != DC_TYPE_UEMIS) { const char *dirname = "/dev"; +#ifdef __OpenBSD__ + const char *patterns[] = { + "ttyU*", + "ttyC*", + NULL + }; +#else const char *patterns[] = { "ttyUSB*", "ttyS*", @@ -118,6 +125,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type) "rfcomm*", NULL }; +#endif dp = opendir(dirname); if (dp == NULL) { @@ -143,6 +151,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type) } closedir(dp); } +#ifdef __linux__ if (dc_type != DC_TYPE_SERIAL) { int num_uemis = 0; file = fopen("/proc/mounts", "r"); @@ -177,6 +186,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type) if (num_uemis == 1 && entries == 1) /* if we found only one and it's a mounted Uemis, pick it */ index = 0; } +#endif return index; } |