Commit fe5af64f authored by Ghislain MARY's avatar Ghislain MARY

Fix hiredis packaging.

parent 81f5f029
......@@ -23,7 +23,11 @@
lcb_git_repository("https://github.com/redis/hiredis.git")
lcb_external_source_paths("externals/hiredis")
lcb_patch_command("COMMAND" "${CMAKE_COMMAND}" "-E" "copy" "${CMAKE_CURRENT_SOURCE_DIR}/builders/hiredis/CMakeLists.txt" "<SOURCE_DIR>")
lcb_patch_command("COMMAND" "${CMAKE_COMMAND}" "-E" "make_directory" "<SOURCE_DIR>/build/")
lcb_patch_command("COMMAND" "${CMAKE_COMMAND}" "-E" "copy" "${CMAKE_CURRENT_SOURCE_DIR}/builders/hiredis/build/CMakeLists.txt" "<SOURCE_DIR>/build/")
lcb_package_source(YES)
lcb_dependencies(bctoolbox)
lcb_spec_file("hiredis.spec")
lcb_use_autotools_for_rpm(YES)
lcb_patch_command("COMMAND" "${CMAKE_COMMAND}" "-E" "copy" "${CMAKE_CURRENT_SOURCE_DIR}/builders/hiredis/hiredis.spec" "<SOURCE_DIR>")
lcb_patch_command("COMMAND" "${CMAKE_COMMAND}" "-E" "copy" "${CMAKE_CURRENT_SOURCE_DIR}/builders/hiredis/build/hiredis.spec.cmake" "<SOURCE_DIR>/build/")
......@@ -26,6 +26,10 @@ project(hiredis LANGUAGES C VERSION 0.13.3)
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
include(GNUInstallDirs)
find_package(BcToolbox 0.0.3 REQUIRED)
set(HEADER_FILES
async.h
hiredis.h
......@@ -45,25 +49,29 @@ if(ENABLE_STATIC)
add_library(hiredis-static STATIC ${SOURCE_FILES})
set_target_properties(hiredis-static PROPERTIES OUTPUT_NAME hiredis)
install(TARGETS hiredis-static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
if(ENABLE_SHARED)
add_library(hiredis SHARED ${SOURCE_FILES})
set_target_properties(hiredis PROPERTIES VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
install(TARGETS hiredis
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(FILES ${HEADER_FILES}
DESTINATION include/hiredis
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
install(DIRECTORY adapters DESTINATION include/hiredis)
\ No newline at end of file
install(DIRECTORY adapters DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis)
add_subdirectory(build)
############################################################################
# CMakeLists.txt
# Copyright (C) 2017 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
if (NOT CPACK_PACKAGE_NAME)
set(CPACK_PACKAGE_NAME "hiredis")
ENDIF()
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION})
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES
"${CMAKE_BINARY_DIR}"
"^${PROJECT_SOURCE_DIR}/.git*"
)
bc_project_build_version(${PROJECT_VERSION} PROJECT_VERSION_BUILD)
if(PROJECT_VERSION_BUILD)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${PROJECT_VERSION_BUILD}")
endif()
message("-- Package file name is ${CPACK_PACKAGE_FILE_NAME}" )
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hiredis.spec.cmake ${CMAKE_CURRENT_SOURCE_DIR}/../hiredis.spec)
include(CPack)
%define pkg_name hiredis
%define finalpkg_name %{?_with_bc:bc-%{pkg_name}}%{!?_with_bc:%{pkg_name}}
%define pkg_name %{?_with_bc:bc-hiredis}%{!?_with_bc:hiredis}
%{?_with_bc: %define _prefix /opt/belledonne-communications}
# re-define some directories for older RPMBuild versions which don't. This messes up the doc/ dir
# taken from https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros
......@@ -9,14 +8,18 @@
%define _datadir %{_datarootdir}
%define _docdir %{_datadir}/doc
%define build_number @PROJECT_VERSION_BUILD@
%if %{build_number}
%define build_number_ext -%{build_number}
%endif
Name: %{finalpkg_name}
Version: 0.13.3
Release: 3%{?dist}
Name: %{pkg_name}
Version: @PROJECT_VERSION@
Release: %{build_number}%{?dist}
Summary: Minimalistic C client library for Redis
License: BSD
URL: https://github.com/redis/hiredis
Source0: v%{version}.tar.gz
Source0: %{name}-%{version}%{?build_number_ext}.tar.gz
%description
Hiredis is a minimalistic C client library for the Redis database.
......@@ -29,19 +32,26 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
This package contains libraries and header files for
developing applications that use %{name}.
%if 0%{?rhel} && 0%{?rhel} <= 7
%global cmake_name cmake3
%define ctest_name ctest3
%else
%global cmake_name cmake
%define ctest_name ctest
%endif
%prep
%setup -q -n hiredis-%{version}
%setup -q -n %{name}-%{version}%{?build_number_ext}
%build
make %{?_smp_mflags} OPTIMIZATION="%{optflags}"
%{expand:%%%cmake_name} . -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} -DCMAKE_PREFIX_PATH:PATH=%{_prefix}
make %{?_smp_mflags}
%install
make install PREFIX=%{buildroot}%{_prefix} INSTALL_LIBRARY_PATH=%{buildroot}%{_libdir}
mkdir -p %{buildroot}%{_bindir}
cp hiredis-test %{buildroot}%{_bindir}
make install DESTDIR=%{buildroot}
find %{buildroot} -name '*.a' -delete -print
%clean
rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
......@@ -49,13 +59,12 @@ find %{buildroot} -name '*.a' -delete -print
%files
%doc COPYING
%{_bindir}/hiredis-test
%{_libdir}/libhiredis.so.0.13
%{_libdir}/pkgconfig/hiredis.pc
%files devel
%doc README.md
%{_includedir}/%{pkg_name}/
%{_includedir}/hiredis/
%{_libdir}/libhiredis.a
%{_libdir}/libhiredis.so
%changelog
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment