This commit is contained in:
Veeti Paananen 2013-06-25 01:31:27 +03:00
parent 5ba73998c3
commit fe4e3498f9
7 changed files with 40 additions and 129 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/v0.18.0.tar.gz
/v0.19.0.tar.gz

View File

@ -1,92 +0,0 @@
From 429218190bf4bcc90d86f0878e81469b3ae3c389 Mon Sep 17 00:00:00 2001
From: Veeti Paananen <veeti.paananen@rojekti.fi>
Date: Thu, 2 May 2013 14:07:22 +0300
Subject: [PATCH] Build with the system's http-parser installation if available
---
CMakeLists.txt | 15 +++++++++++++--
deps/cmake/FindHTTP_Parser.cmake | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 2 deletions(-)
create mode 100644 deps/cmake/FindHTTP_Parser.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f6b06b..b176035 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,9 @@
PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+# Add find modules to the path
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules")
+
# Build options
#
OPTION( SONAME "Set the (SO)VERSION of the target" ON )
@@ -97,8 +100,16 @@ ELSE ()
IF (NOT AMIGA)
FIND_PACKAGE(OpenSSL)
ENDIF ()
- FILE(GLOB SRC_HTTP deps/http-parser/*.c)
- INCLUDE_DIRECTORIES(deps/http-parser)
+
+ FIND_PACKAGE(HTTP_Parser QUIET)
+ IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
+ INCLUDE_DIRECTORIES(${HTTP_PARSER_INCLUDE_DIRS})
+ LINK_LIBRARIES(${HTTP_PARSER_LIBRARIES})
+ ELSE()
+ MESSAGE("http-parser was not found or is too old; using bundled 3rd-party sources.")
+ INCLUDE_DIRECTORIES(deps/http-parser)
+ FILE(GLOB SRC_HTTP deps/http-parser/*.c)
+ ENDIF()
ENDIF()
# Specify sha1 implementation
diff --git a/cmake/Modules/FindHTTP_Parser.cmake b/cmake/Modules/FindHTTP_Parser.cmake
new file mode 100644
index 0000000..d92bf75
--- /dev/null
+++ b/cmake/Modules/FindHTTP_Parser.cmake
@@ -0,0 +1,39 @@
+# - Try to find http-parser
+#
+# Defines the following variables:
+#
+# HTTP_PARSER_FOUND - system has http-parser
+# HTTP_PARSER_INCLUDE_DIR - the http-parser include directory
+# HTTP_PARSER_LIBRARIES - Link these to use http-parser
+# HTTP_PARSER_VERSION_MAJOR - major version
+# HTTP_PARSER_VERSION_MINOR - minor version
+# HTTP_PARSER_VERSION_STRING - the version of http-parser found
+
+# Find the header and library
+FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
+FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
+
+# Found the header, read version
+if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h")
+ FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
+ IF (HTTP_PARSER_H)
+ STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}")
+ STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}")
+ SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
+ ENDIF()
+ UNSET(HTTP_PARSER_H)
+ENDIF()
+
+# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
+# to TRUE if all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
+
+# Hide advanced variables
+MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
+
+# Set standard variables
+IF (HTTP_PARSER_FOUND)
+ SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
+ set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
+ENDIF()
--
1.8.1.4

View File

@ -1,26 +0,0 @@
diff -up libgit2-0.18.0/CMakeLists.txt.system-libxdiff libgit2-0.18.0/CMakeLists.txt
--- libgit2-0.18.0/CMakeLists.txt.system-libxdiff 2013-05-30 12:50:45.703153568 -0400
+++ libgit2-0.18.0/CMakeLists.txt 2013-05-30 12:52:01.708154709 -0400
@@ -286,11 +286,11 @@ ELSEIF (AMIGA)
ELSE()
FILE(GLOB SRC_OS src/unix/*.c)
ENDIF()
-FILE(GLOB SRC_GIT2 src/*.c src/transports/*.c src/xdiff/*.c)
+FILE(GLOB SRC_GIT2 src/*.c src/transports/*.c)
# Compile and link libgit2
ADD_LIBRARY(git2 ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SHA1} ${WIN_RC})
-TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES})
+TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES} -lxdiff)
TARGET_OS_LIBRARIES(git2)
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
@@ -350,7 +350,7 @@ IF (BUILD_CLAR)
ADD_EXECUTABLE(libgit2_clar ${SRC_GIT2} ${SRC_OS} ${SRC_CLAR} ${SRC_TEST} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SHA1})
- TARGET_LINK_LIBRARIES(libgit2_clar ${SSL_LIBRARIES})
+ TARGET_LINK_LIBRARIES(libgit2_clar ${SSL_LIBRARIES} -lxdiff)
TARGET_OS_LIBRARIES(libgit2_clar)
MSVC_SPLIT_SOURCES(libgit2_clar)

View File

@ -0,0 +1,29 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b931dc5..2aa8fde 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -298,7 +298,7 @@ ELSEIF (AMIGA)
ELSE()
FILE(GLOB SRC_OS src/unix/*.c)
ENDIF()
-FILE(GLOB SRC_GIT2 src/*.c src/transports/*.c src/xdiff/*.c)
+FILE(GLOB SRC_GIT2 src/*.c src/transports/*.c)
# Determine architecture of the machine
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -313,6 +313,7 @@ ENDIF()
ADD_LIBRARY(git2 ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SHA1} ${WIN_RC})
TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES})
TARGET_LINK_LIBRARIES(git2 ${SSH_LIBRARIES})
+TARGET_LINK_LIBRARIES(git2 -lxdiff)
TARGET_OS_LIBRARIES(git2)
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
@@ -388,6 +389,7 @@ IF (BUILD_CLAR)
TARGET_LINK_LIBRARIES(libgit2_clar ${SSL_LIBRARIES})
TARGET_LINK_LIBRARIES(libgit2_clar ${SSH_LIBRARIES})
+ TARGET_LINK_LIBRARIES(libgit2_clar -lxdiff)
TARGET_OS_LIBRARIES(libgit2_clar)
MSVC_SPLIT_SOURCES(libgit2_clar)

View File

@ -1,20 +1,17 @@
Name: libgit2
Version: 0.18.0
Release: 5%{?dist}
Version: 0.19.0
Release: 1%{?dist}
Summary: A C implementation of the Git core methods as a library
License: GPLv2 with exceptions
URL: http://libgit2.github.com/
Source0: https://github.com/libgit2/libgit2/archive/v%{version}.tar.gz
# Remove bundling of http-parser
Patch0: libgit2-0.18.0-http.patch
# Use system libxdiff
Patch1: libgit2-0.18.0-system-libxdiff.patch
Patch0: libgit2-0.19.0-system-libxdiff.patch
# Add htonl() and friends declarations on non-x86 arches
Patch2: libgit2-0.18.0-non-x86.patch
Patch1: libgit2-0.19.0-non-x86.patch
BuildRequires: cmake >= 2.6
BuildRequires: http-parser-devel
@ -45,9 +42,8 @@ developing applications that use %{name}.
find examples -name ".gitignore" -delete
# Apply patches
%patch0 -p1
%patch1 -p1 -b .system-libxdiff
%patch2 -p1 -b .non-x86
%patch0 -p1 -b .system-libxdiff
%patch1 -p1 -b .non-x86
# Fix pkgconfig generation
sed -i 's|@CMAKE_INSTALL_PREFIX@/||' libgit2.pc.in
@ -90,6 +86,9 @@ make install DESTDIR=%{buildroot}
%changelog
* Tue Jun 25 2013 Veeti Paananen <veeti.paananen@rojekti.fi> - 0.19.0-1
- 0.19.0
* Wed Jun 19 2013 Dan Horák <dan[at]danny.cz> - 0.18.0-5
- Add htonl() and friends declarations on non-x86 arches
- Rebuilt with fixed libxdiff for big endian arches

View File

@ -1 +1 @@
ce6845df0dd084ef2633a69dba64929c v0.18.0.tar.gz
d682d9424d95f697bf3f89b358fe8e1a v0.19.0.tar.gz