1bdf0f55dSmrg#
20568f49bSmrg#  Copyright © 2019 Thomas Dickey
3bdf0f55dSmrg#  Copyright © 2003 Keith Packard, Noah Levitt
4bdf0f55dSmrg#
5bdf0f55dSmrg#  Permission to use, copy, modify, distribute, and sell this software and its
6bdf0f55dSmrg#  documentation for any purpose is hereby granted without fee, provided that
7bdf0f55dSmrg#  the above copyright notice appear in all copies and that both that
8bdf0f55dSmrg#  copyright notice and this permission notice appear in supporting
9bdf0f55dSmrg#  documentation, and that the name of Keith Packard not be used in
10bdf0f55dSmrg#  advertising or publicity pertaining to distribution of the software without
11bdf0f55dSmrg#  specific, written prior permission.  Keith Packard makes no
12bdf0f55dSmrg#  representations about the suitability of this software for any purpose.  It
13bdf0f55dSmrg#  is provided "as is" without express or implied warranty.
14bdf0f55dSmrg#
15bdf0f55dSmrg#  KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16bdf0f55dSmrg#  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17bdf0f55dSmrg#  EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18bdf0f55dSmrg#  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19bdf0f55dSmrg#  DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20bdf0f55dSmrg#  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21bdf0f55dSmrg#  PERFORMANCE OF THIS SOFTWARE.
22bdf0f55dSmrg#
23bdf0f55dSmrg
24bdf0f55dSmrg# Initialize Autoconf
25fdf6a26fSmrgAC_PREREQ([2.70])
2635525df4SmrgAC_INIT([libXt], [1.3.1],
27fdf6a26fSmrg	[https://gitlab.freedesktop.org/xorg/lib/libxt/-/issues/], [libXt])
28bdf0f55dSmrgAC_CONFIG_SRCDIR([Makefile.am])
29bdf0f55dSmrgAC_CONFIG_HEADERS([config.h])
30249c3046SmrgAC_CONFIG_MACRO_DIR([m4])
31bdf0f55dSmrg
32fdf6a26fSmrg# Set common system defines for POSIX extensions, such as _GNU_SOURCE
33fdf6a26fSmrg# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL)
34fdf6a26fSmrg# to avoid autoconf errors.
35fdf6a26fSmrgAC_USE_SYSTEM_EXTENSIONS
36fdf6a26fSmrg
37bdf0f55dSmrg# Initialize Automake
38fdf6a26fSmrgAM_INIT_AUTOMAKE([foreign dist-xz])
39444c061aSmrg
40bdf0f55dSmrg# Initialize libtool
41fdf6a26fSmrgLT_INIT
42bdf0f55dSmrg
43fdf6a26fSmrg# Require X.Org macros 1.16 or later for XORG_MEMORY_CHECK_FLAGS
441477040fSmrgm4_ifndef([XORG_MACROS_VERSION],
45fdf6a26fSmrg	  [m4_fatal([must install xorg-macros 1.16 or later before running autoconf/autogen])])
46fdf6a26fSmrgXORG_MACROS_VERSION(1.16)
471477040fSmrgXORG_DEFAULT_OPTIONS
48bdf0f55dSmrgXORG_CHECK_MALLOC_ZERO
499e7bcd65SmrgXORG_ENABLE_SPECS
509e7bcd65SmrgXORG_WITH_XMLTO(0.0.20)
519e7bcd65SmrgXORG_WITH_FOP
529e7bcd65SmrgXORG_WITH_XSLTPROC
539e7bcd65SmrgXORG_CHECK_SGML_DOCTOOLS(1.01)
549e7bcd65SmrgXORG_PROG_RAWCPP
559e7bcd65SmrgXORG_WITH_PERL
569e7bcd65Smrg
57444c061aSmrg
58bdf0f55dSmrg# Checks for header files.
59bdf0f55dSmrgAC_CHECK_HEADER([alloca.h], AC_DEFINE(INCLUDE_ALLOCA_H, 1, [Define to 1 if Xalloca.h should include <alloca.h>]))
60bdf0f55dSmrg
61fdf6a26fSmrg# Checks for library functions.
62fdf6a26fSmrgAC_CHECK_FUNCS([reallocarray])
63fdf6a26fSmrg
64fdf6a26fSmrg# Obtain compiler/linker options for dependencies
65bdf0f55dSmrgPKG_CHECK_MODULES(XT, sm ice x11 xproto kbproto)
662265a131Smrg
67bdf0f55dSmrg# Set-up variables to use build machine compiler when cross-compiling
682265a131Smrgif test x"$CC_FOR_BUILD" = x; then
692265a131Smrg	if test x"$cross_compiling" = xyes; then
702265a131Smrg		AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
712265a131Smrg	else
720568f49bSmrg		CC_FOR_BUILD="$CC"
732265a131Smrg	fi
742265a131Smrgfi
750568f49bSmrgif test x"$cross_compiling" != xyes; then
760568f49bSmrg       : ${CFLAGS_FOR_BUILD=${CFLAGS}}
770568f49bSmrg       : ${LDFLAGS_FOR_BUILD=${LDFLAGS}}
780568f49bSmrgfi
792265a131SmrgAC_SUBST([CC_FOR_BUILD])
80339a7c43SmrgDEFAULT_CPPFLAGS_FOR_BUILD="${CPPFLAGS}"
81339a7c43SmrgAC_CHECK_FUNC(asprintf,
82339a7c43Smrg  [DEFAULT_CPPFLAGS_FOR_BUILD="${DEFAULT_CPPFLAGS_FOR_BUILD} -DHAVE_ASPRINTF -D_GNU_SOURCE"])
83339a7c43SmrgCPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${DEFAULT_CPPFLAGS_FOR_BUILD}}
84339a7c43SmrgAC_SUBST(CPPFLAGS_FOR_BUILD)
85339a7c43SmrgDEFAULT_CFLAGS_FOR_BUILD="${CFLAGS} ${CWARNFLAGS}"
862ae83157SmrgAC_SUBST(CFLAGS_FOR_BUILD)
872ae83157SmrgAC_SUBST(LDFLAGS_FOR_BUILD)
88444c061aSmrg
89444c061aSmrg# Map function checks to old Imake #defines
902265a131Smrgcase $host_os in
91bdf0f55dSmrg	# darwin through Snow Leopard has poll() but can't be used to poll character devices.
92bdf0f55dSmrg	darwin@<:@789@:>@*|darwin10*) ;;
93bdf0f55dSmrg	darwin*)
94bdf0f55dSmrg		_ac_xorg_macosx_version_min=""
95bdf0f55dSmrg		if echo $CPPFLAGS $CFLAGS | grep -q mmacosx-version-min ; then
96bdf0f55dSmrg			_ac_xorg_macosx_version_min=`echo $CPPFLAGS $CFLAGS | sed 's/^.*-mmacosx-version-min=\(@<:@^ @:>@*\).*$/\1/'`
97bdf0f55dSmrg		else
98bdf0f55dSmrg			_ac_xorg_macosx_version_min=$MACOSX_DEPLOYMENT_TARGET
99bdf0f55dSmrg		fi
100bdf0f55dSmrg		case $_ac_xorg_macosx_version_min in
101bdf0f55dSmrg			10.@<:@0123456@:>@|10.@<:@0123456@:>@.*) ;;
102bdf0f55dSmrg			*)
103bdf0f55dSmrg				AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
104bdf0f55dSmrg			;;
105bdf0f55dSmrg		esac
106bdf0f55dSmrg		unset _ac_xorg_macosx_version_min
107bdf0f55dSmrg		;;
1082265a131Smrg	*)
109bdf0f55dSmrg		AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
1102265a131Smrg	;;
1112265a131Smrgesac
1122265a131Smrg
1139e7bcd65Smrg# Link with winsock if mingw target
1149e7bcd65Smrgcase $host_os in
1159e7bcd65Smrg	*mingw*)
116fdf6a26fSmrg		AC_CHECK_LIB([ws2_32],[main])
1179e7bcd65Smrg	;;
1189e7bcd65Smrg	*)
1199e7bcd65Smrg	;;
1209e7bcd65Smrgesac
121444c061aSmrg
122444c061aSmrg# Options
1230568f49bSmrgAC_MSG_CHECKING(if XKB support is wanted)
124bdf0f55dSmrgAC_ARG_ENABLE(xkb, AS_HELP_STRING([--disable-xkb], [Disable XKB support]),
125444c061aSmrg	XKB="$enableval", XKB="yes")
1260568f49bSmrgAC_MSG_RESULT($XKB)
127444c061aSmrgif test "x$XKB" = "xyes" ; then
128444c061aSmrg	AC_DEFINE(XKB, 1, [Define to 1 to use XKB for keysym resolution.])
129444c061aSmrgfi
130444c061aSmrg
1310568f49bSmrgAC_MSG_CHECKING(if C const-support is wanted)
1320568f49bSmrgAC_ARG_ENABLE(const, AS_HELP_STRING([--disable-const], [Disable const-support]),
1330568f49bSmrg	USE_CONST="$enableval", USE_CONST="yes")
1340568f49bSmrgAC_MSG_RESULT($USE_CONST)
1350568f49bSmrgif test "x$USE_CONST" = "xyes" ; then
1360568f49bSmrg	AC_DEFINE(_CONST_X_STRING, 1, [Define to 1 to use standard C const feature.])
1370568f49bSmrgfi
1380568f49bSmrg
1390568f49bSmrgAC_MSG_CHECKING(if geo-tattler traces are wanted)
1400568f49bSmrgAC_ARG_ENABLE(geo-tattler, AS_HELP_STRING([--enable-geo-tattler], [Enable geo-tattler traces]),
1410568f49bSmrg	GEO_TATTLER="$enableval", GEO_TATTLER="no")
1420568f49bSmrgAC_MSG_RESULT($GEO_TATTLER)
1430568f49bSmrgif test "x$GEO_TATTLER" = "xyes" ; then
1440568f49bSmrg	AC_DEFINE(XT_GEO_TATTLER, 1, [Define to 1 to enable geo-tattler traces.])
1450568f49bSmrgfi
1460568f49bSmrg
1479e7bcd65Smrg# --enable-unit-tests
1489e7bcd65SmrgXORG_ENABLE_UNIT_TESTS
149fdf6a26fSmrgXORG_WITH_GLIB([2.40])
150fdf6a26fSmrgXORG_MEMORY_CHECK_FLAGS
151fdf6a26fSmrgif test "x$enable_unit_tests" != "xno" ; then
152fdf6a26fSmrg	AC_CHECK_FUNCS([malloc_usable_size])
153fdf6a26fSmrg	AC_CHECK_HEADERS([malloc.h])
154fdf6a26fSmrgfi
1559e7bcd65Smrg
156444c061aSmrg# Replaces XFileSearchPathDefault from Imake configs
157444c061aSmrgXFILESEARCHPATHDEFAULT='$(sysconfdir)/X11/%L/%T/%N%C%S:$(sysconfdir)/X11/%l/%T/%N%C%S:$(sysconfdir)/X11/%T/%N%C%S:$(sysconfdir)/X11/%L/%T/%N%S:$(sysconfdir)/X11/%l/%T/%N%S:$(sysconfdir)/X11/%T/%N%S:$(datadir)/X11/%L/%T/%N%C%S:$(datadir)/X11/%l/%T/%N%C%S:$(datadir)/X11/%T/%N%C%S:$(datadir)/X11/%L/%T/%N%S:$(datadir)/X11/%l/%T/%N%S:$(datadir)/X11/%T/%N%S:$(libdir)/X11/%L/%T/%N%C%S:$(libdir)/X11/%l/%T/%N%C%S:$(libdir)/X11/%T/%N%C%S:$(libdir)/X11/%L/%T/%N%S:$(libdir)/X11/%l/%T/%N%S:$(libdir)/X11/%T/%N%S'
158444c061aSmrg
1590568f49bSmrgAC_MSG_CHECKING(for X files search path)
160444c061aSmrgAC_ARG_WITH(xfile-search-path,
161bdf0f55dSmrg	AS_HELP_STRING([--with-xfile-search-path=<path>],
162444c061aSmrg		       [Set path to search for app-defaults and other files]),
163444c061aSmrg	[XFILESEARCHPATHDEFAULT="$withval"], [])
1640568f49bSmrgAC_MSG_RESULT(${XFILESEARCHPATHDEFAULT:-none})
165444c061aSmrgAC_SUBST([XFILESEARCHPATHDEFAULT])
166444c061aSmrg
1670568f49bSmrgAC_MSG_CHECKING(for X app-defaults directory)
168444c061aSmrgAC_ARG_WITH(appdefaultdir,
169bdf0f55dSmrg	AS_HELP_STRING([--with-appdefaultdir=<path>],
170444c061aSmrg		       [Set app-default directory (default: ${datadir}/X11/app-defaults)]),
171444c061aSmrg	[appdefaultdir="$withval"],
172444c061aSmrg	[appdefaultdir=${datadir}/X11/app-defaults])
1730568f49bSmrgAC_MSG_RESULT($appdefaultdir)
1742ae83157SmrgAX_DEFINE_DIR([appdefaultdir], [appdefaultdir], [app default data directory])
175444c061aSmrg
176444c061aSmrg# Replacement for Imake ToolkitStringsABIOptions, controls string tables
177444c061aSmrg# generated by util/string.list in StringDefs.h & Shell.h
1780568f49bSmrgAC_MSG_CHECKING(for ABI options)
179444c061aSmrgcase $host_os in
180444c061aSmrg	solaris*)
1812265a131Smrg		# Solaris uses -intelabi even on SPARC
1820568f49bSmrg		STRINGSABIOPTIONS="-intelabi -solarisabinames"
183444c061aSmrg		;;
184444c061aSmrg	sco* | svr4*)
185444c061aSmrg		case $host_cpu in
186444c061aSmrg		    i*86) STRINGSABIOPTIONS="-intelabi" ;;
187444c061aSmrg		       *) STRINGSABIOPTIONS="" ;;
188444c061aSmrg		esac
189444c061aSmrg		;;
190444c061aSmrgesac
1910568f49bSmrgAC_MSG_RESULT(${STRINGSABIOPTIONS:-none})
192444c061aSmrgAC_SUBST(STRINGSABIOPTIONS)
193444c061aSmrg
1949e7bcd65SmrgERRORDBDIR=${datadir}/X11
1959e7bcd65SmrgAC_SUBST(ERRORDBDIR)
1969e7bcd65Smrg
197bdf0f55dSmrgAC_CONFIG_FILES([Makefile
198bdf0f55dSmrg		src/Makefile
199bdf0f55dSmrg		util/Makefile
200bdf0f55dSmrg		include/Makefile
201bdf0f55dSmrg		man/Makefile
202bdf0f55dSmrg		specs/Makefile
2030568f49bSmrg		specs/libXt.ent
2049e7bcd65Smrg		test/Makefile
205bdf0f55dSmrg		xt.pc])
206bdf0f55dSmrgAC_OUTPUT
207