This fixes the search for posix_spawn() to use AC_SEARCH_LIBS which
is needed for uClibc which puts the function in librt [1].  The fix
is in gnulib commit d6eab2e [2], but we can't just apply that patch
and autoreconf because that means we must depend on autotools.eclass
and this leads to a circular dependency.  So we have to patch
configure directlly.

[1] https://bugs.gentoo.org/show_bug.cgi?id=580688
[2] http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=d6eab2e70fc5ccc82a73e5c988b76a229e4cd3d5
[3] https://bugs.gentoo.org/show_bug.cgi?id=581086

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>

diff -Naur m4-1.4.17.orig/configure m4-1.4.17/configure
--- m4-1.4.17.orig/configure	2013-09-22 06:38:28.000000000 +0000
+++ m4-1.4.17/configure	2016-04-25 22:27:12.774118561 +0000
@@ -808,6 +808,7 @@
 GNULIB_SIGNAL_H_SIGPIPE
 GNULIB_RAISE
 GNULIB_PTHREAD_SIGMASK
+LIB_POSIX_SPAWN
 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN
 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2
 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE
@@ -3590,7 +3591,6 @@
 as_fn_append ac_func_list " mkstemp"
 as_fn_append ac_func_list " nl_langinfo"
 as_fn_append ac_func_list " pipe2"
-as_fn_append ac_func_list " posix_spawn"
 gl_printf_safe=yes
 as_fn_append ac_func_list " isblank"
 as_fn_append ac_func_list " iswctype"
@@ -15877,8 +15881,78 @@
 
 
 
+  LIB_POSIX_SPAWN=
+
+  gl_saved_libs=$LIBS
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing posix_spawn" >&5
+$as_echo_n "checking for library containing posix_spawn... " >&6; }
+if ${ac_cv_search_posix_spawn+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char posix_spawn ();
+int
+main ()
+{
+return posix_spawn ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' rt; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_posix_spawn=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_posix_spawn+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_posix_spawn+:} false; then :
+
+else
+  ac_cv_search_posix_spawn=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_posix_spawn" >&5
+$as_echo "$ac_cv_search_posix_spawn" >&6; }
+ac_res=$ac_cv_search_posix_spawn
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+  test "$ac_cv_search_posix_spawn" = "none required" ||
+                    LIB_POSIX_SPAWN=$ac_cv_search_posix_spawn
+fi
+
+    for ac_func in posix_spawn
+do :
+  ac_fn_c_check_func "$LINENO" "posix_spawn" "ac_cv_func_posix_spawn"
+if test "x$ac_cv_func_posix_spawn" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_POSIX_SPAWN 1
+_ACEOF
 
+fi
+done
 
+  LIBS=$gl_saved_libs
 
   if test $ac_cv_func_posix_spawn != yes; then
     HAVE_POSIX_SPAWN=0
