x_ac_lz4.m4 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ##*****************************************************************************
  2. # AUTHOR:
  3. # Danny Auble <da@schedmd.com>
  4. #
  5. # SYNOPSIS:
  6. # X_AC_LZ4
  7. #
  8. # DESCRIPTION:
  9. # Test if we have liblz4 installed. If found define appropriate ENVs.
  10. #
  11. ##*****************************************************************************
  12. AC_DEFUN([X_AC_LZ4],
  13. #
  14. # Handle user hints
  15. #
  16. [AC_MSG_CHECKING(if lz4 is installed)
  17. lz4_places="/usr/local /usr /opt/local /sw"
  18. AC_ARG_WITH([lz4],
  19. [ --with-lz4=DIR root directory path of lz4 installation @<:@defaults to
  20. /usr/local or /usr if not found in /usr/local@:>@
  21. --without-lz4 to disable lz4 usage completely],
  22. [if test "$withval" != no ; then
  23. AC_MSG_RESULT(yes)
  24. if test -d "$withval"
  25. then
  26. lz4_places="$withval $lz4_places"
  27. else
  28. AC_MSG_WARN([$withval does not exist, checking usual places])
  29. fi
  30. else
  31. lz4_places=
  32. AC_MSG_RESULT(no)
  33. fi],
  34. [AC_MSG_RESULT(yes ${lz4_places})])
  35. #
  36. # Locate lz4, if installed
  37. #
  38. if test -n "${lz4_places}"
  39. then
  40. # check the user supplied or any other more or less 'standard' place:
  41. # Most UNIX systems : /usr/local and /usr
  42. # MacPorts / Fink on OSX : /opt/local respectively /sw
  43. for LZ4_HOME in ${lz4_places} ; do
  44. if test -f "${LZ4_HOME}/include/lz4.h"; then break; fi
  45. LZ4_HOME=""
  46. done
  47. LZ4_OLD_LDFLAGS=$LDFLAGS
  48. LZ4_OLD_CPPFLAGS=$CPPFLAGS
  49. if test -n "${LZ4_HOME}"; then
  50. LZ4_CPPFLAGS="-I${LZ4_HOME}/include"
  51. LZ4_LDFLAGS="-L${LZ4_HOME}/lib"
  52. LZ4_LIBS="-llz4"
  53. LDFLAGS="$LDFLAGS -L${LZ4_LDFLAGS}"
  54. CPPFLAGS="$CPPFLAGS -I${LZ4_CPPFLAGS}"
  55. fi
  56. AC_LANG_SAVE
  57. AC_LANG_C
  58. AC_CHECK_LIB([lz4], [LZ4_compress_destSize], [ac_cv_lz4=yes], [ac_cv_lz4=no])
  59. AC_CHECK_HEADER([lz4.h], [ac_cv_lz4_h=yes], [ac_cv_lz4_h=no])
  60. AC_LANG_RESTORE
  61. # Restore variables
  62. LDFLAGS="$LZ4_OLD_LDFLAGS"
  63. CPPFLAGS="$LZ4_OLD_CPPFLAGS"
  64. if test "$ac_cv_lz4" = "yes" && test "$ac_cv_lz4_h" = "yes"
  65. then
  66. #
  67. # If both library and header were found, action-if-found
  68. #
  69. AC_SUBST(LZ4_CPPFLAGS)
  70. AC_SUBST(LZ4_LDFLAGS)
  71. AC_SUBST(LZ4_LIBS)
  72. AC_DEFINE([HAVE_LZ4], [1],
  73. [Define to 1 if you have 'lz4' library (-llz4)])
  74. AC_MSG_RESULT([LZ4 test program built properly.])
  75. else
  76. AC_MSG_WARN([LZ4 test program build failed.])
  77. fi
  78. else
  79. AC_MSG_WARN([unable to locate LZ4 install.])
  80. fi
  81. ])