-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
executable file
·853 lines (693 loc) · 24.9 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
AC_INIT(X11workbench, 1.0, bobf@mrp3.com, X11workbench)
# check/get base source directory based on a single unique file name
AC_CONFIG_SRCDIR(X11workbench.c)
# output defines to a header file 'X11workbenchToolkit_config.h'
AC_CONFIG_HEADERS([include/X11workbenchToolkit_config.h])
# enable automake using 'more modern' syntax where AC_INIT defines the project and version
AM_INIT_AUTOMAKE
# prereq autoconf 2.53 or later
AC_PREREQ(2.53)
# FYI assuming automake >= 15
# order of search for CC - use 'cc' first, then 'gcc', then 'cl'
# this way the system-defined C compiler will be invoked by default
# TODO: add a configure option to force gcc, clang, Microsoft C, etc.
AC_PROG_CC([cc gcc cl])
# AM_PROG_CC_C_O required based on a warning on a linux box for per-target
# flags on pixmap_helper.c with automake 1.11,and it must be AFTER AC_PROG_CC
AM_PROG_CC_C_O
# consider adding this for make -j support. currently I do my own...
# AX_AM_JOBSERVER([default_value])
# see https://www.gnu.org/software/autoconf-archive/ax_am_jobserver.html
# this will enable the '--enable-jobserver' configure parameter
AC_PROG_RANLIB
AC_PATH_X
AC_PATH_XTRA
AC_TYPE_SIGNAL
AC_PROG_AWK
AC_PROG_LN_S
# check for presence of doxygen
ifdef([XORG_WITH_DOXYGEN],
[
XORG_WITH_DOXYGEN([1.7])
# this sets have_doxygen to yes if doxygen is present
],
[
have_doxygen=no
AM_CONDITIONAL([HAVE_DOXYGEN], [test x$have_doxygen = xyes])
])
# see if I have multiple CPUs (this works on FreeBSD and Linux, not sure about others)
AC_MSG_CHECKING([how many cores the host CPU has])
if test -e conftest.out ; then
rm -f conftest.out
fi
if test -e /proc/cpuinfo ; then
grep -i "^processor" /proc/cpuinfo | wc -l >conftest.out
else
sysctl hw.ncpu | awk '{ print $2; }' >conftest.out
fi
if test -s conftest.out ; then
ac_num_cores=`cat conftest.out`
ac_status=0
rm conftest.out
echo $ac_num_cores
else
ac_status=1
ac_num_cores=1
echo "cannot determine; assuming 1"
fi
# --enable-release (default has debugging enabled)
# --enable-noopt (default is optimization enabled)
# --enable-libXpm (default is NOT to link to libXpm)
# --enable-libXft (default is to link to libXft)
# --enable-libXext (default is to link to libXext)
# --enable-fatalwarn (default is warnings NOT fatal)
AC_ARG_ENABLE(release,
[ --enable-release CUSTOM - Turn off all debugging for release version],
[case "${enableval}" in
yes) release=true ; AC_MSG_RESULT([CONFIGURE INFORMATION: building a RELEASE version]) ;;
no) release=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-release) ;;
esac],
[release=false])
AC_ARG_ENABLE(noopt,
[ --enable-noopt CUSTOM - removes optimized code, useful for debug],
[case "${enableval}" in
yes) noopt=true ; AC_MSG_WARN([code optimization disabled; for debug only]) ;;
no) noopt=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-noopt) ;;
esac],
[noopt=false])
AC_ARG_ENABLE(libXpm,
[ --enable-libXpm CUSTOM - use libXpm, rather than the (faster) internal implementation],
[case "${enableval}" in
yes) libXpm=true ; AC_MSG_WARN([linking with libXpm - this could impact application performance]) ;;
no) libXpm=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-libXpm) ;;
esac],
[libXpm=false])
AC_ARG_ENABLE(libXft,
[ --disable-libXft CUSTOM - do NOT use libXft for 'FreeType' font support and rendering],
[case "${enableval}" in
yes) libXft=true ;;
no) libXft=false ; AC_MSG_WARN([NOT linking with libXft]) ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-libXft) ;;
esac],
[libXft=true])
AC_ARG_ENABLE(libXext,
[ --disable-libXext CUSTOM - do NOT use libXext extensions (such as the shared memory extension)],
[case "${enableval}" in
yes) libXext=true ;;
no) libXext=false ; AC_MSG_WARN([NOT linking with libXext]) ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-libXext) ;;
esac],
[libXext=true])
AC_ARG_ENABLE(fatalwarn,
[ --enable-fatalwarn CUSTOM - cause warnings to be treated as errors],
[case "${enableval}" in
yes) fatalwarn=true ; AC_MSG_RESULT([CONFIGURE INFORMATION: Warnings are now fatal, treated as errors]) ;;
no) fatalwarn=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-fatalwarn) ;;
esac],
[fatalwarn=false])
AM_CONDITIONAL(NO_DEBUG, test x$release = xtrue)
AM_CONDITIONAL(NO_OPT, test x$noopt = xtrue)
AM_CONDITIONAL(FATAL_WARN, test x$fatalwarn = xtrue)
local_incdir="\$(top_srcdir)/include"
local_xpmdir="\$(top_srcdir)/xpm"
if test x$noopt = xtrue ; then
CFLAGS="$CFLAGS -O0 $_X_CFLAGS -I$local_incdir -I$local_xpmdir"
else
CFLAGS="$CFLAGS $X_CFLAGS -I$local_incdir -I$local_xpmdir"
fi
CPPFLAGS="$CPPFLAGS $X_CFLAGS -I$local_incdir -I$local_xpmdir"
CXXFLAGS="$CXXFLAGS $X_CFLAGS -I$local_incdir -I$local_xpmdir"
# TODO: do I need AC_SUBST for CFLAGS, etc. here?
#################################################################
# header file and function checks (some recommended by autoscan)
#################################################################
AC_CHECK_HEADER([unistd.h],[],AC_MSG_ERROR([missing unistd.h]))
AC_CHECK_HEADER([X11/Xlib.h],[],AC_MSG_ERROR([missing Xlib.h - you should install 'xorg-dev' or similar]))
AC_CHECK_HEADER([X11/Xmd.h],[],AC_MSG_ERROR([missing Xmd.h - you need to install the X11 developer packages]))
AC_CHECK_HEADER([X11/Xutil.h],[],AC_MSG_ERROR([missing Xutil.h - you need to install the X11 developer packages]))
AC_CHECK_HEADER([X11/Xatom.h],[],AC_MSG_ERROR([missing Xatom.h - you need to install the X11 developer packages]))
#autoscan recommends
AC_CHECK_HEADERS([fcntl.h])
AC_CHECK_HEADERS([limits.h])
AC_CHECK_HEADERS([locale.h])
AC_CHECK_HEADERS([malloc.h])
AC_CHECK_HEADERS([netinet/in.h])
AC_CHECK_HEADERS([sys/param.h])
AC_CHECK_HEADERS([sys/time.h])
#autoscan recommends
AC_CHECK_HEADER_STDBOOL
#autoscan recommends
AC_C_INLINE
AC_FUNC_CHOWN
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
#autoscan recommends
AC_CHECK_FUNCS([bzero])
AC_CHECK_FUNCS([dup2])
AC_CHECK_FUNCS([ftruncate])
AC_CHECK_FUNCS([getcwd])
AC_CHECK_FUNCS([gettimeofday])
AC_CHECK_FUNCS([mblen])
AC_CHECK_FUNCS([memchr])
AC_CHECK_FUNCS([memmove])
AC_CHECK_FUNCS([mkdir])
AC_CHECK_FUNCS([select])
AC_CHECK_FUNCS([setlocale])
AC_CHECK_FUNCS([strcasecmp])
AC_CHECK_FUNCS([strchr])
AC_CHECK_FUNCS([strncasecmp])
AC_CHECK_FUNCS([strrchr])
AC_CHECK_FUNCS([strstr])
# BSD and clang extensions that might require support for gcc, others
AC_CHECK_FUNCS([strlcpy])
AC_CHECK_FUNCS([strlcat])
# This is where I check for the presence of libXpm - if the configure script uses the
# option '--enable-libXpm' then I will test for its presence. Otherwise, the internal
# implementation will be used, at least as far as the libraries are concerned. This
# would not prevent an application from using the pre-compiled libraries and ALSO use
# libXpm. It would only prevent the X11 toolkit library itself from linking to it.
test_have_xpm=false
if test x$libXpm = xtrue ; then
AC_CHECK_HEADER([X11/xpm.h],test_have_xpm=true,AC_MSG_WARN([missing xpm.h - you should consider installing libXpm]))
fi
# This is where I check for libXft - the header will be X11/Xft/Xft.h
# First, make sure freetype2 is available. this also modifies CFLAGS and LDFLAGS
test_have_xft=false
ifdef([AC_CHECK_FT2],
# this is complex so I have indented all of the [] sections to make them visible, even if it's a little ugly
[
if test x$libXft = xtrue ; then
AC_CHECK_FT2([7.0.1],,[libXft=false; AC_MSG_WARN([freetype missing or incompatible version; will not link with libXft])])
fi
if test x$libXft = xtrue ; then
my_save_CFLAGS="$CFLAGS"
my_save_CPPFLAGS="$CPPFLAGS"
my_save_LDFLAGS="$LDFLAGS"
CFLAGS="$CFLAGS $FT2_CFLAGS"
CPPFLAGS="$CPPFLAGS $FT2_CFLAGS"
LDFLAGS="$LDFLAGS -L$ac_x_libraries $FT2_LIBS -lXft"
AC_CHECK_HEADER(
[X11/Xft/Xft.h],
# if the header exists I need to check the version defined in it with a compile
# and I might as well do a test-link while I'm at it
[
AC_LANG_PUSH([C])
AC_MSG_CHECKING([if libXft can link ok and is at least version 2.0])
AC_LINK_IFELSE(
[
AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xft/Xft.h> /* required header for Xft definitions */
#if XFT_VERSION < 20000
#error XFT is too old
#endif
int main()
{
// note that I don't fail this by running it; if X11 is being
// accessed remotely I need to rely on these at run time
// but as an example I leave it just like this
if(XftInit(0) != FcTrue || XftInitFtLibrary() != FcTrue )
{
exit(3);
}
return 0;
}]] )
],
[
AC_MSG_RESULT([yes!!! w00t!!!])
test_have_xft=true
],
[
AC_MSG_RESULT([no])
] )
AC_LANG_POP([C])
],
[
AC_MSG_WARN([***************************************************************************])
AC_MSG_WARN([missing Xft.h - will not be building the toolkit with libXft])
AC_MSG_WARN([ you should consider installing the developer libXft package])
AC_MSG_WARN([***************************************************************************])
])
LDFLAGS="$my_save_LDFLAGS"
CFLAGS="$my_save_CFLAGS"
CPPFLAGS="$my_save_CPPFLAGS"
fi
],
[
AC_MSG_WARN([Freetype M4 macros not installed - do you need the developer package?])
])
test_have_xext=false
if test x$libXext = xtrue ; then
my_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -L$ac_x_libraries"
AC_CHECK_LIB(Xext, XShmQueryExtension,
[
test_have_xext=true
LDFLAGS="$LDFLAGS -lX11 -lXext"
AC_CHECK_HEADER([X11/extensions/XShm.h],
[
AC_CHECK_FUNCS([XShmQueryExtension],
[
AC_DEFINE(X11WORKBENCH_TOOLKIT_HAVE_XSHM_EXTENSION,[1],[whether or not libXext and XShm extensions are available] )
],
[
AC_MSG_WARN([Unable to properly link with libXext for XShmQueryExtension test - are the lib dependencies ok?])
])
],
[
AC_MSG_WARN([***************************************************************************])
AC_MSG_WARN([missing XShm.h - will not be building the toolkit with libXext. You should])
AC_MSG_WARN([ consider installing the developer libXext package])
AC_MSG_WARN([***************************************************************************])
],
[
#include "X11/Xlib.h"
#include "sys/ipc.h"
#include "sys/shm.h"
])
],
[
AC_MSG_WARN([***************************************************************************])
AC_MSG_WARN([missing libXext - you should consider installing it])
AC_MSG_WARN([***************************************************************************])
])
LDFLAGS="$my_save_LDFLAGS"
fi
# check for a few functions that I want to verify exist
AC_CHECK_FUNCS([printf])
AC_CHECK_FUNCS([alarm])
AC_CHECK_FUNCS([memset])
AC_CHECK_FUNCS([nanosleep])
AC_CHECK_FUNCS([dlopen])
# the 'clock_gettime' function might require '-lrt'
AC_CHECK_LIB(rt, clock_gettime,
[
test_need_lrt=true
my_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDLAGS -lrt"
AC_CHECK_FUNCS([clock_gettime])
LDFLAGS="$my_save_LDFLAGS"
],
[
# doing it this way is simpler
AC_CHECK_FUNCS([clock_gettime])
])
# the 'dlopen' function might require '-ldl'
AC_CHECK_LIB(dl, dlopen,
[
test_need_ldl=true
my_save_LDLAGS="$LDFLAGS"
LDFLAGS="$LDLAGS -ldl"
AC_CHECK_FUNCS([dlopen])
LDFLAGS="$my_save_LDLAGS"
],
[
# doing it this way is simpler
AC_CHECK_FUNCS([dlopen])
])
################################
# custom function checks go here
################################
# malloc_usable_size - mostly for debugging purposes, not supported everywhere
AC_CHECK_FUNC(malloc_usable_size, [AC_DEFINE(HAVE_MALLOC_USABLE_SIZE,[1],[whether or not malloc_usable_size is available] ) ])
############################################################################################
# __builtin_expect - see if compiler supports it
my_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_LANG_PUSH([C])
AC_MSG_CHECKING([if the compiler supports __builtin_expect])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
int main()
{
if(__builtin_expect(1 == 1, 1))
{
return 0;
}
exit(3);
return 0;
}]] )],
[
AC_MSG_RESULT([yes])
AC_DEFINE([COMPILER_SUPPORTS_BUILTIN_EXPECT],[1],[Compiler supports __builtin_expect])
],
[
AC_MSG_RESULT([no])
] )
AC_LANG_POP([C])
CFLAGS="$my_save_CFLAGS"
############################################################################################
# __attribute__((unused)) - see if compiler supports it
my_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_LANG_PUSH([C])
AC_MSG_CHECKING([if the compiler supports __attribute__((unused))])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
int main()
{
int iTemp __attribute__((unused)) = 0;
return 0;
}]] )],
[
AC_MSG_RESULT([yes])
AC_DEFINE([COMPILER_SUPPORTS_UNUSED_ATTRIBUTE],[1],[Compiler supports __attribute__((unused))])
],
[
AC_MSG_RESULT([no])
] )
AC_LANG_POP([C])
CFLAGS="$my_save_CFLAGS"
############################################################################################
# #attribute( printf
my_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
compiler_has_attribute_for_printf=no
AC_LANG_PUSH([C])
AC_MSG_CHECKING([if the compiler supports __attribute__((format(printf,n,m))) for functions and -Wformat])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h> /* stdarg to make sure I have va_list and other important stuff */
void WBDebugPrint(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
void WBDebugPrint(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
vfprintf(stderr, fmt, va);
fflush(stderr); // dump NOW before (possibly) crashing
// TODO: log file?
va_end(va);
}
int main()
{
WBDebugPrint("Hello, world %s\n", "testing");
return 0;
}]] )],
[
CFLAGS="$CFLAGS -Wformat"
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h> /* stdarg to make sure I have va_list and other important stuff */
void WBDebugPrint(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
void WBDebugPrint(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
vfprintf(stderr, fmt, va);
fflush(stderr); // dump NOW before (possibly) crashing
// TODO: log file?
va_end(va);
}
int main()
{
WBDebugPrint("Hello, world %s\n", "testing");
return 0;
}]] )],
[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h> /* stdarg to make sure I have va_list and other important stuff */
void WBDebugPrint(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
void WBDebugPrint(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
vfprintf(stderr, fmt, va);
fflush(stderr); // dump NOW before (possibly) crashing
// TODO: log file?
va_end(va);
}
int main()
{
WBDebugPrint("Hello, world %d\n", "testing"); // warning fails this
return 0;
}]] )],
[
# failing the test is 'success' this time through
# and succeeding is a failure (since the warning doesn't work)
AC_MSG_RESULT([no (does not properly support -Wformat)])
compiler_has_attribute_for_printf=no
],
[
AC_MSG_RESULT([yes])
compiler_has_attribute_for_printf=yes
AC_DEFINE([COMPILER_HAS_ATTRIBUTE_FOR_PRINTF],[1],[Compiler supports attributes for 'printf'-like calls])
] )
],
[
AC_MSG_RESULT([no (does not support -Wformat)])
compiler_has_attribute_for_printf=no
] )
],
[
AC_MSG_RESULT([no])
compiler_has_attribute_for_printf=no
] )
AC_LANG_POP([C])
CFLAGS="$my_save_CFLAGS"
# this conditional will cause Makefile.am to enable -Wformat where appropriate
AM_CONDITIONAL(PRINTF_ATTRIBUTE, test x$compiler_has_attribute_for_printf=xyes)
############################################################################################
# #pragma GCC diagnostic error "-Wincompatible-pointer-types"
my_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_LANG_PUSH([C])
AC_MSG_CHECKING([if the compiler supports pragma for GCC diagnostic error -Wincompatible-pointer-types])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#pragma GCC diagnostic error "-Wincompatible-pointer-types"
#include <stdio.h>
#include <stdlib.h>
int main()
{
return 0;
}]] )],
[
AC_MSG_RESULT([yes])
compiler_has_pragma_for_incompatible_pointer_types=yes
AC_DEFINE([COMPILER_HAS_PRAGMA_FOR_INCOMPATIBLE_POINTER_TYPES],[1],[Compiler supports pragma for GCC diagnostic error -Wincompatible-pointer-types])
],
[
AC_MSG_RESULT([no])
compiler_has_pragma_for_incompatible_pointer_types=no
] )
AC_LANG_POP([C])
CFLAGS="$my_save_CFLAGS"
############################################################################################
# qsort_r - definition for GNU C and BSD differ, other platforms may not have it at all
# best to use libc version if available; otherwise, internal implementation
AC_CHECK_FUNC(qsort_r, [AC_DEFINE(HAVE_QSORT_R,[1],[whether or not qsort_r is available] ) ])
# if it does have qsort_r then make sure it has the BSD-ordered parameters (Linux typically does not)
# if it doesn't, then I use my already written equivalent version; otherwise use libc's version
if test "$ac_cv_func_qsort_r" == yes ; then
my_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
# if I have support for the pointer mismatch pragma, add this to CFLAGS
if test $compiler_has_pragma_for_incompatible_pointer_types -ne 0 ; then
CFLAGS="$CFLAGS -DCOMPILER_HAS_PRAGMA_FOR_INCOMPATIBLE_POINTER_TYPES"
fi
AC_LANG_PUSH([C])
AC_MSG_CHECKING([that qsort_r is the BSD version])
AC_LINK_IFELSE(
[
AC_LANG_SOURCE(
[[
#ifdef COMPILER_HAS_PRAGMA_FOR_INCOMPATIBLE_POINTER_TYPES
#pragma GCC diagnostic error "-Wincompatible-pointer-types"
#else
#error For now we disallow this, to protect QSORT_R calls, and only use the internal version
#endif // COMPILER_HAS_PRAGMA_FOR_INCOMPATIBLE_POINTER_TYPES
#include <stdio.h>
#include <stdlib.h>
int unsorted[16]={1,3,5,7,9,11,13,15,2,4,6,8,10,12,14,16};
int bsd_sort_compare(void *a, const void *b, const void *c)
{
const int *p1, *p2;
if(a != (void *)unsorted)
{
exit(2);
}
p1 = (const int *)b;
p2 = (const int *)c;
if(*p1 > *p2)
{
return 1;
}
else if(*p2 > *p1)
{
return -1;
}
return 0;
}
int main()
{
int i1;
qsort_r(unsorted, 16, sizeof(unsorted[0]), (void *)unsorted, bsd_sort_compare);
for(i1=1; i1 < 16; i1++)
{
if(unsorted[i1 - 1] + 1 != unsorted[i1])
{
exit(3);
}
}
return 0;
}
]] )
],
[
AC_MSG_RESULT([yes])
AC_DEFINE([QSORT_R_BSD],[1],[BSD version of qsort_r])
],
[
AC_MSG_RESULT([no])
AC_DEFINE([QSORT_R_GNUC],[1],[GNUC version of qsort_r])
] )
AC_LANG_POP([C])
CFLAGS="$my_save_CFLAGS"
else
AC_MSG_WARN([qsort_r not compatible; using internal qsort_r implementation])
fi
############################################################################################
############################################################################################
# LONG LONG DATATYPE - checking for support (simple)
#
AC_LANG_PUSH([C])
AC_MSG_CHECKING([that the 'long long' data type is supported])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
int main()
{
static long long llTemp1 = 0;
static unsigned long long ullTemp2 = 0;
return 0;
}]] )],
[
AC_MSG_RESULT([yes!!! (supported)])
AC_DEFINE([HAVE_LONGLONG],[1],[ defined whenever 'long long' is supported ])
],
[
AC_MSG_RESULT([no (not supported)])
] )
AC_LANG_POP([C])
############################################################################################
AC_C_CONST
AC_HEADER_STDC
AC_CANONICAL_HOST
# optional things for Interix vs the rest of the world
# Interix is deprecated and I should get rid of this
case $host in
i*86-pc-interix*)
MAN_PAGES="X11workbench.interix"
;;
*)
MAN_PAGES="X11workbench.1"
;;
esac
if test x$test_have_xpm = xtrue ; then
AC_DEFINE([X11WORKBENCH_TOOLKIT_HAVE_XPM],[1],[whether or not libXpm should be used])
fi
if test x$test_have_xft = xtrue ; then
AC_DEFINE([X11WORKBENCH_TOOLKIT_HAVE_XFT],[1],[whether or not libXft should be used])
# NOTE: the AC_CHECK_FT2 macro SHOULD HAVE already modified CFLAGS and LIBS
# however, whenever I look at the output, I don't see it. So...
CFLAGS="$CFLAGS $FT2_CFLAGS"
CXXFLAGS="$CXXFLAGS $FT2_CFLAGS"
CPPFLAGS="$CPPFLAGS $FT2_CFLAGS"
LIBS="$LIBS $FT2_LIBS"
fi
if test x$test_have_xext = xtrue ; then
AC_DEFINE([X11WORKBENCH_TOOLKIT_HAVE_XEXT],[1],[whether or not libXext should be used])
fi
# optional things for cygwin vs the rest of the world
case $host in
# typically i686-pc-cygwin
*-*-cygwin)
is_cygwin=true
;;
*)
is_cygwin=false
;;
esac
#################################################################
# ADDITIONAL GLOBAL DEFINES (things to export)
# CONDITIONALS
AM_CONDITIONAL(IS_CYGWIN, test x$is_cygwin = xtrue)
AM_CONDITIONAL(NOT_CYGWIN, test x$is_cygwin = xfalse)
## LIBRARY LINKAGE STUFF
# XPM library (program will use its own implementation when libXpm is not available)
# note that this conditional defines the linkage, not the library include symbols
AM_CONDITIONAL(HAVE_XPM_LIB, test x$test_have_xpm = xtrue )
# XFT library - use libXft for certain rendering operations when available
AM_CONDITIONAL(HAVE_XFT_LIB, test x$test_have_xft = xtrue )
# XExt library - use libXext for things like XShm API functions
AM_CONDITIONAL(HAVE_XEXT_LIB, test x$test_have_xext = xtrue)
# additional library linkages
AM_CONDITIONAL(NEED_LRT, test x$test_need_lrt = xtrue)
AM_CONDITIONAL(NEED_LDL, test x$test_need_ldl = xtrue)
# Additional global defines go here
NUM_CORES="$ac_num_cores"
GLOBAL_XPATH=`echo "$ac_x_libraries" | sed 's/\/lib//g'`
GLOBAL_XPATH="$GLOBAL_XPATH"
#################################################################
#############################
# MULTI-CORE BUILDS via '-j'
#############################
# Whenever the host (build) system has more than one core, this
# will automatically invoke '-j' to use one job per available core.
# experimentation shows that specifying the '-j' argument on
# the make command line overrides this...
if test $NUM_CORES -gt 1 ; then
AM_MAKEFLAGS="-j \$(NUM_CORES) $AM_MAKEFLAGS"
fi
# LAST MINUTE CFLAGS TWEEKS
if test x$compiler_has_attribute_for_printf==xyes ; then
CFLAGS="-Wformat $CFLAGS"
CPPFLAGS="-Wformat $CPPFLAGS"
CXXFLAGS="-Wformat $CXXFLAGS"
fi
#################################################################
# Makefile variable SUBSTITUTIONS (so they go into Makefile)
# After all of that, I need the variable substitutions. They go here.
# This is for stuff I did not actually create a var already for, that
# needs to be defined in Makefile
# additional substitutions for man pages and X11 libraries
AC_SUBST([MAN_PAGES])
AC_SUBST([GLOBAL_XPATH])
AC_SUBST([NUM_CORES])
AC_SUBST([IS_CYGWIN])
AC_SUBST([NOT_CYGWIN])
AC_SUBST([HAVE_XPM_LIB])
AC_SUBST([HAVE_XFT_LIB])
AC_SUBST([HAVE_XEXT_LIB])
AC_SUBST([CFLAGS])
AC_SUBST([CPPFLAGS])
AC_SUBST([CXXFLAGS])
AC_SUBST([LIBS])
AC_SUBST([AM_MAKEFLAGS])
########################################################################
# the end
AC_CONFIG_FILES([Makefile lib/Makefile])
AC_OUTPUT