/usr/bin/safe_camlp4 is in ocaml-findlib 1.4-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #! /bin/sh
# Call camlp4 with fallback method if dynamic loading is not supported
dl_string="dynamic loading not supported on this platform"
fn_string="The external function .* is not available"
tmp_stderr="tmp.safe_camlp4_stderr.$$"
tmp_camlp4="tmp.safe_camlp4_camlp4.$$"
trap "rm -f $tmp_stderr $tmp_camlp4" 0
print_stderr=1
code=0
camlp4 "$@" 2>$tmp_stderr || {
code=$?
grep "$dl_string" $tmp_stderr >/dev/null 2>&1; t1=$?
grep "$fn_string" $tmp_stderr >/dev/null 2>&1; t2=$?
if [ $t1 -eq 0 -o $t2 -eq 0 ]; then
# Fallback:
print_stderr=0
cp4_mods=""
cp4_args=""
i=0
for arg in "$@"; do
if [ $i -gt 0 ]; then
cp4_mods="$cp4_mods -I $arg"
cp4_args="$cp4_args -I $arg"
i=0
else
case "$arg" in
*.cma|*.cmo)
cp4_mods="$cp4_mods $arg" ;;
-I)
i=1 ;;
*)
cp4_args="$cp4_args $arg" ;;
esac
fi
done
mkcamlp4 -o $tmp_camlp4 $cp4_mods || exit
./$tmp_camlp4 $cp4_args || exit
code=0
fi
}
if [ $print_stderr -gt 0 ]; then
cat $tmp_stderr >&2
fi
exit $code
|