This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
8bbbb36e2d15e715956efbef71949948ba599c64
[metaconfig.git] / U / perl / dtraceobject.U
1 ?RCS: Copyright (c) 2016 Tony Cook
2 ?RCS:
3 ?RCS: You may distribute under the terms of either the GNU General Public
4 ?RCS: License or the Artistic License, as specified in the README file.
5 ?RCS:
6 ?MAKE:dtraceobject dtracexnolibs: usedtrace dtrace cc ccflags optimize \
7                 Compile cat rm_try
8 ?MAKE:  -pick add $@ %<
9 ?S:dtraceobject:
10 ?S:     Whether we need to build an object file with the dtrace tool.
11 ?S:.
12 ?S:dtracexnolibs:
13 ?S:     Whether dtrace accepts -xnolibs.  If available we call dtrace -h
14 ?S:     and dtrace -G with -xnolibs to allow dtrace to run in a jail on
15 ?S:     FreeBSD.
16 ?S:.
17 ?T:xnolibs
18 : Probe whether dtrace builds an object, as newer Illumos requires an input
19 : object file that uses at least one of the probes defined in the .d file
20 case "$usedtrace" in
21 $define)
22     case "$dtracexnolibs" in
23     $define|true|[yY]*)
24         dtracexnolibs=$define
25         $dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h
26         ;;
27     ' '|'')
28         if $dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
29              dtracexnolibs=$define
30              echo "Your dtrace accepts -xnolibs"
31         elif $dtrace -h -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
32              dtracexnolibs=$undef
33              echo "Your dtrace doesn't accept -xnolibs"
34         else
35              echo "Your dtrace doesn't work at all, try building without dtrace support" >&4
36              exit 1
37         fi
38         ;;
39     *)
40         dtracexnolibs=$undef
41         $dtrace -h -s ../perldtrace.d -o perldtrace.h
42         ;;
43     esac
44     case $dtracexnolibs in
45     $define) xnolibs=-xnolibs ;;
46     *) xnolibs= ;;
47     esac
48
49     case "$dtraceobject" in
50     $define|true|[yY]*)
51         dtraceobject=$define
52         ;;
53     ' '|'')
54         $cat >try.c <<EOM
55 #include "perldtrace.h"
56 int main(void) {
57     PERL_LOADED_FILE("dummy");
58     return 0;
59 }
60 EOM
61         dtraceobject=$undef
62         if $cc -c -o try.o $optimize $ccflags try.c \
63                     && $dtrace -G $xnolibs -s ../perldtrace.d try.o >/dev/null 2>&1; then
64                 dtraceobject=$define
65             echo "Your dtrace builds an object file"
66         fi
67         ;;
68     *) dtraceobject=$undef ;;
69     esac
70     $rm_try perldtrace.o perldtrace.h
71 esac
72