From cfc78ffdf06d96c43272ba42cecf75f00126d2a5 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Thu, 30 Jul 2015 18:11:29 +0200 Subject: Fix OpenBSD build --- CMakeLists.txt | 37 ++++++++++++++++++++++++++++--------- degesch.c | 2 +- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdbc45f..8170ce2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,19 +27,32 @@ pkg_check_modules (libssl REQUIRED libssl libcrypto) pkg_check_modules (ncursesw ncursesw) if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD") - # iconv() doesn't have to be present in libc - # FIXME: detect if we need the library independently on the platform - list (APPEND project_libraries iconv) - # Need this for SIGWINCH; our POSIX version macros make it undefined - add_definitions (-D__BSD_VISIBLE=1) + include_directories(/usr/local/include) + link_directories(/usr/local/lib) + # Need this for SIGWINCH in FreeBSD and OpenBSD respectively; + # our POSIX version macros make it undefined + add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1) endif ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD") -# -lpthread is only there for debugging (gdb & errno) -# -lrt is only for glibc < 2.17 -list (APPEND project_libraries ${libssl_LIBRARIES} rt pthread) +# iconv may or may not be present in libc +find_library (iconv_LIBRARIES iconv) +if (iconv_LIBRARIES) + list (APPEND project_libraries ${iconv_LIBRARIES}) +endif (iconv_LIBRARIES) + +list (APPEND project_libraries ${libssl_LIBRARIES}) include_directories (${libssl_INCLUDE_DIRS}) link_directories (${libssl_LIBRARY_DIRS}) +# -lpthread is only there for debugging (gdb & errno) +# -lrt is only for glibc < 2.17 +foreach (extra rt pthread) + find_library (extra_lib ${extra}) + if (extra_lib) + list (APPEND project_libraries ${extra}) + endif (extra_lib) +endforeach (extra) + if (ncursesw_FOUND) list (APPEND project_libraries ${ncursesw_LIBRARIES}) include_directories (${ncursesw_INCLUDE_DIRS}) @@ -53,7 +66,13 @@ endif (ncursesw_FOUND) if ((WANT_READLINE AND WANT_LIBEDIT) OR (NOT WANT_READLINE AND NOT WANT_LIBEDIT)) message (SEND_ERROR "You have to choose either GNU Readline or libedit") elseif (WANT_READLINE) - list (APPEND project_libraries readline) + # OpenBSD's default readline is too old + if ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD") + include_directories (/usr/local/include/ereadline) + list (APPEND project_libraries ereadline) + else ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD") + list (APPEND project_libraries readline) + endif ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD") elseif (WANT_LIBEDIT) pkg_check_modules (libedit REQUIRED libedit) list (APPEND project_libraries ${libedit_LIBRARIES}) diff --git a/degesch.c b/degesch.c index 4f51039..ac14042 100644 --- a/degesch.c +++ b/degesch.c @@ -59,7 +59,7 @@ enum #include #include -#ifndef TIOCGWINSZ +#ifdef TIOCGWINSZ #include #endif // ! TIOCGWINSZ -- cgit v1.2.3-70-g09d2