Imported Upstream version 8.2.2
[platform/upstream/harfbuzz.git] / configure.ac
1 AC_PREREQ([2.64])
2 AC_INIT([HarfBuzz],
3         [8.2.2],
4         [https://github.com/harfbuzz/harfbuzz/issues/new],
5         [harfbuzz],
6         [http://harfbuzz.org/])
7
8 AC_CONFIG_MACRO_DIR([m4])
9 AC_CONFIG_SRCDIR([src/harfbuzz.pc.in])
10 AC_CONFIG_HEADERS([config.h])
11
12 AM_INIT_AUTOMAKE([1.13.0 gnits tar-ustar dist-xz no-dist-gzip -Wall no-define color-tests -Wno-portability])
13 AM_SILENT_RULES([yes])
14 AX_CODE_COVERAGE
15
16 # Initialize libtool
17 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
18 LT_PREREQ([2.2])
19 LT_INIT([disable-static])
20
21 # Check for programs
22 AC_PROG_CC
23 AC_PROG_CC_C99
24 AM_PROG_CC_C_O
25 AC_PROG_CXX
26 AX_CXX_COMPILE_STDCXX(11)
27 AC_SYS_LARGEFILE
28 PKG_PROG_PKG_CONFIG([0.28])
29 AM_MISSING_PROG([RAGEL], [ragel])
30 AM_MISSING_PROG([GIT], [git])
31
32 # Version
33 m4_define(hb_version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
34 m4_define(hb_version_major,m4_argn(1,hb_version_triplet))
35 m4_define(hb_version_minor,m4_argn(2,hb_version_triplet))
36 m4_define(hb_version_micro,m4_argn(3,hb_version_triplet))
37 HB_VERSION_MAJOR=hb_version_major
38 HB_VERSION_MINOR=hb_version_minor
39 HB_VERSION_MICRO=hb_version_micro
40 HB_VERSION=AC_PACKAGE_VERSION
41 AC_SUBST(HB_VERSION_MAJOR)
42 AC_SUBST(HB_VERSION_MINOR)
43 AC_SUBST(HB_VERSION_MICRO)
44 AC_SUBST(HB_VERSION)
45
46 # Libtool version
47 m4_define([hb_version_int],
48           m4_eval(60000 + hb_version_major*100 + hb_version_minor*10 + hb_version_micro))
49 HB_LIBTOOL_VERSION_INFO=hb_version_int:0:hb_version_int
50 AC_SUBST(HB_LIBTOOL_VERSION_INFO)
51
52 AC_ARG_WITH([libstdc++],
53         [AS_HELP_STRING([--with-libstdc++=@<:@yes/no@:>@],
54                         [Allow linking with libstdc++ @<:@default=no@:>@])],
55         [with_libstdcxx=$withval],
56         [with_libstdcxx=no])
57 AM_CONDITIONAL(WITH_LIBSTDCXX, [test "x$with_libstdcxx" = "xyes"])
58
59 # Documentation
60 have_gtk_doc=false
61 m4_ifdef([GTK_DOC_CHECK], [
62 GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
63         if test "x$enable_gtk_doc" = xyes; then
64                 have_gtk_doc=true
65         fi
66 ], [
67         AM_CONDITIONAL([ENABLE_GTK_DOC], false)
68 ])
69
70 # Functions and headers
71 AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale uselocale sincosf)
72 AC_CHECK_HEADERS(unistd.h sys/mman.h stdbool.h xlocale.h)
73
74 # Compiler flags
75 AC_CANONICAL_HOST
76 AC_CHECK_ALIGNOF([struct{char;}])
77 if test "x$GCC" = "xyes"; then
78
79         # Make symbols link locally
80         AX_CHECK_LINK_FLAG([[-Bsymbolic-functions]], [LDFLAGS="$LDFLAGS -Bsymbolic-functions"])
81
82         # Make it possible to not link to libstdc++
83         # No threadsafe statics in C++ as we do it ourselves.
84         # We don't use these features, so it's safe to disable them
85         # even in the cases where we DO link to libstdc++.
86         # Put -fno-rtti before $CXXFLAGS such that users can re-enable it
87         # by overriding CXXFLAGS.
88         CXXFLAGS="-fno-rtti $CXXFLAGS -fno-exceptions -fno-threadsafe-statics"
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
107 fi
108
109 AM_CONDITIONAL(HAVE_GCC, test "x$GCC" = "xyes")
110
111 hb_os_win32=no
112 AC_MSG_CHECKING([for native Win32])
113 case "$host" in
114   *-*-mingw*)
115     hb_os_win32=yes
116     ;;
117 esac
118 AC_MSG_RESULT([$hb_os_win32])
119 AM_CONDITIONAL(OS_WIN32, test "$hb_os_win32" = "yes")
120
121 have_pthread=false
122 AX_PTHREAD([have_pthread=true])
123 if $have_pthread; then
124         AC_DEFINE(HAVE_PTHREAD, 1, [Have POSIX threads])
125 fi
126 AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread)
127
128 dnl ==========================================================================
129
130 AC_ARG_WITH(glib,
131         [AS_HELP_STRING([--with-glib=@<:@yes/no/auto@:>@],
132                         [Use glib @<:@default=auto@:>@])],,
133         [with_glib=auto])
134 have_glib=false
135 GLIB_DEPS="glib-2.0 >= 2.19.1"
136 AC_SUBST(GLIB_DEPS)
137 if test "x$with_glib" = "xyes" -o "x$with_glib" = "xauto"; then
138         PKG_CHECK_MODULES(GLIB, $GLIB_DEPS, have_glib=true, :)
139 fi
140 if test "x$with_glib" = "xyes" -a "x$have_glib" != "xtrue"; then
141         AC_MSG_ERROR([glib support requested but glib-2.0 not found])
142 fi
143 if $have_glib; then
144         AC_DEFINE(HAVE_GLIB, 1, [Have glib2 library])
145 fi
146 AM_CONDITIONAL(HAVE_GLIB, $have_glib)
147
148 dnl ===========================================================================
149
150 AC_ARG_WITH(gobject,
151         [AS_HELP_STRING([--with-gobject=@<:@yes/no/auto@:>@],
152                         [Use gobject @<:@default=no@:>@])],,
153         [with_gobject=no])
154 have_gobject=false
155 if test "x$with_gobject" = "xyes" -o "x$with_gobject" = "xauto"; then
156         PKG_CHECK_MODULES(GOBJECT, gobject-2.0 glib-2.0, have_gobject=true, :)
157 fi
158 if test "x$with_gobject" = "xyes" -a "x$have_gobject" != "xtrue"; then
159         AC_MSG_ERROR([gobject support requested but gobject-2.0 / glib-2.0 not found])
160 fi
161 if $have_gobject; then
162         AC_DEFINE(HAVE_GOBJECT, 1, [Have gobject2 library])
163         GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
164         AC_SUBST(GLIB_MKENUMS)
165 fi
166 AM_CONDITIONAL(HAVE_GOBJECT, $have_gobject)
167 AC_SUBST(have_gobject)
168
169 dnl ===========================================================================
170
171
172 dnl ===========================================================================
173 # Gobject-Introspection
174 have_introspection=false
175 m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [
176         if $have_gobject; then
177                 GOBJECT_INTROSPECTION_CHECK([1.34.0])
178                 if test "x$found_introspection" = xyes; then
179                         have_introspection=true
180                 fi
181         else
182                 AM_CONDITIONAL([HAVE_INTROSPECTION], false)
183         fi
184 ], [
185         AM_CONDITIONAL([HAVE_INTROSPECTION], false)
186 ])
187
188 dnl ==========================================================================
189
190 AC_ARG_WITH(cairo,
191         [AS_HELP_STRING([--with-cairo=@<:@yes/no/auto@:>@],
192                         [Use cairo @<:@default=auto@:>@])],,
193         [with_cairo=auto])
194 have_cairo=false
195 if test "x$with_cairo" = "xyes" -o "x$with_cairo" = "xauto"; then
196         PKG_CHECK_MODULES(CAIRO, cairo >= 1.8.0, have_cairo=true, :)
197         save_libs=$LIBS
198         LIBS="$LIBS $CAIRO_LIBS"
199         AC_CHECK_FUNCS(cairo_user_font_face_set_render_color_glyph_func)
200         LIBS=$save_libs
201 fi
202 if test "x$with_cairo" = "xyes" -a "x$have_cairo" != "xtrue"; then
203         AC_MSG_ERROR([cairo support requested but not found])
204 fi
205 if $have_cairo; then
206         AC_DEFINE(HAVE_CAIRO, 1, [Have cairo graphics library])
207 fi
208 AM_CONDITIONAL(HAVE_CAIRO, $have_cairo)
209
210 have_cairo_ft=false
211 if $have_cairo; then
212         PKG_CHECK_MODULES(CAIRO_FT, cairo-ft, have_cairo_ft=true, :)
213 fi
214 if $have_cairo_ft; then
215         AC_DEFINE(HAVE_CAIRO_FT, 1, [Have cairo-ft support in cairo graphics library])
216 fi
217 AM_CONDITIONAL(HAVE_CAIRO_FT, $have_cairo_ft)
218
219 dnl ==========================================================================
220
221 AC_ARG_WITH(chafa,
222         [AS_HELP_STRING([--with-chafa=@<:@yes/no/auto@:>@],
223                         [Use chafa @<:@default=auto@:>@])],,
224         [with_chafa=auto])
225 have_chafa=false
226 if test "x$with_chafa" = "xyes" -o "x$with_chafa" = "xauto"; then
227         PKG_CHECK_MODULES(CHAFA, chafa >= 1.6.0, have_chafa=true, :)
228 fi
229 if test "x$with_chafa" = "xyes" -a "x$have_chafa" != "xtrue"; then
230         AC_MSG_ERROR([chafa support requested but not found])
231 fi
232 if $have_chafa; then
233         AC_DEFINE(HAVE_CHAFA, 1, [Have chafa terminal graphics library])
234 fi
235 AM_CONDITIONAL(HAVE_CHAFA, $have_chafa)
236
237 dnl ==========================================================================
238
239 AC_ARG_WITH(icu,
240         [AS_HELP_STRING([--with-icu=@<:@yes/no/builtin/auto@:>@],
241                         [Use ICU @<:@default=auto@:>@])],,
242         [with_icu=auto])
243 have_icu=false
244 if test "x$with_icu" = "xyes" -o "x$with_icu" = "xbuiltin" -o "x$with_icu" = "xauto"; then
245         PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, :)
246 fi
247 if test \( "x$with_icu" = "xyes" -o "x$with_icu" = "xbuiltin" \) -a "x$have_icu" != "xtrue"; then
248         AC_MSG_ERROR([icu support requested but icu-uc not found])
249 fi
250
251 if $have_icu; then
252         CXXFLAGS="$CXXFLAGS `$PKG_CONFIG --variable=CXXFLAGS icu-uc`"
253         AC_DEFINE(HAVE_ICU, 1, [Have ICU library])
254         if test "x$with_icu" = "xbuiltin"; then
255                 AC_DEFINE(HAVE_ICU_BUILTIN, 1, [Use hb-icu Unicode callbacks])
256         fi
257 fi
258 AM_CONDITIONAL(HAVE_ICU, $have_icu)
259 AM_CONDITIONAL(HAVE_ICU_BUILTIN, $have_icu && test "x$with_icu" = "xbuiltin")
260
261 dnl ===========================================================================
262
263 AC_ARG_WITH(graphite2,
264         [AS_HELP_STRING([--with-graphite2=@<:@yes/no/auto@:>@],
265                         [Use the graphite2 library @<:@default=no@:>@])],,
266         [with_graphite2=no])
267 have_graphite2=false
268 GRAPHITE2_DEPS="graphite2 >= 1.2.0"
269 AC_SUBST(GRAPHITE2_DEPS)
270 if test "x$with_graphite2" = "xyes" -o "x$with_graphite2" = "xauto"; then
271         PKG_CHECK_MODULES(GRAPHITE2, $GRAPHITE2_DEPS, have_graphite2=true, :)
272         if test "x$have_graphite2" != "xtrue"; then
273                 # If pkg-config is not available, graphite2 can still be there
274                 ac_save_CFLAGS="$CFLAGS"
275                 ac_save_CPPFLAGS="$CPPFLAGS"
276                 CFLAGS="$CFLAGS $GRAPHITE2_CFLAGS"
277                 CPPFLAGS="$CPPFLAGS $GRAPHITE2_CFLAGS"
278                 AC_CHECK_HEADER(graphite2/Segment.h, have_graphite2=true, :)
279                 CPPFLAGS="$ac_save_CPPFLAGS"
280                 CFLAGS="$ac_save_CFLAGS"
281         fi
282 fi
283 if test "x$with_graphite2" = "xyes" -a "x$have_graphite2" != "xtrue"; then
284         AC_MSG_ERROR([graphite2 support requested but libgraphite2 not found])
285 fi
286 if $have_graphite2; then
287         AC_DEFINE(HAVE_GRAPHITE2, 1, [Have Graphite2 library])
288 fi
289 AM_CONDITIONAL(HAVE_GRAPHITE2, $have_graphite2)
290
291 dnl ==========================================================================
292
293 AC_ARG_WITH(freetype,
294         [AS_HELP_STRING([--with-freetype=@<:@yes/no/auto@:>@],
295                         [Use the FreeType library @<:@default=auto@:>@])],,
296         [with_freetype=auto])
297 have_freetype=false
298 FREETYPE_DEPS="freetype2 >= 12.0.6"
299 AC_SUBST(FREETYPE_DEPS)
300 if test "x$with_freetype" = "xyes" -o "x$with_freetype" = "xauto"; then
301         # See freetype/docs/VERSION.DLL; 12.0.6 means freetype-2.4.2
302         PKG_CHECK_MODULES(FREETYPE, $FREETYPE_DEPS, have_freetype=true, :)
303 fi
304 if test "x$with_freetype" = "xyes" -a "x$have_freetype" != "xtrue"; then
305         AC_MSG_ERROR([FreeType support requested but libfreetype2 not found])
306 fi
307 if $have_freetype; then
308         AC_DEFINE(HAVE_FREETYPE, 1, [Have FreeType 2 library])
309         save_libs=$LIBS
310         LIBS="$LIBS $FREETYPE_LIBS"
311         AC_CHECK_FUNCS(FT_Get_Var_Blend_Coordinates FT_Set_Var_Blend_Coordinates FT_Done_MM_Var FT_Get_Transform)
312         LIBS=$save_libs
313 fi
314 AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype)
315
316 dnl ===========================================================================
317
318 AC_ARG_WITH(uniscribe,
319         [AS_HELP_STRING([--with-uniscribe=@<:@yes/no/auto@:>@],
320                         [Use the Uniscribe library @<:@default=no@:>@])],,
321         [with_uniscribe=no])
322 have_uniscribe=false
323 if test "x$with_uniscribe" = "xyes" -o "x$with_uniscribe" = "xauto"; then
324         AC_CHECK_HEADERS(usp10.h windows.h, have_uniscribe=true)
325 fi
326 if test "x$with_uniscribe" = "xyes" -a "x$have_uniscribe" != "xtrue"; then
327         AC_MSG_ERROR([uniscribe support requested but not found])
328 fi
329 if $have_uniscribe; then
330         UNISCRIBE_CFLAGS=
331         UNISCRIBE_LIBS="-lusp10 -lgdi32 -lrpcrt4"
332         AC_SUBST(UNISCRIBE_CFLAGS)
333         AC_SUBST(UNISCRIBE_LIBS)
334         AC_DEFINE(HAVE_UNISCRIBE, 1, [Have Uniscribe library])
335 fi
336 AM_CONDITIONAL(HAVE_UNISCRIBE, $have_uniscribe)
337
338 dnl ===========================================================================
339
340 AC_ARG_WITH(gdi,
341         [AS_HELP_STRING([--with-gdi=@<:@yes/no/auto@:>@],
342                         [Provide GDI integration helpers @<:@default=no@:>@])],,
343         [with_gdi=no])
344 have_gdi=false
345 if test "x$with_gdi" = "xyes" -o "x$with_gdi" = "xauto"; then
346         AC_CHECK_HEADERS(windows.h, have_gdi=true)
347 fi
348 if test "x$with_gdi" = "xyes" -a "x$have_gdi" != "xtrue"; then
349         AC_MSG_ERROR([gdi support requested but not found])
350 fi
351 if $have_gdi; then
352         GDI_CFLAGS=
353         GDI_LIBS="-lgdi32"
354         AC_SUBST(GDI_CFLAGS)
355         AC_SUBST(GDI_LIBS)
356         AC_DEFINE(HAVE_GDI, 1, [Have GDI library])
357 fi
358 AM_CONDITIONAL(HAVE_GDI, $have_gdi)
359
360 dnl ===========================================================================
361
362 AC_ARG_WITH(directwrite,
363         [AS_HELP_STRING([--with-directwrite=@<:@yes/no/auto@:>@],
364                         [Use the DirectWrite library (experimental) @<:@default=no@:>@])],,
365         [with_directwrite=no])
366 have_directwrite=false
367 AC_LANG_PUSH([C++])
368 if test "x$with_directwrite" = "xyes" -o "x$with_directwrite" = "xauto"; then
369         AC_CHECK_HEADERS(dwrite_1.h, have_directwrite=true)
370 fi
371 AC_LANG_POP([C++])
372 if test "x$with_directwrite" = "xyes" -a "x$have_directwrite" != "xtrue"; then
373         AC_MSG_ERROR([directwrite support requested but not found])
374 fi
375 if $have_directwrite; then
376         AC_DEFINE(HAVE_DIRECTWRITE, 1, [Have DirectWrite library])
377 fi
378 AM_CONDITIONAL(HAVE_DIRECTWRITE, $have_directwrite)
379
380 dnl ===========================================================================
381
382 AC_ARG_WITH(coretext,
383         [AS_HELP_STRING([--with-coretext=@<:@yes/no/auto@:>@],
384                         [Use CoreText @<:@default=no@:>@])],,
385         [with_coretext=no])
386 have_coretext=false
387 if test "x$with_coretext" = "xyes" -o "x$with_coretext" = "xauto"; then
388         AC_CHECK_TYPE(CTFontRef, have_coretext=true,, [#include <ApplicationServices/ApplicationServices.h>])
389
390         if $have_coretext; then
391                 CORETEXT_CFLAGS=
392                 CORETEXT_LIBS="-framework ApplicationServices"
393                 AC_SUBST(CORETEXT_CFLAGS)
394                 AC_SUBST(CORETEXT_LIBS)
395         else
396                 # On iOS CoreText and CoreGraphics are stand-alone frameworks
397                 if test "x$have_coretext" != "xtrue"; then
398                         # Check for a different symbol to avoid getting cached result.
399                         AC_CHECK_TYPE(CTRunRef, have_coretext=true,, [#include <CoreText/CoreText.h>])
400                 fi
401
402                 if $have_coretext; then
403                         CORETEXT_CFLAGS=
404                         CORETEXT_LIBS="-framework CoreText -framework CoreGraphics -framework CoreFoundation"
405                         AC_SUBST(CORETEXT_CFLAGS)
406                         AC_SUBST(CORETEXT_LIBS)
407                 fi
408         fi
409 fi
410 if test "x$with_coretext" = "xyes" -a "x$have_coretext" != "xtrue"; then
411         AC_MSG_ERROR([CoreText support requested but libcoretext not found])
412 fi
413 if $have_coretext; then
414         AC_DEFINE(HAVE_CORETEXT, 1, [Have Core Text backend])
415 fi
416 AM_CONDITIONAL(HAVE_CORETEXT, $have_coretext)
417
418 dnl ===========================================================================
419
420 AC_ARG_WITH(wasm,
421         [AS_HELP_STRING([--with-wasm=@<:@yes/no/auto@:>@],
422                         [Use the wasm-micro-runtime library @<:@default=no@:>@])],,
423         [with_wasm=no])
424 have_wasm=false
425 if test "x$with_wasm" = "xyes" -o "x$with_wasm" = "xauto"; then
426         AC_CHECK_HEADERS(wasm_export.h, have_wasm=true)
427 fi
428 if test "x$with_wasm" = "xyes" -a "x$have_wasm" != "xtrue"; then
429         AC_MSG_ERROR([wasm support requested but not found])
430 fi
431 if $have_wasm; then
432         WASM_CFLAGS=
433         WASM_LIBS="-liwasm"
434         AC_SUBST(WASM_CFLAGS)
435         AC_SUBST(WASM_LIBS)
436         AC_DEFINE(HAVE_WASM, 1, [Have wasm-micro-runtime library])
437 fi
438 AM_CONDITIONAL(HAVE_WASM, $have_wasm)
439
440 dnl ===========================================================================
441
442 AC_CONFIG_FILES([
443 Makefile
444 src/Makefile
445 src/harfbuzz-config.cmake
446 util/Makefile
447 test/Makefile
448 test/api/Makefile
449 test/fuzzing/Makefile
450 test/shape/Makefile
451 test/shape/data/Makefile
452 test/shape/data/aots/Makefile
453 test/shape/data/in-house/Makefile
454 test/shape/data/text-rendering-tests/Makefile
455 test/subset/Makefile
456 test/subset/data/Makefile
457 test/subset/data/repack_tests/Makefile
458 test/threads/Makefile
459 perf/Makefile
460 docs/Makefile
461 docs/version.xml
462 ])
463
464 AC_OUTPUT
465
466 echo
467 echo "C++ compiler version:"
468 $CXX --version
469 echo
470
471 AC_MSG_NOTICE([
472
473 Autotools is no longer our supported build system for building the library
474 for *nix distributions, please migrate to meson.
475
476 ])
477
478
479 AC_MSG_NOTICE([
480
481 Build configuration:
482
483 Unicode callbacks (you want at least one):
484         Builtin                 true
485         Glib:                   ${have_glib}
486         ICU:                    ${have_icu}
487
488 Font callbacks (the more the merrier):
489         FreeType:               ${have_freetype}
490
491 Tools used for command-line utilities:
492         Cairo:                  ${have_cairo}
493         Chafa:                  ${have_chafa}
494
495 Additional shapers:
496         Graphite2:              ${have_graphite2}
497
498 Platform shapers (not normally needed):
499         CoreText:               ${have_coretext}
500         DirectWrite:            ${have_directwrite}
501         GDI:                    ${have_gdi}
502         Uniscribe:              ${have_uniscribe}
503         WebAssembly:            ${have_wasm}
504
505 Other features:
506         Documentation:          ${enable_gtk_doc}
507         GObject bindings:       ${have_gobject}
508         Introspection:          ${have_introspection}
509 ])