forked from performancecopilot/pcp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
3921 lines (3597 loc) · 113 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-2020 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(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([threads],
[AC_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],
[AC_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],
[AC_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],
[AC_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],
[AC_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],
[AC_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([qt],
[AC_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],
[AC_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],
[AC_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],
[AC_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],
[AC_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],
[AC_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],
[AC_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([pmdastatsd],
[AC_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([pmdapodman],
[AC_HELP_STRING([--with-pmdapodman],
[enable podman pmda (default is on)])],
[do_pmdapodman=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdapodman=$withval"],
[do_pmdapodman=check])
AC_ARG_WITH([pmdabcc],
[AC_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([pmdabpftrace],
[AC_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],
[AC_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([pmdanutcracker],
[AC_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],
[AC_HELP_STRING([--with-pmdasnmp],
[enable SNMP pmda (default is on)])],
[do_pmdasnmp=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdasnmp=$withval"],
[do_pmdasnmp=check])
AC_ARG_WITH([selinux],
[AC_HELP_STRING([--with-selinux],
[enable building of selinux package (default is on)])],
[do_selinux=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-selinux=$withval"],
[do_selinux=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],
[AC_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],
[AC_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],
[AC_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],
[AC_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_SYSTEM
if test -z "$target"
then
echo '
FATAL ERROR: Cannot guess your target, try explicit specification
using --target or mailto: [email protected] 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
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
version=`sw_vers -productVersion`
CFLAGS="-fPIC -no-cpp-precomp -fno-strict-aliasing"
case "$version"
in
10.[0-5].*)
dnl no knowledge before this ...
;;
10.[6-9].*|10.1[0-3].*)
target_distro=cocoa
CFLAGS="$CFLAGS -arch i386 -arch x86_64"
;;
*)
dnl at least 10.14 (Mojave) ...
target_distro=cocoa
CFLAGS="$CFLAGS -arch x86_64"
;;
esac
export CFLAGS
pcp_platform_paths='/usr/local/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)])
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=auxww
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=auxww
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
if test "$use_optimization" = no
then
optimization="-O0 -g"
else
optimization="-O2 -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
AC_SUBST(PCFLAGS)
AC_SUBST(PLDFLAGS)
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
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 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_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
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_OUTPUT(src/include/pcp/platform_defs.h src/include/pcp/platformsz.h)
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_CHECK_PROGS(PYTHON, [python2 python2.7 python])
AC_SUBST(PYTHON)
dnl check if python3 available for the build and runtime
AC_CHECK_PROGS(PYTHON3, [python3 python3.7 python3.6 python3.4])
AC_SUBST(PYTHON3)
dnl check availability of Python header files
dnl usage PCP_CHECK_PYTHON_HEADER(major, minor)
dnl
AC_DEFUN([PCP_CHECK_PYTHON_HEADER],
[ PY_MAJOR="$1"
PY_MINOR="$2"
PY_VERSION="python$PY_MAJOR.$PY_MINOR"
PY_INCLUDE_DIRS="-I/usr/include/${PY_VERSION}m -I/usr/include/${PY_VERSION}"
saved_CFLAGS="$CFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
CFLAGS="$CFLAGS $PY_INCLUDE_DIRS"
CPPFLAGS="$CPPFLAGS $PY_INCLUDE_DIRS"
AC_CHECK_HEADERS([Python.h], [], [
echo WARNING: Python version $PY_MAJOR.$PY_MINOR header file may be missing.
echo Proceeding with the Python $PY_MAJOR installation found, regardless.])
CPPFLAGS="$saved_CPPFLAGS"
CFLAGS="$saved_CFLAGS"
])
dnl check if python tools/packages wanted (need python >= 2.6)
enable_python2=false
AS_IF([test "x$do_python" != "xno"], [
enable_python2=true
if test "$do_python" = "check" -a -f /etc/os-release
then
(
. /etc/os-release
case "$ID"
in
debian)
if test -z "$VERSION_ID" -o "$VERSION_ID" -ge 11; then
touch config.python2_eol
fi
;;
ubuntu)
VERSION_NO=`echo "$VERSION_ID" | sed 's/[[^0-9]]//'`
if test "$VERSION_NO" -ge 2004; then
touch config.python2_eol
fi
;;
esac
)
fi
if test -f config.python2_eol
then
rm config.python2_eol
echo "WARNING: Python 2 is not supported anymore (EOL since 2020), please use Python 3 instead."
enable_python2=false
fi
if test "$enable_python2" = "true" -a -z "$PYTHON"
then
enable_python2=false
fi
if $enable_python2
then
AC_MSG_CHECKING([Python2 version])
eval `$PYTHON -V 2>&1 | awk '/^Python/ { ver=2; print $ver }' | awk -F. '{ major=1; minor=2; point=3; printf "export PY_MAJOR=%d PY_MINOR=%d PY_POINT=%d\n",$major,$minor,$point }'`
AC_MSG_RESULT([$PY_MAJOR.$PY_MINOR.$PY_POINT])
if test "$PY_MAJOR" -lt 2; then
echo WARNING: Python version 2.6 or later does not seem to be installed.
enable_python2=false
else
if test "$PY_MAJOR" -eq 2 -a "$PY_MINOR" -lt 6 ; then
echo WARNING: Python version 2.$PY_MINOR is too old.
echo Python version 2.6 or later is required for Python builds.
enable_python2=false
else
PCP_CHECK_PYTHON_HEADER([$PY_MAJOR], [$PY_MINOR])
fi
fi
fi
if test "$do_python" != "check" -a "$enable_python2" != "true"
then
AC_MSG_ERROR([cannot enable Python - no supported version found])
fi
])
AC_SUBST(enable_python2)
dnl check if python3 tools/packages wanted (need python >= 3.3)
enable_python3=false
AS_IF([test "x$do_python3" != "xno"], [
enable_python3=true
if test -z "$PYTHON3"
then
enable_python3=false
else
AC_MSG_CHECKING([Python3 version])
eval `$PYTHON3 -V 2>&1 | awk '/^Python/ { ver=2; print $ver }' | awk -F. '{ major=1; minor=2; point=3; printf "export PY_MAJOR=%d PY_MINOR=%d PY_POINT=%d\n",$major,$minor,$point }'`
AC_MSG_RESULT([$PY_MAJOR.$PY_MINOR.$PY_POINT])
if test "$PY_MAJOR" -lt 3; then
echo WARNING: Python version 3.3 or later does not seem to be installed.
enable_python3=false
else
if test "$PY_MAJOR" -eq 3 -a "$PY_MINOR" -lt 3 ; then
echo WARNING: Python version 3.$PY_MINOR is too old.
echo Python version 3.3 or later is required for Python builds.
enable_python3=false
else
PCP_CHECK_PYTHON_HEADER([$PY_MAJOR], [$PY_MINOR])
fi
fi
fi
if test "$do_python3" != "check" -a "$enable_python3" != "true"
then
AC_MSG_ERROR([cannot enable Python3 - no supported version found])
fi
])
AC_SUBST(enable_python3)
dnl convenience macro to determine if either python is available
AC_MSG_CHECKING([for any python version])
if test "$cross_compiling" = "yes"; then
ans=$have_python
echo "cross-compile -> \"$ans\"" >&5
elif test "$enable_python2" = "true" -o "$enable_python3" = "true"
then
have_python=true
else
have_python=false
fi
AC_SUBST(have_python)
if $have_python; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
dnl choose the prefered python executable (py2 -> py3 transtion)
if test "$enable_python3" = "true"
then
pcp_python_prog=$PYTHON3
elif test "$enable_python2" = "true"
then
pcp_python_prog=$PYTHON
else
pcp_python_prog=""
fi
AC_SUBST(pcp_python_prog)
dnl Enable for support for the /usr/bin/dstat compatibility symlink
AC_MSG_CHECKING(for dstat symlink)
enable_dstat=false
if test "$do_dstat_symlink" = "check" -o "$do_dstat_symlink" = "yes"
then
if test "$have_python" = "false" -a "$do_dstat_symlink" = "yes"
then
AC_MSG_ERROR([cannot enable dstat symlink - no python found])
else
enable_dstat=true
fi
fi
AC_SUBST(enable_dstat)
if $enable_dstat; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
dnl check availability of some Python modules
dnl usage PCP_CHECK_PYTHON_MODULE(module_name) or
dnl PCP_CHECK_PYTHON_MODULE(module_name, <import string>)