-
-
Notifications
You must be signed in to change notification settings - Fork 234
/
configure.ac
3952 lines (3641 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
dnl Copyright (c) 2012-2023 Red Hat.
dnl Copyright (c) 2008 Aconex. All Rights Reserved.
dnl Copyright (c) 2000-2004,2008 Silicon Graphics, Inc. All Rights Reserved.
dnl
dnl This program is free software; you can redistribute it and/or modify it
dnl under the terms of the GNU General Public License as published by the
dnl Free Software Foundation; either version 2 of the License, or (at your
dnl option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl unpacking check - this file must exist
AC_INIT
AC_CONFIG_SRCDIR([src/include/pcp/pmapi.h])
dnl need 2.63 for AS_VAR_IF and AS_VAR_COPY
AC_PREREQ([2.63])dnl
AC_ARG_WITH([64bit],
[AS_HELP_STRING([--with-64bit],
[turn on 64 bit compilation mode (default is platform dependent)])],
[use_64bit=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-64bit=$withval"])
AC_ARG_WITH([optimization],
[AS_HELP_STRING([--with-optimization],
[enable optimization for C/C++ code (default is yes)])],
[use_optimization=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-optimization=$withval"],
[use_optimizaton=yes])
AC_ARG_WITH([gperftools],
[AS_HELP_STRING([--with-gperftools],
[enable gperftools for CPU and heap profiling (default is no)])],
[use_gperftools=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-gperftools=$withval"],
[use_gperftools=no])
AC_ARG_WITH([sanitizer],
[AS_HELP_STRING([--with-sanitizer],
[enable sanitizers (default is no, common values are 'address', 'thread' or 'leak')])],
[use_sanitizer=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-sanitizer=$withval"],
[use_sanitizer=no])
AC_ARG_WITH([threads],
[AS_HELP_STRING([--with-threads],[enable support for multiple threads (default is on)])],
[do_threads=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-threads=$withval"],
[do_threads=check])
AC_ARG_WITH([secure-sockets],
[AS_HELP_STRING([--with-secure-sockets],[enable support for secure sockets (default is on)])],
[do_secure=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-secure-sockets=$withval"],
[do_secure=check])
AC_ARG_WITH([static-probes],
[AS_HELP_STRING([--with-static-probes],[enable support for static probes (default is on)])],
[do_probes=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-static-probes=$withval"],
[do_probes=check])
AC_ARG_WITH([infiniband],
[AS_HELP_STRING([--with-infiniband],[enable support for Infiniband metrics (default is on)])],
[do_infiniband=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-infiniband=$withval"],
[do_infiniband=check])
AC_ARG_WITH([user],
[AS_HELP_STRING([--with-user],
[user account under which daemons run (default is pcp)])],
[pcp_user=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-user-account=$withval"],
[pcp_user=pcp])
AC_SUBST(pcp_user)
AC_ARG_WITH([group],
[AS_HELP_STRING([--with-group],
[user group under which daemons run (default is pcp)])],
[pcp_group=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-group-account=$withval"],
[pcp_group=pcp])
AC_SUBST(pcp_group)
AC_ARG_WITH([discovery],
[AS_HELP_STRING([--with-discovery],[enable support for service discovery (default is on)])],
[do_discovery=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-discovery=$withval"],
[do_discovery=check])
AC_ARG_WITH([systemd],
[AS_HELP_STRING([--with-systemd],[enable support for systemd services (default is on)])],
[do_systemd=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-systemd=$withval"],
[do_systemd=check])
AC_ARG_WITH([selinux],
[AS_HELP_STRING([--with-selinux],[enable support for selinux (default is check)])],
[do_selinux=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-selinux=$withval"],
[do_selinux=check])
AC_ARG_WITH([qt],
[AS_HELP_STRING([--with-qt],[enable support for tools requiring Qt (default is on)])],
[do_qt=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-qt=$withval"],
[do_qt=check])
AC_ARG_WITH([qt3d],
[AS_HELP_STRING([--with-qt3d],[enable support for 3D scene graph API (default is on)])],
[do_qt3d=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-qt3d=$withval"],
[do_qt3d=check])
AC_ARG_WITH([perl],
[AS_HELP_STRING([--with-perl],[enable support for tools requiring Perl (default is on)])],
[do_perl=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-perl=$withval"],
[do_perl=check])
AC_ARG_WITH([python],
[AS_HELP_STRING([--with-python],[enable support for tools requiring Python (default is on)])],
[do_python=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-python=$withval"],
[do_python=check])
AC_ARG_WITH([python3],
[AS_HELP_STRING([--with-python3],[enable support for tools requiring Python3 (default is on)])],
[do_python3=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-python3=$withval"],
[do_python3=check])
AC_ARG_WITH([dstat-symlink],
[AS_HELP_STRING([--with-dstat-symlink],[enable support for /usr/bin/dstat symlink (default is on)])],
[do_dstat_symlink=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-dstat-symlink=$withval"],
[do_dstat_symlink=check])
AC_ARG_WITH([perfevent],
[AS_HELP_STRING([--with-perfevent],[enable perfevent pmda (default is on)])],
[do_perfevent=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-perfevent=$withval"],
[do_perfevent=check])
AC_ARG_WITH([pmdagfs2],
[AS_HELP_STRING([--with-pmdagfs2],[enable GFS2 pmda (default is on)])],
[do_pmdagfs2=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdagfs2=$withval"],
[do_pmdagfs2=check])
AC_ARG_WITH([pmdastatsd],
[AS_HELP_STRING([--with-pmdastatsd],[enable statds pmda (default is on)])],
[do_pmdastatsd=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdastatsd=$withval"],
[do_pmdastatsd=check])
AC_ARG_WITH([pmdabcc],
[AS_HELP_STRING([--with-pmdabcc],[enable BCC pmda (default is on)])],
[do_pmdabcc=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdabcc=$withval"],
[do_pmdabcc=check])
AC_ARG_WITH([pmdabpf],
[AS_HELP_STRING([--with-pmdabpf],[enable BPF pmda (default is on)])],
[do_pmdabpf=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdabpf=$withval"],
[do_pmdabpf=check])
AC_ARG_WITH([pmdabpftrace],
[AS_HELP_STRING([--with-pmdabpftrace],[enable bpftrace pmda (default is on)])],
[do_pmdabpftrace=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdabpftrace=$withval"],
[do_pmdabpftrace=check])
AC_ARG_WITH([pmdajson],
[AS_HELP_STRING([--with-pmdajson],[enable JSON pmda (default is on)])],
[do_pmdajson=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdajson=$withval"],
[do_pmdajson=check])
AC_ARG_WITH([pmdamongodb],
[AS_HELP_STRING([--with-pmdamongodb],[enable MongoDB pmda (default is on)])],
[do_pmdamongodb=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdamongodb=$withval"],
[do_pmdamongodb=check])
AC_ARG_WITH([pmdanutcracker],
[AS_HELP_STRING([--with-pmdanutcracker],[enable nutcracker pmda (default is on)])],
[do_pmdanutcracker=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdanutcracker=$withval"],
[do_pmdanutcracker=check])
AC_ARG_WITH([pmdasnmp],
[AS_HELP_STRING([--with-pmdasnmp],[enable SNMP pmda (default is on)])],
[do_pmdasnmp=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdasnmp=$withval"],
[do_pmdasnmp=check])
dnl things set in the environment by Makepkgs never make it into an RPM
dnl build where the environment is stripped ... use a --with-foo=path
dnl construct to workaround this
AC_ARG_WITH([make],
[AS_HELP_STRING([--with-make],[path to GNU compatible make(1) (default is empty for auto discovery)])],
[MAKE=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-make=$withval"],
[MAKE=''])
AC_ARG_WITH([tar],
[AS_HELP_STRING([--with-tar],[path to GNU compatible tar(1) (default is empty for auto discovery)])],
[TAR=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-tar=$withval"],
[TAR=''])
AC_ARG_WITH([zip],
[AS_HELP_STRING([--with-zip],[path to GNU compatible zip(1) (default is empty for auto discovery)])],
[ZIP=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-zip=$withval"],
[ZIP=''])
AC_ARG_WITH(
[transparent-decompression],
[AS_HELP_STRING([--with-transparent-decompression],[enable support for transparent decompression of archives (default is on)])],
[do_decompression=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-transparent-decompression=$withval"],
[do_decompression=check])
dnl
dnl Note: the following environment variables may be set to override defaults:
dnl MAKE CC CPP LD LEX YACC INSTALL AWK SED ECHO
dnl
dnl Guess target platfrom
AC_CANONICAL_TARGET
if test -z "$target"
then
echo '
FATAL ERROR: Cannot guess your target, try explicit specification
using --target or mailto: pcp@groups.io to ask.'
rm -rf conftest conftest.*
exit 1
else
dnl Remove 4th name component, if present, from target, target_os,
dnl build and build_os. Squash all x86 cpus into one LCD form - i386
target=`echo $target | sed '[s/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/]'`
target_os=`echo $target_os | sed '[s/solaris2\..*/solaris/]'`
target_os=`echo $target_os | sed '[s/^\([^-][^-]*\)-.*$/\1/]' | sed '[s/[\.0-9]*//g]'`
build=`echo $build | sed '[s/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/]'`
build_os=`echo $build_os | sed '[s/solaris2\..*/solaris/]'`
build_os=`echo $build_os | sed '[s/^\([^-][^-]*\)-.*$/\1/]'`
fi
echo Building on $build for $target
echo "Build: os=$build_os cpu=$build_cpu"
echo "Target: os=$target_os cpu=$target_cpu"
if test "$cross_compiling" = "yes"; then
if test -f ./config.$target_os; then
. ./config.$target_os
else
echo
echo "
FATAL ERROR: Cannot perform cross-compilation without a file to source
configuration information from (config.$target_os is missing)"
rm -rf conftest conftest.*
exit 1
fi
fi
AC_SUBST(cross_compiling)
dnl CFLAGS setting is a co-dependency between here and PCFLAGS in
dnl src/include/builddefs.in ... need to be the same in both places
gcc_debug=true
target_distro=$target_os
if test $target_os = linux
then
AC_DEFINE(IS_LINUX, [1], [Platform is Linux])
test -f /etc/SuSE-release && target_distro=suse
target_distro_variant=''
if test -f /etc/os-release
then
grep -q 'ID_LIKE="suse"' /etc/os-release 2>/dev/null && target_distro=suse
grep -qi 'opensuse"' /etc/os-release 2>/dev/null && target_distro_variant=opensuse
fi
test -f /etc/fedora-release && target_distro=fedora
test -f /etc/redhat-release && target_distro=redhat
test -f /etc/debian_version && target_distro=debian
test -f /etc/slackware-version && target_distro=slackware
test -f /etc/gentoo-release && target_distro=gentoo
test -f /etc/mandriva-release && target_distro=mandriva
test -f /etc/arch-release && target_distro=arch
export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
pcp_ps_all_flags=-efw
elif test $target_os = darwin
then
AC_DEFINE(IS_DARWIN, [1], [Platform is Darwin (Mac OS X)])
target_distro=macosx
export CFLAGS="-fPIC -no-cpp-precomp -fno-strict-aliasing"
pcp_platform_paths='/usr/local/bin:/opt/homebrew/bin'
pcp_ps_all_flags="-axw -o user,pid,ppid,cpu,stime,tty,time,command"
elif test $target_os = mingw
then
AC_DEFINE(IS_MINGW, [1], [Platform is MinGW (Windows)])
export CFLAGS="-fno-strict-aliasing"
pcp_platform_paths=''
pcp_ps_all_flags=-efW
elif test $target_os = solaris
then
AC_DEFINE(IS_SOLARIS, [1], [Platform is Solaris])
export CFLAGS_IF_GCC="-fPIC -fno-strict-aliasing -D_XPG4_2 -D__EXTENSIONS__"
export CFLAGS_IF_SUNCC="-fPIC -xalias_level=any -D_XPG4_2 -D__EXTENSIONS__"
pcp_platform_paths='/usr/bin/X11:/usr/local/bin:/opt/sfw/bin:/opt/csw/bin'
pcp_ps_all_flags=-ef
elif test $target_os = aix
then
AC_DEFINE(IS_AIX, [1], [Platform is AIX])
export CFLAGS="-qcpluscmt"
pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
pcp_ps_all_flags=-ef
elif test $target_os = freebsd || test $target_os = kfreebsd
then
AC_DEFINE(IS_FREEBSD, [1], [Platform is FreeBSD])
test -f /etc/debian_version && target_distro=debian
export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
if test $target_os = kfreebsd
then
pcp_ps_all_flags=-efw
else
pcp_ps_all_flags="-axww -o user,pid,ppid,%cpu,start,tty,time,args"
fi
pcp_platform_paths='/usr/bin/X11'
test -d /usr/local/bin && pcp_platform_paths="$pcp_platform_paths:/usr/local/bin"
test -d /usr/bsd && pcp_platform_paths="$pcp_platform_paths:/usr/bsd"
elif test $target_os = gnu
then
AC_DEFINE(IS_GNU, [1], [Platform is GNU Hurd])
test -f /etc/debian_version && target_distro=debian
export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
pcp_ps_all_flags=-efw
elif test $target_os = netbsdelf -o $target_os = netbsd
then
target_os=netbsd
AC_DEFINE(IS_NETBSD, [1], [Platform is NetBSD])
export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE -D_NETBSD_SOURCE"
pcp_platform_paths='/usr/pkg/bin'
pcp_ps_all_flags=auxww
elif test $target_os = openbsd
then
target_os=openbsd
AC_DEFINE(IS_OPENBSD, [1], [Platform is OpenBSD])
export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
pcp_platform_paths='/usr/local/bin'
pcp_ps_all_flags="-axww -o user,pid,ppid,%cpu,start,tty,time,args"
if test "$target_cpu" = "i386" -a "$host_os" = "openbsd6.8"
then
dnl build with -g are broken here due to a gcc bug
gcc_debug=false
fi
else
echo
echo "FATAL ERROR: need platform-specific customization for \"$target_os\""
rm -rf conftest conftest.*
exit 1
fi
AC_SUBST(pcp_platform_paths)
AC_SUBST(pcp_ps_all_flags)
dnl default C and C++ compiler optimization to -O2 -g (latter depends on $gcc_debug)
if test "$use_optimization" = no
then
optimization="-O0"
$gcc_debug && optimization="$optimization -g"
else
optimization="-O2"
$gcc_debug && optimization="$optimization -g"
fi
AC_SUBST(optimization)
PKG_PROG_PKG_CONFIG
if test -z "$PKG_CONFIG"; then
AC_MSG_ERROR([cannot find a 'pkg-config' command])
fi
dnl check if user wants their own C compiler
cflags_abi=
AC_PROG_CC(suncc egcc gcc cc clang)
if test $target_os = solaris
then
AC_PATH_PROG(CCPATH,$CC,$CC)
cc=$CCPATH
if test "$GCC" = "yes"
then
CFLAGS="$CFLAGS $CFLAGS_IF_GCC"
else
CFLAGS="$CFLAGS $CFLAGS_IF_SUNCC"
fi
if test "$use_64bit" = "no"
then
:
else
AC_MSG_CHECKING([for 64 bit Solaris host])
case `isainfo -k`
in
amd64|sparcv9)
cflags_abi=-m64
CFLAGS="$CFLAGS -m64"
LDFLAGS="$LDFLAGS -m64"
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT(no)
;;
esac
fi
else
cc=$CC
fi
AC_SUBST(cc)
cc_is_gcc=$GCC
AC_SUBST(cc_is_gcc)
AC_SUBST(cflags_abi)
dnl these become CFLAGS and LDFLAGS for the build
PCFLAGS="$CFLAGS"
PLDFLAGS=$LDFLAGS
if echo "$CFLAGS" | grep 'D_FORTIFY_SOURCE' >/dev/null
then
dnl for cc use locally in configure (not exported via $PCFLAGS),
dnl add -O in case -D_FORTIFY_SOURCE has been added to CFLAGS above,
dnl as -D_FORTIFY_SOURCE requires -O but we've separated optimization
dnl flags out into $CFLAGS_OPT for our build infrastructure
CFLAGS="-O $PCFLAGS"
fi
dnl some versions of gcc (e.g. version 4.8.4 on Gentoo Hardened) have added
dnl a predefined for _FORTIFY_SOURCE but only when -O is specified ... so
dnl to be safe we have -U_FORTIFY_SOURCE before -D_FORTIFY_SOURCE=2 below
dnl Add some security-related gcc flags
if echo "$CFLAGS" | grep stack-protector >/dev/null
then
dnl already set, probably from the environment
:
else
AC_ARG_ENABLE([ssp],
[AS_HELP_STRING([--disable-ssp], [disable gcc stack-protector])])
AS_IF([test "x$cc_is_gcc" = xyes -a "x$enable_ssp" != xno -a "x$use_optimization" = xyes ],[
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -O -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int something ();])], [
AC_MSG_NOTICE([Compiling with gcc -fstack-protector-all et al.])
PCFLAGS="$PCFLAGS -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"],[
AC_MSG_NOTICE([Compiler does not support -fstack-protector-all et al.])
CFLAGS="$save_CFLAGS"
])
])
fi
dnl Add other non-default gcc static checking flags
if ! echo "$CFLAGS" | grep -- -Wshadow >/dev/null
then
AS_IF([test "x$cc_is_gcc" = xyes ],[PCFLAGS="$PCFLAGS -Wshadow"])
fi
dnl Disable array bounds as pmResult is often mischaracterised
if ! echo "$CFLAGS" | grep -- -Wno-array-bounds >/dev/null
then
AS_IF([test "x$cc_is_gcc" = xyes ],[PCFLAGS="$PCFLAGS -Wno-array-bounds"])
fi
force_time_t=false
dnl we also need to worry about time_t ... we need it to be 64-bits for Y2038;
dnl _FILE_OFFSET_BITS and _TIME_BITS must be set together for the 32-bit case.
AC_MSG_CHECKING([default sizeof time_t])
cat <<End-of-File >conftest.c
#include <stdio.h>
#include <sys/time.h>
int main() { printf("%d", (int)sizeof(time_t)); return 0; }
End-of-File
(eval $ac_compile) 2>&5
(eval $ac_link) 2>&5
ans=`./conftest`
echo "./conftest -> \"$ans\"" >&5
AC_MSG_RESULT([$ans])
rm -f conftest.done
if test "$ans" = 4; then
dnl well that's disappointing the default time_t won't survive
dnl Y2038 ... let's see if -D_TIME_BIT64 makes any difference
AC_MSG_CHECKING([sizeof time_t with -D_TIME_BITS=64])
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64"
(eval $ac_compile) 2>&5
(eval $ac_link) 2>&5
CFLAGS="$save_CFLAGS"
ans=`./conftest`
echo "./conftest -D_TIME_BITS=64 -> \"$ans\"" >&5
if test "$ans" = 8; then
PCFLAGS="$PCFLAGS -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64"
AC_MSG_RESULT([$ans => -D_TIME_BITS=64])
touch conftest.done
force_time_t=true
else
AC_MSG_RESULT([$ans => no way to make this Y2038 safe])
fi
fi
if test ! -f conftest.done; then
dnl we may need to check off_t ... we need it to be 64-bits for V3 archives
dnl this check is optional only because it may be set already (just prior).
AC_MSG_CHECKING([default sizeof off_t])
cat <<End-of-File >conftest.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main() { printf("%d", (int)sizeof(off_t)); return 0; }
End-of-File
(eval $ac_compile) 2>&5
(eval $ac_link) 2>&5
ans=`./conftest`
echo "./conftest -> \"$ans\"" >&5
rm -rf conftest conftest.*
if test "$ans" = 4; then
PCFLAGS="$PCFLAGS -D_FILE_OFFSET_BITS=64"
AC_MSG_RESULT([$ans => -D_FILE_OFFSET_BITS=64])
else
AC_MSG_RESULT($ans)
fi
fi
rm -rf conftest conftest.*
AC_SUBST(PCFLAGS)
AC_SUBST(PLDFLAGS)
dnl we have some constraints around the packing of pmResults of various
dnl flavours and Python modules handling of pmHighResResult
dnl 1) we need the offset of the numpmid field in __pmResult to be at least as
dnl big as the offset of the numpmid field in pmResult _and_ pmHighResResult
dnl (for the tricky games in libpcp to minimize copying)
dnl 2) we need to know if the compiler is adding padding between the timestamp
dnl and the numpmid fields of pmHighResResult (for Python packing and
dnl unpacking)
cat <<End-of-File >conftest.c
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/time.h>
typedef struct {
int64_t sec;
int32_t nsec;
} __pmTimestamp;
typedef struct {
__pmTimestamp stamp;
int numpmid;
} __pmResult;
typedef struct {
struct timeval stamp;
int numpmid;
} pmResult;
typedef struct {
struct timespec stamp;
int numpmid;
} pmHighResResult;
void
main(void)
{
__pmResult __rp;
pmResult rp;
pmHighResResult hrp;
int nb;
nb = (int)offsetof(pmResult,numpmid);
if (nb < (int)offsetof(pmHighResResult,numpmid))
nb = (int)offsetof(pmHighResResult,numpmid);
if (nb > (int)offsetof(__pmResult,numpmid))
printf("__pmResult pad %d\n", nb - (int)offsetof(__pmResult,numpmid));
nb = (int)(sizeof(hrp.stamp) - sizeof(hrp.stamp.tv_sec) - sizeof(hrp.stamp.tv_nsec));
if (nb > 0)
printf("timespec pad %d\n", nb);
}
End-of-File
save_CFLAGS="$CFLAGS"
CFLAGS="$PCFLAGS"
(eval $ac_compile) 2>&5
(eval $ac_link) 2>&5
./conftest >conftest.out
CFLAGS="$save_CFLAGS"
AC_MSG_CHECKING([__pmResult padding])
ans=`sed <conftest.out -n -e '/__pmResult pad/s/.* //p'`
if test -n "$ans"
then
AC_DEFINE_UNQUOTED(PM_PAD_RESULT, $ans, [])
AC_MSG_RESULT($ans)
else
AC_MSG_RESULT([no])
fi
AC_MSG_CHECKING([timespec padding])
ans=`sed <conftest.out -n -e '/timespec pad/s/.* //p'`
if test -n "$ans"
then
AC_DEFINE_UNQUOTED(PM_PAD_TIMESPEC, $ans, [])
AC_MSG_RESULT($ans)
else
AC_MSG_RESULT([no])
fi
dnl Check for even more security-related gcc/linker flags, useful for daemons
AC_ARG_ENABLE([pie],
[AS_HELP_STRING([--disable-pie], [disable position-independent-executable])])
AS_IF([test "x$cc_is_gcc" = xyes -a "x$enable_pie" != xno],[
PIECFLAGS='-fPIE'
PIELDFLAGS='-pie -Wl,-z,relro -Wl,-z,now'
save_CFLAGS="$CFLAGS"
save_LDFLAGS="$LDFLAGS"
CFLAGS="$CFLAGS $PIECFLAGS"
LDFLAGS="$LDFLAGS $PIELDFLAGS"
AC_LINK_IFELSE([AC_LANG_SOURCE([void main () {}])], [
AC_MSG_NOTICE([Compiling with gcc pie et al.])
], [
AC_MSG_NOTICE([Compiler does not support -pie et al.])
PIECFLAGS=""
PIELDFLAGS=""
])
CFLAGS="$save_CFLAGS"
LDFLAGS="$save_LDFLAGS"
])
AC_SUBST(PIELDFLAGS)
AC_SUBST(PIECFLAGS)
dnl Check for support for symbol hiding via gcc flags
AC_ARG_ENABLE([visibility],
[AS_HELP_STRING([--disable-visibility], [disable gcc symbol visibility])])
AS_IF([test "x$cc_is_gcc" = xyes -a "$enable_visibility" != no],[
INVISIBILITY="-fvisibility=hidden"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -c $INVISIBILITY"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int visible () { return 0; }])], [
AC_MSG_NOTICE([Compiling DSO PMDAs with gcc -fvisibility=hidden])
], [
AC_MSG_NOTICE([Compiler does not support -fvisibility.])
INVISIBILITY=""
])
CFLAGS="$save_CFLAGS"
])
AC_SUBST(INVISIBILITY)
dnl Check for (opt-in) support for --std=c99
AC_MSG_CHECKING([for --std=c99 support])
AS_IF([test "x$cc_is_gcc" = xyes],[
C99_CFLAGS="--std=c99"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $C99_CFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <stdio.h>]],
[[for (int i=0; i<1; i++)]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
C99_CFLAGS=""])
CFLAGS="$save_CFLAGS"
])
AC_SUBST(C99_CFLAGS)
dnl Check for a C++ compiler
AC_PROG_CXX(eg++ g++ c++ clang++)
cxx=$CXX
AC_SUBST(cxx)
AC_MSG_CHECKING([for working C++ compiler])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <cstdio>]],
[[const char gday[] = "G'day, world\n";]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
cxx=""])
AC_LANG_POP([C++])
dnl Prevent shared libraries from being built for libpcp and other core libraries
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--disable-shared], [disable core shared libary generation])],
[PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --disable-shared=$withval"],
[enable_shared=false])
AC_SUBST(enable_shared)
dnl check if user wants to use any of their own commands;
dnl ordering is important: some tests use earlier results
test -z "$AWK" && AC_PATH_PROGS(AWK, gawk awk, /usr/bin/awk)
case "$AWK"
in
gawk|*/gawk)
awk="$AWK --posix"
;;
*)
awk=$AWK
;;
esac
AC_SUBST(awk)
if test -z "$SED"; then
AC_PATH_PROG(SED, sed, /bin/sed)
fi
if test ! -x "$SED"; then
AC_MSG_ERROR([cannot find a valid 'sed' command.])
fi
sed=$SED
AC_SUBST(sed)
if test -z "$ECHO"; then
AC_PATH_PROG(ECHO, echo, /bin/echo)
fi
if test ! -x "$ECHO"; then
AC_MSG_ERROR([cannot find a valid 'echo' command.])
fi
echo=$ECHO
AC_SUBST(echo)
if test -z "$FIND"; then
AC_PATH_PROG(FIND, find, /usr/bin/find)
fi
if test ! -x "$FIND"; then
AC_MSG_ERROR([cannot find a valid 'find' command.])
fi
find=$FIND
AC_SUBST(find)
if test -z "$WHICH"; then
AC_PATH_PROG(WHICH, which, /usr/bin/which)
fi
if test ! -x "$WHICH"; then
AC_MSG_ERROR([cannot find a valid 'which' command.])
fi
which=$WHICH
AC_SUBST(which)
if test -z "$AR"; then
AC_PATH_PROGS(AR, [gcc-ar ar], /usr/bin/ar)
fi
if test ! -x "$AR"; then
AC_MSG_ERROR([cannot find a valid 'ar' command.])
fi
ar=$AR
AC_SUBST(ar)
AC_PROG_LEX([noyywrap])
lex=`$echo $LEX | awk '{print $1}'`
lex=`$which "$lex"`
if test ! -x "$lex"; then
AC_MSG_ERROR([cannot find a valid 'lex'/'flex' command.])
fi
lex=$LEX
AC_SUBST(lex)
AC_PROG_YACC
yacc=`$echo $YACC | awk '{print $1}'`
yacc=`$which "$yacc"`
if test ! -x "$yacc"; then
AC_MSG_ERROR([cannot find a valid 'yacc'/'bison' command.])
fi
dnl if this is bison, don't use the -y option
yacc=`echo $YACC | sed -e '/^bison /{
s/$/ /
s/ -y / /
s/ $//
}'`
AC_SUBST(yacc)
AC_CHECK_PROGS(RAGEL, ragel, [])
AC_SUBST(RAGEL)
dnl check we don't get the Windows sort ...
AC_MSG_CHECKING([where unix-like sort(1) lives])
if test $target_os = mingw; then
for d in /bin /usr/bin /mingw/bin /mingw/usr/bin
do
if test -x $d/sort; then
sort=$d/sort
break
fi
done
else
sort=`$which sort`
fi
AC_MSG_RESULT($sort)
$sort -n </dev/null
if test $? != 0
then
echo
echo "FATAL ERROR: $sort -n failed!"
rm -rf conftest conftest.*
exit 1
fi
AC_SUBST(sort)
dnl echo_n set to -n if echo understands -n to suppress newline
dnl echo_c set to \c if echo understands \c to suppress newline
AC_MSG_CHECKING([if echo uses -n or backslash-c to suppress newlines])
if ( $echo "testing\c"; $echo 1,2,3 ) | grep c >/dev/null
then
if ( $echo -n testing; $echo 1,2,3 ) | sed s/-n/xn/ | grep xn >/dev/null
then
echo_n= echo_c=
AC_MSG_RESULT([neither?])
else
echo_n=-n echo_c=
AC_MSG_RESULT([ -n])
fi
else
echo_n= echo_c='\\c'
AC_MSG_RESULT([backslash-c])
fi
AC_SUBST(echo_n)
AC_SUBST(echo_c)
dnl subsequent configure checks rely on $EGREP being set
AC_PROG_EGREP
dnl Check for static probes (dtrace, systemtap)
if test "$do_probes" = "check" -o "$do_probes" = "yes"
then
enable_probes=true
AC_CHECK_PROGS(DTRACE, dtrace, [])
if test -z "$DTRACE"
then
if test "$do_probes" = "yes"
then
AC_MSG_ERROR([cannot enable static probes - no dtrace executable])
fi
enable_probes=false
fi
AC_CHECK_HEADERS([sys/sdt.h], [
if $enable_probes = true
then
if test $target_os = kfreebsd
then
enable_probes=false
elif test $target_os = freebsd
then
dnl dtrace support in FreeBSD depends on configuration of kernel
rm -f conftest.d conftest.h
cat <<End-of-File >conftest.d
provider eek {
probe urk(int);
};
End-of-File
if dtrace -s conftest.d -h >/dev/null 2>&1
then
if test ! -f conftest.h
then
enable_probes=false
if test "$do_probes" = "yes"
then
AC_MSG_ERROR([cannot enable static probes - no .h from dtrace -h])
fi
fi
else
enable_probes=false
if test "$do_probes" = "yes"
then
AC_MSG_ERROR([cannot enable static probes - dtrace failed])
fi
fi
fi
fi
], [
enable_probes=false
if test "$do_probes" = "yes"
then
AC_MSG_ERROR([cannot enable static probes - no SDT header])
fi
])
if test "$enable_probes" = "true"
then
AC_DEFINE(HAVE_STATIC_PROBES, [1], [Static probes (dtrace, systemtap)])
fi
AC_SUBST(enable_probes)
AC_SUBST(DTRACE)
fi
dnl Check for gperftools
AS_IF([test "x$use_gperftools" != "xno"], [
PKG_CHECK_MODULES([gperftools], [libprofiler, libtcmalloc])
])
dnl Check for sanitizers
sanitizer=""
if test "x$use_sanitizer" != "xno"; then
sanitizer="-fsanitize=$use_sanitizer"
fi
AC_SUBST(sanitizer)
dnl Check for service discovery mechanisms (DNS-SD, Avahi)
AS_IF([test "x$do_discovery" != "xno"], [
# on Mac OS X, dns_sd.h
# on Linux, aloha Avahi
enable_avahi=true
PKG_CHECK_MODULES([avahi], [avahi-client],
[AC_CHECK_LIB(avahi-client, avahi_client_new,
[lib_for_avahi="-lavahi-common -lavahi-client"],
[enable_avahi=false])
],[enable_avahi=false])
AC_CHECK_HEADERS([avahi-client/publish.h],, [enable_avahi=false])
AC_CHECK_HEADERS([avahi-common/alternative.h],, [enable_avahi=false])
if test "$enable_avahi" = "true"
then
AC_SUBST(lib_for_avahi)
AC_SUBST(avahi_CFLAGS)
AC_DEFINE(HAVE_AVAHI, [1], [Service discovery via Avahi])
enable_discovery=true
fi
if test "$do_discovery" != "check" -a "$enable_discovery" != "true"
then
AC_MSG_ERROR([cannot enable service discovery - no supported mechanisms])
fi
if test "$enable_discovery" = "true"
then
AC_DEFINE(HAVE_SERVICE_DISCOVERY, [1], [Service discovery mechanisms])
fi
])
AC_SUBST(enable_discovery)
AC_SUBST(enable_avahi)
dnl Check for systemd services
enable_systemd=false
AC_MSG_CHECKING([if systemd should be used])
AS_IF([test "x$do_systemd" != "xno"], [
enable_systemd=true
PKG_CHECK_VAR([SYSTEMD_TMPFILESDIR], [systemd], [tmpfilesdir],
[pcp_systemdtmpfiles_dir=$SYSTEMD_TMPFILESDIR],
[pcp_systemdtmpfiles_dir=$pcp_lib32_dir/tmpfiles.d])
AC_SUBST(pcp_systemdtmpfiles_dir)
PKG_CHECK_VAR([SYSTEMD_SYSUSERSDIR], [systemd], [sysusersdir],
[pcp_systemdsysusers_dir=$SYSTEMD_SYSUSERSDIR],
[pcp_systemdsysusers_dir=$pcp_lib32_dir/sysusers.d])
AC_SUBST(pcp_systemdsysusers_dir)
PKG_CHECK_VAR([SYSTEMD_SYSTEMUNITDIR], [systemd], [systemdsystemunitdir],
[pcp_systemdunit_dir=$SYSTEMD_SYSTEMUNITDIR], [enable_systemd=false])
AC_SUBST(pcp_systemdunit_dir)
if test -z "$pcp_systemdunit_dir"
then
if test "$do_systemd" = "yes"
then
AC_MSG_ERROR([cannot enable systemd support - no systemunitdir path])
fi
enable_systemd=false
fi
])
if $enable_systemd
then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_SUBST(enable_systemd)
if $enable_systemd
then
dnl sd_notify() is needed in __pmServerNotifySystemd(), but only if systemd
dnl is being used
AC_CHECK_HEADERS([systemd/sd-daemon.h], [have_sd_daemon=true], [have_sd_daemon=false])
$have_sd_daemon || echo WARNING: using systemd, but header systemd/sd-daemon.h not installed
fi
sd_service_type="simple"
if $enable_systemd
then
dnl if systemd version is 239 or newer, use type=exec for logutil scripts
dnl else fallback to type=simple (e.g. on centos7 and some other platforms)
systemd_version=`systemd-analyze --version | $AWK '/^systemd/ {print $2}'`
if test "$systemd_version" -ge 239
then
sd_service_type="exec"
fi
fi
AC_SUBST(sd_service_type)
dnl NB: No AC_PREFIX_DEFAULT is needed, as the default configure invocation
dnl targets a build for non-system directories such as /usr/local.
dnl AC_PREFIX_DEFAULT([])
. ./VERSION.pcp
PACKAGE_VERSION=${PACKAGE_MAJOR}.${PACKAGE_MINOR}.${PACKAGE_REVISION}
AC_SUBST(PACKAGE_VERSION)
AC_SUBST(PACKAGE_MAJOR)
AC_SUBST(PACKAGE_MINOR)
AC_SUBST(PACKAGE_REVISION)
AC_SUBST(PACKAGE_BUILD)
if test -z "$PACKAGE_BUILD_DATE" ; then
# use SOURCE_DATE_EPOCH for a deterministic builddate (reproducible builds)
PACKAGE_BUILD_DATE=`TZ=UTC date -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y-%m-%d 2>/dev/null`
test $? -eq 0 || PACKAGE_BUILD_DATE=`date +%Y-%m-%d`
fi
AC_SUBST(PACKAGE_BUILD_DATE)
if test -z "$PACKAGE_DISTRIBUTION" ; then
PACKAGE_DISTRIBUTION=$target_distro
fi
AC_SUBST(PACKAGE_DISTRIBUTION)
dnl generate PM_VERSION_CURRENT for header
pm_version_current=`awk </dev/null "BEGIN { print (${PACKAGE_MAJOR}*256+${PACKAGE_MINOR})*256+${PACKAGE_REVISION} }"`
AC_SUBST(pm_version_current)
dnl output header files with cpp defs HAVE_*, etc
AC_CONFIG_HEADERS(src/include/pcp/config.h src/include/pcp/configsz.h)
AC_CONFIG_FILES([src/include/pcp/platform_defs.h src/include/pcp/platformsz.h])
AC_OUTPUT
AC_CHECK_PROGS(GIT, git)
AC_SUBST(GIT)
AC_CHECK_PROGS(PYLINT, pylint, /bin/true)
AC_SUBST(PYLINT)
dnl check if python available for the build and runtime
AC_PATH_PROGS(PYTHON, [/usr/bin/python2 python2 python2.7 python])
AC_SUBST(PYTHON)
dnl check if python3 available for the build and runtime
AC_PATH_PROGS(PYTHON3, [/usr/bin/python3 python3 python3.9])