| 1 |
dnl Checks for libcnotify required headers and functions |
| 2 |
dnl |
| 3 |
dnl Version: 20240513 |
| 4 |
|
| 5 |
dnl Function to detect if libcnotify is available |
| 6 |
dnl ac_libcnotify_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments |
| 7 |
AC_DEFUN([AX_LIBCNOTIFY_CHECK_LIB], |
| 8 |
[AS_IF( |
| 9 |
[test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libcnotify" = xno], |
| 10 |
[ac_cv_libcnotify=no], |
| 11 |
[ac_cv_libcnotify=check |
| 12 |
dnl Check if the directory provided as parameter exists |
| 13 |
dnl For both --with-libcnotify which returns "yes" and --with-libcnotify= which returns "" |
| 14 |
dnl treat them as auto-detection. |
| 15 |
AS_IF( |
| 16 |
[test "x$ac_cv_with_libcnotify" != x && test "x$ac_cv_with_libcnotify" != xauto-detect && test "x$ac_cv_with_libcnotify" != xyes], |
| 17 |
[AX_CHECK_LIB_DIRECTORY_EXISTS([libcnotify])], |
| 18 |
[dnl Check for a pkg-config file |
| 19 |
AS_IF( |
| 20 |
[test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"], |
| 21 |
[PKG_CHECK_MODULES( |
| 22 |
[libcnotify], |
| 23 |
[libcnotify >= 20120425], |
| 24 |
[ac_cv_libcnotify=yes], |
| 25 |
[ac_cv_libcnotify=check]) |
| 26 |
]) |
| 27 |
AS_IF( |
| 28 |
[test "x$ac_cv_libcnotify" = xyes], |
| 29 |
[ac_cv_libcnotify_CPPFLAGS="$pkg_cv_libcnotify_CFLAGS" |
| 30 |
ac_cv_libcnotify_LIBADD="$pkg_cv_libcnotify_LIBS"]) |
| 31 |
]) |
| 32 |
|
| 33 |
AS_IF( |
| 34 |
[test "x$ac_cv_libcnotify" = xcheck], |
| 35 |
[dnl Check for headers |
| 36 |
AC_CHECK_HEADERS([libcnotify.h]) |
| 37 |
|
| 38 |
AS_IF( |
| 39 |
[test "x$ac_cv_header_libcnotify_h" = xno], |
| 40 |
[ac_cv_libcnotify=no], |
| 41 |
[ac_cv_libcnotify=yes |
| 42 |
|
| 43 |
AX_CHECK_LIB_FUNCTIONS( |
| 44 |
[libcnotify], |
| 45 |
[cnotify], |
| 46 |
[[libcnotify_get_version], |
| 47 |
[libcnotify_printf], |
| 48 |
[libcnotify_print_data], |
| 49 |
[libcnotify_print_error_backtrace], |
| 50 |
[libcnotify_stream_set], |
| 51 |
[libcnotify_stream_open], |
| 52 |
[libcnotify_stream_close], |
| 53 |
[libcnotify_verbose_set]]) |
| 54 |
|
| 55 |
ac_cv_libcnotify_LIBADD="-lcnotify"]) |
| 56 |
]) |
| 57 |
|
| 58 |
AX_CHECK_LIB_DIRECTORY_MSG_ON_FAILURE([libcnotify]) |
| 59 |
]) |
| 60 |
|
| 61 |
AS_IF( |
| 62 |
[test "x$ac_cv_libcnotify" = xyes], |
| 63 |
[AC_DEFINE( |
| 64 |
[HAVE_LIBCNOTIFY], |
| 65 |
[1], |
| 66 |
[Define to 1 if you have the `cnotify' library (-lcnotify).]) |
| 67 |
]) |
| 68 |
|
| 69 |
AS_IF( |
| 70 |
[test "x$ac_cv_libcnotify" = xyes], |
| 71 |
[AC_SUBST( |
| 72 |
[HAVE_LIBCNOTIFY], |
| 73 |
[1]) ], |
| 74 |
[AC_SUBST( |
| 75 |
[HAVE_LIBCNOTIFY], |
| 76 |
[0]) |
| 77 |
]) |
| 78 |
]) |
| 79 |
|
| 80 |
dnl Function to detect if libcnotify dependencies are available |
| 81 |
AC_DEFUN([AX_LIBCNOTIFY_CHECK_LOCAL], |
| 82 |
[dnl Headers included in libcnotify/libcnotify_print.c |
| 83 |
AC_CHECK_HEADERS([stdarg.h varargs.h]) |
| 84 |
|
| 85 |
AS_IF( |
| 86 |
[test "x$ac_cv_header_stdarg_h" != xyes && test "x$ac_cv_header_varargs_h" != xyes], |
| 87 |
[AC_MSG_FAILURE( |
| 88 |
[Missing headers: stdarg.h and varargs.h], |
| 89 |
[1]) |
| 90 |
]) |
| 91 |
|
| 92 |
dnl Headers included in libcnotify/libcnotify_stream.c |
| 93 |
AC_CHECK_HEADERS([errno.h]) |
| 94 |
|
| 95 |
ac_cv_libcnotify_CPPFLAGS="-I../libcnotify -I\$(top_srcdir)/libcnotify"; |
| 96 |
ac_cv_libcnotify_LIBADD="../libcnotify/libcnotify.la"; |
| 97 |
|
| 98 |
ac_cv_libcnotify=local |
| 99 |
]) |
| 100 |
|
| 101 |
dnl Function to detect how to enable libcnotify |
| 102 |
AC_DEFUN([AX_LIBCNOTIFY_CHECK_ENABLE], |
| 103 |
[AX_COMMON_ARG_WITH( |
| 104 |
[libcnotify], |
| 105 |
[libcnotify], |
| 106 |
[search for libcnotify in includedir and libdir or in the specified DIR, or no if to use local version], |
| 107 |
[auto-detect], |
| 108 |
[DIR]) |
| 109 |
|
| 110 |
dnl Check for a shared library version |
| 111 |
AX_LIBCNOTIFY_CHECK_LIB |
| 112 |
|
| 113 |
dnl Check if the dependencies for the local library version |
| 114 |
AS_IF( |
| 115 |
[test "x$ac_cv_libcnotify" != xyes], |
| 116 |
[AX_LIBCNOTIFY_CHECK_LOCAL |
| 117 |
|
| 118 |
AC_DEFINE( |
| 119 |
[HAVE_LOCAL_LIBCNOTIFY], |
| 120 |
[1], |
| 121 |
[Define to 1 if the local version of libcnotify is used.]) |
| 122 |
AC_SUBST( |
| 123 |
[HAVE_LOCAL_LIBCNOTIFY], |
| 124 |
[1]) |
| 125 |
]) |
| 126 |
|
| 127 |
AM_CONDITIONAL( |
| 128 |
[HAVE_LOCAL_LIBCNOTIFY], |
| 129 |
[test "x$ac_cv_libcnotify" = xlocal]) |
| 130 |
AS_IF( |
| 131 |
[test "x$ac_cv_libcnotify_CPPFLAGS" != "x"], |
| 132 |
[AC_SUBST( |
| 133 |
[LIBCNOTIFY_CPPFLAGS], |
| 134 |
[$ac_cv_libcnotify_CPPFLAGS]) |
| 135 |
]) |
| 136 |
AS_IF( |
| 137 |
[test "x$ac_cv_libcnotify_LIBADD" != "x"], |
| 138 |
[AC_SUBST( |
| 139 |
[LIBCNOTIFY_LIBADD], |
| 140 |
[$ac_cv_libcnotify_LIBADD]) |
| 141 |
]) |
| 142 |
|
| 143 |
AS_IF( |
| 144 |
[test "x$ac_cv_libcnotify" = xyes], |
| 145 |
[AC_SUBST( |
| 146 |
[ax_libcnotify_pc_libs_private], |
| 147 |
[-lcnotify]) |
| 148 |
]) |
| 149 |
|
| 150 |
AS_IF( |
| 151 |
[test "x$ac_cv_libcnotify" = xyes], |
| 152 |
[AC_SUBST( |
| 153 |
[ax_libcnotify_spec_requires], |
| 154 |
[libcnotify]) |
| 155 |
AC_SUBST( |
| 156 |
[ax_libcnotify_spec_build_requires], |
| 157 |
[libcnotify-devel]) |
| 158 |
]) |
| 159 |
]) |
| 160 |
|