From d2f0d0f4e3a876c97ac26fc4149e43e392ef30b4 Mon Sep 17 00:00:00 2001 From: Russell Sim Date: Mon, 21 May 2012 22:13:29 +1000 Subject: [PATCH] Build both static and shared libraries --- debian/changelog | 2 ++ debian/libgit2-dev.install | 1 + debian/patches/build_static.patch | 37 +++++++++++++++++++++++++++++++ debian/patches/series | 2 +- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 debian/patches/build_static.patch diff --git a/debian/changelog b/debian/changelog index 0a96df8eb..97ef9852e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ libgit2 (0.17.0-1) UNRELEASED; urgency=low * New Upstream Release. + * Patch added that enables building as both static and dynamic + library. -- Russell Sim Sun, 20 May 2012 21:34:12 +1000 diff --git a/debian/libgit2-dev.install b/debian/libgit2-dev.install index bd12dbf16..576366b05 100644 --- a/debian/libgit2-dev.install +++ b/debian/libgit2-dev.install @@ -1,3 +1,4 @@ /usr/include +/usr/lib/lib*.a /usr/lib/lib*.so /usr/lib/pkgconfig diff --git a/debian/patches/build_static.patch b/debian/patches/build_static.patch new file mode 100644 index 000000000..ce154ebda --- /dev/null +++ b/debian/patches/build_static.patch @@ -0,0 +1,37 @@ +Build both static and shared libraries. +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bfbabc0..891d2af 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -49,7 +49,6 @@ SET(INSTALL_LIB lib CACHE PATH "Where to install libraries to.") + SET(INSTALL_INC include CACHE PATH "Where to install headers to.") + + # Build options +-OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON) + OPTION (THREADSAFE "Build libgit2 as threadsafe" OFF) + OPTION (BUILD_CLAR "Build Tests using the Clar suite" ON) + OPTION (TAGS "Generate tags" OFF) +@@ -110,7 +109,8 @@ ELSE() + ENDIF () + + # Compile and link libgit2 +-ADD_LIBRARY(git2 ${SRC} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${WIN_RC}) ++ADD_LIBRARY(git2 SHARED ${SRC} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${WIN_RC}) ++ADD_LIBRARY(git2static STATIC ${SRC} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${WIN_RC}) + + IF (WIN32) + TARGET_LINK_LIBRARIES(git2 ws2_32) +@@ -120,11 +120,12 @@ ENDIF () + + TARGET_LINK_LIBRARIES(git2 ${CMAKE_THREAD_LIBS_INIT}) + SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING}) ++SET_TARGET_PROPERTIES(git2static PROPERTIES OUTPUT_NAME git2) + SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_VERSION_MAJOR}) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libgit2.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libgit2.pc @ONLY) + + # Install +-INSTALL(TARGETS git2 ++INSTALL(TARGETS git2 git2static + RUNTIME DESTINATION ${INSTALL_BIN} + LIBRARY DESTINATION ${INSTALL_LIB} + ARCHIVE DESTINATION ${INSTALL_LIB} diff --git a/debian/patches/series b/debian/patches/series index 8b1378917..573b75649 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1 @@ - +build_static.patch