configure.ac revision f7c72b42efb8d42859023659fd2e3d589523436d
1AC_PREREQ([2.64])
2AC_INIT([HarfBuzz],
3        [0.9.19],
4        [http://bugs.freedesktop.org/enter_bug.cgi?product=harfbuzz],
5        [harfbuzz],
6        [http://harfbuzz.org/])
7
8AC_CONFIG_MACRO_DIR([m4])
9AC_CONFIG_SRCDIR([src/harfbuzz.pc.in])
10AC_CONFIG_HEADERS([config.h])
11
12AM_INIT_AUTOMAKE([1.11.1 gnits dist-bzip2 no-dist-gzip -Wall no-define color-tests -Wno-portability])
13AM_SILENT_RULES([yes])
14
15# Initialize libtool
16m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
17LT_PREREQ([2.2])
18LT_INIT([disable-static])
19
20# Check for programs
21AC_PROG_CC
22AM_PROG_CC_C_O
23AC_PROG_CXX
24PKG_PROG_PKG_CONFIG([0.20])
25
26# Version
27m4_define(hb_version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
28m4_define(hb_version_major,m4_argn(1,hb_version_triplet))
29m4_define(hb_version_minor,m4_argn(2,hb_version_triplet))
30m4_define(hb_version_micro,m4_argn(3,hb_version_triplet))
31HB_VERSION_MAJOR=hb_version_major
32HB_VERSION_MINOR=hb_version_minor
33HB_VERSION_MICRO=hb_version_micro
34HB_VERSION=AC_PACKAGE_VERSION
35AC_SUBST(HB_VERSION_MAJOR)
36AC_SUBST(HB_VERSION_MINOR)
37AC_SUBST(HB_VERSION_MICRO)
38AC_SUBST(HB_VERSION)
39
40# Libtool version
41m4_define([hb_version_int],
42	  m4_eval(hb_version_major*10000 + hb_version_minor*100 + hb_version_micro))
43m4_if(m4_eval(hb_version_minor % 2), [1],
44      dnl for unstable releases
45      [m4_define([hb_libtool_revision], 0)],
46      dnl for stable releases
47      [m4_define([hb_libtool_revision], hb_version_micro)])
48m4_define([hb_libtool_age],
49	  m4_eval(hb_version_int - hb_libtool_revision))
50m4_define([hb_libtool_current],
51	  m4_eval(hb_version_major + hb_libtool_age))
52HB_LIBTOOL_VERSION_INFO=hb_libtool_current:hb_libtool_revision:hb_libtool_age
53AC_SUBST(HB_LIBTOOL_VERSION_INFO)
54
55dnl GOBJECT_INTROSPECTION_CHECK([0.9.0])
56GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
57
58# Functions and headers
59AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty)
60AC_CHECK_HEADERS(unistd.h sys/mman.h)
61
62# Compiler flags
63AC_CANONICAL_HOST
64if test "x$GCC" = "xyes"; then
65
66	# Make symbols link locally
67	LDFLAGS="$LDFLAGS -Bsymbolic-functions"
68
69	# Make sure we don't link to libstdc++
70	CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions"
71
72	# Assorted warnings
73	CXXFLAGS="$CXXFLAGS -Wcast-align"
74
75	case "$host" in
76		*-*-mingw*)
77		;;
78		*)
79			# Hide inline methods
80			CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
81		;;
82	esac
83
84	case "$host" in
85		arm-*-*)
86			# Request byte alignment on arm
87			CXXFLAGS="$CXXFLAGS -mstructure-size-boundary=8"
88		;;
89	esac
90fi
91
92AM_CONDITIONAL(HAVE_GCC, test "x$GCC" = "xyes")
93
94hb_os_win32=no
95AC_MSG_CHECKING([for native Win32])
96case "$host" in
97  *-*-mingw*)
98    hb_os_win32=yes
99    ;;
100esac
101AC_MSG_RESULT([$hb_os_win32])
102AM_CONDITIONAL(OS_WIN32, test "$hb_os_win32" = "yes")
103
104have_pthread=false
105if test "$hb_os_win32" = no; then
106	AX_PTHREAD([have_pthread=true])
107fi
108if $have_pthread; then
109	AC_DEFINE(HAVE_PTHREAD, 1, [Have POSIX threads])
110fi
111AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread)
112
113dnl ==========================================================================
114
115have_ot=true
116if $have_ot; then
117	AC_DEFINE(HAVE_OT, 1, [Have native OpenType Layout backend])
118fi
119AM_CONDITIONAL(HAVE_OT, $have_ot)
120
121dnl ===========================================================================
122
123have_hb_old=false
124if $have_hb_old; then
125	AC_DEFINE(HAVE_HB_OLD, 1, [Have Old HarfBuzz backend])
126fi
127AM_CONDITIONAL(HAVE_HB_OLD, $have_hb_old)
128
129dnl ===========================================================================
130
131AC_ARG_WITH(glib,
132	[AS_HELP_STRING([--with-glib=@<:@yes/no/auto@:>@],
133			[Use glib @<:@default=auto@:>@])],,
134	[with_glib=auto])
135have_glib=false
136if test "x$with_glib" = "xyes" -o "x$with_glib" = "xauto"; then
137	PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, have_glib=true, :)
138fi
139if test "x$with_glib" = "xyes" -a "x$have_glib" != "xtrue"; then
140	AC_MSG_ERROR([glib support requested but glib-2.0 not found])
141fi
142if $have_glib; then
143	AC_DEFINE(HAVE_GLIB, 1, [Have glib2 library])
144fi
145AM_CONDITIONAL(HAVE_GLIB, $have_glib)
146
147have_gobject=false
148if $have_glib; then
149	PKG_CHECK_MODULES(GOBJECT, gobject-2.0 glib-2.0 >= 2.16, have_gobject=true, :)
150fi
151if $have_gobject; then
152	AC_DEFINE(HAVE_GOBJECT, 1, [Have gobject2 library])
153	GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
154	AC_SUBST(GLIB_MKENUMS)
155fi
156AM_CONDITIONAL(HAVE_GOBJECT, $have_gobject)
157
158dnl ===========================================================================
159
160have_ucdn=true
161if $have_glib; then
162	have_ucdn=false
163fi
164if $have_ucdn; then
165	AC_DEFINE(HAVE_UCDN, 1, [Have UCDN Unicode functions])
166fi
167AM_CONDITIONAL(HAVE_UCDN, $have_ucdn)
168
169dnl ==========================================================================
170
171AC_ARG_WITH(cairo,
172	[AS_HELP_STRING([--with-cairo=@<:@yes/no/auto@:>@],
173			[Use cairo @<:@default=auto@:>@])],,
174	[with_cairo=auto])
175have_cairo=false
176if test "x$with_cairo" = "xyes" -o "x$with_cairo" = "xauto"; then
177	PKG_CHECK_MODULES(CAIRO, cairo >= 1.8.0, have_cairo=true, :)
178fi
179if test "x$with_cairo" = "xyes" -a "x$have_cairo" != "xtrue"; then
180	AC_MSG_ERROR([cairo support requested but not found])
181fi
182if $have_cairo; then
183	AC_DEFINE(HAVE_CAIRO, 1, [Have cairo graphics library])
184fi
185AM_CONDITIONAL(HAVE_CAIRO, $have_cairo)
186
187have_cairo_ft=false
188if $have_cairo; then
189	PKG_CHECK_MODULES(CAIRO_FT, cairo-ft, have_cairo_ft=true, :)
190fi
191if $have_cairo_ft; then
192	AC_DEFINE(HAVE_CAIRO_FT, 1, [Have cairo-ft support in cairo graphics library])
193fi
194AM_CONDITIONAL(HAVE_CAIRO_FT, $have_cairo_ft)
195
196dnl ==========================================================================
197
198AC_ARG_WITH(icu,
199	[AS_HELP_STRING([--with-icu=@<:@yes/no/auto@:>@],
200			[Use ICU @<:@default=auto@:>@])],,
201	[with_icu=auto])
202have_icu=false
203if test "x$with_icu" = "xyes" -o "x$with_icu" = "xauto"; then
204	PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, :)
205
206	dnl Fallback to icu-config if ICU pkg-config files could not be found
207	if test "$have_icu" != "true"; then
208		AC_CHECK_TOOL(ICU_CONFIG, icu-config, no)
209		AC_MSG_CHECKING([for ICU by using icu-config fallback])
210		if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; then
211			have_icu=true
212			# We don't use --cflags as this gives us a lot of things that we don't
213			# necessarily want, like debugging and optimization flags
214			# See man (1) icu-config for more info.
215			ICU_CFLAGS=`$ICU_CONFIG --cppflags`
216			ICU_LIBS=`$ICU_CONFIG --ldflags-searchpath --ldflags-libsonly`
217			AC_SUBST(ICU_CFLAGS)
218			AC_SUBST(ICU_LIBS)
219			AC_MSG_RESULT([yes])
220		else
221			AC_MSG_RESULT([no])
222		fi
223	fi
224fi
225if test "x$with_icu" = "xyes" -a "x$have_icu" != "xtrue"; then
226	AC_MSG_ERROR([icu support requested but icu-uc not found])
227fi
228if $have_icu; then
229	CXXFLAGS="$CXXFLAGS `$PKG_CONFIG --variable=CXXFLAGS icu-uc`"
230	AC_DEFINE(HAVE_ICU, 1, [Have ICU library])
231fi
232AM_CONDITIONAL(HAVE_ICU, $have_icu)
233
234dnl ==========================================================================
235
236have_icu_le=false
237dnl PKG_CHECK_MODULES(ICU_LE, icu-le icu-uc, have_icu_le=true, :)
238if $have_icu_le; then
239	AC_DEFINE(HAVE_ICU_LE, 1, [Have ICU Layout Engine library])
240fi
241AM_CONDITIONAL(HAVE_ICU_LE, $have_icu_le)
242
243dnl ==========================================================================
244
245AC_ARG_WITH(graphite2,
246	[AS_HELP_STRING([--with-graphite2=@<:@yes/no/auto@:>@],
247			[Use the graphite2 library @<:@default=no@:>@])],,
248	[with_graphite2=no])
249have_graphite2=false
250if test "x$with_graphite2" = "xyes" -o "x$with_graphite2" = "xauto"; then
251	PKG_CHECK_MODULES(GRAPHITE2, graphite2, have_graphite2=true, :)
252fi
253if test "x$with_graphite2" = "xyes" -a "x$have_graphite2" != "xtrue"; then
254	AC_MSG_ERROR([graphite2 support requested but libgraphite2 not found])
255fi
256if $have_graphite2; then
257    AC_DEFINE(HAVE_GRAPHITE2, 1, [Have Graphite2 library])
258fi
259AM_CONDITIONAL(HAVE_GRAPHITE2, $have_graphite2)
260
261dnl ==========================================================================
262
263AC_ARG_WITH(freetype,
264	[AS_HELP_STRING([--with-freetype=@<:@yes/no/auto@:>@],
265			[Use the FreeType library @<:@default=auto@:>@])],,
266	[with_freetype=auto])
267have_freetype=false
268if test "x$with_freetype" = "xyes" -o "x$with_freetype" = "xauto"; then
269	PKG_CHECK_MODULES(FREETYPE, freetype2 >= 2.3.8, have_freetype=true, :)
270fi
271if test "x$with_freetype" = "xyes" -a "x$have_freetype" != "xtrue"; then
272	AC_MSG_ERROR([FreeType support requested but libfreetype2 not found])
273fi
274if $have_freetype; then
275	AC_DEFINE(HAVE_FREETYPE, 1, [Have FreeType 2 library])
276	_save_libs="$LIBS"
277	_save_cflags="$CFLAGS"
278	LIBS="$LIBS $FREETYPE_LIBS"
279	CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
280	AC_CHECK_FUNCS(FT_Face_GetCharVariantIndex)
281	LIBS="$_save_libs"
282	CFLAGS="$_save_cflags"
283fi
284AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype)
285
286dnl ===========================================================================
287
288AC_ARG_WITH(uniscribe,
289	[AS_HELP_STRING([--with-uniscribe=@<:@yes/no/auto@:>@],
290			[Use the Uniscribe library @<:@default=no@:>@])],,
291	[with_uniscribe=no])
292have_uniscribe=false
293if test "x$with_uniscribe" = "xyes" -o "x$with_uniscribe" = "xauto"; then
294	AC_CHECK_HEADERS(usp10.h windows.h, have_uniscribe=true)
295fi
296if test "x$with_uniscribe" = "xyes" -a "x$have_uniscribe" != "xtrue"; then
297	AC_MSG_ERROR([uniscribe support requested but not found])
298fi
299if $have_uniscribe; then
300	UNISCRIBE_CFLAGS=
301	UNISCRIBE_LIBS="-lusp10 -lgdi32 -lrpcrt4"
302	AC_SUBST(UNISCRIBE_CFLAGS)
303	AC_SUBST(UNISCRIBE_LIBS)
304	AC_DEFINE(HAVE_UNISCRIBE, 1, [Have Uniscribe library])
305fi
306AM_CONDITIONAL(HAVE_UNISCRIBE, $have_uniscribe)
307
308dnl ===========================================================================
309
310AC_ARG_WITH(coretext,
311	[AS_HELP_STRING([--with-coretext=@<:@yes/no/auto@:>@],
312			[Use CoreText @<:@default=no@:>@])],,
313	[with_coretext=no])
314have_coretext=false
315if test "x$with_coretext" = "xyes" -o "x$with_coretext" = "xauto"; then
316	AC_CHECK_TYPE(CTFontRef, have_coretext=true,, [#include <ApplicationServices/ApplicationServices.h>])
317fi
318if test "x$with_coretext" = "xyes" -a "x$have_coretext" != "xtrue"; then
319	AC_MSG_ERROR([CoreText support requested but libcoretext not found])
320fi
321if $have_coretext; then
322	CORETEXT_CFLAGS=
323	CORETEXT_LIBS="-framework ApplicationServices"
324	AC_SUBST(CORETEXT_CFLAGS)
325	AC_SUBST(CORETEXT_LIBS)
326	AC_DEFINE(HAVE_CORETEXT, 1, [Have Core Text backend])
327fi
328AM_CONDITIONAL(HAVE_CORETEXT, $have_coretext)
329
330dnl ===========================================================================
331
332AC_CACHE_CHECK([for Intel atomic primitives], hb_cv_have_intel_atomic_primitives, [
333	hb_cv_have_intel_atomic_primitives=false
334	AC_TRY_LINK([
335		void memory_barrier (void) { __sync_synchronize (); }
336		int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
337		int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
338		void mutex_unlock (int *m) { __sync_lock_release (m); }
339		], [], hb_cv_have_intel_atomic_primitives=true
340	)
341])
342if $hb_cv_have_intel_atomic_primitives; then
343	AC_DEFINE(HAVE_INTEL_ATOMIC_PRIMITIVES, 1, [Have Intel __sync_* atomic primitives])
344fi
345
346dnl ===========================================================================
347
348AC_CACHE_CHECK([for Solaris atomic operations], hb_cv_have_solaris_atomic_ops, [
349	hb_cv_have_solaris_atomic_ops=false
350	AC_TRY_LINK([
351		#include <atomic.h>
352		/* This requires Solaris Studio 12.2 or newer: */
353		#include <mbarrier.h>
354		void memory_barrier (void) { __machine_rw_barrier (); }
355		int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); }
356		void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); }
357		], [], hb_cv_have_solaris_atomic_ops=true
358	)
359])
360if $hb_cv_have_solaris_atomic_ops; then
361	AC_DEFINE(HAVE_SOLARIS_ATOMIC_OPS, 1, [Have Solaris __machine_*_barrier and atomic_* operations])
362fi
363
364if test "$os_win32" = no && ! $have_pthread; then
365	AC_CHECK_HEADERS(sched.h)
366	AC_SEARCH_LIBS(sched_yield,rt,AC_DEFINE(HAVE_SCHED_YIELD, 1, [Have sched_yield]))
367fi
368
369dnl ===========================================================================
370
371AC_CONFIG_FILES([
372Makefile
373src/Makefile
374src/hb-version.h
375src/hb-icu-le/Makefile
376src/hb-old/Makefile
377src/hb-ucdn/Makefile
378util/Makefile
379test/Makefile
380test/api/Makefile
381test/shaping/Makefile
382docs/Makefile
383docs/reference/Makefile
384])
385
386AC_OUTPUT
387
388AC_MSG_NOTICE([
389
390Build configuration:
391
392Unicode callbacks (you want at least one):
393	Glib:			${have_glib}
394	ICU:			${have_icu}
395	UCDN:			${have_ucdn}
396
397Font callbacks (the more the better):
398	FreeType:		${have_freetype}
399
400Tools used for command-line utilities:
401	Cairo:			${have_cairo}
402
403Additional shapers (the more the better):
404	Graphite2:		${have_graphite2}
405
406Test / platform shapers (not normally needed):
407	CoreText:		${have_coretext}
408	ICU Layout Engine:	${have_icu_le}
409	Old HarfBuzz:		${have_hb_old}
410	Uniscribe:		${have_uniscribe}
411
412Documentation:
413	Referece docs:		${enable_gtk_doc}
414])
415