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