0002-cmake-FindLibMagic-cmake-fix-static-linking.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 7fdcabd80c823694d190e5baa8c657ffcae5e777 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Fri, 31 Jan 2020 17:14:11 +0100
  4. Subject: [PATCH] cmake/FindLibMagic.cmake: fix static linking
  5. libmagic can optionally depends on xz (for lzma) or bzip2 since version
  6. 5.38 and
  7. https://github.com/file/file/commit/b259a07ea95827f565faa20f0316e5b2704064f7
  8. so use pkg-config to retrieve those static dependencies and avoid the
  9. following build failure:
  10. [100%] Linking CXX executable gerbera
  11. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: /home/br-user/autobuild/run/instance-0/output-1/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libmagic.a(compress.o): in function `uncompressbuf':
  12. compress.c:(.text+0x69c): undefined reference to `BZ2_bzDecompressInit'
  13. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x710): undefined reference to `BZ2_bzDecompress'
  14. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x730): undefined reference to `BZ2_bzDecompressEnd'
  15. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x7bc): undefined reference to `lzma_auto_decoder'
  16. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x828): undefined reference to `lzma_code'
  17. /home/br-user/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: compress.c:(.text+0x848): undefined reference to `lzma_end'
  18. It should be noted that libmagic.pc is not currently provided in the
  19. official file package (which provides libmagic), an issue has been
  20. opened to add libmagic.pc: https://bugs.astron.com/view.php?id=136
  21. Fixes:
  22. - http://autobuild.buildroot.org/results/37b1ef54dc41100689f311fbc31fc9300dc6ae63
  23. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  24. [Retrieved from:
  25. https://github.com/gerbera/gerbera/commit/7fdcabd80c823694d190e5baa8c657ffcae5e777]
  26. ---
  27. cmake/FindLibMagic.cmake | 15 +++++++++++++--
  28. 1 file changed, 13 insertions(+), 2 deletions(-)
  29. diff --git a/cmake/FindLibMagic.cmake b/cmake/FindLibMagic.cmake
  30. index f68ab923..04995af4 100644
  31. --- a/cmake/FindLibMagic.cmake
  32. +++ b/cmake/FindLibMagic.cmake
  33. @@ -1,11 +1,22 @@
  34. INCLUDE (FindPackageHandleStandardArgs)
  35. -FIND_PATH(MAGIC_INCLUDE_DIR magic.h)
  36. -FIND_LIBRARY(MAGIC_LIBRARIES NAMES magic)
  37. +find_package(PkgConfig QUIET)
  38. +
  39. +pkg_check_modules(PC_MAGIC QUIET libmagic)
  40. +
  41. +FIND_PATH(MAGIC_INCLUDE_DIR magic.h
  42. + HINTS ${PC_MAGIC_INCLUDEDIR} ${PC_MAGIC_INCLUDE_DIRS})
  43. +FIND_LIBRARY(MAGIC_LIBRARIES NAMES magic
  44. + HINTS ${PC_MAGIC_LIBDIR} ${PC_MAGIC_LIBRARY_DIRS})
  45. # handle the QUIETLY and REQUIRED arguments and set MAGIC_FOUND to TRUE
  46. find_package_handle_standard_args(MAGIC DEFAULT_MSG MAGIC_LIBRARIES)
  47. +if (MAGIC_FOUND)
  48. + set (MAGIC_LIBRARIES ${MAGIC_LIBRARY} ${PC_MAGIC_LIBRARIES})
  49. + set (MAGIC_INCLUDE_DIRS ${MAGIC_INCLUDE_DIR} )
  50. +endif ()
  51. +
  52. MARK_AS_ADVANCED(
  53. MAGIC_LIBRARIES
  54. MAGIC_INCLUDE_DIRS )