Code

configure.ac: repair the getmouse() check
authorMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 09:51:25 +0000 (10:51 +0100)
committerMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 09:51:25 +0000 (10:51 +0100)
Was broken by commit b73fd31ce0dc27d8

configure.ac
m4/mpd_with_flags.m4 [new file with mode: 0644]

index 2a78958598272c5e0c1dac6d9c585c647768b07a..6273a09ed0a6b0ab52d39e75d9226996ddd83b28 100644 (file)
@@ -227,11 +227,10 @@ AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$enable_help_screen = xyes)
 
 dnl Optional - curses getmouse support
 
-dnl AC_CHECK_LIB depends on being able to prepend a '-l', remove the '-l' from CURSES_LIB first
-AC_CHECK_LIB([$(expr substr $CURSES_LIB 3 99)],
-               [getmouse],
+MPD_WITH_LIBRARY([CURSES],
+       [AC_CHECK_FUNC([getmouse],
                [ax_cv_curses_mouse=yes],
-               [ax_cv_curses_mouse=no])
+               [ax_cv_curses_mouse=no])])
 
 AC_ARG_ENABLE([mouse], 
        AS_HELP_STRING([--enable-mouse],
diff --git a/m4/mpd_with_flags.m4 b/m4/mpd_with_flags.m4
new file mode 100644 (file)
index 0000000..4f82b79
--- /dev/null
@@ -0,0 +1,23 @@
+dnl Run code with the specified CFLAGS/CXXFLAGS and LIBS appended.
+dnl Restores the old values afterwards.
+dnl
+dnl Parameters: cflags, libs, code
+AC_DEFUN([MPD_WITH_FLAGS], [
+       ac_save_CFLAGS="$[]CFLAGS"
+       ac_save_CXXFLAGS="$[]CXXFLAGS"
+       ac_save_LIBS="$[]LIBS"
+       CFLAGS="$[]CFLAGS $1"
+       CXXFLAGS="$[]CXXFLAGS $1"
+       LIBS="$[]LIBS $2"
+       $3
+       CFLAGS="$[]ac_save_CFLAGS"
+       CXXFLAGS="$[]ac_save_CXXFLAGS"
+       LIBS="$[]ac_save_LIBS"
+])
+
+dnl Run code with the specified library's CFLAGS/CXXFLAGS and LIBS
+dnl appended.  Restores the old values afterwards.
+dnl
+dnl Parameters: libname, code
+AC_DEFUN([MPD_WITH_LIBRARY],
+       [MPD_WITH_FLAGS([$[]$1_CFLAGS], [$[]$1_LIBS], [$2])])