1dnl Copyright (c) 2000-2010, 2014-2017, 2020 Paul Mattes.
2dnl All rights reserved.
3dnl
4dnl Redistribution and use in source and binary forms, with or without
5dnl modification, are permitted provided that the following conditions
6dnl are met:
7dnl     * Redistributions of source code must retain the above copyright
8dnl       notice, this list of conditions and the following disclaimer.
9dnl     * Redistributions in binary form must reproduce the above copyright
10dnl       notice, this list of conditions and the following disclaimer in the
11dnl       documentation and/or other materials provided with the distribution.
12dnl     * Neither the name of Paul Mattes nor his contributors may be used
13dnl       to endorse or promote products derived from this software without
14dnl       specific prior written permission.
15dnl
16dnl THIS SOFTWARE IS PROVIDED BY PAUL MATTES "AS IS" AND ANY EXPRESS
17dnl OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19dnl DISCLAIMED. IN NO EVENT SHALL PAUL MATTES BE LIABLE FOR ANY DIRECT,
20dnl INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21dnl (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24dnl STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25dnl IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26dnl POSSIBILITY OF SUCH DAMAGE.
27
28dnl Process this file with autoconf to produce a configure script.
29AC_INIT(pr3287,4.0)
30AC_PREREQ(2.50)
31
32dnl Checks for programs.
33AC_PROG_INSTALL
34AC_PROG_CC
35
36dnl Figure out what sort of host and compiler this is.
37AC_CANONICAL_HOST
38ansi="-std=c99 -pedantic"
39case "$host_os" in
40*cygwin*)	ansi=""
41		;;
42solaris2*)	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
43		;;
44darwin*)	CCOPTIONS="$CCOPTIONS -no-cpp-precomp -Wno-deprecated-declarations"
45		;;
46linux*)		CPPFLAGS="$CPPFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_SOURCE -D_XOPEN_SOURCE"
47		;;
48esac
49if test "$GCC" = yes
50then	# Add common gcc options, plus flags for dependency generation.
51	CCOPTIONS="$CCOPTIONS -Wall -Wsign-compare $ansi -Wno-variadic-macros -MMD -MP"
52fi
53AC_SUBST(host)
54AC_SUBST(CCOPTIONS)
55
56dnl Check for libraries.
57dnl Note that the order here is important.  The last libraries should appear
58dnl first, so that objects in them can be used by subsequent libraries.
59AC_SEARCH_LIBS(gethostbyname, nsl)
60AC_SEARCH_LIBS(socket, socket)
61
62dnl Checks for header files.
63AC_CHECK_HEADERS(iconv.h)
64
65dnl Check for SSL header file.
66AC_ARG_WITH(ssl,[  --with-ssl=DIR          specify OpenSSL install directory])
67if test "$enable_tls" != no
68then	orig_CPPFLAGS="$CPPFLAGS"
69	unset any
70	for dir in "$with_ssl" /usr/local /usr/local/ssl /usr/lib/ssl /usr/pkg/ssl /usr/ssl /var/ssl /opt/ssl
71	do	header_fail=0
72		if test -n "$dir" -a ! -d "$dir/include"
73		then	header_fail=1
74			continue
75		fi
76		if test -n "$any"
77		then	AC_MSG_NOTICE(retrying with -I$dir/include)
78		fi
79		if test -n "$dir"
80		then	CPPFLAGS="$orig_CPPFLAGS -I$dir/include"
81		fi
82		AC_CHECK_HEADERS(openssl/ssl.h, ,[header_fail=1])
83		if test "$header_fail" -eq 0
84		then	break
85		fi
86		unset `echo ac_cv_header_openssl/ssl_h | $as_tr_sh`
87		CPPFLAGS="$orig_CPPFLAGS"
88		any=1
89	done
90	if test $header_fail -eq 1
91	then	AC_MSG_WARN(Disabling TLS)
92		enable_tls="no"
93		unset HAVE_LIBSSL
94	fi
95fi
96
97dnl Checks for library functions.
98AC_CHECK_FUNCS(vasprintf)
99
100dnl Set up the configuration directory.
101LIBX3270DIR='${sysconfdir}/x3270'
102AC_SUBST(LIBX3270DIR)
103
104dnl Check for unwanted parts.
105AC_ARG_ENABLE(dbcs,[  --disable-dbcs          leave out DBCS support])
106case "$enable_dbcs" in
107no)	;;
108*)	AC_DEFINE(X3270_DBCS,1)
109	;;
110esac
111AC_ARG_ENABLE(ipv6,[  --disable-ipv6          leave out IPv6 support])
112case "$enable_ipv6" in
113""|yes)	AC_DEFINE(X3270_IPV6,1)
114	;;
115esac
116
117dnl Generate conf.h.
118AC_CONFIG_HEADER(conf.h)
119
120dnl Generate the Makefiles.
121AC_CONFIG_FILES(Makefile Makefile.obj)
122AC_OUTPUT
123