Gentoo Archives: gentoo-commits

From: Alessandro Barbieri <lssndrbarbieri@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/guru:dev commit in: media-libs/sjpeg/files/, media-libs/sjpeg/
Date: Wed, 27 Oct 2021 15:25:46
Message-Id: 1635348317.37896c92138b32edd51e60af9f9b8bc203f4ad77.Alessandro-Barbieri@gentoo
1 commit: 37896c92138b32edd51e60af9f9b8bc203f4ad77
2 Author: Alessandro Barbieri <lssndrbarbieri <AT> gmail <DOT> com>
3 AuthorDate: Wed Oct 27 15:25:17 2021 +0000
4 Commit: Alessandro Barbieri <lssndrbarbieri <AT> gmail <DOT> com>
5 CommitDate: Wed Oct 27 15:25:17 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=37896c92
7
8 media-libs/sjpeg: rename and install libsjpeg-utils.so
9
10 Closes: https://bugs.gentoo.org/820491
11 Package-Manager: Portage-3.0.28, Repoman-3.0.3
12 Signed-off-by: Alessandro Barbieri <lssndrbarbieri <AT> gmail.com>
13
14 media-libs/sjpeg/CMakeLists.txt | 242 +++++++++++++++++++++
15 media-libs/sjpeg/Manifest | 2 +-
16 media-libs/sjpeg/files/sjpeg-rename-libutils.patch | 68 ++++++
17 ...210422.ebuild => sjpeg-1.0_p20210422-r1.ebuild} | 2 +
18 4 files changed, 313 insertions(+), 1 deletion(-)
19
20 diff --git a/media-libs/sjpeg/CMakeLists.txt b/media-libs/sjpeg/CMakeLists.txt
21 new file mode 100644
22 index 000000000..b14baba1f
23 --- /dev/null
24 +++ b/media-libs/sjpeg/CMakeLists.txt
25 @@ -0,0 +1,242 @@
26 +# Copyright 2020 Google LLC.
27 +#
28 +# Licensed under the Apache License, Version 2.0 (the "License");
29 +# you may not use this file except in compliance with the License.
30 +# You may obtain a copy of the License at
31 +#
32 +# https://www.apache.org/licenses/LICENSE-2.0
33 +#
34 +# Unless required by applicable law or agreed to in writing, software
35 +# distributed under the License is distributed on an "AS IS" BASIS,
36 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 +# See the License for the specific language governing permissions and
38 +# limitations under the License.
39 +
40 +cmake_minimum_required(VERSION 2.8.7)
41 +
42 +project(sjpeg
43 + LANGUAGES C CXX)
44 +set(CMAKE_C_STANDARD 99)
45 +set(CMAKE_CXX_STANDARD 11)
46 +
47 +# Options for coder / decoder executables.
48 +option(SJPEG_ENABLE_SIMD "Enable any SIMD optimization." ON)
49 +option(SJPEG_BUILD_EXAMPLES "Build the sjpeg / vjpeg command line tools." ON)
50 +
51 +set(SJPEG_DEP_LIBRARIES)
52 +set(SJPEG_DEP_INCLUDE_DIRS)
53 +
54 +if(NOT CMAKE_BUILD_TYPE)
55 + set(CMAKE_BUILD_TYPE "Release" CACHE STRING
56 + "Build type: Release, Debug or RelWithDebInfo" FORCE
57 + )
58 +endif()
59 +
60 +include(GNUInstallDirs)
61 +
62 +set(PROJECT_VERSION 0.1)
63 +
64 +################################################################################
65 +# Android only.
66 +
67 +if(ANDROID)
68 + include_directories(${SJPEG_ANDROID_NDK_PATH}/sources/android/cpufeatures)
69 + add_library(cpufeatures
70 + STATIC ${SJPEG_ANDROID_NDK_PATH}/sources/android/cpufeatures/cpu-features.c
71 + )
72 + target_link_libraries(cpufeatures dl)
73 + set(SJPEG_DEP_LIBRARIES ${SJPEG_DEP_LIBRARIES} cpufeatures)
74 + set(SJPEG_DEP_INCLUDE_DIRS ${SJPEG_DEP_INCLUDE_DIRS}
75 + ${SJPEG_ANDROID_NDK_PATH}/sources/android/cpufeatures
76 + )
77 +endif()
78 +
79 +## Check for SIMD extensions.
80 +include(${CMAKE_CURRENT_LIST_DIR}/cmake/cpu.cmake)
81 +
82 +################################################################################
83 +# sjpeg source files.
84 +
85 +# Build the sjpeg library.
86 +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/ ${SJPEG_DEP_INCLUDE_DIRS})
87 +add_library(sjpeg ${CMAKE_CURRENT_SOURCE_DIR}/src/bit_writer.cc
88 + ${CMAKE_CURRENT_SOURCE_DIR}/src/bit_writer.h
89 + ${CMAKE_CURRENT_SOURCE_DIR}/src/colors_rgb.cc
90 + ${CMAKE_CURRENT_SOURCE_DIR}/src/dichotomy.cc
91 + ${CMAKE_CURRENT_SOURCE_DIR}/src/enc.cc
92 + ${CMAKE_CURRENT_SOURCE_DIR}/src/fdct.cc
93 + ${CMAKE_CURRENT_SOURCE_DIR}/src/headers.cc
94 + ${CMAKE_CURRENT_SOURCE_DIR}/src/md5sum.h
95 + ${CMAKE_CURRENT_SOURCE_DIR}/src/jpeg_tools.cc
96 + ${CMAKE_CURRENT_SOURCE_DIR}/src/score_7.cc
97 + ${CMAKE_CURRENT_SOURCE_DIR}/src/sjpeg.h
98 + ${CMAKE_CURRENT_SOURCE_DIR}/src/sjpegi.h
99 + ${CMAKE_CURRENT_SOURCE_DIR}/src/yuv_convert.cc
100 +)
101 +if(SJPEG_DEP_LIBRARIES)
102 + target_link_libraries(sjpeg ${SJPEG_DEP_LIBRARIES})
103 +endif()
104 +
105 +# Make sure the OBJECT libraries are built with position independent code
106 +# (it is not ON by default).
107 +set_target_properties(sjpeg PROPERTIES POSITION_INDEPENDENT_CODE ON)
108 +
109 +# Set the version numbers.
110 +set_target_properties(sjpeg PROPERTIES VERSION ${PROJECT_VERSION}
111 + SOVERSION ${PROJECT_VERSION})
112 +
113 +# Find the standard image libraries.
114 +set(SJPEG_DEP_IMG_LIBRARIES)
115 +set(SJPEG_DEP_IMG_INCLUDE_DIRS)
116 +foreach(I_LIB PNG JPEG)
117 + find_package(${I_LIB})
118 + set(SJPEG_HAVE_${I_LIB} ${${I_LIB}_FOUND})
119 + if(${I_LIB}_FOUND)
120 + set(SJPEG_DEP_IMG_LIBRARIES ${SJPEG_DEP_IMG_LIBRARIES}
121 + ${${I_LIB}_LIBRARIES})
122 + set(SJPEG_DEP_IMG_INCLUDE_DIRS ${SJPEG_DEP_IMG_INCLUDE_DIRS}
123 + ${${I_LIB}_INCLUDE_DIRS})
124 + endif()
125 +endforeach()
126 +
127 +# Find the OpenGL/GLUT libraries.
128 +set(SJPEG_DEP_GL_LIBRARIES)
129 +set(SJPEG_DEP_GL_INCLUDE_DIRS)
130 +find_package(OpenGL)
131 +if(OPENGL_gl_LIBRARY)
132 + set(SJPEG_DEP_GL_LIBRARIES
133 + ${SJPEG_DEP_GL_LIBRARIES} ${OPENGL_gl_LIBRARY})
134 + set(SJPEG_DEP_GL_INCLUDE_DIRS
135 + ${SJPEG_DEP_GL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR})
136 + set(SJPEG_HAVE_OPENGL TRUE)
137 +endif()
138 +find_package(GLUT)
139 +if(GLUT_FOUND)
140 + set(SJPEG_DEP_GL_LIBRARIES
141 + ${SJPEG_DEP_GL_LIBRARIES} ${GLUT_glut_LIBRARY})
142 + set(SJPEG_DEP_GL_INCLUDE_DIRS
143 + ${SJPEG_DEP_GL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIR})
144 + set(SJPEG_HAVE_GLUT TRUE)
145 +endif()
146 +
147 +# build the sjpeg-utils library
148 +include_directories(${SJPEG_DEP_IMG_INCLUDE_DIRS})
149 +add_library(sjpeg-utils
150 + ${CMAKE_CURRENT_SOURCE_DIR}/examples/utils.cc
151 + ${CMAKE_CURRENT_SOURCE_DIR}/examples/utils.h
152 +)
153 +
154 +if(WIN32)
155 + # quiet warnings related to fopen, sscanf
156 + target_compile_definitions(sjpeg-utils PRIVATE _CRT_SECURE_NO_WARNINGS)
157 +endif()
158 +if(SJPEG_HAVE_OPENGL)
159 + # check pthread for GL libraries
160 + set(THREADS_PREFER_PTHREAD_FLAG ON)
161 + find_package(Threads)
162 + if(Threads_FOUND)
163 + if(CMAKE_USE_PTHREADS_INIT)
164 + list(APPEND SJPEG_DEP_GL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
165 + endif()
166 + endif()
167 + target_compile_definitions(sjpeg-utils PUBLIC SJPEG_HAVE_OPENGL)
168 + add_definitions(${OPENGL_DEFINITIONS})
169 +endif()
170 +if(SJPEG_HAVE_GLUT)
171 + add_definitions(${GLUT_DEFINITIONS})
172 +endif()
173 +if(SJPEG_HAVE_JPEG)
174 + target_compile_definitions(sjpeg-utils PUBLIC SJPEG_HAVE_JPEG)
175 +endif()
176 +if(SJPEG_HAVE_PNG)
177 + target_compile_definitions(sjpeg-utils PUBLIC SJPEG_HAVE_PNG)
178 +endif()
179 +if(SJPEG_DEP_IMG_LIBRARIES)
180 + # check pthread for GL libraries
181 + target_link_libraries(sjpeg-utils ${SJPEG_DEP_IMG_LIBRARIES}
182 + ${SJPEG_DEP_GL_LIBRARIES})
183 +endif()
184 +# set_target_properties(sjpeg-utils PROPERTIES POSITION_INDEPENDENT_CODE ON)
185 +
186 +# Build the executables if asked for.
187 +if(SJPEG_BUILD_EXAMPLES)
188 + # sjpeg
189 + add_executable(sjpeg-bin ${CMAKE_CURRENT_SOURCE_DIR}/examples/sjpeg.cc)
190 + target_link_libraries(sjpeg-bin sjpeg sjpeg-utils)
191 + set_target_properties(sjpeg-bin PROPERTIES OUTPUT_NAME sjpeg)
192 +
193 + # vjpeg
194 + include_directories(${SJPEG_DEP_GL_INCLUDE_DIRS})
195 + add_executable(vjpeg ${CMAKE_CURRENT_SOURCE_DIR}/examples/vjpeg.cc)
196 + # Force to link against pthread.
197 + include(CheckCXXSourceCompiles)
198 + set(CMAKE_REQUIRED_FLAGS_INI ${CMAKE_REQUIRED_FLAGS})
199 + set(CMAKE_REQUIRED_FLAGS "-Wl,--no-as-needed")
200 + check_cxx_source_compiles("int main(void){return 0;}" FLAG_NO_AS_NEEDED)
201 + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_INI})
202 + if(FLAG_NO_AS_NEEDED)
203 + target_link_libraries(vjpeg "-Wl,--no-as-needed")
204 + endif()
205 +
206 + # check whether we need to include GLUT/glut.h or GL/glut.h
207 + include(CheckIncludeFileCXX)
208 + check_include_file_cxx(GLUT/glut.h HAVE_GLUT_GLUT_H)
209 + check_include_file_cxx(GL/glut.h HAVE_GL_GLUT_H)
210 + if(HAVE_GLUT_GLUT_H)
211 + add_definitions(-DHAVE_GLUT_GLUT_H)
212 + elseif(HAVE_GL_GLUT_H)
213 + add_definitions(-DHAVE_GL_GLUT_H)
214 + endif()
215 + target_link_libraries(vjpeg ${SJPEG_DEP_GL_LIBRARIES} sjpeg sjpeg-utils)
216 +
217 + install(TARGETS sjpeg-bin vjpeg RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
218 +endif()
219 +
220 +# Install the different headers and libraries.
221 +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sjpeg.h
222 + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
223 +install(TARGETS sjpeg
224 + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
225 + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
226 +
227 +# Create the CMake version file.
228 +include(CMakePackageConfigHelpers)
229 +write_basic_package_version_file(
230 + "${CMAKE_CURRENT_BINARY_DIR}/sjpegConfigVersion.cmake"
231 + VERSION ${PROJECT_VERSION}
232 + COMPATIBILITY AnyNewerVersion
233 +)
234 +
235 +# Create the Config file.
236 +include(CMakePackageConfigHelpers)
237 +set(ConfigPackageLocation ${CMAKE_INSTALL_DATADIR}/sjpeg/cmake/)
238 +configure_package_config_file(
239 + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sjpegConfig.cmake.in
240 + ${CMAKE_CURRENT_BINARY_DIR}/sjpegConfig.cmake
241 + INSTALL_DESTINATION ${ConfigPackageLocation}
242 +)
243 +
244 +# Install the generated CMake files.
245 +install(
246 + FILES "${CMAKE_CURRENT_BINARY_DIR}/sjpegConfigVersion.cmake"
247 + "${CMAKE_CURRENT_BINARY_DIR}/sjpegConfig.cmake"
248 + DESTINATION ${ConfigPackageLocation}
249 +)
250 +
251 +
252 +################################################################################
253 +# Man page.
254 +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man/sjpeg.1
255 + ${CMAKE_CURRENT_SOURCE_DIR}/man/vjpeg.1
256 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
257 +
258 +message(STATUS "<<< Gentoo configuration >>>
259 +Build type ${CMAKE_BUILD_TYPE}
260 +Install path ${CMAKE_INSTALL_PREFIX}
261 +Compiler flags:
262 +C ${CMAKE_C_FLAGS}
263 +C++ ${CMAKE_CXX_FLAGS}
264 +Linker flags:
265 +Executable ${CMAKE_EXE_LINKER_FLAGS}
266 +Module ${CMAKE_MODULE_LINKER_FLAGS}
267 +Shared ${CMAKE_SHARED_LINKER_FLAGS}\n")
268
269 diff --git a/media-libs/sjpeg/Manifest b/media-libs/sjpeg/Manifest
270 index 399c5ad69..83c017554 100644
271 --- a/media-libs/sjpeg/Manifest
272 +++ b/media-libs/sjpeg/Manifest
273 @@ -1 +1 @@
274 -DIST sjpeg-1.0_p20210422.tar.gz 2481123 BLAKE2B dc645e6e97873389b40463561683be744fb951c914b55dd5183e190982dbe4aeea98ee3c1271d2447ad1e5b4e23ea03cdf86ff3a9d7372631b0f9ca01cd4ac4f SHA512 cf9e5a744f79996817679dc2e64be2efd64cbc9bb5f505f5c6530f92d60fe99715c57bcf71e0bb80c77732ace1d71fbf1ff9b4e4ec2562a9576c74a4410c2cb1
275 +DIST sjpeg-1.0_p20210422-r1.tar.gz 2481123 BLAKE2B dc645e6e97873389b40463561683be744fb951c914b55dd5183e190982dbe4aeea98ee3c1271d2447ad1e5b4e23ea03cdf86ff3a9d7372631b0f9ca01cd4ac4f SHA512 cf9e5a744f79996817679dc2e64be2efd64cbc9bb5f505f5c6530f92d60fe99715c57bcf71e0bb80c77732ace1d71fbf1ff9b4e4ec2562a9576c74a4410c2cb1
276
277 diff --git a/media-libs/sjpeg/files/sjpeg-rename-libutils.patch b/media-libs/sjpeg/files/sjpeg-rename-libutils.patch
278 new file mode 100644
279 index 000000000..a78764e8f
280 --- /dev/null
281 +++ b/media-libs/sjpeg/files/sjpeg-rename-libutils.patch
282 @@ -0,0 +1,68 @@
283 +--- a/CMakeLists.txt
284 ++++ b/CMakeLists.txt
285 +@@ -119,16 +119,16 @@
286 + set(SJPEG_HAVE_GLUT TRUE)
287 + endif()
288 +
289 +-# build the utils library
290 ++# build the sjpeg-utils library
291 + include_directories(${SJPEG_DEP_IMG_INCLUDE_DIRS})
292 +-add_library(utils
293 ++add_library(sjpeg-utils
294 + ${CMAKE_CURRENT_SOURCE_DIR}/examples/utils.cc
295 + ${CMAKE_CURRENT_SOURCE_DIR}/examples/utils.h
296 + )
297 +
298 + if(WIN32)
299 + # quiet warnings related to fopen, sscanf
300 +- target_compile_definitions(utils PRIVATE _CRT_SECURE_NO_WARNINGS)
301 ++ target_compile_definitions(sjpeg-utils PRIVATE _CRT_SECURE_NO_WARNINGS)
302 + endif()
303 + if(SJPEG_HAVE_OPENGL)
304 + # check pthread for GL libraries
305 +@@ -139,30 +139,30 @@
306 + list(APPEND SJPEG_DEP_GL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
307 + endif()
308 + endif()
309 +- target_compile_definitions(utils PUBLIC SJPEG_HAVE_OPENGL)
310 ++ target_compile_definitions(sjpeg-utils PUBLIC SJPEG_HAVE_OPENGL)
311 + add_definitions(${OPENGL_DEFINITIONS})
312 + endif()
313 + if(SJPEG_HAVE_GLUT)
314 + add_definitions(${GLUT_DEFINITIONS})
315 + endif()
316 + if(SJPEG_HAVE_JPEG)
317 +- target_compile_definitions(utils PUBLIC SJPEG_HAVE_JPEG)
318 ++ target_compile_definitions(sjpeg-utils PUBLIC SJPEG_HAVE_JPEG)
319 + endif()
320 + if(SJPEG_HAVE_PNG)
321 +- target_compile_definitions(utils PUBLIC SJPEG_HAVE_PNG)
322 ++ target_compile_definitions(sjpeg-utils PUBLIC SJPEG_HAVE_PNG)
323 + endif()
324 + if(SJPEG_DEP_IMG_LIBRARIES)
325 + # check pthread for GL libraries
326 +- target_link_libraries(utils ${SJPEG_DEP_IMG_LIBRARIES}
327 ++ target_link_libraries(sjpeg-utils ${SJPEG_DEP_IMG_LIBRARIES}
328 + ${SJPEG_DEP_GL_LIBRARIES})
329 + endif()
330 +-# set_target_properties(utils PROPERTIES POSITION_INDEPENDENT_CODE ON)
331 ++# set_target_properties(sjpeg-utils PROPERTIES POSITION_INDEPENDENT_CODE ON)
332 +
333 + # Build the executables if asked for.
334 + if(SJPEG_BUILD_EXAMPLES)
335 + # sjpeg
336 + add_executable(sjpeg-bin ${CMAKE_CURRENT_SOURCE_DIR}/examples/sjpeg.cc)
337 +- target_link_libraries(sjpeg-bin sjpeg utils)
338 ++ target_link_libraries(sjpeg-bin sjpeg sjpeg-utils)
339 + set_target_properties(sjpeg-bin PROPERTIES OUTPUT_NAME sjpeg)
340 +
341 + # vjpeg
342 +@@ -187,7 +187,7 @@
343 + elseif(HAVE_GL_GLUT_H)
344 + add_definitions(-DHAVE_GL_GLUT_H)
345 + endif()
346 +- target_link_libraries(vjpeg ${SJPEG_DEP_GL_LIBRARIES} sjpeg utils)
347 ++ target_link_libraries(vjpeg ${SJPEG_DEP_GL_LIBRARIES} sjpeg sjpeg-utils)
348 +
349 + install(TARGETS sjpeg-bin vjpeg RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
350 + endif()
351
352 diff --git a/media-libs/sjpeg/sjpeg-1.0_p20210422.ebuild b/media-libs/sjpeg/sjpeg-1.0_p20210422-r1.ebuild
353 similarity index 91%
354 rename from media-libs/sjpeg/sjpeg-1.0_p20210422.ebuild
355 rename to media-libs/sjpeg/sjpeg-1.0_p20210422-r1.ebuild
356 index 8fa4e90d5..edf31df85 100644
357 --- a/media-libs/sjpeg/sjpeg-1.0_p20210422.ebuild
358 +++ b/media-libs/sjpeg/sjpeg-1.0_p20210422-r1.ebuild
359 @@ -27,6 +27,7 @@ DEPEND="
360 "
361 RDEPEND="${DEPEND}"
362
363 +PATCHES="${FILESDIR}/${PN}-rename-libutils.patch"
364 DOCS=( AUTHORS NEWS README README.md ChangeLog )
365
366 src_configure() {
367 @@ -46,4 +47,5 @@ src_configure() {
368 src_install() {
369 cmake_src_install
370 einstalldocs
371 + dolib.so "${BUILD_DIR}/libsjpeg-utils.so"
372 }