forked from hpjansson/chafa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
646 lines (549 loc) · 21.4 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
dnl ----------------------------
dnl Automake/autoconf input file
dnl ----------------------------
dnl --- Package configuration ---
m4_define([chafa_major_version], [1])
m4_define([chafa_minor_version], [13])
m4_define([chafa_micro_version], [0])
m4_define([chafa_version], [chafa_major_version.chafa_minor_version.chafa_micro_version])
AC_PREREQ([2.69])
AM_INIT_AUTOMAKE([1.9 foreign dist-xz no-dist-gzip -Wall])
AC_CONFIG_SRCDIR([chafa.pc.in])
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_HEADERS(config.h)
CHAFA_MAJOR_VERSION=chafa_major_version
CHAFA_MINOR_VERSION=chafa_minor_version
CHAFA_MICRO_VERSION=chafa_micro_version
CHAFA_VERSION=chafa_version
AC_SUBST(CHAFA_MAJOR_VERSION)
AC_SUBST(CHAFA_MINOR_VERSION)
AC_SUBST(CHAFA_MICRO_VERSION)
AC_SUBST(CHAFA_VERSION)
AC_DEFINE(CHAFA_MAJOR_VERSION, [chafa_major_version], [Chafa major version])
AC_DEFINE(CHAFA_MINOR_VERSION, [chafa_minor_version], [Chafa minor version])
AC_DEFINE(CHAFA_MICRO_VERSION, [chafa_micro_version], [Chafa micro version])
AC_DEFINE_UNQUOTED(CHAFA_VERSION, "$CHAFA_VERSION", [Package version string])
dnl --- Standard setup ---
BASE_CFLAGS="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 \
-Wall -Wextra -Wmissing-prototypes -Wwrite-strings -Wunused-macros -Wundef \
-Wpointer-arith -Werror=format-security"
# May want to look into -Wconversion sometime. For now, it's just too much noise.
AC_USE_SYSTEM_EXTENSIONS
AM_SANITY_CHECK
AM_MAINTAINER_MODE
AC_C_CONST
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AM_PROG_AR
# We keep this obsolete macro around to allow configuration on older systems
# that require -std=c99, cf. CentOS 7. See github#113.
AC_PROG_CC_STDC
LT_INIT([win32-dll])
dnl --- Check for extra compiler warnings ---
AX_CHECK_COMPILE_FLAG([-Wstack-usage=131072],[BASE_CFLAGS="$BASE_CFLAGS -Wstack-usage=131072"],,[-Werror])
AX_CHECK_COMPILE_FLAG([-Wfor-loop-analysis],[BASE_CFLAGS="$BASE_CFLAGS -Wfor-loop-analysis"],,[-Werror])
AX_CHECK_COMPILE_FLAG([-Wlogical-op],[BASE_CFLAGS="$BASE_CFLAGS -Wlogical-op"],,[-Werror])
AX_CHECK_COMPILE_FLAG([-Wlogical-op-parentheses],[BASE_CFLAGS="$BASE_CFLAGS -Wlogical-op-parentheses"],,[-Werror])
dnl --- Required standards ---
dnl POSIX.1-2008 is required to get SA_RESETHAND. We should get this by default
dnl on most systems, but keep the check around just in case.
dnl AC_MSG_CHECKING(for POSIX.1-2008)
dnl AC_EGREP_CPP(posix_200809L_supported,
dnl [#define _POSIX_C_SOURCE 200809L
dnl #include <unistd.h>
dnl #ifdef _POSIX_VERSION
dnl # if _POSIX_VERSION == 200809L
dnl posix_200809L_supported
dnl # endif
dnl #endif
dnl ],
dnl [AC_MSG_RESULT(yes)],
dnl [AC_MSG_RESULT(no)
dnl AC_MSG_FAILURE([Implementation must conform to the POSIX.1-2008 standard.])]
dnl )
dnl
dnl AC_DEFINE([_POSIX_C_SOURCE], [200809L], [Minimum POSIX standard we need])
dnl --- Dependency check ---
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.26)
AC_ARG_WITH(tools,
[AS_HELP_STRING([--without-tools], [don't build command-line tools [default=on]])],
,
with_tools=yes)
AS_IF([test "$with_tools" != no], [
dnl FreeType (required)
PKG_CHECK_MODULES(FREETYPE, [freetype2 >= 2.0.0],,
[AC_MSG_ERROR([You need freetype2-devel (or libfreetype6-dev on Debian) to build command-line tools, or pass --without-tools to build without.])])
dnl ImageMagick/MagickWand (optional)
AC_ARG_WITH(imagemagick,
[AS_HELP_STRING([--without-imagemagick], [don't build ImageMagick loader [default=on]])],
,
with_imagemagick=yes)
AS_IF([test "$with_imagemagick" != no], [PKG_CHECK_MODULES(MAGICKWAND, [MagickWand >= 6],,
missing_rpms="$missing_rpms ImageMagick-devel"
missing_debs="$missing_debs libmagickwand-dev"
with_imagemagick=no)])
AS_IF([test "$with_imagemagick" != no], [AC_DEFINE([HAVE_MAGICKWAND], [1], [Define if we have ImageMagick support.])])
dnl libjpeg (optional)
AC_ARG_WITH(jpeg,
[AS_HELP_STRING([--without-jpeg], [don't build JPEG loader [default=on]])],
,
with_jpeg=yes)
AS_IF([test "$with_jpeg" != no], [PKG_CHECK_MODULES(JPEG, [libjpeg],,
missing_rpms="$missing_rpms libjpeg-devel"
missing_debs="$missing_debs libjpeg-dev"
with_jpeg=no)])
AS_IF([test "$with_jpeg" != no], [AC_DEFINE([HAVE_JPEG], [1], [Define if we have JPEG support.])])
dnl librsvg (optional)
AC_ARG_WITH(svg,
[AS_HELP_STRING([--without-svg], [don't build SVG loader [default=on]])],
,
with_svg=yes)
AS_IF([test "$with_svg" != no], [PKG_CHECK_MODULES(SVG, [librsvg-2.0],,
missing_rpms="$missing_rpms librsvg-devel"
missing_debs="$missing_debs librsvg2-dev"
with_svg=no)])
AS_IF([test "$with_svg" != no], [AC_DEFINE([HAVE_SVG], [1], [Define if we have SVG support.])])
dnl libtiff (optional)
AC_ARG_WITH(tiff,
[AS_HELP_STRING([--without-tiff], [don't build TIFF loader [default=on]])],
,
with_tiff=yes)
AS_IF([test "$with_tiff" != no], [PKG_CHECK_MODULES(TIFF, [libtiff-4],,
missing_rpms="$missing_rpms libtiff-devel"
missing_debs="$missing_debs libtiff-dev"
with_tiff=no)])
AS_IF([test "$with_tiff" != no], [AC_DEFINE([HAVE_TIFF], [1], [Define if we have TIFF support.])])
dnl libwebp (optional)
AC_ARG_WITH(webp,
[AS_HELP_STRING([--without-webp], [don't build WebP loader [default=on]])],
,
with_webp=yes)
AS_IF([test "$with_webp" != no], [
PKG_CHECK_MODULES(WEBP, [libwebpdemux],,
missing_rpms="$missing_rpms libwebp-devel"
missing_debs="$missing_debs libwebp-dev"
with_webp=no)])
AS_IF([test "$with_webp" != no], [AC_DEFINE([HAVE_WEBP], [1], [Define if we have WebP support.])])
])
AM_CONDITIONAL([WANT_TOOLS], [test "$with_tools" != no])
AM_CONDITIONAL([HAVE_MAGICKWAND], [test "$with_tools" != no -a "$with_imagemagick" != no])
AM_CONDITIONAL([HAVE_JPEG], [test "$with_tools" != no -a "$with_jpeg" != no])
AM_CONDITIONAL([HAVE_SVG], [test "$with_tools" != no -a "$with_svg" != no])
AM_CONDITIONAL([HAVE_TIFF], [test "$with_tools" != no -a "$with_tiff" != no])
AM_CONDITIONAL([HAVE_WEBP], [test "$with_tools" != no -a "$with_webp" != no])
# Used by gtk-doc's fixxref.
GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
AC_SUBST(GLIB_PREFIX)
dnl --- Documentation ---
# gtkdocize greps for ^GTK_DOC_CHECK and parses it, so you need to have
# it on its own line.
m4_ifdef([GTK_DOC_CHECK], [
GTK_DOC_CHECK([1.20], [--flavour no-tmpl])
],[
AM_CONDITIONAL([ENABLE_GTK_DOC],[false])
])
AC_ARG_ENABLE(man,
[AS_HELP_STRING([--enable-man],
[generate man pages [default=auto]])],,
enable_man=maybe)
AS_IF([test "$enable_man" != no], [
AC_PATH_PROG([XSLTPROC], [xsltproc])
AS_IF([test -z "$XSLTPROC"], [
AS_IF([test "$enable_man" = yes], [
AC_MSG_ERROR([xsltproc is required for --enable-man])
])
enable_man=no
])
])
AS_IF([ test "$enable_man" != no ], [
dnl check for DocBook DTD in the local catalog
JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN],
[DocBook XML DTD V4.1.2], [have_docbook_dtd=yes], [have_docbook_dtd=no])
AS_IF([test "$have_docbook_dtd" != yes], [
AS_IF([test "$enable_man" = yes ], [
AC_MSG_ERROR([DocBook DTD is required for --enable-man])
])
enable_man=no
])
])
AS_IF([test "$enable_man" != no], [
dnl check for DocBook XSL stylesheets in the local catalog
JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
[DocBook XSL Stylesheets], [have_docbook_style=yes],[have_docbook_style=no])
AS_IF([ test "$have_docbook_style" != yes ], [
AS_IF([ test "$enable_man" = yes ], [
AC_MSG_ERROR([DocBook XSL Stylesheets are required for --enable-man])
])
enable_man=no
])
])
AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no)
AC_MSG_CHECKING([whether to generate man pages])
AS_IF([ test "$enable_man" != no ], [
enable_man=yes
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])
dnl --- Specific checks ---
AC_CHECK_FUNCS(ctermid getrandom mmap sigaction)
AC_CHECK_HEADERS(sys/ioctl.h termios.h windows.h)
dnl
dnl Define IS_WIN32_BUILD if we're building for Microsoft Windows. In order to
dnl get UTF-8 support in command-line arguments and environment vars, we need
dnl to build a resource file with windres and link it in.
dnl
is_windows_build=no
case "${host_os}" in
cygwin*|mingw*)
is_windows_build=yes
;;
esac
AM_CONDITIONAL([IS_WIN32_BUILD],
[test "x$is_windows_build" = "xyes"])
AC_CHECK_TOOL([WINDRES], [windres], [:])
dnl
dnl Check for -Bsymbolic-functions linker flag used to avoid
dnl intra-library PLT jumps, if available.
dnl
AC_ARG_ENABLE(Bsymbolic,
[AS_HELP_STRING([--disable-Bsymbolic],
[avoid linking with -Bsymbolic])],,
[SAVED_LDFLAGS="${LDFLAGS}" SAVED_LIBS="${LIBS}"
AC_MSG_CHECKING([for -Bsymbolic linker flag])
LDFLAGS=-Wl,-Bsymbolic
LIBS=
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[return 0]])],[AC_MSG_RESULT(yes)
enable_Bsymbolic=yes],[AC_MSG_RESULT(no)
enable_Bsymbolic=no])
LDFLAGS="${SAVED_LDFLAGS}" LIBS="${SAVED_LIBS}"])
if test "x${enable_Bsymbolic}" = "xyes"; then
CHAFA_BDYNAMIC_FLAGS=-Wl,-Bsymbolic
fi
dnl
dnl Check for runtime gcc x86 instruction set detection. Used in 'chafa-features.c'.
dnl
AC_CACHE_CHECK([for gcc __builtin_cpu_init function],
[ax_cv_gcc_check_x86_cpu_init],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <stdlib.h>],
[__builtin_cpu_init ();])],
[ax_cv_gcc_check_x86_cpu_init=yes],
[ax_cv_gcc_check_x86_cpu_init=no])])
AC_CACHE_CHECK([for gcc __builtin_cpu_supports function],
[ax_cv_gcc_check_x86_cpu_supports],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <stdlib.h>],
[__builtin_cpu_supports ("mmx");])],
[ax_cv_gcc_check_x86_cpu_supports=yes],
[ax_cv_gcc_check_x86_cpu_supports=no])])
dnl AM_CONDITIONAL([HAVE_GCC_X86_FEATURE_BUILTINS], [test "$ac_cv_gcc_check_x86_cpu_init" = "yes" && test "$ac_cv_gcc_check_x86_cpu_supports" = "yes"])
AS_IF([test "$ax_cv_gcc_check_x86_cpu_init" = "yes" && test "$ax_cv_gcc_check_x86_cpu_supports" = "yes"], [
AC_DEFINE([HAVE_GCC_X86_FEATURE_BUILTINS], [1], [Define if gcc x86 feature builtins work.])
])
dnl Check for working MMX intrinsics
AC_MSG_CHECKING(for working MMX intrinsics)
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -mmmx"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <mmintrin.h>]],
[[__m64 t [2] = { 0 }; t [0] = _mm_setzero_si64 ();]])],
[AC_DEFINE([HAVE_MMX_INTRINSICS], [1], [Define if MMX intrinsics work.])
ac_cv_mmx_intrinsics=yes],
[ac_cv_mmx_intrinsics=no])
CFLAGS="${SAVED_CFLAGS}"
AC_MSG_RESULT(${ac_cv_mmx_intrinsics})
AM_CONDITIONAL([HAVE_MMX_INTRINSICS], [test "$ac_cv_mmx_intrinsics" = "yes"])
dnl Check for working SSE intrinsics
AC_MSG_CHECKING(for working SSE 4.1 intrinsics)
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -msse4.1"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <smmintrin.h>]],
[[__m128i t = { 0 }; int r = _mm_test_all_ones (t);]])],
[AC_DEFINE([HAVE_SSE41_INTRINSICS], [1], [Define if SSE 4.1 intrinsics work.])
ac_cv_sse41_intrinsics=yes],
[ac_cv_sse41_intrinsics=no])
CFLAGS="${SAVED_CFLAGS}"
AC_MSG_RESULT(${ac_cv_sse41_intrinsics})
AM_CONDITIONAL([HAVE_SSE41_INTRINSICS], [test "$ac_cv_sse41_intrinsics" = "yes"])
dnl Check for working AVX2 intrinsics
AC_MSG_CHECKING(for working AVX2 intrinsics)
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -mavx2"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <immintrin.h>]],
[[__m256i t = { 0 }; __m256i r = _mm256_abs_epi32 (t);]])],
[AC_DEFINE([HAVE_AVX2_INTRINSICS], [1], [Define if AVX2 intrinsics work.])
ac_cv_avx2_intrinsics=yes],
[ac_cv_avx2_intrinsics=no])
CFLAGS="${SAVED_CFLAGS}"
AC_MSG_RESULT(${ac_cv_avx2_intrinsics})
AM_CONDITIONAL([HAVE_AVX2_INTRINSICS], [test "$ac_cv_avx2_intrinsics" = "yes"])
dnl Check for working 64bit popcnt intrinsics
AC_MSG_CHECKING(for working 64bit popcnt intrinsics)
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -mpopcnt"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <stdint.h>
#include <nmmintrin.h>]],
[[uint64_t t = 0; t = _mm_popcnt_u64 (t);]])],
[AC_DEFINE([HAVE_POPCNT64_INTRINSICS], [1], [Define if 64bit popcnt intrinsics work.])
ac_cv_popcnt64_intrinsics=yes],
[ac_cv_popcnt64_intrinsics=no])
CFLAGS="${SAVED_CFLAGS}"
AC_MSG_RESULT(${ac_cv_popcnt64_intrinsics})
dnl Check for working 32bit popcnt intrinsics
AC_MSG_CHECKING(for working 32bit popcnt intrinsics)
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -mpopcnt"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <stdint.h>
#include <nmmintrin.h>]],
[[uint32_t t = 0; t = _mm_popcnt_u32 (t);]])],
[AC_DEFINE([HAVE_POPCNT32_INTRINSICS], [1], [Define if 32bit popcnt intrinsics work.])
ac_cv_popcnt32_intrinsics=yes],
[ac_cv_popcnt32_intrinsics=no])
CFLAGS="${SAVED_CFLAGS}"
AC_MSG_RESULT(${ac_cv_popcnt32_intrinsics})
AM_CONDITIONAL([HAVE_POPCNT_INTRINSICS],
[test "$ac_cv_popcnt64_intrinsics" = "yes" -o "$ac_cv_popcnt32_intrinsics" = "yes"])
dnl
dnl Check for -fvisibility=hidden to determine if we can do GNU-style
dnl visibility attributes for symbol export control
dnl
CHAFA_VISIBILITY_CFLAGS=""
case "$host" in
*-*-mingw*)
dnl On mingw32 we do -fvisibility=hidden and __declspec(dllexport)
AC_DEFINE([_CHAFA_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
[Defines how to decorate public symbols while building])
CHAFA_VISIBILITY_CFLAGS="-fvisibility=hidden"
;;
*)
dnl On other compilers, check if we can do -fvisibility=hidden
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="-fvisibility=hidden"
AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0]])],[AC_MSG_RESULT(yes)
enable_fvisibility_hidden=yes],[AC_MSG_RESULT(no)
enable_fvisibility_hidden=no])
CFLAGS="${SAVED_CFLAGS}"
AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
AC_DEFINE([_CHAFA_EXTERN], [__attribute__((visibility("default"))) extern],
[Defines how to decorate public symbols while building])
CHAFA_VISIBILITY_CFLAGS="-fvisibility=hidden"
])
;;
esac
dnl
dnl We're not picky about floating point behavior, and this makes e.g.
dnl lrintf() a lot faster.
dnl
AX_CHECK_COMPILE_FLAG([-ffast-math],
[BASE_CFLAGS="$BASE_CFLAGS -ffast-math"],
,
[-Werror])
dnl --- ImageMagick checks ---
dnl ImageMagick 6 needs #include <wand/MagickWand.h>
dnl ImageMagick 7 needs #include <MagickWand/MagickWand.h>
SAVED_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CFLAGS $MAGICKWAND_CFLAGS"
AC_CHECK_HEADERS([wand/MagickWand.h])
AC_CHECK_HEADERS([MagickWand/MagickWand.h])
CPPFLAGS=$SAVED_CPPFLAGS
AC_MSG_CHECKING(for 4-arg MagickResizeImage)
SAVED_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $MAGICKWAND_CFLAGS"
SAVED_LDFLAGS=$LDFLAGS
LDFLAGS="$MAGICKWAND_LIBS $LDFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_WAND_MAGICKWAND_H
# include <wand/MagickWand.h>
#else
# include <MagickWand/MagickWand.h>
#endif
]], [[MagickResizeImage (0, 0, 0, 0);]])],
AC_DEFINE([HAVE_MAGICK_RESIZE_IMAGE_4], [1], [Define if MagickResizeImage takes 4 arguments.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS=$SAVED_CFLAGS
LDFLAGS=$SAVED_LDFLAGS
AC_MSG_CHECKING(for 5-arg MagickResizeImage)
SAVED_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $MAGICKWAND_CFLAGS"
SAVED_LDFLAGS=$LDFLAGS
LDFLAGS="$MAGICKWAND_LIBS $LDFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_WAND_MAGICKWAND_H
# include <wand/MagickWand.h>
#else
# include <MagickWand/MagickWand.h>
#endif
]], [[MagickResizeImage (0, 0, 0, 0, 1.0);]])],
AC_DEFINE([HAVE_MAGICK_RESIZE_IMAGE_5], [1], [Define if MagickResizeImage takes 5 arguments.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS=$SAVED_CFLAGS
LDFLAGS=$SAVED_LDFLAGS
AC_MSG_CHECKING(for MagickAutoOrientImage)
SAVED_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $MAGICKWAND_CFLAGS"
SAVED_LDFLAGS=$LDFLAGS
LDFLAGS="$MAGICKWAND_LIBS $LDFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_WAND_MAGICKWAND_H
# include <wand/MagickWand.h>
#else
# include <MagickWand/MagickWand.h>
#endif
]], [[MagickAutoOrientImage (0);]])],
AC_DEFINE([HAVE_MAGICK_AUTO_ORIENT_IMAGE], [1], [Define if we have MagickAutoOrientImage.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS=$SAVED_CFLAGS
LDFLAGS=$SAVED_LDFLAGS
dnl --- Set compiler flags ---
dnl Disable some LodePNG features. In particular, the CRC feature, which would
dnl sometimes cause valid images to not load because of issues in the
dnl encoding software.
LODEPNG_FEATURES="\
-DLODEPNG_NO_COMPILE_ENCODER \
-DLODEPNG_NO_COMPILE_DISK \
-DLODEPNG_NO_COMPILE_CPP \
-DLODEPNG_NO_COMPILE_CRC"
LODEPNG_CFLAGS="$BASE_CFLAGS $LODEPNG_FEATURES"
LODEPNG_LDFLAGS="$CHAFA_BDYNAMIC_FLAGS"
LIBNSGIF_CFLAGS="$BASE_CFLAGS"
LIBNSGIF_LDFLAGS="$CHAFA_BDYNAMIC_FLAGS"
LIBCHAFA_CFLAGS="$BASE_CFLAGS $CHAFA_VISIBILITY_CFLAGS"
LIBCHAFA_LDFLAGS="$CHAFA_BDYNAMIC_FLAGS"
CHAFA_CFLAGS="$BASE_CFLAGS $CHAFA_VISIBILITY_CFLAGS $LODEPNG_FEATURES"
CHAFA_LDFLAGS="$CHAFA_BDYNAMIC_FLAGS"
AC_SUBST(LODEPNG_CFLAGS)
AC_SUBST(LODEPNG_LDFLAGS)
AC_SUBST(LIBNSGIF_CFLAGS)
AC_SUBST(LIBNSGIF_LDFLAGS)
AC_SUBST(LIBCHAFA_CFLAGS)
AC_SUBST(LIBCHAFA_LDFLAGS)
AC_SUBST(CHAFA_CFLAGS)
AC_SUBST(CHAFA_LDFLAGS)
AC_ARG_ENABLE(rpath,
[AS_HELP_STRING([--enable-rpath],
[use rpath [default=no]])])
AM_CONDITIONAL(ENABLE_RPATH, test "$enable_rpath" == yes)
dnl --- Output ---
AC_CONFIG_FILES([Makefile
chafa/Makefile
chafa/chafaconfig.h
chafa/internal/Makefile
chafa/internal/smolscale/Makefile
libnsgif/Makefile
lodepng/Makefile
chafa.pc
docs/Makefile
docs/version.xml
tests/Makefile
tests/data/Makefile
tests/data/bad/Makefile
tests/data/good/Makefile
tools/Makefile
tools/chafa/Makefile
tools/fontgen/Makefile])
AC_OUTPUT
dnl --- Print a neatly colorized summary ---
colorize_vars="
enable_man
ac_cv_mmx_intrinsics
ac_cv_sse41_intrinsics
ac_cv_avx2_intrinsics
ac_cv_popcnt32_intrinsics
ac_cv_popcnt64_intrinsics
with_tools
with_imagemagick
with_jpeg
with_svg
with_tiff
with_webp
"
dnl Only use colors if the terminal supports the aixterm-style bright ones (16 total).
cols=$(tput colors 2>/dev/null)
if test ${cols:--1} -ge 16; then
normal=$(tput sgr0)
red=$(tput setaf 9)
green=$(tput setaf 10)
yellow=$(tput setaf 11)
blue=$(tput setaf 12)
pyes=${green}yes${normal}
pno=${red}no${normal}
pyno=${yellow}no${normal}
else
normal=
red=
green=
yellow=
blue=
pyes=yes
pno=no
pyno=no
fi
dnl Gross. At least make sure eval arguments are sanitized.
for i in $colorize_vars; do
eval state=\$$i
if test x$state != xno; then state=yes; fi
eval p$i=\$p$state
done
dnl gtk-doc needs special handling; since docs come pregenerated in the tarball, "no"
dnl here is less critical, so use a different color. Also, enable_gtk_doc can be empty.
if test x$enable_gtk_doc = xyes; then
penable_gtk_doc=$pyes
else
penable_gtk_doc=$pyno
fi
echo >&AS_MESSAGE_FD $normal
echo >&AS_MESSAGE_FD "Build man page .............. $penable_man"
echo >&AS_MESSAGE_FD "Rebuild API documentation ... $penable_gtk_doc (--enable-gtk-doc)"
echo >&AS_MESSAGE_FD "Support MMX ................. $pac_cv_mmx_intrinsics"
echo >&AS_MESSAGE_FD "Support SSE 4.1 ............. $pac_cv_sse41_intrinsics"
echo >&AS_MESSAGE_FD "Support AVX2 ................ $pac_cv_avx2_intrinsics"
echo >&AS_MESSAGE_FD "Support popcount32 .......... $pac_cv_popcnt32_intrinsics"
echo >&AS_MESSAGE_FD "Support popcount64 .......... $pac_cv_popcnt64_intrinsics"
echo >&AS_MESSAGE_FD
echo >&AS_MESSAGE_FD "Build command-line tool ..... $pwith_tools"
if test "x$with_tools" != xno; then
echo >&AS_MESSAGE_FD "With GIF loader ............. $pyes (internal)"
echo >&AS_MESSAGE_FD "With ImageMagick loader ..... $pwith_imagemagick"
echo >&AS_MESSAGE_FD "With JPEG loader ............ $pwith_jpeg"
echo >&AS_MESSAGE_FD "With PNG loader ............. $pyes (internal)"
echo >&AS_MESSAGE_FD "With SVG loader ............. $pwith_svg"
echo >&AS_MESSAGE_FD "With TIFF loader ............ $pwith_tiff"
echo >&AS_MESSAGE_FD "With WebP loader ............ $pwith_webp"
echo >&AS_MESSAGE_FD "With XWD loader ............. $pyes (internal)"
fi
echo >&AS_MESSAGE_FD
echo >&AS_MESSAGE_FD "Install prefix .............. $blue$prefix$normal"
echo >&AS_MESSAGE_FD
echo >&AS_MESSAGE_FD "You can now type ${blue}gmake${normal} or ${blue}make${normal} to build the project."
dnl --- Warn about missing dependencies ---
dnl Remove leading spaces.
missing_rpms=$(echo $missing_rpms | sed 's/^ *//')
missing_debs=$(echo $missing_debs | sed 's/^ *//')
if test "x$missing_rpms" != x; then
echo >&AS_MESSAGE_FD
echo >&AS_MESSAGE_FD "Some optional libraries were not found. You may want to install these and"
echo >&AS_MESSAGE_FD "run configure again (package names may be different on your system)."
echo >&AS_MESSAGE_FD
echo >&AS_MESSAGE_FD "On Fedora, openSUSE or similar:"
echo >&AS_MESSAGE_FD "${blue}${missing_rpms}${normal}"
echo >&AS_MESSAGE_FD
echo >&AS_MESSAGE_FD "On Debian, Ubuntu or similar:"
echo >&AS_MESSAGE_FD "${blue}${missing_debs}${normal}"
echo >&AS_MESSAGE_FD
fi