build: Prefer AC_CHECK_TYPE() over AC_LINK_IFELSE().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 5 Aug 2017 16:01:41 +0000 (18:01 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 12 Aug 2017 17:22:02 +0000 (19:22 +0200)
Both invocations of AC_LINK_IFELSE() check if a C structure is
defined. We don't need to run the linker for that, saving a few cycles
on Linux systems where both structures are defined.

configure.ac

index 811364b19b4aded3c0d5f090ef16094e8a5162ea..b6aac81b98973f384fff3deafb5be36eac05fa88 100644 (file)
@@ -163,17 +163,12 @@ AC_DEFINE_UNQUOTED(ICONV_CAST, $cast, [cast for second arg to iconv()])
 AC_MSG_RESULT($msg)
 UNSTASH_FLAGS
 ########################################################################### ucred
-AC_MSG_CHECKING(for struct ucred)
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+AC_CHECK_TYPE([struct ucred], [
+       AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
+], [], [
        #include <sys/types.h>
        #include <sys/socket.h>
-]], [[
-       struct ucred sucred; sucred.pid=0;
-]])],[have_ucred=yes],[have_ucred=no])
-AC_MSG_RESULT($have_ucred)
-if test ${have_ucred} = yes; then
-       AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
-fi
+])
 ########################################################################### curses
 STASH_FLAGS
 LIB_ARG_WITH([curses], [])
@@ -184,18 +179,12 @@ curses_ldflags="$curses_ldflags $LIBS"
 LIB_SUBST_FLAGS(curses)
 UNSTASH_FLAGS
 ########################################################################### ip_mreqn
-AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast))
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+AC_CHECK_TYPE([struct ip_mreqn], [
+       AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 if you have struct ip_mreqn)
+], [], [
        #include <netdb.h>
        #include <net/if.h>
-]], [[
-       struct ip_mreqn mn;
-       mn.imr_ifindex = 0;
-]])],[have_ip_mreqn=yes],[have_ip_mreqn=no])
-AC_MSG_RESULT($have_ip_mreqn)
-if test ${have_ip_mreqn} = yes; then
-       AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 if you have struct ip_mreqn)
-fi
+])
 ########################################################################### ogg
 STASH_FLAGS
 LIB_ARG_WITH([ogg], [-logg])