Skip to content

Commit 9daf6dd

Browse files
committed
acinclude.m4: make kernel-specific flags cacheable
Specifically when cross-compiling, one can be willing to force these variable values using the environment of a config.cache file. This commit makes this possible. The affected variables are: * libzmq_cv_sock_cloexec * libzmq_cv_so_keepalive * libzmq_cv_tcp_keepcnt * libzmq_cv_tcp_keepidle * libzmq_cv_tcp_keepintvl * libzmq_cv_tcp_keepalive Signed-off-by: Lionel Orry <[email protected]>
1 parent 8e89d11 commit 9daf6dd

File tree

1 file changed

+48
-36
lines changed

1 file changed

+48
-36
lines changed

acinclude.m4

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ dnl # LIBZMQ_CHECK_SOCK_CLOEXEC([action-if-found], [action-if-not-found])
586586
dnl # Check if SOCK_CLOEXEC is supported #
587587
dnl ################################################################################
588588
AC_DEFUN([LIBZMQ_CHECK_SOCK_CLOEXEC], [{
589-
AC_MSG_CHECKING(whether SOCK_CLOEXEC is supported)
590-
AC_TRY_RUN([/* SOCK_CLOEXEC test */
589+
AC_CACHE_CHECK([whether SOCK_CLOEXEC is supported], [libzmq_cv_sock_cloexec],
590+
[AC_TRY_RUN([/* SOCK_CLOEXEC test */
591591
#include <sys/types.h>
592592
#include <sys/socket.h>
593593
@@ -596,11 +596,13 @@ int main (int argc, char *argv [])
596596
int s = socket (PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
597597
return (s == -1);
598598
}
599-
],
600-
[AC_MSG_RESULT(yes) ; libzmq_cv_sock_cloexec="yes" ; $1],
601-
[AC_MSG_RESULT(no) ; libzmq_cv_sock_cloexec="no" ; $2],
602-
[AC_MSG_RESULT(not during cross-compile) ; libzmq_cv_sock_cloexec="no"]
599+
],
600+
[libzmq_cv_sock_cloexec="yes"],
601+
[libzmq_cv_sock_cloexec="no"],
602+
[libzmq_cv_sock_cloexec="not during cross-compile"]
603+
)]
603604
)
605+
AS_IF([test "x$libzmq_cv_sock_cloexec" = "xyes"], [$1], [$2])
604606
}])
605607

606608
dnl ################################################################################
@@ -628,8 +630,8 @@ dnl # LIBZMQ_CHECK_SO_KEEPALIVE([action-if-found], [action-if-not-found])
628630
dnl # Check if SO_KEEPALIVE is supported #
629631
dnl ################################################################################
630632
AC_DEFUN([LIBZMQ_CHECK_SO_KEEPALIVE], [{
631-
AC_MSG_CHECKING(whether SO_KEEPALIVE is supported)
632-
AC_TRY_RUN([/* SO_KEEPALIVE test */
633+
AC_CACHE_CHECK([whether SO_KEEPALIVE is supported], [libzmq_cv_so_keepalive],
634+
[AC_TRY_RUN([/* SO_KEEPALIVE test */
633635
#include <sys/types.h>
634636
#include <sys/socket.h>
635637
@@ -641,20 +643,22 @@ int main (int argc, char *argv [])
641643
((rc = setsockopt (s, SOL_SOCKET, SO_KEEPALIVE, (char*) &opt, sizeof (int))) == -1)
642644
);
643645
}
644-
],
645-
[AC_MSG_RESULT(yes) ; libzmq_cv_so_keepalive="yes" ; $1],
646-
[AC_MSG_RESULT(no) ; libzmq_cv_so_keepalive="no" ; $2],
647-
[AC_MSG_RESULT(not during cross-compile) ; libzmq_cv_so_keepalive="no"]
646+
],
647+
[libzmq_cv_so_keepalive="yes"],
648+
[libzmq_cv_so_keepalive="no"],
649+
[libzmq_cv_so_keepalive="not during cross-compile"]
650+
)]
648651
)
652+
AS_IF([test "x$libzmq_cv_so_keepalive" = "xyes"], [$1], [$2])
649653
}])
650654

651655
dnl ################################################################################
652656
dnl # LIBZMQ_CHECK_TCP_KEEPCNT([action-if-found], [action-if-not-found]) #
653657
dnl # Check if TCP_KEEPCNT is supported #
654658
dnl ################################################################################
655659
AC_DEFUN([LIBZMQ_CHECK_TCP_KEEPCNT], [{
656-
AC_MSG_CHECKING(whether TCP_KEEPCNT is supported)
657-
AC_TRY_RUN([/* TCP_KEEPCNT test */
660+
AC_CACHE_CHECK([whether TCP_KEEPCNT is supported], [libzmq_cv_tcp_keepcnt],
661+
[AC_TRY_RUN([/* TCP_KEEPCNT test */
658662
#include <sys/types.h>
659663
#include <sys/socket.h>
660664
#include <netinet/in.h>
@@ -669,20 +673,22 @@ int main (int argc, char *argv [])
669673
((rc = setsockopt (s, IPPROTO_TCP, TCP_KEEPCNT, (char*) &opt, sizeof (int))) == -1)
670674
);
671675
}
672-
],
673-
[AC_MSG_RESULT(yes) ; libzmq_cv_tcp_keepcnt="yes" ; $1],
674-
[AC_MSG_RESULT(no) ; libzmq_cv_tcp_keepcnt="no" ; $2],
675-
[AC_MSG_RESULT(not during cross-compile) ; libzmq_cv_tcp_keepcnt="no"]
676+
],
677+
[libzmq_cv_tcp_keepcnt="yes"],
678+
[libzmq_cv_tcp_keepcnt="no"],
679+
[libzmq_cv_tcp_keepcnt="not during cross-compile"]
680+
)]
676681
)
682+
AS_IF([test "x$libzmq_cv_tcp_keepcnt" = "xyes"], [$1], [$2])
677683
}])
678684

679685
dnl ################################################################################
680686
dnl # LIBZMQ_CHECK_TCP_KEEPIDLE([action-if-found], [action-if-not-found]) #
681687
dnl # Check if TCP_KEEPIDLE is supported #
682688
dnl ################################################################################
683689
AC_DEFUN([LIBZMQ_CHECK_TCP_KEEPIDLE], [{
684-
AC_MSG_CHECKING(whether TCP_KEEPIDLE is supported)
685-
AC_TRY_RUN([/* TCP_KEEPIDLE test */
690+
AC_CACHE_CHECK([whether TCP_KEEPIDLE is supported], [libzmq_cv_tcp_keepidle],
691+
[AC_TRY_RUN([/* TCP_KEEPIDLE test */
686692
#include <sys/types.h>
687693
#include <sys/socket.h>
688694
#include <netinet/in.h>
@@ -697,20 +703,22 @@ int main (int argc, char *argv [])
697703
((rc = setsockopt (s, IPPROTO_TCP, TCP_KEEPIDLE, (char*) &opt, sizeof (int))) == -1)
698704
);
699705
}
700-
],
701-
[AC_MSG_RESULT(yes) ; libzmq_cv_tcp_keepidle="yes" ; $1],
702-
[AC_MSG_RESULT(no) ; libzmq_cv_tcp_keepidle="no" ; $2],
703-
[AC_MSG_RESULT(not during cross-compile) ; libzmq_cv_tcp_keepidle="no"]
706+
],
707+
[libzmq_cv_tcp_keepidle="yes"],
708+
[libzmq_cv_tcp_keepidle="no"],
709+
[libzmq_cv_tcp_keepidle="not during cross-compile"]
710+
)]
704711
)
712+
AS_IF([test "x$libzmq_cv_tcp_keepidle" = "xyes"], [$1], [$2])
705713
}])
706714

707715
dnl ################################################################################
708716
dnl # LIBZMQ_CHECK_TCP_KEEPINTVL([action-if-found], [action-if-not-found]) #
709717
dnl # Check if TCP_KEEPINTVL is supported #
710718
dnl ################################################################################
711719
AC_DEFUN([LIBZMQ_CHECK_TCP_KEEPINTVL], [{
712-
AC_MSG_CHECKING(whether TCP_KEEPINTVL is supported)
713-
AC_TRY_RUN([/* TCP_KEEPINTVL test */
720+
AC_CACHE_CHECK([whether TCP_KEEPINTVL is supported], [libzmq_cv_tcp_keepintvl],
721+
[AC_TRY_RUN([/* TCP_KEEPINTVL test */
714722
#include <sys/types.h>
715723
#include <sys/socket.h>
716724
#include <netinet/in.h>
@@ -725,20 +733,22 @@ int main (int argc, char *argv [])
725733
((rc = setsockopt (s, IPPROTO_TCP, TCP_KEEPINTVL, (char*) &opt, sizeof (int))) == -1)
726734
);
727735
}
728-
],
729-
[AC_MSG_RESULT(yes) ; libzmq_cv_tcp_keepintvl="yes" ; $1],
730-
[AC_MSG_RESULT(no) ; libzmq_cv_tcp_keepintvl="no" ; $2],
731-
[AC_MSG_RESULT(not during cross-compile) ; libzmq_cv_tcp_keepintvl="no"]
736+
],
737+
[libzmq_cv_tcp_keepintvl="yes"],
738+
[libzmq_cv_tcp_keepintvl="no"],
739+
[libzmq_cv_tcp_keepintvl="not during cross-compile"]
740+
)]
732741
)
742+
AS_IF([test "x$libzmq_cv_tcp_keepintvl" = "xyes"], [$1], [$2])
733743
}])
734744

735745
dnl ################################################################################
736746
dnl # LIBZMQ_CHECK_TCP_KEEPALIVE([action-if-found], [action-if-not-found]) #
737747
dnl # Check if TCP_KEEPALIVE is supported #
738748
dnl ################################################################################
739749
AC_DEFUN([LIBZMQ_CHECK_TCP_KEEPALIVE], [{
740-
AC_MSG_CHECKING(whether TCP_KEEPALIVE is supported)
741-
AC_TRY_RUN([/* TCP_KEEPALIVE test */
750+
AC_CACHE_CHECK([whether TCP_KEEPALIVE is supported], [libzmq_cv_tcp_keepalive],
751+
[AC_TRY_RUN([/* TCP_KEEPALIVE test */
742752
#include <sys/types.h>
743753
#include <sys/socket.h>
744754
#include <netinet/in.h>
@@ -753,11 +763,13 @@ int main (int argc, char *argv [])
753763
((rc = setsockopt (s, IPPROTO_TCP, TCP_KEEPALIVE, (char*) &opt, sizeof (int))) == -1)
754764
);
755765
}
756-
],
757-
[AC_MSG_RESULT(yes) ; libzmq_cv_tcp_keepalive="yes" ; $1],
758-
[AC_MSG_RESULT(no) ; libzmq_cv_tcp_keepalive="no" ; $2],
759-
[AC_MSG_RESULT(not during cross-compile) ; libzmq_cv_tcp_keepalive="no"]
766+
],
767+
[libzmq_cv_tcp_keepalive="yes"],
768+
[libzmq_cv_tcp_keepalive="no"],
769+
[libzmq_cv_tcp_keepalive="not during cross-compile"]
770+
)]
760771
)
772+
AS_IF([test "x$libzmq_cv_tcp_keepalive" = "xyes"], [$1], [$2])
761773
}])
762774

763775
dnl ################################################################################

0 commit comments

Comments
 (0)