summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2016-06-15 21:40:51 +0200
committerGitHub <noreply@github.com>2016-06-15 21:40:51 +0200
commit201f2813564103cdf4f49e222bff46e15b3b7cea (patch)
tree685122cc528c42eb97bad9e7e42fb9ad7216dda3
parent982dbb104f5d5643f4312d516c4d29989433dc2f (diff)
parent1ae88bec875746ec5b44def0af6e9f2b96d62d2c (diff)
downloadautoconf-archive-201f2813564103cdf4f49e222bff46e15b3b7cea.tar.gz
Merge pull request #81 from olaf-mandel/ax_check_open62541
Add AX_CHECK_OPEN62541_{H,LIB} macros
-rw-r--r--m4/ax_open62541_check_h.m4106
-rw-r--r--m4/ax_open62541_check_lib.m4100
-rw-r--r--m4/ax_open62541_path.m487
3 files changed, 293 insertions, 0 deletions
diff --git a/m4/ax_open62541_check_h.m4 b/m4/ax_open62541_check_h.m4
new file mode 100644
index 0000000..e639530
--- /dev/null
+++ b/m4/ax_open62541_check_h.m4
@@ -0,0 +1,106 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_open62541_check_h.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_OPEN62541_CHECK_H([HEADERS = `...see_below...'], [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+# DESCRIPTION
+#
+# Searches for the header file(s) of the open62541 library [1].
+#
+# The open62541 library is a cmake-based project, that provides its header
+# files in one of two layouts:
+#
+# 1) As individual files, e.g. ua_config.h, ua_server.h, ua_types.h, ...
+# 2) As a single amalgamation file open62541.h
+#
+# The second case is enabled when configuring open62541 with the options
+# "-D UA_ENABLE_AMALGAMATION=true to" cmake, which seems to be preferred.
+# Code using the library can distinguish which layout is used by checking
+# for the macro "UA_NO_AMALGAMATION": if it is defined, the first layout
+# is used.
+#
+# The AX_OPEN62541_CHECK_H macro checks first for the amalgamation and, if
+# that is not found, for the individual headers. It defines
+# "UA_NO_AMALGAMATION" if necessary.
+#
+# The individual headers to check for if no amalgamation is found can be
+# provided as a space-separated list in the first argument. If that is
+# empty, it defaults to all files known to be contained in the
+# amalgamation:
+#
+# * logger_stdout.h
+# * networklayer_tcp.h
+# * ua_client.h
+# * ua_client_highlevel.h
+# * ua_config.h
+# * ua_config_standard.h
+# * ua_connection.h
+# * ua_constants.h
+# * ua_job.h
+# * ua_log.h
+# * ua_nodeids.h
+# * ua_server.h
+# * ua_server_external_ns.h
+# * ua_types.h
+# * ua_types_generated.h
+#
+# If the with_open62541 shell variable is set to "no" (e.g. from running
+# the AX_OPEN62541_PATH macro and the user giving configure the option
+# "--without-open62541"), then expands ACTION-IF-NOT-FOUND without any
+# checks.
+#
+# [1]: <http://open62541.org/>
+#
+# LICENSE
+#
+# Copyright (c) 2016 Olaf Mandel <olaf@mandel.name>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+# AX_OPEN62541_CHECK_H([HEADERS], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------------------
+AC_DEFUN([AX_OPEN62541_CHECK_H],
+[m4_pushdef([headers], m4_normalize([$1]))dnl
+m4_ifblank(m4_defn([headers]), [m4_define([headers],
+ [logger_stdout.h]dnl
+ [networklayer_tcp.h]dnl
+ [ua_client.h]dnl
+ [ua_client_highlevel.h]dnl
+ [ua_config.h]dnl
+ [ua_config_standard.h]dnl
+ [ua_connection.h]dnl
+ [ua_constants.h]dnl
+ [ua_job.h]dnl
+ [ua_log.h]dnl
+ [ua_nodeids.h]dnl
+ [ua_server.h]dnl
+ [ua_server_external_ns.h]dnl
+ [ua_types.h]dnl
+ [ua_types_generated.h])])dnl
+dnl ua_server_external_ns.h depends on ua_server.h but fails to include it:
+dnl so specify the includes:
+pushdef([includes],
+[#ifdef HAVE_UA_SERVER_H
+# include <ua_server.h>
+#endif])dnl
+dnl
+AS_IF([test x${with_open62541:+set} != xset -o "x$with_open62541" != xno],
+ [AC_CHECK_HEADERS([open62541.h], [$2],
+ [AC_CHECK_HEADERS(m4_defn([headers]), [$2]dnl
+[AC_DEFINE([UA_NO_AMALGAMATION], [1],
+ [Use individual open62541 headers instead of the amalgamation.])],
+ [$3],
+ [m4_defn([includes])])],
+ [AC_INCLUDES_DEFAULT])],
+ [$3])
+m4_popdef([headers], [includes])dnl
+])# AX_OPEN62541_CHECK_H
diff --git a/m4/ax_open62541_check_lib.m4 b/m4/ax_open62541_check_lib.m4
new file mode 100644
index 0000000..8d66273
--- /dev/null
+++ b/m4/ax_open62541_check_lib.m4
@@ -0,0 +1,100 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_open62541_check_lib.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_OPEN62541_CHECK_LIB([STATIC-FIRST = `no'], [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+# DESCRIPTION
+#
+# Searches for the library file of the open62541 library [1].
+#
+# The open62541 library is a cmake-based project, that supplies both a
+# shared and a static library (with different names). The
+# AX_OPEN62541_CHECK_LIB macro can search for both and adds the first one
+# found to the LIBS Makefile variable. The search can be in either order
+# (shared first or static first), which is selectable on macro invocation
+# with the STATIC-FIRST parameter. The user can change this default by
+# invoking configure with either the --with-open62541-shared or
+# --with-open62541-static option (the named one is checked first).
+#
+# Either shared or static library can be excluded from checking completely
+# with the options --without-open62541-shared and
+# --without-open62541-static.
+#
+# If the with_open62541 shell variable is set to "no" (e.g. from running
+# the AX_OPEN62541_PATH macro and the user giving configure the option
+# "--without-open62541"), then expands ACTION-IF-NOT-FOUND without any
+# checks. The same is true if both --without-open62541-shared and
+# --without-open62541-static are given.
+#
+# [1]: <http://open62541.org/>
+#
+# LICENSE
+#
+# Copyright (c) 2016 Olaf Mandel <olaf@mandel.name>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+# _AX_OPEN62541_CHECK_LIB_arg(THIS, OTHER)
+# ----------------------------------------
+# Define the option --with-open62541-THIS, including checking that no
+# unknown argument is given or that both --with-open62541-THIS and
+# --with-open62541-OTHER are called.
+m4_define([_AX_OPEN62541_CHECK_LIB_arg],
+[AC_ARG_WITH([open62541-$1],
+ [AS_HELP_STRING([--with-open62541-$1],
+ [search for the $1 open62541 library first])],
+ [], [])dnl
+AS_IF([test x${with_open62541_$1:+set} == xset]dnl
+[ -a "x$with_open62541_$1" != xno -a "x$with_open62541_$1" != xyes],
+ [AC_MSG_FAILURE([--with-open62541-$1 does not take an argument])],
+ [test x${with_open62541_$1:+set} == xset]dnl
+[ -a "x$with_open62541_$1" == xyes -a x${with_open62541_$2:+set} == xset]dnl
+[ -a "x$with_open62541_$2" == xyes],
+ [AC_MSG_FAILURE([--with-open62541-$1 and --with-open62541-$2 are]dnl
+[ mutually exclusive])])
+])# _AX_OPEN62541_CHECK_LIB_arg
+
+# _AX_OPEN62541_CHECK_LIB_1(SHARED-STATIC, ACTION-IF-FOUND,
+# ACTION-IF-NOT-FOUND)
+# ---------------------------------------------------------
+# Checks for the desired library if not forbidden by
+# with_open62541_(shared|static) shell variables.
+m4_define([_AX_OPEN62541_CHECK_LIB_1],
+[m4_pushdef([lib], m4_if([$1], [shared], [open62541],
+ [$1], [static], [open62541-static]))dnl
+AS_IF([test "x$with_open62541_$1" != xno],
+ [AC_CHECK_LIB(m4_defn([lib]), [UA_Server_new], [$2], [$3])],
+ [$3])
+m4_popdef([lib])dnl
+])# _AX_OPEN62541_CHECK_LIB_1
+
+# AX_OPEN62541_CHECK_LIB([STATIC-FIRST], [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------
+AC_DEFUN([AX_OPEN62541_CHECK_LIB],
+[m4_pushdef([staticfirst], m4_normalize([$1]))dnl
+m4_bmatch(m4_defn([staticfirst]),
+ [^\([Nn][Oo]?\|0\)$], [m4_define([staticfirst], [])])dnl
+m4_pushdef([first], m4_ifblank(m4_defn([staticfirst]), [shared], [static]))dnl
+m4_pushdef([secnd], m4_ifblank(m4_defn([staticfirst]), [static], [shared]))dnl
+dnl
+_AX_OPEN62541_CHECK_LIB_arg([shared], [static])dnl
+_AX_OPEN62541_CHECK_LIB_arg([static], [shared])dnl
+AS_IF([test x${with_open62541:+set} == xset -a "x$with_open62541" == xno],
+ [$3],
+ [test "x$with_open62541_]m4_defn([secnd])[" != xyes],
+ [_AX_OPEN62541_CHECK_LIB_1(m4_defn([first]), [$2],
+ [_AX_OPEN62541_CHECK_LIB_1(m4_defn([secnd]), [$2], [$3])])],
+ [_AX_OPEN62541_CHECK_LIB_1(m4_defn([secnd]), [$2],
+ [_AX_OPEN62541_CHECK_LIB_1(m4_defn([first]), [$2], [$3])])])dnl
+m4_popdef([staticfirst], [first], [secnd])dnl
+])# AX_OPEN62541_CHECK_LIB
diff --git a/m4/ax_open62541_path.m4 b/m4/ax_open62541_path.m4
new file mode 100644
index 0000000..43772a2
--- /dev/null
+++ b/m4/ax_open62541_path.m4
@@ -0,0 +1,87 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_open62541_path.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_OPEN62541_PATH()
+#
+# DESCRIPTION
+#
+# Sets pre-processor and linker search paths for the open62541 library
+# [1].
+#
+# The open62541 library is a cmake-based project, that is not always
+# installed to the system: it does not even provide an install target by
+# default. In that case, the location of several directories need to be
+# added to the pre-processor and linker search paths:
+#
+# * -I<src>/include
+# * -I<src>/plugins
+# * -I<build>/src_generated
+# * -I<build>
+# * -L<build>
+#
+# Here "src" indicates the location of the library source directory and
+# "build" the location of the out-of-source build.
+#
+# This macro provides the configure options --with-open62541=dir and
+# --with-open62541-build=dir to set the two directories. This macro will
+# append to CPPFLAGS and LDFLAGS if a dir is supplied.
+#
+# For --with-open62541, the dir is optional: if either the values "no"
+# (from --without-open62541) or "yes" (for no argument) are specified,
+# this macro does nothing but these values may be used by other code. If
+# --with-open62541 is not specified, the variable with_open62541 is not
+# set.
+#
+# For --with-open62541-build, the dir is compulsory.
+# --with-open62541-build must not be given without also specifying
+# --with-open62541. If --with-open62541 is given but
+# --with-open62541-build is not, the default value is "<src>/build".
+#
+# [1]: <http://open62541.org/>
+#
+# LICENSE
+#
+# Copyright (c) 2016 Olaf Mandel <olaf@mandel.name>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+# AX_OPEN62541_PATH()
+# -------------------
+AC_DEFUN([AX_OPEN62541_PATH],
+[AC_ARG_WITH([open62541],
+ [AS_HELP_STRING([--with-open62541@<:@=dir@:>@],
+ [set the open62541 library source location])],
+ [], [])dnl
+AC_ARG_WITH([open62541-build],
+ [AS_HELP_STRING([--with-open62541-build=dir],
+ [set the open62541 build dir location]dnl
+[ (@<:@default=$src/build@:>@)])],
+ [], [])dnl
+[with_open62541=${with_open62541%/}]
+AS_IF([test x${with_open62541_build:+set} != xset],
+ [AS_IF([test x${with_open62541:+set} == xset]dnl
+[ -a "x$with_open62541" != xno -a "x$with_open62541" != xyes],
+ [with_open62541_build=$with_open62541/build])],
+ [test "x$with_open62541_build" == xno]dnl
+[ -o "x$with_open62541_build" == xyes],
+ [AC_MSG_FAILURE([--with-open62541-build needs its argument])],
+ [test x${with_open62541:+set} != xset -o "x$with_open62541" == xyes],
+ [AC_MSG_FAILURE([--with-open62541-build also requires]dnl
+[ --with-open62541 to set a directory])],
+ [with_open62541_build=${with_open62541_build%/}])
+dnl
+AS_IF([test x${with_open62541:+set} == xset -a "x$with_open62541" != xno]dnl
+[ -a "x$with_open62541" != xyes],
+ [CPPFLAGS="$CPPFLAGS${CPPFLAGS:+ }-I$with_open62541/include]dnl
+[ -I$with_open62541/plugins -I$with_open62541_build/src_generated]dnl
+[ -I$with_open62541_build"
+LDFLAGS="$LDFLAGS${LDFLAGS:+ }-L$with_open62541_build"])
+])# AX_OPEN62541_PATH