You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
4.7 KiB

  1. From 5ebbd50cffc013a7dd0f3b1eaaa83d199e8e47fd Mon Sep 17 00:00:00 2001
  2. From: Mike Frysinger <vapier@gentoo.org>
  3. Date: Sun, 24 Jul 2016 00:14:20 +0530
  4. Subject: [PATCH] cmake: add soname info to libgd.so
  5. Pull out the library versioning info out of configure and into a common
  6. script that both cmake & autotools can run. This way we have a single
  7. source of truth for the versioning info.
  8. ---
  9. CMakeLists.txt | 11 +++++++++++
  10. config/getlib.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
  11. configure.ac | 25 +++++++++++--------------
  12. src/CMakeLists.txt | 2 ++
  13. 4 files changed, 66 insertions(+), 14 deletions(-)
  14. create mode 100755 config/getlib.sh
  15. diff --git a/CMakeLists.txt b/CMakeLists.txt
  16. index 7c8ad34b..9fe2eb4e 100644
  17. --- a/CMakeLists.txt
  18. +++ b/CMakeLists.txt
  19. @@ -78,6 +78,17 @@ else (USE_EXT_GD)
  20. SET(GD_VERSION_INT "2020555")
  21. + MACRO(GV_LT VER VAR)
  22. + execute_process(
  23. + COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/config/getlib.sh ${VER}
  24. + OUTPUT_VARIABLE ${VAR}
  25. + )
  26. + ENDMACRO(GV_LT)
  27. +
  28. + GV_LT(SONAME GDLIB_LIB_SOVERSION)
  29. + GV_LT(VERSION GDLIB_LIB_VERSION)
  30. + MESSAGE(STATUS "gd shared lib version ${GDLIB_LIB_SOVERSION} (${GDLIB_LIB_VERSION})")
  31. +
  32. SET(CMAKE_REQUIRED_INCLUDES "/usr/include" "/usr/local/include")
  33. include(CheckIncludeFiles)
  34. diff --git a/config/getlib.sh b/config/getlib.sh
  35. new file mode 100755
  36. index 00000000..4835cf6c
  37. --- /dev/null
  38. +++ b/config/getlib.sh
  39. @@ -0,0 +1,42 @@
  40. +#!/bin/sh
  41. +
  42. +GETVER="${0%/*}/getver.pl"
  43. +GDLIB_MAJOR=$("${GETVER}" MAJOR)
  44. +GDLIB_MINOR=$("${GETVER}" MINOR)
  45. +GDLIB_REVISION=$("${GETVER}" RELEASE)
  46. +
  47. +# Dynamic library version information
  48. +# See http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
  49. +
  50. +GDLIB_LT_CURRENT=3
  51. +# This is the version where the soname (current above) changes. We use it
  52. +# to reset the revision base back to zero. It's a bit of a pain, but some
  53. +# systems restrict the revision range below to [0..255] (like OS X).
  54. +GDLIB_PREV_MAJOR=2
  55. +GDLIB_PREV_MINOR=2
  56. +# This isn't 100% correct, but it tends to be a close enough approximation
  57. +# for how we manage the codebase. It's rare to do a release that doesn't
  58. +# modify the library since this project is centered around the library.
  59. +GDLIB_LT_REVISION=$(( ((GDLIB_MAJOR - GDLIB_PREV_MAJOR) << 6) | ((GDLIB_MINOR - GDLIB_PREV_MINOR) << 3) | GDLIB_REVISION ))
  60. +GDLIB_LT_AGE=0
  61. +
  62. +# The first three fields we feed into libtool and the OS target determines how
  63. +# they get used. The last two fields we feed into cmake. We use the same rules
  64. +# as Linux SONAME versioning in libtool, but cmake should handle it for us.
  65. +case $1 in
  66. +CURRENT)
  67. + printf '%s' "${GDLIB_LT_CURRENT}"
  68. + ;;
  69. +REVISION)
  70. + printf '%s' "${GDLIB_LT_REVISION}"
  71. + ;;
  72. +AGE)
  73. + printf '%s' "${GDLIB_LT_AGE}"
  74. + ;;
  75. +VERSION)
  76. + printf '%s' "$(( GDLIB_LT_CURRENT - GDLIB_LT_AGE )).${GDLIB_LT_AGE}.${GDLIB_LT_REVISION}"
  77. + ;;
  78. +SONAME)
  79. + printf '%s' "$(( GDLIB_LT_CURRENT - GDLIB_LT_AGE ))"
  80. + ;;
  81. +esac
  82. diff --git a/configure.ac b/configure.ac
  83. index 91643bd6..c3fb034e 100644
  84. --- a/configure.ac
  85. +++ b/configure.ac
  86. @@ -34,20 +34,17 @@ AC_SUBST(GDLIB_REVISION)
  87. AC_SUBST(GDLIB_EXTRA)
  88. AC_SUBST(GDLIB_VERSION)
  89. -# Dynamic library version information
  90. -# See http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
  91. -
  92. -GDLIB_LT_CURRENT=3
  93. -dnl This is the version where the soname (current above) changes. We use it
  94. -dnl to reset the revision base back to zero. It's a bit of a pain, but some
  95. -dnl systems restrict the revision range below to [0..255] (like OS X).
  96. -GDLIB_PREV_MAJOR=2
  97. -GDLIB_PREV_MINOR=2
  98. -dnl This isn't 100% correct, but it tends to be a close enough approximation
  99. -dnl for how we manage the codebase. It's rare to do a release that doesn't
  100. -dnl modify the library since this project is centered around the library.
  101. -GDLIB_LT_REVISION=$(( ((GDLIB_MAJOR - GDLIB_PREV_MAJOR) << 6) | ((GDLIB_MINOR - GDLIB_PREV_MINOR) << 3) | GDLIB_REVISION ))
  102. -GDLIB_LT_AGE=0
  103. +dnl Keep the libtool version details in an external script so cmake can
  104. +dnl access the values too.
  105. +define([lt_gv], [config/getlib.sh ]$1)
  106. +m4_define([gd_LT_CURRENT], esyscmd(lt_gv(CURRENT)))
  107. +m4_define([gd_LT_REVISION], esyscmd(lt_gv(REVISION)))
  108. +m4_define([gd_LT_AGE], esyscmd(lt_gv(AGE)))
  109. +
  110. +GDLIB_LT_CURRENT=gd_LT_CURRENT
  111. +GDLIB_LT_REVISION=gd_LT_REVISION
  112. +GDLIB_LT_AGE=gd_LT_AGE
  113. +
  114. AC_SUBST(GDLIB_LT_CURRENT)
  115. AC_SUBST(GDLIB_LT_REVISION)
  116. AC_SUBST(GDLIB_LT_AGE)
  117. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  118. index 08fd6991..a621fe1e 100644
  119. --- a/src/CMakeLists.txt
  120. +++ b/src/CMakeLists.txt
  121. @@ -76,6 +76,8 @@ include(GNUInstallDirs)
  122. if (BUILD_SHARED_LIBS)
  123. add_library(${GD_LIB} ${LIBGD_SRC_FILES})
  124. set_target_properties(${GD_LIB} PROPERTIES
  125. + SOVERSION ${GDLIB_LIB_SOVERSION}
  126. + VERSION ${GDLIB_LIB_VERSION}
  127. C_VISIBILITY_PRESET hidden
  128. CXX_VISIBILITY_PRESET hidden
  129. )