configure.ac revision 339a7c43
1#
2#  Copyright © 2003 Keith Packard, Noah Levitt
3#
4#  Permission to use, copy, modify, distribute, and sell this software and its
5#  documentation for any purpose is hereby granted without fee, provided that
6#  the above copyright notice appear in all copies and that both that
7#  copyright notice and this permission notice appear in supporting
8#  documentation, and that the name of Keith Packard not be used in
9#  advertising or publicity pertaining to distribution of the software without
10#  specific, written prior permission.  Keith Packard makes no
11#  representations about the suitability of this software for any purpose.  It
12#  is provided "as is" without express or implied warranty.
13#
14#  KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15#  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16#  EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17#  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18#  DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19#  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20#  PERFORMANCE OF THIS SOFTWARE.
21#
22
23# Initialize Autoconf
24AC_PREREQ([2.60])
25AC_INIT([libXt], [1.1.5],
26        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXt])
27AC_CONFIG_SRCDIR([Makefile.am])
28AC_CONFIG_HEADERS([config.h])
29AC_CONFIG_MACRO_DIR([m4])
30
31# Initialize Automake
32AM_INIT_AUTOMAKE([foreign dist-bzip2])
33
34# Initialize libtool
35AC_PROG_LIBTOOL
36
37# Require X.Org macros 1.13 or later for XORG_ENABLE_UNIT_TESTS
38m4_ifndef([XORG_MACROS_VERSION],
39          [m4_fatal([must install xorg-macros 1.13 or later before running autoconf/autogen])])
40XORG_MACROS_VERSION(1.13)
41XORG_DEFAULT_OPTIONS
42XORG_CHECK_MALLOC_ZERO
43XORG_ENABLE_SPECS
44XORG_WITH_XMLTO(0.0.20)
45XORG_WITH_FOP
46XORG_WITH_XSLTPROC
47XORG_CHECK_SGML_DOCTOOLS(1.01)
48XORG_PROG_RAWCPP
49XORG_WITH_PERL
50
51
52# Checks for header files.
53AC_CHECK_HEADER([alloca.h], AC_DEFINE(INCLUDE_ALLOCA_H, 1, [Define to 1 if Xalloca.h should include <alloca.h>]))
54
55# Obtain compiler/linker options for depedencies
56PKG_CHECK_MODULES(XT, sm ice x11 xproto kbproto)
57
58# Set-up variables to use build machine compiler when cross-compiling
59if test x"$CC_FOR_BUILD" = x; then
60	if test x"$cross_compiling" = xyes; then
61		AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
62	else
63	        CC_FOR_BUILD="$CC"
64	fi
65fi
66AC_SUBST([CC_FOR_BUILD])
67DEFAULT_CPPFLAGS_FOR_BUILD="${CPPFLAGS}"
68AC_CHECK_FUNC(asprintf,
69  [DEFAULT_CPPFLAGS_FOR_BUILD="${DEFAULT_CPPFLAGS_FOR_BUILD} -DHAVE_ASPRINTF -D_GNU_SOURCE"])
70CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${DEFAULT_CPPFLAGS_FOR_BUILD}}
71AC_SUBST(CPPFLAGS_FOR_BUILD)
72DEFAULT_CFLAGS_FOR_BUILD="${CFLAGS} ${CWARNFLAGS}"
73CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${DEFAULT_CFLAGS_FOR_BUILD}}
74AC_SUBST(CFLAGS_FOR_BUILD)
75LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}}
76AC_SUBST(LDFLAGS_FOR_BUILD)
77
78# Map function checks to old Imake #defines
79case $host_os in
80	# darwin through Snow Leopard has poll() but can't be used to poll character devices.
81	darwin@<:@789@:>@*|darwin10*) ;;
82	darwin*)
83		_ac_xorg_macosx_version_min=""
84		if echo $CPPFLAGS $CFLAGS | grep -q mmacosx-version-min ; then
85			_ac_xorg_macosx_version_min=`echo $CPPFLAGS $CFLAGS | sed 's/^.*-mmacosx-version-min=\(@<:@^ @:>@*\).*$/\1/'`
86		else
87			_ac_xorg_macosx_version_min=$MACOSX_DEPLOYMENT_TARGET
88		fi
89		case $_ac_xorg_macosx_version_min in
90			10.@<:@0123456@:>@|10.@<:@0123456@:>@.*) ;;
91			*)
92				AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
93			;;
94		esac
95		unset _ac_xorg_macosx_version_min
96		;;
97	*)
98		AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
99	;;
100esac
101
102# Link with winsock if mingw target
103case $host_os in
104	*mingw*)
105		AC_HAVE_LIBRARY(ws2_32)
106	;;
107	*)
108	;;
109esac
110
111# Options
112AC_ARG_ENABLE(xkb, AS_HELP_STRING([--disable-xkb], [Disable XKB support]),
113	XKB="$enableval", XKB="yes")
114if test "x$XKB" = "xyes" ; then
115	AC_DEFINE(XKB, 1, [Define to 1 to use XKB for keysym resolution.])
116fi
117
118# --enable-unit-tests
119XORG_ENABLE_UNIT_TESTS
120XORG_WITH_GLIB([2.16])
121
122# Memory checking support
123case $host_os in
124     solaris*)
125        AC_CHECK_LIB([umem], [umem_alloc],
126            [MALLOC_DEBUG_ENV='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
127        ;;
128     *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
129        # both directly and inverted, so should not be 0 or 255.
130        MALLOC_DEBUG_ENV='MALLOC_PERTURB_=15'
131        ;;
132     *bsd*|darwin*)
133        MALLOC_DEBUG_ENV='MallocPreScribble=1 MallocScribble=1'
134        ;;
135esac
136AC_SUBST([MALLOC_DEBUG_ENV])
137
138# Replaces XFileSearchPathDefault from Imake configs
139XFILESEARCHPATHDEFAULT='$(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'
140
141AC_ARG_WITH(xfile-search-path,
142	AS_HELP_STRING([--with-xfile-search-path=<path>],
143		       [Set path to search for app-defaults and other files]),
144	[XFILESEARCHPATHDEFAULT="$withval"], [])
145AC_SUBST([XFILESEARCHPATHDEFAULT])
146
147AC_ARG_WITH(appdefaultdir,
148	AS_HELP_STRING([--with-appdefaultdir=<path>],
149		       [Set app-default directory (default: ${datadir}/X11/app-defaults)]),
150	[appdefaultdir="$withval"],
151	[appdefaultdir=${datadir}/X11/app-defaults])
152AX_DEFINE_DIR([appdefaultdir], [appdefaultdir], [app default data directory])
153
154# Replacement for Imake ToolkitStringsABIOptions, controls string tables
155# generated by util/string.list in StringDefs.h & Shell.h
156case $host_os in
157	solaris*)
158		# Solaris uses -intelabi even on SPARC
159  		STRINGSABIOPTIONS="-intelabi -solarisabinames"
160		;;
161	sco* | svr4*)
162		case $host_cpu in
163		    i*86) STRINGSABIOPTIONS="-intelabi" ;;
164		       *) STRINGSABIOPTIONS="" ;;
165		esac
166		;;
167esac
168AC_SUBST(STRINGSABIOPTIONS)
169
170ERRORDBDIR=${datadir}/X11
171AC_SUBST(ERRORDBDIR)
172
173case $host_os in
174    darwin*)
175        OS_CFLAGS="-Wl,-flat_namespace"
176	;;
177    *)
178        OS_CFLAGS=
179        ;;
180esac
181
182XT_CFLAGS="$XT_CFLAGS $OS_CFLAGS"
183
184AC_CONFIG_FILES([Makefile
185		src/Makefile
186		util/Makefile
187		include/Makefile
188		man/Makefile
189		specs/Makefile
190		test/Makefile
191		xt.pc])
192AC_OUTPUT
193