1dnl Copyright (c) 2000-2009, 2016-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(x3270,4.0)
30AC_PREREQ(2.50)
31AC_CONFIG_HEADER(conf.h)
32
33dnl Checks for programs.
34AC_PROG_INSTALL
35AC_PROG_CC
36
37dnl Compute host-specific flags.
38AC_CANONICAL_HOST
39case "$host_os" in
40solaris2*)	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
41		;;
42darwin*)	CCOPTIONS="$CCOPTIONS -no-cpp-precomp -Wno-deprecated-declarations -Wno-extended-offsetof"
43		;;
44linux*)		CPPFLAGS="$CPPFLAGS -D_POSIX_SOURCE -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE"
45		;;
46esac
47if test "$GCC" = yes
48then	# Add common gcc options, plus flags for dependency generation.
49    	CCOPTIONS="$CCOPTIONS -Wall -Wsign-compare -std=c99 -pedantic -Wno-variadic-macros -MMD -MP"
50fi
51AC_SUBST(host)
52AC_SUBST(CCOPTIONS)
53
54dnl Checks for header files.
55AC_CHECK_HEADERS(sys/select.h)
56AC_CHECK_HEADERS(pty.h)
57AC_CHECK_HEADERS(libutil.h)
58AC_CHECK_HEADERS(util.h)
59AC_CHECK_HEADERS(getopt.h)
60
61dnl Check for X
62AC_PATH_X
63if test "$no_x" = "yes"; then AC_MSG_ERROR('Cannot find X utilities or libraries'); fi
64if test -n "$x_includes"
65then	CPPFLAGS="$CPPFLAGS -I$x_includes"
66fi
67if test -n "$x_libraries"
68then	LDFLAGS="$LDFLAGS -L$x_libraries"
69fi
70
71dnl Check for --enable-app-defaults
72AC_ARG_ENABLE(app-defaults,
73    [  --enable-app-defaults   use a separate app-defaults file],
74    [DEFINE_UAD="#define USE_APP_DEFAULTS 1"; if test "$enable_app_defaults" = "yes"; then UAD_FLAGS="-DCOLOR"; else UAD_FLAGS="$enable_app_defaults"; fi],
75    [DEFINE_UAD=""; UAD_FLAGS="-DCOLOR"; FALLBACKS_O=fallbacks.o])
76AC_SUBST(UAD_FLAGS)
77AC_SUBST(DEFINE_UAD)
78AC_SUBST(FALLBACKS_O)
79
80dnl Check for --with-fontdir=DIR
81AC_ARG_WITH(fontdir,[  --with-fontdir=DIR      install fonts in directory DIR [DIR=misc]])
82case "$with_fontdir" in
83""|yes|no)
84	IFONTDIR='$'"(FONTDIR)/misc"
85	CIFONTDIR='$'"(exec_prefix)/fonts/misc"
86	;;
87/*)
88	IFONTDIR="$with_fontdir"
89	CIFONTDIR="$with_fontdir"
90	;;
91*)
92	IFONTDIR='$'"(FONTDIR)/$with_fontdir"
93	CIFONTDIR='$'"(exec_prefix)/fonts/$with_fontdir"
94	;;
95esac
96AC_SUBST(IFONTDIR)
97AC_SUBST(CIFONTDIR)
98
99# Set up the configuration directory.
100LIBX3270DIR='${sysconfdir}/x3270'
101AC_SUBST(LIBX3270DIR)
102
103dnl Check for other libraries.
104dnl Note that the order here is important.  The last libraries should appear
105dnl first, so that objects in them can be used by subsequent libraries.
106AC_SEARCH_LIBS(forkpty, util)
107AC_CHECK_FUNCS(forkpty)
108AC_SEARCH_LIBS(gethostbyname, nsl_s nsl)
109AC_SEARCH_LIBS(socket, socket)
110AC_CHECK_HEADERS(X11/Shell.h, , AC_MSG_ERROR("Cannot find X11 header files"))
111AC_CHECK_HEADERS(X11/Xmu/Atoms.h, , AC_MSG_ERROR("Cannot find Xmu header files"))
112AC_CHECK_HEADERS(X11/Xaw/Form.h, , AC_MSG_ERROR("Cannot find Xaw header files"))
113AC_SEARCH_LIBS(XFillRectangle, X11, , AC_MSG_ERROR("Cannot find libX11"))
114AC_SEARCH_LIBS(XtVaSetValues, Xt, , AC_MSG_ERROR("Cannot find libXt"))
115AC_SEARCH_LIBS(XmuAddInitializer, Xmu, , AC_MSG_ERROR("Cannot find libXmu"))
116AC_SEARCH_LIBS(XawInitializeWidgetSet, Xaw, , AC_MSG_ERROR("Cannot find libXaw"))
117
118dnl Checks for library functions.
119AC_CHECK_FUNCS(vasprintf)
120AC_FUNC_FSEEKO
121
122dnl Check for xmkmkf or bdftopcf and mkfontdir
123AC_CHECK_PROG(bdftopcf_found,bdftopcf,found,notfound)
124if test "$bdftopcf_found" = "notfound"
125then	AC_MSG_ERROR('Cannot find bdftopcf')
126fi
127AC_CHECK_PROG(mkfontdir_found,mkfontdir,found,notfound)
128if test "$mkfontdir_found" = "notfound"
129then	AC_MSG_ERROR('Cannot find mkfontdir')
130fi
131
132dnl Check for unwanted parts.
133AC_ARG_ENABLE(dbcs,[  --disable-dbcs          leave out DBCS support])
134case "$enable_dbcs" in
135no)	;;
136*)	AC_DEFINE(X3270_DBCS,1)
137	;;
138esac
139AC_ARG_ENABLE(local_process,[  --disable-local-process leave out local process support])
140case "$enable_local_process" in
141""|yes)	AC_DEFINE(X3270_LOCAL_PROCESS,1)
142	;;
143esac
144AC_ARG_ENABLE(ipv6,[  --disable-ipv6          leave out IPv6 support])
145case "$enable_ipv6" in
146""|yes) AC_DEFINE(X3270_IPV6,1)
147	;;
148esac
149
150if test "$x_includes"
151then	XINC=-I$x_includes
152fi
153if test "$x_libraries"
154then	XLIB=-L$x_libraries
155fi
156AC_SUBST(XINC)
157AC_SUBST(XLIB)
158AC_CONFIG_FILES(Makefile Makefile.obj)
159AC_OUTPUT
160