Merge pull request #1947 from tonytheodore/libshh

add package libssh
This commit is contained in:
Tony Theodore 2017-10-29 12:28:08 +11:00 committed by GitHub
commit 3cd00a8a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 275 additions and 0 deletions

214
src/libssh-1-fixes.patch Normal file
View File

@ -0,0 +1,214 @@
This file is part of MXE. See LICENSE.md for licensing information.
Contains ad hoc patches for cross building.
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tony Theodore <tonyt@logyst.com>
Date: Sun, 29 Oct 2017 00:11:28 +1100
Subject: [PATCH] add option to disable shared libs
Taken from:
https://www.libssh.org/archive/libssh/2017-10/0000012.html
diff --git a/DefineOptions.cmake b/DefineOptions.cmake
index 1111111..2222222 100644
--- a/DefineOptions.cmake
+++ b/DefineOptions.cmake
@@ -3,6 +3,7 @@ option(WITH_ZLIB "Build with ZLIB support" ON)
option(WITH_SSH1 "Build with SSH1 support" OFF)
option(WITH_SFTP "Build with SFTP support" ON)
option(WITH_SERVER "Build with SSH server support" ON)
+option(WITH_SHARED_LIB "Build with a shared library" ON)
option(WITH_STATIC_LIB "Build with a static library" OFF)
option(WITH_DEBUG_CRYPTO "Build with cryto debug output" OFF)
option(WITH_DEBUG_CALLTRACE "Build with calltrace debug output" ON)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1111111..2222222 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -225,6 +225,7 @@ include_directories(
${LIBSSH_PRIVATE_INCLUDE_DIRS}
)
+if (WITH_SHARED_LIB)
add_library(${LIBSSH_SHARED_LIBRARY} SHARED ${libssh_SRCS})
target_link_libraries(${LIBSSH_SHARED_LIBRARY} ${LIBSSH_LINK_LIBRARIES})
@@ -259,6 +260,7 @@ install(
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
COMPONENT libraries
)
+endif (WITH_SHARED_LIB)
if (WITH_STATIC_LIB)
add_library(${LIBSSH_STATIC_LIBRARY} STATIC ${libssh_SRCS})
diff --git a/src/threads/CMakeLists.txt b/src/threads/CMakeLists.txt
index 1111111..2222222 100644
--- a/src/threads/CMakeLists.txt
+++ b/src/threads/CMakeLists.txt
@@ -59,6 +59,7 @@ include_directories(
if (libssh_threads_SRCS)
set(LIBSSH_THREADS ON CACHE "libssh threads lib" INTERNAL)
+ if (WITH_SHARED_LIB)
add_library(${LIBSSH_THREADS_SHARED_LIBRARY} SHARED ${libssh_threads_SRCS})
target_link_libraries(${LIBSSH_THREADS_SHARED_LIBRARY} ${LIBSSH_THREADS_LINK_LIBRARIES})
@@ -88,6 +89,7 @@ if (libssh_threads_SRCS)
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
COMPONENT libraries
)
+ endif (WITH_SHARED_LIB)
if (WITH_STATIC_LIB)
add_library(${LIBSSH_THREADS_STATIC_LIBRARY} STATIC ${libssh_threads_SRCS})
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tony Theodore <tonyt@logyst.com>
Date: Sun, 29 Oct 2017 00:45:55 +1100
Subject: [PATCH] add indentation for shared lib hunks
Taken from:
https://www.libssh.org/archive/libssh/2017-10/0000012.html
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1111111..2222222 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -226,40 +226,40 @@ include_directories(
)
if (WITH_SHARED_LIB)
-add_library(${LIBSSH_SHARED_LIBRARY} SHARED ${libssh_SRCS})
-
-target_link_libraries(${LIBSSH_SHARED_LIBRARY} ${LIBSSH_LINK_LIBRARIES})
-
-set_target_properties(
- ${LIBSSH_SHARED_LIBRARY}
- PROPERTIES
- VERSION
- ${LIBRARY_VERSION}
- SOVERSION
- ${LIBRARY_SOVERSION}
- OUTPUT_NAME
- ssh
- DEFINE_SYMBOL
- LIBSSH_EXPORTS
-)
+ add_library(${LIBSSH_SHARED_LIBRARY} SHARED ${libssh_SRCS})
+
+ target_link_libraries(${LIBSSH_SHARED_LIBRARY} ${LIBSSH_LINK_LIBRARIES})
+
+ set_target_properties(
+ ${LIBSSH_SHARED_LIBRARY}
+ PROPERTIES
+ VERSION
+ ${LIBRARY_VERSION}
+ SOVERSION
+ ${LIBRARY_SOVERSION}
+ OUTPUT_NAME
+ ssh
+ DEFINE_SYMBOL
+ LIBSSH_EXPORTS
+ )
-if (WITH_VISIBILITY_HIDDEN)
- set_target_properties(${LIBSSH_SHARED_LIBRARY} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
-endif (WITH_VISIBILITY_HIDDEN)
+ if (WITH_VISIBILITY_HIDDEN)
+ set_target_properties(${LIBSSH_SHARED_LIBRARY} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+ endif (WITH_VISIBILITY_HIDDEN)
-if (MINGW)
- set_target_properties(${LIBSSH_SHARED_LIBRARY} PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup")
-endif ()
+ if (MINGW)
+ set_target_properties(${LIBSSH_SHARED_LIBRARY} PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup")
+ endif ()
-install(
- TARGETS
- ${LIBSSH_SHARED_LIBRARY}
- RUNTIME DESTINATION ${BIN_INSTALL_DIR}
- LIBRARY DESTINATION ${LIB_INSTALL_DIR}
- ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
- COMPONENT libraries
-)
+ install(
+ TARGETS
+ ${LIBSSH_SHARED_LIBRARY}
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ COMPONENT libraries
+ )
endif (WITH_SHARED_LIB)
if (WITH_STATIC_LIB)
diff --git a/src/threads/CMakeLists.txt b/src/threads/CMakeLists.txt
index 1111111..2222222 100644
--- a/src/threads/CMakeLists.txt
+++ b/src/threads/CMakeLists.txt
@@ -60,35 +60,35 @@ if (libssh_threads_SRCS)
set(LIBSSH_THREADS ON CACHE "libssh threads lib" INTERNAL)
if (WITH_SHARED_LIB)
- add_library(${LIBSSH_THREADS_SHARED_LIBRARY} SHARED ${libssh_threads_SRCS})
-
- target_link_libraries(${LIBSSH_THREADS_SHARED_LIBRARY} ${LIBSSH_THREADS_LINK_LIBRARIES})
-
- set_target_properties(
- ${LIBSSH_THREADS_SHARED_LIBRARY}
- PROPERTIES
- VERSION
- ${LIBRARY_VERSION}
- SOVERSION
- ${LIBRARY_SOVERSION}
- OUTPUT_NAME
- ssh_threads
- DEFINE_SYMBOL
- LIBSSH_EXPORTS
- )
+ add_library(${LIBSSH_THREADS_SHARED_LIBRARY} SHARED ${libssh_threads_SRCS})
- if (WITH_VISIBILITY_HIDDEN)
- set_target_properties(${LIBSSH_THREADS_SHARED_LIBRARY} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
- endif (WITH_VISIBILITY_HIDDEN)
+ target_link_libraries(${LIBSSH_THREADS_SHARED_LIBRARY} ${LIBSSH_THREADS_LINK_LIBRARIES})
- install(
- TARGETS
+ set_target_properties(
${LIBSSH_THREADS_SHARED_LIBRARY}
- RUNTIME DESTINATION ${BIN_INSTALL_DIR}
- LIBRARY DESTINATION ${LIB_INSTALL_DIR}
- ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
- COMPONENT libraries
- )
+ PROPERTIES
+ VERSION
+ ${LIBRARY_VERSION}
+ SOVERSION
+ ${LIBRARY_SOVERSION}
+ OUTPUT_NAME
+ ssh_threads
+ DEFINE_SYMBOL
+ LIBSSH_EXPORTS
+ )
+
+ if (WITH_VISIBILITY_HIDDEN)
+ set_target_properties(${LIBSSH_THREADS_SHARED_LIBRARY} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+ endif (WITH_VISIBILITY_HIDDEN)
+
+ install(
+ TARGETS
+ ${LIBSSH_THREADS_SHARED_LIBRARY}
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ COMPONENT libraries
+ )
endif (WITH_SHARED_LIB)
if (WITH_STATIC_LIB)

61
src/libssh.mk Normal file
View File

@ -0,0 +1,61 @@
# This file is part of MXE. See LICENSE.md for licensing information.
PKG := libssh
$(PKG)_WEBSITE := https://www.libssh.org
$(PKG)_DESCR := SSHv2 and SSHv1 protocol on client and server side
$(PKG)_IGNORE :=
$(PKG)_VERSION := 0.7.5
$(PKG)_CHECKSUM := d275b1b3622c36efacfac748d5eecaf0e80349a551f72abb6ce5afa8c2e6b784
$(PKG)_SUBDIR := libssh-$($(PKG)_VERSION)
$(PKG)_FILE := libssh-$($(PKG)_VERSION).tar.gz
$(PKG)_URL := https://git.libssh.org/projects/libssh.git/snapshot/libssh-$($(PKG)_VERSION).tar.gz
$(PKG)_DEPS := gcc openssl zlib
define $(PKG)_UPDATE
$(WGET) -q -O- 'https://git.libssh.org/projects/libssh.git/refs/tags' | \
$(SED) -n "s,.*>libssh-\([0-9]*\.[^<]*\)\.tar.*,\1,p" | \
$(SORT) -Vr | \
head -1
endef
define $(PKG)_BUILD
# build and install the library
cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(SOURCE_DIR)' \
-DWITH_STATIC_LIB=$(CMAKE_STATIC_BOOL) \
-DWITH_SHARED_LIB=$(CMAKE_SHARED_BOOL) \
-DWITH_BENCHMARKS=OFF \
-DWITH_CLIENT_TESTING=OFF \
-DWITH_DEBUG_CALLTRACE=OFF \
-DWITH_DEBUG_CRYPTO=OFF \
-DWITH_EXAMPLES=OFF \
-DWITH_GCRYPT=OFF \
-DWITH_GSSAPI=OFF \
-DWITH_INTERNAL_DOC=OFF \
-DWITH_NACL=OFF \
-DWITH_PCAP=OFF \
-DWITH_SERVER=ON \
-DWITH_SFTP=ON \
-DWITH_SSH1=ON \
-DWITH_TESTING=OFF \
-DWITH_ZLIB=ON
$(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
$(MAKE) -C '$(BUILD_DIR)' -j 1 install
# create pkg-config file
$(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig'
(echo 'Name: $(PKG)'; \
echo 'Version: $($(PKG)_VERSION)'; \
echo 'Description: libssh'; \
echo 'Requires: openssl'; \
echo 'Libs: -lssh'; \
echo 'Cflags.private: -DLIBSSH_STATIC';) \
> '$(PREFIX)/$(TARGET)/lib/pkgconfig/$(PKG).pc'
# compile test
'$(TARGET)-gcc' \
-W -Wall -Werror -pedantic \
$(SOURCE_DIR)/examples/{authentication.c,knownhosts.c,connect_ssh.c,exec.c} \
-o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \
`'$(TARGET)-pkg-config' $(PKG) --cflags --libs`
endef