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