1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3#
4# Copyright (C) 2011--2015 Olaf Bergmann <bergmann@tzi.org>
5#
6# Permission is hereby granted, free of charge, to any person
7# obtaining a copy of this software and associated documentation
8# files (the "Software"), to deal in the Software without
9# restriction, including without limitation the rights to use, copy,
10# modify, merge, publish, distribute, sublicense, and/or sell copies
11# of the Software, and to permit persons to whom the Software is
12# furnished to do so, subject to the following conditions:
13#
14# The above copyright notice and this permission notice shall be
15# included in all copies or substantial portions of the Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24# SOFTWARE.
25
26AC_PREREQ([2.65])
27AC_INIT([tinydtls], [0.8.2])
28AC_CONFIG_SRCDIR([dtls.c])
29dnl AC_CONFIG_HEADERS([config.h])
30
31AC_ARG_WITH(contiki,
32  [AS_HELP_STRING([--with-contiki],[build libtinydtls for the Contiki OS])],
33  [AC_DEFINE(WITH_CONTIKI,1,[Define to 1 if building for Contiki.])
34   WITH_CONTIKI=1],
35  [])
36
37AC_PATH_PROG(DOXYGEN, doxygen, [:])
38AC_PATH_PROG(ETAGS, etags, [/bin/false])
39
40if test "${with_contiki}" != "yes" ; then
41# Checks for programs.
42AC_PROG_MAKE_SET
43AC_PROG_CC
44AC_PROG_RANLIB
45
46AC_C_BIGENDIAN
47
48# Checks for libraries.
49AC_SEARCH_LIBS([gethostbyname], [nsl])
50AC_SEARCH_LIBS([socket], [socket])
51fi
52
53AC_ARG_WITH(debug,
54  [AS_HELP_STRING([--without-debug],[disable all debug output and assertions])],
55  [CPPFLAGS="${CPPFLAGS} -DNDEBUG"
56   NDEBUG=1],
57  [])
58
59AC_ARG_WITH(ecc,
60  [AS_HELP_STRING([--without-ecc],[disable support for TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8])],
61  [],
62  [AC_DEFINE(DTLS_ECC, 1, [Define to 1 if building with ECC support.])
63   OPT_OBJS="${OPT_OBJS} ecc/ecc.o"
64   DTLS_ECC=1])
65
66AC_ARG_WITH(psk,
67  [AS_HELP_STRING([--without-psk],[disable support for TLS_PSK_WITH_AES_128_CCM_8])],
68  [],
69  [AC_DEFINE(DTLS_PSK, 1, [Define to 1 if building with PSK support])
70   DTLS_PSK=1])
71
72CPPFLAGS="${CPPFLAGS} -DDTLSv12 -DWITH_SHA256"
73OPT_OBJS="${OPT_OBJS} sha2/sha2.o"
74
75AC_SUBST(OPT_OBJS)
76AC_SUBST(NDEBUG)
77AC_SUBST(WITH_CONTIKI)
78AC_SUBST(DTLS_ECC)
79AC_SUBST(DTLS_PSK)
80
81if test "${with_contiki}" = "yes" ; then
82  AC_MSG_NOTICE([skipping header checks for Contiki])
83else
84  # Checks for header files.
85  AC_CHECK_HEADERS([assert.h arpa/inet.h fcntl.h inttypes.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/param.h sys/socket.h unistd.h])
86
87  AC_CHECK_HEADERS([sys/time.h time.h])
88  AC_CHECK_HEADERS([sys/types.h sys/stat.h])
89
90# Checks for typedefs, structures, and compiler characteristics.
91AC_C_INLINE
92AC_TYPE_SIZE_T
93
94AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
95		[AC_DEFINE(HAVE_SOCKADDR_IN6_SIN6_LEN, [1],
96                  [Define to 1 if struct sockaddr_in6 has a member sin6_len.])], [],
97		[#include <netinet/in.h>])
98
99# Checks for library functions.
100AC_FUNC_MALLOC
101AC_CHECK_FUNCS([memset select socket strdup strerror strnlen fls vprintf])
102fi
103
104AC_CONFIG_HEADERS([dtls_config.h tinydtls.h])
105
106# Adds Contiki-specific definitions to the end of dtls_config.h
107AH_BOTTOM([
108#ifdef WITH_CONTIKI
109#include "platform-specific/platform.h"
110#endif])
111
112AC_CONFIG_FILES([Makefile
113                 doc/Makefile
114                 doc/Doxyfile
115                 tests/Makefile
116                 examples/contiki/Makefile
117                 platform-specific/Makefile
118		 sha2/Makefile
119		 aes/Makefile
120		 ecc/Makefile])
121AC_OUTPUT
122