• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1AC_PREREQ([2.64])
2AC_INIT([HarfBuzz],
3        [1.4.2],
4        [https://github.com/behdad/harfbuzz/issues/new],
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 tar-ustar dist-bzip2 no-dist-gzip -Wall no-define color-tests -Wno-portability])
13AM_CONDITIONAL(AUTOMAKE_OLDER_THAN_1_13, test $am__api_version = 1.11 -o $am__api_version = 1.12)
14AM_SILENT_RULES([yes])
15
16# Initialize libtool
17m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
18LT_PREREQ([2.2])
19LT_INIT([disable-static])
20
21# Check for programs
22AC_USE_SYSTEM_EXTENSIONS
23AC_PROG_CC
24AM_PROG_CC_C_O
25AC_PROG_CXX
26AC_SYS_LARGEFILE
27PKG_PROG_PKG_CONFIG([0.20])
28AM_MISSING_PROG([RAGEL], [ragel])
29AM_MISSING_PROG([GIT], [git])
30
31# Version
32m4_define(hb_version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
33m4_define(hb_version_major,m4_argn(1,hb_version_triplet))
34m4_define(hb_version_minor,m4_argn(2,hb_version_triplet))
35m4_define(hb_version_micro,m4_argn(3,hb_version_triplet))
36HB_VERSION_MAJOR=hb_version_major
37HB_VERSION_MINOR=hb_version_minor
38HB_VERSION_MICRO=hb_version_micro
39HB_VERSION=AC_PACKAGE_VERSION
40AC_SUBST(HB_VERSION_MAJOR)
41AC_SUBST(HB_VERSION_MINOR)
42AC_SUBST(HB_VERSION_MICRO)
43AC_SUBST(HB_VERSION)
44
45# Libtool version
46m4_define([hb_version_int],
47	  m4_eval(hb_version_major*10000 + hb_version_minor*100 + hb_version_micro))
48m4_if(m4_eval(hb_version_minor % 2), [1],
49      dnl for unstable releases
50      [m4_define([hb_libtool_revision], 0)],
51      dnl for stable releases
52      [m4_define([hb_libtool_revision], hb_version_micro)])
53m4_define([hb_libtool_age],
54	  m4_eval(hb_version_int - hb_libtool_revision))
55m4_define([hb_libtool_current],
56	  m4_eval(hb_libtool_age))
57HB_LIBTOOL_VERSION_INFO=hb_libtool_current:hb_libtool_revision:hb_libtool_age
58AC_SUBST(HB_LIBTOOL_VERSION_INFO)
59
60# Documentation
61have_gtk_doc=false
62m4_ifdef([GTK_DOC_CHECK], [
63GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
64	if test "x$enable_gtk_doc" = xyes; then
65		have_gtk_doc=true
66	fi
67], [
68	AM_CONDITIONAL([ENABLE_GTK_DOC], false)
69])
70
71# Functions and headers
72AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty)
73AC_CHECK_HEADERS(unistd.h sys/mman.h)
74
75# Compiler flags
76AC_CANONICAL_HOST
77AC_CHECK_ALIGNOF([struct{char;}])
78if test "x$GCC" = "xyes"; then
79
80	# Make symbols link locally
81	LDFLAGS="$LDFLAGS -Bsymbolic-functions"
82
83	# Make sure we don't link to libstdc++
84	CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions"
85
86	# Assorted warnings
87	CXXFLAGS="$CXXFLAGS -Wcast-align"
88
89	case "$host" in
90		*-*-mingw*)
91		;;
92		*)
93			# Hide inline methods
94			CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
95		;;
96	esac
97
98	case "$host" in
99		arm-*-*)
100			if test "x$ac_cv_alignof_struct_char__" != x1; then
101				# Request byte alignment
102				CXXFLAGS="$CXXFLAGS -mstructure-size-boundary=8"
103			fi
104		;;
105	esac
106fi
107
108AM_CONDITIONAL(HAVE_GCC, test "x$GCC" = "xyes")
109
110hb_os_win32=no
111AC_MSG_CHECKING([for native Win32])
112case "$host" in
113  *-*-mingw*)
114    hb_os_win32=yes
115    ;;
116esac
117AC_MSG_RESULT([$hb_os_win32])
118AM_CONDITIONAL(OS_WIN32, test "$hb_os_win32" = "yes")
119
120have_pthread=false
121if test "$hb_os_win32" = no; then
122	AX_PTHREAD([have_pthread=true])
123fi
124if $have_pthread; then
125	AC_DEFINE(HAVE_PTHREAD, 1, [Have POSIX threads])
126fi
127AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread)
128
129dnl ==========================================================================
130
131have_ot=true
132if $have_ot; then
133	AC_DEFINE(HAVE_OT, 1, [Have native OpenType Layout backend])
134fi
135AM_CONDITIONAL(HAVE_OT, $have_ot)
136
137have_fallback=true
138if $have_fallback; then
139	AC_DEFINE(HAVE_FALLBACK, 1, [Have simple TrueType Layout backend])
140fi
141AM_CONDITIONAL(HAVE_FALLBACK, $have_fallback)
142
143dnl ===========================================================================
144
145AC_ARG_WITH(glib,
146	[AS_HELP_STRING([--with-glib=@<:@yes/no/auto@:>@],
147			[Use glib @<:@default=auto@:>@])],,
148	[with_glib=auto])
149have_glib=false
150GLIB_DEPS="glib-2.0 >= 2.19.1"
151AC_SUBST(GLIB_DEPS)
152if test "x$with_glib" = "xyes" -o "x$with_glib" = "xauto"; then
153	PKG_CHECK_MODULES(GLIB, $GLIB_DEPS, have_glib=true, :)
154fi
155if test "x$with_glib" = "xyes" -a "x$have_glib" != "xtrue"; then
156	AC_MSG_ERROR([glib support requested but glib-2.0 not found])
157fi
158if $have_glib; then
159	AC_DEFINE(HAVE_GLIB, 1, [Have glib2 library])
160fi
161AM_CONDITIONAL(HAVE_GLIB, $have_glib)
162
163dnl ===========================================================================
164
165AC_ARG_WITH(gobject,
166	[AS_HELP_STRING([--with-gobject=@<:@yes/no/auto@:>@],
167			[Use gobject @<:@default=auto@:>@])],,
168	[with_gobject=no])
169have_gobject=false
170if test "x$with_gobject" = "xyes" -o "x$with_gobject" = "xauto"; then
171	PKG_CHECK_MODULES(GOBJECT, gobject-2.0 glib-2.0, have_gobject=true, :)
172fi
173if test "x$with_gobject" = "xyes" -a "x$have_gobject" != "xtrue"; then
174	AC_MSG_ERROR([gobject support requested but gobject-2.0 / glib-2.0 not found])
175fi
176if $have_gobject; then
177	AC_DEFINE(HAVE_GOBJECT, 1, [Have gobject2 library])
178	GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
179	AC_SUBST(GLIB_MKENUMS)
180fi
181AM_CONDITIONAL(HAVE_GOBJECT, $have_gobject)
182
183dnl ===========================================================================
184
185
186dnl ===========================================================================
187# Gobject-Introspection
188have_introspection=false
189m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [
190	if $have_gobject; then
191		GOBJECT_INTROSPECTION_CHECK([1.34.0])
192		if test "x$found_introspection" = xyes; then
193			have_introspection=true
194		fi
195	else
196		AM_CONDITIONAL([HAVE_INTROSPECTION], false)
197	fi
198], [
199	AM_CONDITIONAL([HAVE_INTROSPECTION], false)
200])
201
202dnl ==========================================================================
203
204AC_ARG_WITH(cairo,
205	[AS_HELP_STRING([--with-cairo=@<:@yes/no/auto@:>@],
206			[Use cairo @<:@default=auto@:>@])],,
207	[with_cairo=auto])
208have_cairo=false
209if test "x$with_cairo" = "xyes" -o "x$with_cairo" = "xauto"; then
210	PKG_CHECK_MODULES(CAIRO, cairo >= 1.8.0, have_cairo=true, :)
211fi
212if test "x$with_cairo" = "xyes" -a "x$have_cairo" != "xtrue"; then
213	AC_MSG_ERROR([cairo support requested but not found])
214fi
215if $have_cairo; then
216	AC_DEFINE(HAVE_CAIRO, 1, [Have cairo graphics library])
217fi
218AM_CONDITIONAL(HAVE_CAIRO, $have_cairo)
219
220have_cairo_ft=false
221if $have_cairo; then
222	PKG_CHECK_MODULES(CAIRO_FT, cairo-ft, have_cairo_ft=true, :)
223fi
224if $have_cairo_ft; then
225	AC_DEFINE(HAVE_CAIRO_FT, 1, [Have cairo-ft support in cairo graphics library])
226fi
227AM_CONDITIONAL(HAVE_CAIRO_FT, $have_cairo_ft)
228
229dnl ==========================================================================
230
231AC_ARG_WITH(fontconfig,
232	[AS_HELP_STRING([--with-fontconfig=@<:@yes/no/auto@:>@],
233			[Use fontconfig @<:@default=auto@:>@])],,
234	[with_fontconfig=auto])
235have_fontconfig=false
236if test "x$with_fontconfig" = "xyes" -o "x$with_fontconfig" = "xauto"; then
237	PKG_CHECK_MODULES(FONTCONFIG, fontconfig, have_fontconfig=true, :)
238fi
239if test "x$with_fontconfig" = "xyes" -a "x$have_fontconfig" != "xtrue"; then
240	AC_MSG_ERROR([fontconfig support requested but not found])
241fi
242if $have_fontconfig; then
243	AC_DEFINE(HAVE_FONTCONFIG, 1, [Have fontconfig library])
244fi
245AM_CONDITIONAL(HAVE_FONTCONFIG, $have_fontconfig)
246
247dnl ==========================================================================
248
249AC_ARG_WITH(icu,
250	[AS_HELP_STRING([--with-icu=@<:@yes/no/builtin/auto@:>@],
251			[Use ICU @<:@default=auto@:>@])],,
252	[with_icu=auto])
253have_icu=false
254if test "x$with_icu" = "xyes" -o "x$with_icu" = "xbuiltin" -o "x$with_icu" = "xauto"; then
255	PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, :)
256
257	dnl Fallback to icu-config if ICU pkg-config files could not be found
258	if test "$have_icu" != "true"; then
259		AC_CHECK_TOOL(ICU_CONFIG, icu-config, no)
260		AC_MSG_CHECKING([for ICU by using icu-config fallback])
261		if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; then
262			have_icu=true
263			# We don't use --cflags as this gives us a lot of things that we don't
264			# necessarily want, like debugging and optimization flags
265			# See man (1) icu-config for more info.
266			ICU_CFLAGS=`$ICU_CONFIG --cppflags`
267			ICU_LIBS=`$ICU_CONFIG --ldflags-searchpath --ldflags-libsonly`
268			AC_SUBST(ICU_CFLAGS)
269			AC_SUBST(ICU_LIBS)
270			AC_MSG_RESULT([yes])
271		else
272			AC_MSG_RESULT([no])
273		fi
274	fi
275fi
276if test \( "x$with_icu" = "xyes" -o "x$with_icu" = "xbuiltin" \) -a "x$have_icu" != "xtrue"; then
277	AC_MSG_ERROR([icu support requested but icu-uc not found])
278fi
279
280if $have_icu; then
281	CXXFLAGS="$CXXFLAGS `$PKG_CONFIG --variable=CXXFLAGS icu-uc`"
282	AC_DEFINE(HAVE_ICU, 1, [Have ICU library])
283	if test "x$with_icu" = "xbuiltin"; then
284		AC_DEFINE(HAVE_ICU_BUILTIN, 1, [Use hb-icu Unicode callbacks])
285	fi
286fi
287AM_CONDITIONAL(HAVE_ICU, $have_icu)
288AM_CONDITIONAL(HAVE_ICU_BUILTIN, $have_icu && test "x$with_icu" = "xbuiltin")
289
290dnl ===========================================================================
291
292AC_ARG_WITH(ucdn,
293	[AS_HELP_STRING([--with-ucdn=@<:@yes/no@:>@],
294			[Use builtin UCDN library @<:@default=yes@:>@])],,
295	[with_ucdn=yes])
296have_ucdn=false
297if test "x$with_ucdn" = "xyes"; then
298	have_ucdn=true
299fi
300if $have_ucdn; then
301	AC_DEFINE(HAVE_UCDN, 1, [Have UCDN Unicode functions])
302fi
303AM_CONDITIONAL(HAVE_UCDN, $have_ucdn)
304
305dnl ==========================================================================
306
307AC_ARG_WITH(graphite2,
308	[AS_HELP_STRING([--with-graphite2=@<:@yes/no/auto@:>@],
309			[Use the graphite2 library @<:@default=no@:>@])],,
310	[with_graphite2=no])
311have_graphite2=false
312GRAPHITE2_DEPS="graphite2"
313AC_SUBST(GRAPHITE2_DEPS)
314if test "x$with_graphite2" = "xyes" -o "x$with_graphite2" = "xauto"; then
315	PKG_CHECK_MODULES(GRAPHITE2, $GRAPHITE2_DEPS, have_graphite2=true, :)
316	if test "x$have_graphite2" != "xtrue"; then
317                # If pkg-config is not available, graphite2 can still be there
318		ac_save_CFLAGS="$CFLAGS"
319		ac_save_CPPFLAGS="$CPPFLAGS"
320		CFLAGS="$CFLAGS $GRAPHITE2_CFLAGS"
321		CPPFLAGS="$CPPFLAGS $GRAPHITE2_CFLAGS"
322		AC_CHECK_HEADER(graphite2/Segment.h, have_graphite2=true, :)
323		CPPFLAGS="$ac_save_CPPFLAGS"
324		CFLAGS="$ac_save_CFLAGS"
325	fi
326fi
327if test "x$with_graphite2" = "xyes" -a "x$have_graphite2" != "xtrue"; then
328	AC_MSG_ERROR([graphite2 support requested but libgraphite2 not found])
329fi
330if $have_graphite2; then
331	AC_DEFINE(HAVE_GRAPHITE2, 1, [Have Graphite2 library])
332fi
333AM_CONDITIONAL(HAVE_GRAPHITE2, $have_graphite2)
334
335dnl ==========================================================================
336
337AC_ARG_WITH(freetype,
338	[AS_HELP_STRING([--with-freetype=@<:@yes/no/auto@:>@],
339			[Use the FreeType library @<:@default=auto@:>@])],,
340	[with_freetype=auto])
341have_freetype=false
342FREETYPE_DEPS="freetype2 >= 12.0.6"
343AC_SUBST(FREETYPE_DEPS)
344if test "x$with_freetype" = "xyes" -o "x$with_freetype" = "xauto"; then
345	# See freetype/docs/VERSION.DLL; 12.0.6 means freetype-2.4.2
346	PKG_CHECK_MODULES(FREETYPE, $FREETYPE_DEPS, have_freetype=true, :)
347fi
348if test "x$with_freetype" = "xyes" -a "x$have_freetype" != "xtrue"; then
349	AC_MSG_ERROR([FreeType support requested but libfreetype2 not found])
350fi
351if $have_freetype; then
352	AC_DEFINE(HAVE_FREETYPE, 1, [Have FreeType 2 library])
353	save_libs=$LIBS
354	LIBS="$LIBS $FREETYPE_LIBS"
355	AC_CHECK_FUNCS(FT_Get_Var_Blend_Coordinates)
356	LIBS=$save_libs
357fi
358AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype)
359
360dnl ===========================================================================
361
362AC_ARG_WITH(uniscribe,
363	[AS_HELP_STRING([--with-uniscribe=@<:@yes/no/auto@:>@],
364			[Use the Uniscribe library @<:@default=no@:>@])],,
365	[with_uniscribe=no])
366have_uniscribe=false
367if test "x$with_uniscribe" = "xyes" -o "x$with_uniscribe" = "xauto"; then
368	AC_CHECK_HEADERS(usp10.h windows.h, have_uniscribe=true)
369fi
370if test "x$with_uniscribe" = "xyes" -a "x$have_uniscribe" != "xtrue"; then
371	AC_MSG_ERROR([uniscribe support requested but not found])
372fi
373if $have_uniscribe; then
374	UNISCRIBE_CFLAGS=
375	UNISCRIBE_LIBS="-lusp10 -lgdi32 -lrpcrt4"
376	AC_SUBST(UNISCRIBE_CFLAGS)
377	AC_SUBST(UNISCRIBE_LIBS)
378	AC_DEFINE(HAVE_UNISCRIBE, 1, [Have Uniscribe library])
379fi
380AM_CONDITIONAL(HAVE_UNISCRIBE, $have_uniscribe)
381
382dnl ===========================================================================
383
384AC_ARG_WITH(directwrite,
385	[AS_HELP_STRING([--with-directwrite=@<:@yes/no/auto@:>@],
386			[Use the DirectWrite library (experimental) @<:@default=no@:>@])],,
387	[with_directwrite=no])
388have_directwrite=false
389AC_LANG_PUSH([C++])
390if test "x$with_directwrite" = "xyes" -o "x$with_directwrite" = "xauto"; then
391	AC_CHECK_HEADERS(dwrite.h, have_directwrite=true)
392fi
393AC_LANG_POP([C++])
394if test "x$with_directwrite" = "xyes" -a "x$have_directwrite" != "xtrue"; then
395	AC_MSG_ERROR([directwrite support requested but not found])
396fi
397if $have_directwrite; then
398	DIRECTWRITE_CXXFLAGS=
399	DIRECTWRITE_LIBS="-ldwrite"
400	AC_SUBST(DIRECTWRITE_CXXFLAGS)
401	AC_SUBST(DIRECTWRITE_LIBS)
402	AC_DEFINE(HAVE_DIRECTWRITE, 1, [Have DirectWrite library])
403fi
404AM_CONDITIONAL(HAVE_DIRECTWRITE, $have_directwrite)
405
406dnl ===========================================================================
407
408AC_ARG_WITH(coretext,
409	[AS_HELP_STRING([--with-coretext=@<:@yes/no/auto@:>@],
410			[Use CoreText @<:@default=no@:>@])],,
411	[with_coretext=no])
412have_coretext=false
413if test "x$with_coretext" = "xyes" -o "x$with_coretext" = "xauto"; then
414	AC_CHECK_TYPE(CTFontRef, have_coretext=true,, [#include <ApplicationServices/ApplicationServices.h>])
415
416	if $have_coretext; then
417		CORETEXT_CFLAGS=
418		CORETEXT_LIBS="-framework ApplicationServices"
419		AC_SUBST(CORETEXT_CFLAGS)
420		AC_SUBST(CORETEXT_LIBS)
421	else
422		# On iOS CoreText and CoreGraphics are stand-alone frameworks
423		if test "x$have_coretext" != "xtrue"; then
424			# Check for a different symbol to avoid getting cached result.
425			AC_CHECK_TYPE(CTRunRef, have_coretext=true,, [#include <CoreText/CoreText.h>])
426		fi
427
428		if $have_coretext; then
429			CORETEXT_CFLAGS=
430			CORETEXT_LIBS="-framework CoreText -framework CoreGraphics"
431			AC_SUBST(CORETEXT_CFLAGS)
432			AC_SUBST(CORETEXT_LIBS)
433		fi
434	fi
435fi
436if test "x$with_coretext" = "xyes" -a "x$have_coretext" != "xtrue"; then
437	AC_MSG_ERROR([CoreText support requested but libcoretext not found])
438fi
439if $have_coretext; then
440	AC_DEFINE(HAVE_CORETEXT, 1, [Have Core Text backend])
441fi
442AM_CONDITIONAL(HAVE_CORETEXT, $have_coretext)
443
444dnl ===========================================================================
445
446AC_CACHE_CHECK([for Intel atomic primitives], hb_cv_have_intel_atomic_primitives, [
447	hb_cv_have_intel_atomic_primitives=false
448	AC_TRY_LINK([
449		void memory_barrier (void) { __sync_synchronize (); }
450		int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
451		int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
452		void mutex_unlock (int *m) { __sync_lock_release (m); }
453		], [], hb_cv_have_intel_atomic_primitives=true
454	)
455])
456if $hb_cv_have_intel_atomic_primitives; then
457	AC_DEFINE(HAVE_INTEL_ATOMIC_PRIMITIVES, 1, [Have Intel __sync_* atomic primitives])
458fi
459
460dnl ===========================================================================
461
462AC_CACHE_CHECK([for Solaris atomic operations], hb_cv_have_solaris_atomic_ops, [
463	hb_cv_have_solaris_atomic_ops=false
464	AC_TRY_LINK([
465		#include <atomic.h>
466		/* This requires Solaris Studio 12.2 or newer: */
467		#include <mbarrier.h>
468		void memory_barrier (void) { __machine_rw_barrier (); }
469		int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); }
470		void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); }
471		], [], hb_cv_have_solaris_atomic_ops=true
472	)
473])
474if $hb_cv_have_solaris_atomic_ops; then
475	AC_DEFINE(HAVE_SOLARIS_ATOMIC_OPS, 1, [Have Solaris __machine_*_barrier and atomic_* operations])
476fi
477
478if test "$os_win32" = no && ! $have_pthread; then
479	AC_CHECK_HEADERS(sched.h)
480	AC_SEARCH_LIBS(sched_yield,rt,AC_DEFINE(HAVE_SCHED_YIELD, 1, [Have sched_yield]))
481fi
482
483dnl ===========================================================================
484
485AC_CONFIG_FILES([
486Makefile
487src/Makefile
488src/hb-version.h
489src/hb-ucdn/Makefile
490util/Makefile
491test/Makefile
492test/api/Makefile
493test/fuzzing/Makefile
494test/shaping/Makefile
495docs/Makefile
496docs/version.xml
497win32/Makefile
498win32/config.h.win32
499])
500
501AC_OUTPUT
502
503AC_MSG_NOTICE([
504
505Build configuration:
506
507Unicode callbacks (you want at least one):
508	Builtin (UCDN):		${have_ucdn}
509	Glib:			${have_glib}
510	ICU:			${have_icu}
511
512Font callbacks (the more the better):
513	FreeType:		${have_freetype}
514
515Tools used for command-line utilities:
516	Cairo:			${have_cairo}
517	Fontconfig:		${have_fontconfig}
518
519Additional shapers (the more the better):
520	Graphite2:		${have_graphite2}
521
522Platform shapers (not normally needed):
523	CoreText:		${have_coretext}
524	Uniscribe:		${have_uniscribe}
525	DirectWrite:		${have_directwrite}
526
527Other features:
528	Documentation:		${have_gtk_doc}
529	GObject bindings:	${have_gobject}
530	Introspection:		${have_introspection}
531])
532