forked from ArtifexSoftware/ghostpdl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
3707 lines (3235 loc) · 116 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
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
dnl Copyright (C) 2001-2021 Artifex Software, Inc.
dnl All Rights Reserved.
dnl
dnl This software is provided AS-IS with no warranty, either express or
dnl implied.
dnl
dnl This software is distributed under license and may not be copied,
dnl modified or distributed except as expressly authorized under the terms
dnl of the license contained in the file LICENSE in this distribution.
dnl
dnl Refer to licensing information at http://www.artifex.com or contact
dnl Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
dnl CA 94945, U.S.A., +1(415)492-9861, for further information.
dnl Process this file with autoconf to produce a configure script
dnl ------------------------------------------------
dnl Initialization and Versioning
dnl ------------------------------------------------
AC_INIT
AC_PREREQ([2.63])
AC_LANG(C)
AC_CONFIG_SRCDIR(psi/gs.c)
AC_CANONICAL_HOST
dnl Inherit compiler flags from the environment...
CFLAGS="${CFLAGS:=}"
CPPFLAGS="${CPPFLAGS:=}"
CXXFLAGS="${CXXFLAGS:=}"
LDFLAGS="${LDFLAGS:=}"
if test x"$host" != x"$build" ; then
CFLAGSAUX="${CFLAGSAUX:=}"
CPPFLAGSAUX="${CPPFLAGSAUX:=}"
LDFLAGSAUX="${LDFLAGSAUX:=}"
else
CFLAGSAUX="${CFLAGSAUX:-$CFLAGS}"
CPPFLAGSAUX="${CPPFLAGSAUX:-$CPPFLAGS}"
LDFLAGSAUX="${LDFLAGSAUX:-$LDFLAGS}"
fi
THEMAKEFILE="${MAKEFILE:-Makefile}"
AUXFLAGS_MAK=auxflags.mak
ARCH_AUTOCONF_HEADER=arch-config/arch_autoconf.h
ARCH_AUTOCONF_HEADER_PROTO=arch/arch_autoconf.h.in
dnl --------------------------------------------------
dnl Local utilities
dnl --------------------------------------------------
dnl GS_SPLIT_LIBS( LIBS, LINKLINE )
dnl Split a unix-style link line into a list of
dnl bare library names. For example, the line
dnl '-L/usr/X11R6/lib -lX11 -lXt' splits into
dnl LIB='X11 Xt'
dnl
AC_DEFUN([GS_SPLIT_LIBS], [
# the makefile wants a list of just the library names
for gs_item in $2; do
gs_stripped_item=`echo "$gs_item" | sed -e 's/^-l//'`
if test "x$gs_stripped_item" != "x$gs_item"; then
$1="$[$1] $gs_stripped_item"
fi
done
])
dnl GS_SPLIT_LIBPATHS( LIBPATHS, LINKLINE )
dnl Split a unix-style link line into a list of
dnl bare search path entries. For example,
dnl '-L/usr/X11R6/lib -lX11 -L/opt/lib -lXt'
dnl splits to LIBPATHS='/usr/X11R6/lib /opt/lib'
dnl
AC_DEFUN([GS_SPLIT_LIBPATHS], [
for gs_item in $2; do
gs_stripped_item=`echo "$gs_item" | sed -e 's/-L//'`
if test "x$gs_stripped_item" != "x$gs_item"; then
$1="$[$1] $gs_stripped_item"
fi
done
])
dnl --------------------------------------------------
dnl Check for programs
dnl --------------------------------------------------
dnl AC_PROG_CC likes to add '-g -O2' to CFLAGS. however,
dnl we ignore those flags and construct our own.
save_cflags="$CFLAGS"
AC_PROG_CC
AC_PROG_CPP
CFLAGS="$save_cflags"
AUXFLAGS_MAK_LINE00="CCAUX=@CC@"
AUXFLAGS_MAK_LINE01="GCFLAGSAUX=@CPPFLAGS@ @GCFLAGS@ @CFLAGS@"
AUXFLAGS_MAK_LINE02="CAPOPTAUX="
AUXFLAGS_MAK_LINE03="CFLAGSAUX_STANDARD=@OPT_CFLAGS@"
AUXFLAGS_MAK_LINE04="CFLAGSAUX_DEBUG=@DBG_CFLAGS@"
AUXFLAGS_MAK_LINE05="CFLAGSAUX_PROFILE=-pg @OPT_CFLAGS@"
AUXFLAGS_MAK_LINE06="LDFLAGSAUX=@LDFLAGS@"
AUXFLAGS_MAK_LINE07="AUXEXTRALIBS=@LIBS@"
GCFLAGSAUXTMP="\$(GCFLAGS)"
CAPOPTAUXTMP="\$(CAPOPT)"
CFLAGSAUX_STANDARDTMP="\$(CFLAGS_STANDARD)"
CFLAGSAUX_DEBUGTMP="\$(CFLAGS_DEBUG)"
CFLAGSAUX_PROFILETMP="\$(CFLAGS_PROFILE)"
LDFLAGSAUXTMP="\$(LDFLAGS)"
AUXEXTRALIBSTMP="\$(EXTRALIBS)"
# purposefully do not include "help" output for this
AC_ARG_ENABLE([save_confaux])
AC_ARG_ENABLE([auxtools_only])
absolute_source_path=$(cd "$(dirname "$0")" && pwd)
if test x"$host" != x"$build" ; then
# rerun configure for the AUX tools, disabling a load of tests not relevant for CCAUX
olddir=`pwd`
if test x"$enable_save_confaux" = x"yes"; then
CONFAUXDIR=auxtmp
else
CONFAUXDIR=auxtmp$RANDOM$RANDOM
fi
mkdir $CONFAUXDIR
cd $CONFAUXDIR
echo -e $AUXFLAGS_MAK_CONTENTS > $AUXFLAGS_MAK.in
echo $AUXFLAGS_MAK_LINE00 > $AUXFLAGS_MAK.in
echo $AUXFLAGS_MAK_LINE01 >> $AUXFLAGS_MAK.in
echo $AUXFLAGS_MAK_LINE02 >> $AUXFLAGS_MAK.in
echo $AUXFLAGS_MAK_LINE03 >> $AUXFLAGS_MAK.in
echo $AUXFLAGS_MAK_LINE04 >> $AUXFLAGS_MAK.in
echo $AUXFLAGS_MAK_LINE05 >> $AUXFLAGS_MAK.in
echo $AUXFLAGS_MAK_LINE06 >> $AUXFLAGS_MAK.in
echo $AUXFLAGS_MAK_LINE07 >> $AUXFLAGS_MAK.in
AC_MSG_NOTICE([Begin recursive call to configure script (for auxiliary tools)])
"$absolute_source_path/configure" CC="$CCAUX" CFLAGS="$CFLAGSAUX" CPPFLAGS="$CPPFLAGSAUX" LDFLAGS="$LDFLAGSAUX" CCAUX= CFLAGSAUX= CFLAGSAUX= MAKEFILE=$AUXFLAGS_MAK --host=$build --build=$build --enable-auxtools_only --disable-hidden-visibility --with-local-zlib --without-libtiff --disable-contrib --disable-fontconfig --disable-dbus --disable-freetype --disable-fapi --disable-cups --disable-openjpeg --disable-gtk --with-libiconv=no --without-libidn --without-libpaper --without-pdftoraster --without-ijs --without-jbig2dec --without-x --with-drivers=""
status=$?
cp config.log "$olddir/configaux.log"
if test $status -eq 0 ; then
CCAUX=$(grep CCAUX $AUXFLAGS_MAK | sed "s/CCAUX=//g")
GCFLAGSAUXTMP=$(grep GCFLAGSAUX $AUXFLAGS_MAK | sed "s/GCFLAGSAUX=//g")
CAPOPTAUXTMP=$(grep CAPOPTAUX $AUXFLAGS_MAK | sed "s/CAPOPTAUX=//g")
CFLAGSAUX_STANDARDTMP=$(grep CFLAGSAUX_STANDARD $AUXFLAGS_MAK | sed "s/CFLAGSAUX_STANDARD=//g")
CFLAGSAUX_DEBUGTMP=$(grep CFLAGSAUX_DEBUG $AUXFLAGS_MAK | sed "s/CFLAGSAUX_DEBUG=//g")
CFLAGS_PROFILETMP=$(grep CFLAGS_PROFILE $AUXFLAGS_MAK | sed "s/CFLAGS_PROFILE=//g")
LDFLAGSAUXTMP=$(grep LDFLAGSAUX $AUXFLAGS_MAK | sed "s/LDFLAGSAUX=//g")
AUXEXTRALIBSTMP=$(grep AUXEXTRALIBS$ $AUXFLAGS_MAK | sed "s/AUXEXTRALIBS$=//g")
fi
cd "$olddir"
if test x"$enable_save_confaux" != x"yes"; then
rm -rf $CONFAUXDIR
fi
if test $status -ne 0 ; then
AC_MSG_ERROR([Recursive call to configure script failed], $status)
else
AC_MSG_NOTICE([Recursive call to configure script succeeded])
fi
fi
GCFLAGSAUX=$GCFLAGSAUXTMP
CAPOPTAUX=$CAPOPTAUXTMP
CFLAGSAUX_STANDARD=$CFLAGSAUX_STANDARDTMP
CFLAGSAUX_DEBUG=$CFLAGSAUX_DEBUGTMP
CFLAGS_PROFILE=$CFLAGS_PROFILETMP
LDFLAGSAUX=$LDFLAGSAUXTMP
AUXEXTRALIBS=$AUXEXTRALIBSTMP
# we have to do this here in case it took
# AC_PROG_CC to set CC (as it usually does)
CCAUX="${CCAUX:-$CC}"
AC_PROG_SED
dnl See if it is GNU sed or else.
dnl - need more work to tell SED features.
SED_EXTENDED_REGEX_OPT=-nre
sed_variant=`sed --version 2>&1`
sed_variant=`echo $sed_variant|sed -e 's/ .*//'`
if test "$sed_variant" != GNU ; then
SED_EXTENDED_REGEX_OPT=-nEe
fi
AC_SUBST(SED_EXTENDED_REGEX_OPT)
AC_PROG_RANLIB
#AC_PROG_INSTALL
# If the caller has gives a specific pkg-config to use, then
# use it, and skip the tests.
if test x"$PKGCONFIG" != x"" ; then
AC_MSG_NOTICE([Using $PKGCONFIG])
else
# this is an unpleasant hack
# but if we are cross compiling, and there isn't a matching
# pkconfig for the --host setting, then don't use the 'local'
# pkconfig at all
AC_PATH_TOOL(PKGCONFIG, pkg-config)
if test x"$host" != x"$build" ; then
dnl pkg-config is used for several tests now...
AC_PATH_PROG(BUILD_PKGCONFIG, pkg-config)
if test x"$BUILD_PKGCONFIG" = x"$PKGCONFIG" ; then
PKGCONFIG=
fi
fi
fi
AC_PATH_TOOL(STRIP_XE, strip)
# this is an unpleasant hack
# but if we are cross compiling, and there isn't a matching
# pkconfig for the --host setting, then don't use the 'local'
# pkconfig at all
if test x"$host" != x"$build" ; then
AC_PATH_PROG(BUILD_STRIP_XE, strip)
if test x"$BUILD_STRIP_XE" = x"$STRIP_XE" ; then
STRIP_XE=
fi
fi
dnl --------------------------------------------------
dnl Allow excluding the contributed drivers
dnl --------------------------------------------------
AC_ARG_ENABLE([contrib], AS_HELP_STRING([--disable-contrib], [Do not include contributed drivers]))
CONTRIBINCLUDE="include $srcdir/contrib/contrib.mak"
INSTALL_CONTRIB="install-contrib-extras"
if test x"$enable_contrib" = x; then
case $host in
*-mingw*|*-msys*)
AC_MSG_WARN([disabling contrib devices])
enable_contrib=no
;;
*)
;;
esac
fi
if test x"$enable_contrib" != x"no"; then
# This is just an arbitrary file in contrib to check
if test -f $srcdir/contrib/gdevbjc_.c; then
enable_contrib=yes
else
enable_contrib=no
fi
fi
if test x$enable_contrib = xno; then
CONTRIBINCLUDE=""
INSTALL_CONTRIB=""
CFLAGS="$CFLAGS -DNOCONTRIB"
fi
AC_SUBST(CONTRIBINCLUDE)
AC_SUBST(INSTALL_CONTRIB)
dnl --------------------------------------------------
dnl Set build flags based on environment
dnl --------------------------------------------------
CC_OPT_FLAGS_TO_TRY="-O -DNDEBUG"
CC_VISIBILITY_FLAGS_TO_TRY=""
SET_DT_SONAME="-soname="
CFLAGS_LARGEFILE=""
case $host in
*-linux*|*-gnu)
if test x"$GCC" = x"yes"; then
CC_OPT_FLAGS_TO_TRY="-O2 -DNDEBUG"
CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
CC_VISIBILITY_FLAGS_TO_TRY="-fvisibility=hidden"
fi
;;
*bsd*)
if test x"$GCC" = x"yes"; then
CC_OPT_FLAGS_TO_TRY="-O2 -DNDEBUG"
CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
CC_VISIBILITY_FLAGS_TO_TRY="-fvisibility=hidden"
fi
;;
*-darwin*)
if test x"$GCC" = x"yes"; then
CC_OPT_FLAGS_TO_TRY="-O2 -DNDEBUG"
CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
CC_VISIBILITY_FLAGS_TO_TRY="-fvisibility=hidden"
fi
SET_DT_SONAME=""
;;
*-mingw*|*-msys*)
if test x"$GCC" = x"yes"; then
CC_OPT_FLAGS_TO_TRY="-O2 -DNDEBUG"
CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
CC_VISIBILITY_FLAGS_TO_TRY="-fvisibility=hidden"
fi
SET_DT_SONAME=""
;;
*-sun*|*-solaris*)
CC_OPT_FLAGS_TO_TRY="-O2 -DNDEBUG"
CFLAGS_LARGEFILE="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
# the trailing space is required!
if test $GCC = no; then
SET_DT_SONAME="-h "
fi
if test x"$GCC" = x"yes"; then
CC_OPT_FLAGS_TO_TRY="-O2 -DNDEBUG"
CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
CC_VISIBILITY_FLAGS_TO_TRY="-fvisibility=hidden"
else
CC_DBG_FLAGS_TO_TRY="-g -O0"
fi
;;
*-aix*)
if test x"$GCC" = x"yes"; then
CC_OPT_FLAGS_TO_TRY="-O2 -DNDEBUG"
CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
SET_DT_SONAME="so"
CC_VISIBILITY_FLAGS_TO_TRY="-fvisibility=hidden"
fi
;;
esac
AC_SUBST(SET_DT_SONAME)
if test x"$GCC" = x"yes"; then
cflags_to_try="-Wall -Wstrict-prototypes -Wundef \
-Wmissing-declarations -Wmissing-prototypes -Wwrite-strings \
-fno-strict-aliasing -Werror=declaration-after-statement \
-fno-builtin -fno-common -Werror=return-type $CFLAGS_LARGEFILE"
optflags_to_try="$CC_OPT_FLAGS_TO_TRY"
dbgflags_to_try="$CC_DBG_FLAGS_TO_TRY"
else
cflags_to_try="$CFLAGS_LARGEFILE"
optflags_to_try="$CC_OPT_FLAGS_TO_TRY"
dbgflags_to_try="$CC_DBG_FLAGS_TO_TRY"
fi
AC_MSG_CHECKING([if compiler supports restrict])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if defined(__STDC_VERSION__) && __STDC_VERSION__ == 199901L
void test (char * restrict p){}
#else
void test (char * __restrict p){}
#endif
]], [[
#if defined(__STDC_VERSION__) && __STDC_VERSION__ == 199901L
char *restrict t;
#else
char * __restrict t;
#endif
test(t);
return 1;
]])],[
CFLAGS="$CFLAGS -DHAVE_RESTRICT=1"
if test x"$host" = x"$build" ; then
CFLAGSAUX="$CFLAGSAUX -DHAVE_RESTRICT=1"
fi
AC_MSG_RESULT([yes])],[
CFLAGS="$CFLAGS -DHAVE_RESTRICT=0"
if test x"$host" = x"$build" ; then
CFLAGSAUX="$CFLAGSAUX -DHAVE_RESTRICT=0"
fi
AC_MSG_RESULT([no])])
AC_ARG_WITH([arch_h], AS_HELP_STRING([--with-arch_h=<arch.h to use>],
[Use a custom arch.h (must be an absolute path)]),[], [with_arch_h=])
ARCH_CONF_HEADER=
if test x"$with_arch_h" = x""; then
case $host in
x86_64*-mingw*|x86_64*-msys*)
ARCH_CONF_HEADER="\$(GLSRCDIR)/../arch/windows-x64-msvc.h"
;;
*-mingw*|*-msys*)
ARCH_CONF_HEADER="\$(GLSRCDIR)/../arch/windows-x86-msvc.h"
;;
*-darwin*)
ARCH_CONF_HEADER="\$(GLSRCDIR)/../arch/osx-x86-x86_64-ppc-gcc.h"
;;
*)
ARCH_CONF_HEADER=
if test x"$host" != x"$build"; then
ARCH_CONF_HEADER="\$(GLSRCDIR)/../$ARCH_AUTOCONF_HEADER"
else
ARCH_CONF_HEADER=
fi
;;
esac
else
ARCH_CONF_HEADER=$with_arch_h
fi
AC_SUBST(ARCH_CONF_HEADER)
# debug configurarion is available by default with "make debug"
#AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug],
# [turn on debugging]))
#if test x$enable_debug = xyes; then
# optflags_to_try="-g"
# CFLAGS="-DDEBUG $CFLAGS"
#fi
# NOTE: To correctly disable GCC's strict aliasing with '-fno-strict-aliasing'
# option, the 'cflags_to_try' have to be checked after 'optflags_to_try'.
AC_MSG_CHECKING([supported compiler flags])
old_cflags=$CFLAGS
for flag in $optflags_to_try; do
CFLAGS="$CFLAGS $flag"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[
echo " $flag"
OPT_CFLAGS="$OPT_CFLAGS $flag"
],[])
CFLAGS=$old_cflags
done
for flag in $cflags_to_try; do
CFLAGS="$CFLAGS $flag"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[
echo " $flag"
GCFLAGS="$GCFLAGS $flag"
],[])
CFLAGS=$old_cflags
done
old_cflags=$CFLAGS
for flag in $dbgflags_to_try; do
CFLAGS="$CFLAGS $flag"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[
echo " $flag"
DBG_CFLAGS="$DBG_CFLAGS $flag"
],[])
CFLAGS=$old_cflags
done
CFLAGS_VISIBILITY=""
for flag in $CC_VISIBILITY_FLAGS_TO_TRY; do
CFLAGS="$CFLAGS $flag"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[
echo " $flag"
CFLAGS_VISIBILITY="$CFLAGS_VISIBILITY $flag"
],[])
CFLAGS=$old_cflags
done
AC_MSG_RESULT([ ...done.])
dnl ----------------------------
dnl check for sanitize support
dnl ----------------------------
AC_MSG_CHECKING([compiler/linker address santizer support])
AC_ARG_WITH([sanitizer], AS_HELP_STRING([--with-sanitizer=@<:@address/memory@:>@],
[Sanitizer for 'sanitize' target (defaults to 'address')]),
[SANITIZER=$with_sanitizer], [SANITIZER=address])
CFLAGS_SANITIZE=""
CFLAGS_SANITIZE_TRY="-fsanitize=$SANITIZER -fno-omit-frame-pointer"
CFLAGS_SAVED="$CFLAGS"
CFLAGS="$CFLAGS_SANITIZE_TRY"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <stdio.h>], [
return(0);
])],
[CFLAGS_SANITIZE="$CFLAGS"],
[
if test x"$with_sanitizer" != x; then
AC_MSG_ERROR([--with-sanitizer=$with_sanitizer not supported by compiler])
else
CFLAGS_SANITIZE="'****************ADDRESS_SANITIZER_NOT_SUPPORTED*********************'"
fi
]
)
CFLAGS="$CFLAGS_SAVED"
AC_MSG_RESULT([ ...done.])
dnl ----------------------------
dnl check for sanitize build warnings support
dnl ----------------------------
AC_MSG_CHECKING([compiler/linker address santizer build warnings support])
CFLAGS_SANITIZE_TRY="$CFLAGS_SANITIZE -W -Wall -Wno-unused-parameter -Wno-sign-compare -Wno-implicit-fallthrough -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-old-style-declaration -Wno-unused-but-set-parameter"
CFLAGS_SAVED="$CFLAGS"
CFLAGS="$CFLAGS_SANITIZE_TRY"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <stdio.h>], [
return(0);
])],
[CFLAGS_SANITIZE="$CFLAGS"], [echo 'extra warnings not supported'])
CFLAGS="$CFLAGS_SAVED"
AC_MSG_RESULT([ ...done.])
dnl ----------------------------
dnl check for big/little endian
dnl ----------------------------
AC_C_BIGENDIAN([BIGENDIAN=1], [BIGENDIAN=0],
[AC_MSG_ERROR([Endian status cannot be determined])],
[AC_MSG_ERROR([Building of universal binaries is not implemented.])])
dnl --------------------------------------------------
dnl check for sse2 intrinsics
dnl --------------------------------------------------
AC_MSG_CHECKING([sse2 support])
save_cflags=$CFLAGS
CFLAGS="$CFLAGS $OPT_CFLAGS"
HAVE_SSE2=""
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <emmintrin.h>], [
__m128i input1;
unsigned char buf1[[128]];
input1 = _mm_loadu_si128((const __m128i *)buf1);
return(0);
])],
[HAVE_SSE2="-DHAVE_SSE2"], [HAVE_SSE2=""])
AC_ARG_ENABLE([sse2], AS_HELP_STRING([--disable-sse2],
[Do not use sse2 instrinsics]), [
if test "x$enable_sse2" = xno; then
HAVE_SSE2=""
fi])
if test "x$HAVE_SSE2" != x; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_SUBST(HAVE_SSE2)
CFLAGS=$save_cflags
dnl --------------------------------------------------
dnl Check for headers
dnl --------------------------------------------------
AC_HEADER_DIRENT
AC_CHECK_HEADERS([errno.h fcntl.h limits.h malloc.h memory.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/time.h sys/times.h syslog.h unistd.h dirent.h ndir.h sys/dir.h sys/ndir.h inttypes.h])
dnl --------------------------------------------------
dnl Sun, BSD possibly other makes don't have quite the
dnl feature set of GNU make. We still prefer GNU make,
dnl but......
dnl --------------------------------------------------
OBJDIR_BSDMAKE_WORKAROUND=obj
SUB_MAKE_OPTION=
ORDER_ONLY=""
AC_MSG_CHECKING(if make is GNU make)
if make --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then
AC_MSG_RESULT(yes)
SUB_MAKE_OPTION="-f \$(MAKEFILE)"
ORDER_ONLY="|"
else
AC_MSG_RESULT(no)
# BSD Make treats obj special and cd into it first
OBJDIR_BSDMAKEWORKAOROUND="notobj"
fi
AC_SUBST(OBJDIR_BSDMAKE_WORKAROUND)
AC_SUBST(ORDER_ONLY)
AC_SUBST(SUB_MAKE_OPTION)
AC_CHECK_HEADER([sys/window.h])
dnl --------------------------------------------------
dnl Check for typedefs, structures, etc
dnl --------------------------------------------------
AC_C_CONST
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_STRUCT_ST_BLOCKS
AC_STRUCT_TM
dnl see if we're on a system that puts the *int*_t types
dnl from stdint.h in sys/types.h
if test "x$ac_cv_header_stdint_h" != xyes; then
AC_CHECK_TYPES([int8_t, int16_t, int32_t, uint8_t, uint16_t, uint32_t],,,[#include <sys/types.h>])
if test "$ac_cv_type_uint8_t" = yes; then
AC_DEFINE([SYS_TYPES_HAS_STDINT_TYPES])
GCFLAGS="$GCFLAGS -DSYS_TYPES_HAS_STDINT_TYPES"
fi
fi
dnl we aren't interested in all of DEFS, so manually insert
dnl the flags we care about
if test "$ac_cv_c_const" != yes; then
GCFLAGS="$GCFLAGS -Dconst="
fi
if test "x$ac_cv_header_stdint_h" = "xyes"; then
GCFLAGS="$GCFLAGS -DHAVE_STDINT_H=1"
fi
if test "x$ac_cv_header_dirent_h" = "xyes"; then
GCFLAGS="$GCFLAGS -DHAVE_DIRENT_H=1"
fi
if test "x$ac_cv_header_ndir_h" = xyes; then
GCFLAGS="$GCFLAGS -DHAVE_NDIR_H=1"
fi
if test "x$ac_cv_header_sys_dir_h" = "xyes"; then
GCFLAGS="$GCFLAGS -DHAVE_SYS_DIR_H=1"
fi
if test "x$ac_cv_header_sys_ndir_h" = "xyes"; then
GCFLAGS="$GCFLAGS -DHAVE_SYS_NDIR_H=1"
fi
if test "x$ac_cv_header_sys_time_h" = "xyes"; then
GCFLAGS="$GCFLAGS -DHAVE_SYS_TIME_H=1"
fi
if test "x$ac_cv_header_sys_times_h" = "xyes"; then
GCFLAGS="$GCFLAGS -DHAVE_SYS_TIMES_H=1"
fi
if test "x$ac_cv_header_inttypes_h" = "xyes"; then
GCFLAGS="$GCFLAGS -DHAVE_INTTYPES_H=1"
fi
AC_CHECK_LIB([dl], [dlopen],
[AC_CHECK_HEADER([dlfcn.h], [GCFLAGS="$GCFLAGS -DHAVE_LIBDL=1";LIBS="-ldl $LIBS"])]
)
large_color_index=1
AC_ARG_WITH([large_color_index],, large_color_index="$with_large_color_index")
if test x"$large_color_index" != "x0"; then
dnl try to find a 64 bit type for devicen color index
color_ind_type="none"
AC_CHECK_SIZEOF(unsigned long long)
if test $ac_cv_sizeof_unsigned_long_long = 8; then
color_ind_type="unsigned long long"
color_ind_size=$ac_cv_sizeof_unsigned_long_long
else
AC_CHECK_SIZEOF(unsigned long int)
if test $ac_cv_sizeof_unsigned_long_int = 8; then
color_ind_type="unsigned long int"
color_ind_size=$ac_cv_sizeof_unsigned_long_int
else
AC_CHECK_SIZEOF(unsigned __int64)
if test $ac_cv_sizeof_unsigned___int64 = 8; then
color_ind_type="unsigned __int64"
color_ind_size=$ac_cv_sizeof_unsigned___int64
else
AC_CHECK_SIZEOF(u_int64_t)
if test $ac_cv_sizeof_u_int64_t = 8; then
color_ind_type="u_int64_t"
color_ind_size=$ac_cv_sizeof_u_int64_t
fi
fi
fi
fi
else
dnl try to find a 32 bit type for devicen color index
color_ind_type="none"
AC_CHECK_SIZEOF(unsigned long int)
if test $ac_cv_sizeof_unsigned_long_int = 4; then
color_ind_type="unsigned long int"
color_ind_size=$ac_cv_sizeof_unsigned_long_int
else
AC_CHECK_SIZEOF(unsigned int)
if test $ac_cv_sizeof_unsigned_int = 4; then
color_ind_type="unsigned int"
color_ind_size=$ac_cv_sizeof_unsigned_int
else
AC_CHECK_SIZEOF(unsigned __int32)
if test $ac_cv_sizeof_unsigned___int32 = 4; then
color_ind_type="unsigned __int32"
color_in_size=$ac_cv_sizeof_unsigned___int32
else
AC_CHECK_SIZEOF(u_int32_t)
if test $ac_cv_sizeof_u_int32_t = 4; then
color_ind_type="u_int32_t"
color_ind_size=$ac_cv_sizeof_u_int32_t
fi
fi
fi
fi
fi
dnl if a suitable type wasn't found above, we fall back to
dnl a default in genarch.
if test "$color_ind_type" != "none"; then
GCFLAGS="$GCFLAGS -DGX_COLOR_INDEX_TYPE=\"$color_ind_type\""
ARCH_SIZEOF_GX_COLOR_INDEX=$color_ind_size
fi
AC_SUBST(ARCH_SIZEOF_GX_COLOR_INDEX)
dnl --------------------------------------------------
dnl Set options that we want to pass into all other
dnl configure scripts we might call
dnl --------------------------------------------------
SUBCONFIG_OPTS="--build=$build --host=$host"
#SUBCONFIG_OPTS=""
#if test x"$build_alias" != x""; then
# SUBCONFIG_OPTS="$SUBCONFIG_OPTS --build=$build_alias"
#fi
#if test x"$host_alias" != x""; then
# SUBCONFIG_OPTS="$SUBCONFIG_OPTS --host=$host_alias"
#fi
dnl --------------------------------------------------
dnl Check for libraries
dnl --------------------------------------------------
AC_CHECK_LIB(m, cos)
AC_CHECK_FUNCS([pread pwrite], [HAVE_PREAD_PWRITE="-DHAVE_PREAD_PWRITE=1"], [HAVE_PREAD_PWRITE=])
if test "x$HAVE_PREAD_PWRITE" != "x"; then
save_cflags=$CFLAGS
CFLAGS="$CFLAGS -D__USE_UNIX98=1 -D_XOPEN_SOURCE=500"
AC_CHECK_DECLS([pwrite,pread], [], [HAVE_PREAD_PWRITE=])
CFLAGS=$save_cflags
if test "x$HAVE_PREAD_PWRITE" != "x"; then
GCFLAGS="$GCFLAGS -D__USE_UNIX98=1"
fi
fi
AC_SUBST(HAVE_PREAD_PWRITE)
AC_CHECK_DECL([popen], [HAVE_POPEN_PROTO="-DHAVE_POPEN_PROTO=1"], [AVE_POPEN_PROTO=])
AC_SUBST(HAVE_POPEN_PROTO)
SYNC="nosync"
PTHREAD_LIBS=""
RECURSIVE_MUTEXATTR=""
AC_ARG_ENABLE([threading], AS_HELP_STRING([--disable-threading],
[disable support for multithreaded rendering]))
# if you haven't got pread/pwrite, we can't use multithreading
if test "x$HAVE_PREAD_PWRITE" != "x"; then
if test "$enable_threading" != "no"; then
mutex_result="no"
AC_CHECK_LIB(pthread, pthread_create, [
SYNC=posync;
PTHREAD_LIBS="-lpthread"
])
AC_MSG_CHECKING([for recursive mutexes])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[
static int k = PTHREAD_MUTEX_RECURSIVE;
#ifndef pthread_mutexattr_settype
#ifdef __cplusplus
(void) pthread_mutexattr_settype;
#else
(void) pthread_mutexattr_settype;
#endif
#endif
;
return 0;
]])],[RECURSIVE_MUTEXATTR="-DGS_RECURSIVE_MUTEXATTR=PTHREAD_MUTEX_RECURSIVE"
mutex_result="PTHREAD_MUTEX_RECURSIVE"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[
static int k = PTHREAD_MUTEX_RECURSIVE_NP;
#ifndef pthread_mutexattr_settype
#ifdef __cplusplus
(void) pthread_mutexattr_settype;
#else
(void) pthread_mutexattr_settype;
#endif
#endif
;
return 0;
]])],[RECURSIVE_MUTEXATTR="-DGS_RECURSIVE_MUTEXATTR=PTHREAD_MUTEX_RECURSIVE_NP"
mutex_result="PTHREAD_MUTEX_RECURSIVE_NP"],[])])
AC_MSG_RESULT($mutex_result)
fi
fi
AC_SUBST(SYNC)
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(RECURSIVE_MUTEXATTR)
dnl Tesseract/Leptonica detection
TESSERACTDIR=tesseract
LEPTONICADIR=leptonica
OCR_VERSION=0
LEPTONICAINCLUDE=
TESSERACTINCLUDE=
TESSERACT_LIBS=
OCR_DEVS=
OCR_DEVS_WARNING_LINE1=
OCR_DEVS_WARNING_LINE2=
AC_ARG_WITH([tesseract], AS_HELP_STRING([--without-tesseract],
[do not try to use the Tesseract library for OCR]))
if test x$with_tesseract != xno; then
AC_MSG_CHECKING([for local Tesseract library source])
if test -d $srcdir/tesseract && test -d $srcdir/leptonica; then
AC_MSG_RESULT([yes])
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[HAVE_CXX_COMPILER=yes; AC_SUBST(CXX)],[HAVE_CXX_COMPILER=no])
if test x$HAVE_CXX_COMPILER != xyes; then
AC_MSG_WARN([Disabling tesseract as no working C++ compiler])
elif test x$SYNC = xnosync ; then
AC_MSG_ERROR([Threading disabled or not available. Tesseract OCR relies on threading. Rerun configure with "--without-tesseract" to exclude OCR from the build])
else
save_cxxflags="$CXXFLAGS"
cxxflags_to_try="-std=c++17 -stdlib=libstdc++"
CXXFLAGS_TO_USE=""
AC_MSG_CHECKING([supported C++ compiler flags])
for flag in $cxxflags_to_try ; do
CXXFLAGS="$CXXFLAGS $flag"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <cstdlib>]], [[return 0;]])],[
echo " $flag"; CXXFLAGS_TO_USE="$CXXFLAGS_TO_USE $flag"
],[])
CXXFLAGS="$old_cflags"
done
if test x"$GXX" = x"no" || echo $CXXFLAGS_TO_USE | grep "std=c++17" ; then
if test x"$GXX" = x"no" ; then
OCR_DEVS_WARNING_LINE1="C++ compiler does not appear to be gcc or compatible, attempting to continue anyway"
OCR_DEVS_WARNING_LINE2="NOTE: that tesseract requires a C++17 compatible C++ compiler"
fi
CXXFLAGS="$save_cxxflags $CXXFLAGS_TO_USE"
dnl --------------------------------------------------
dnl check for sse4.1, avx, avx2 or fma
dnl --------------------------------------------------
AC_MSG_CHECKING([sse4.1 support])
save_cxxflags=$CXXFLAGS
TESS_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -msse4.1"
TESS_SSE4_1=""
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <emmintrin.h>
#include <smmintrin.h>],
[__m128i input1;
unsigned char buf1[[128]];
input1 = _mm_loadu_si128((const __m128i *)buf1);
input1 = _mm_hadd_epi32(input1, input1);
return(0);
])],
[TESS_SSE4_1="-msse4.1"],
[TESS_SSE4_1=""])
if test "x$TESS_SSE4_1" != x; then
AC_MSG_RESULT(yes)
TESS_CXXFLAGS="$TESS_CXXFLAGS -DHAVE_SSE4_1"
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([avx support])
CXXFLAGS="$save_cxxflags -mavx"
TESS_AVX=""
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <immintrin.h>],
[__m256d input1 = _mm256_setzero_pd();
input1 = _mm256_hadd_pd(input1, input1);
return(0);])],
[TESS_AVX="-mavx"],
[TESS_AVX=""])
if test "x$TESS_AVX" != x; then
AC_MSG_RESULT(yes)
TESS_CXXFLAGS="$TESS_CXXFLAGS -DHAVE_AVX"
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([avx2 support])
CXXFLAGS="$save_cxxflags -mavx2"
TESS_AVX2=""
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <immintrin.h>],
[__m256i input1;
unsigned char buf1[[256]];
input1 = _mm256_loadu_si256((const __m256i *)buf1);
input1 = _mm256_adds_epu8(input1, input1);
return(0);])],
[TESS_AVX2="-mavx2"],
[TESS_AVX2=""])
if test "x$TESS_AVX2" != x; then
AC_MSG_RESULT(yes)
TESS_CXXFLAGS="$TESS_CXXFLAGS -DHAVE_AVX2"
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([fma support])
CXXFLAGS="$save_cxxflags -mfma"
TESS_FMA=""
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <immintrin.h>],
[__m256d input1 = _mm256_setzero_pd();
input1 = _mm256_fmadd_pd(input1, input1, input1);
return(0);])],
[TESS_FMA="-mfma"],
[TESS_FMA=""])
if test "x$TESS_FMA" != x; then
AC_MSG_RESULT(yes)
TESS_CXXFLAGS="$TESS_CXXFLAGS -DHAVE_FMA"
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([neon support])
CXXFLAGS="$save_cxxflags -mfpu=neon -mcpu=cortex-a53"
TESS_NEON=""
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include "arm_neon.h"],
[int32x4_t round = vdupq_n_s32(10);
return(0);])],
[TESS_NEON="-mfpu=neon -mcpu=cortex-a53 -D__ARM_NEON__"],
[TESS_NEON=""])
if test "x$TESS_NEON" != x; then
AC_MSG_RESULT(yes)
TESS_CXXFLAGS="$TESS_CXXFLAGS -DHAVE_NEON"
else
AC_MSG_RESULT(no)
fi
CXXFLAGS="$save_cxxflags"
OCR_VERSION=1
OCR_DEVS="\$(DD)ocr.dev \$(DD)hocr.dev \$(DD)pdfocr8.dev \$(DD)pdfocr24.dev \$(DD)pdfocr32.dev"
LEPTONICAINCLUDE="include base/leptonica.mak"
TESSERACTINCLUDE="include base/tesseract.mak"
TESSERACT_LIBS="-lstdc++"
else
OCR_DEVS_WARNING_LINE1="OCR devices disabled due to incompatible compiler: tesseract requires a C++17 compatible compiler"
fi
fi
AC_LANG_POP()
else
AC_MSG_RESULT([no])
fi
fi
AC_SUBST(TESSERACT_LIBS)
AC_SUBST(LEPTONICAINCLUDE)
AC_SUBST(TESSERACTINCLUDE)
AC_SUBST(LEPTONICADIR)
AC_SUBST(TESSERACTDIR)
AC_SUBST(OCR_DEVS)
AC_SUBST(OCR_VERSION)
AC_SUBST(TESS_AVX)
AC_SUBST(TESS_AVX2)
AC_SUBST(TESS_FMA)
AC_SUBST(TESS_SSE4_1)
AC_SUBST(TESS_NEON)
AC_SUBST(TESS_CXXFLAGS)
dnl Tests for iconv (Needed for OpenPrinting Vector, "opvp" output device)
AC_ARG_WITH(libiconv,
[AS_HELP_STRING([--with-libiconv=@<:@no/gnu/native@:>@],
[use the libiconv library])],,
[with_libiconv=maybe])
found_iconv=no
case $with_libiconv in
maybe)
# Check in the C library first
AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
# Check if we have GNU libiconv
if test $found_iconv = "no"; then