This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix .gitignore: only ignore 'perl' in root of repo, not U/perl subdir
[metaconfig.git] / U / perl / dtraceobject.U
index e9f07dc..8bbbb36 100644 (file)
@@ -3,21 +3,54 @@
 ?RCS: You may distribute under the terms of either the GNU General Public
 ?RCS: License or the Artistic License, as specified in the README file.
 ?RCS:
-?MAKE:dtraceobject: usedtrace dtrace cc ccflags rm optimize Compile cat
-?MAKE: -pick add $@ $@
+?MAKE:dtraceobject dtracexnolibs: usedtrace dtrace cc ccflags optimize \
+               Compile cat rm_try
+?MAKE: -pick add $@ %<
 ?S:dtraceobject:
 ?S:    Whether we need to build an object file with the dtrace tool.
 ?S:.
+?S:dtracexnolibs:
+?S:    Whether dtrace accepts -xnolibs.  If available we call dtrace -h
+?S:    and dtrace -G with -xnolibs to allow dtrace to run in a jail on
+?S:    FreeBSD.
+?S:.
+?T:xnolibs
 : Probe whether dtrace builds an object, as newer Illumos requires an input
 : object file that uses at least one of the probes defined in the .d file
 case "$usedtrace" in
 $define)
+    case "$dtracexnolibs" in
+    $define|true|[yY]*)
+        dtracexnolibs=$define
+       $dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h
+       ;;
+    ' '|'')
+        if $dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
+            dtracexnolibs=$define
+            echo "Your dtrace accepts -xnolibs"
+       elif $dtrace -h -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
+            dtracexnolibs=$undef
+            echo "Your dtrace doesn't accept -xnolibs"
+       else
+             echo "Your dtrace doesn't work at all, try building without dtrace support" >&4
+            exit 1
+       fi
+       ;;
+    *)
+        dtracexnolibs=$undef
+       $dtrace -h -s ../perldtrace.d -o perldtrace.h
+       ;;
+    esac
+    case $dtracexnolibs in
+    $define) xnolibs=-xnolibs ;;
+    *) xnolibs= ;;
+    esac
+
     case "$dtraceobject" in
     $define|true|[yY]*)
         dtraceobject=$define
         ;;
     ' '|'')
-        $dtrace -h -s ../perldtrace.d -o perldtrace.h
         $cat >try.c <<EOM
 #include "perldtrace.h"
 int main(void) {
@@ -27,13 +60,13 @@ int main(void) {
 EOM
         dtraceobject=$undef
         if $cc -c -o try.o $optimize $ccflags try.c \
-                    && $dtrace -G -s ../perldtrace.d try.o >/dev/null 2>&1; then
+                    && $dtrace -G $xnolibs -s ../perldtrace.d try.o >/dev/null 2>&1; then
                 dtraceobject=$define
             echo "Your dtrace builds an object file"
         fi
-        $rm -f try.c try.o perldtrace.o
         ;;
     *) dtraceobject=$undef ;;
     esac
+    $rm_try perldtrace.o perldtrace.h
 esac