* [PATCH lksctp-tools 02/12] build: add m4 macros to probe for kernel features
@ 2018-05-30 17:17 Marcelo Ricardo Leitner
0 siblings, 0 replies; only message in thread
From: Marcelo Ricardo Leitner @ 2018-05-30 17:17 UTC (permalink / raw)
To: linux-sctp
These macros are to assist on probing kernel features. The main reason
for using them is to have the default includes right and the
AM_CONDITIONALs that can be used to selectively enable (unit tests)
sources.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
m4/.gitignore | 1 +
m4/sctp.m4 | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+)
create mode 100644 m4/sctp.m4
diff --git a/m4/.gitignore b/m4/.gitignore
index 0f4126cd671839a82779a5c522f95ec373eb9a00..1ff72df33a7f7e709bb752a23623266d11c92282 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -1 +1,2 @@
*.m4
+!sctp.m4
diff --git a/m4/sctp.m4 b/m4/sctp.m4
new file mode 100644
index 0000000000000000000000000000000000000000..6593517502b565ee1e02f143c8ad2efdcf7e587d
--- /dev/null
+++ b/m4/sctp.m4
@@ -0,0 +1,63 @@
+# Handy references:
+# https://www.gnu.org/software/autoconf/manual/autoconf.html#Generic-Structures
+# AC_CHECK_MEMBER (aggregate.member, [action-if-found], [action-if-not-found], [includes = 'AC_INCLUDES_DEFAULT'])
+# https://www.gnu.org/software/autoconf/manual/autoconf.html#Generic-Types
+# AC_CHECK_TYPE (type, [action-if-found], [action-if-not-found], [includes = 'AC_INCLUDES_DEFAULT'])
+
+# Macros to assist on probing kernel features
+# Probes if a type is defined
+AC_DEFUN([LKSCTP_CHECK_TYPE], [{
+AC_CHECK_TYPE([$1],
+ AC_DEFINE([$2], 1,
+ [Define if $1 is present.])
+ AM_CONDITIONAL([$2], [true]),
+ AM_CONDITIONAL([$2], [false]),
+ [AC_INCLUDES_DEFAULT
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_LINUX_SCTP_H
+# include <linux/sctp.h>
+#endif
+])}])
+
+# Probes if a struct has a given member
+AC_DEFUN([LKSCTP_CHECK_MEMBER], [{
+AC_CHECK_MEMBER([$1],
+ AC_DEFINE([$2], 1,
+ [Define if $1 is present.])
+ AM_CONDITIONAL([$2], [true]),
+ AM_CONDITIONAL([$2], [false]),
+ [AC_INCLUDES_DEFAULT
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_LINUX_SCTP_H
+# include <linux/sctp.h>
+#endif
+])}])
+
+# Probes if a declaration is present
+AC_DEFUN([LKSCTP_CHECK_DECL], [{
+AC_CHECK_DECL([$1],
+ AC_DEFINE([$2], 1,
+ [Define if $1 is present.])
+ AM_CONDITIONAL([$2], [true]),
+ AM_CONDITIONAL([$2], [false]),
+ [AC_INCLUDES_DEFAULT
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_LINUX_SCTP_H
+# include <linux/sctp.h>
+#endif
+])}])
--
2.14.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-05-30 17:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-30 17:17 [PATCH lksctp-tools 02/12] build: add m4 macros to probe for kernel features Marcelo Ricardo Leitner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).