#!/bin/sh
set -e

if [ ! -e /usr/local/lib/ocaml ]; then
    if mkdir /usr/local/lib/ocaml 2>/dev/null; then
	chown root:staff /usr/local/lib/ocaml
	chmod 2775 /usr/local/lib/ocaml
    fi
fi
if [ ! -e /usr/local/lib/ocaml/4.08.1 ]; then
    if mkdir /usr/local/lib/ocaml/4.08.1 2>/dev/null; then
	chown root:staff /usr/local/lib/ocaml/4.08.1
	chmod 2775 /usr/local/lib/ocaml/4.08.1
    fi
fi
if [ ! -e /usr/local/lib/ocaml/4.08.1/stublibs ]; then
    if mkdir /usr/local/lib/ocaml/4.08.1/stublibs 2>/dev/null; then
	chown root:staff /usr/local/lib/ocaml/4.08.1/stublibs
	chmod 2775 /usr/local/lib/ocaml/4.08.1/stublibs
    fi
fi

for i in /usr/lib/ocaml/3.06 /etc/ocaml /var/lib/ocaml; 		\
do									\
	if [ -e $i/ld.conf ]; then					\
		echo "Removing leftover $i/ld.conf";			\
		rm -f $i/ld.conf;					\
		rmdir --ignore-fail-on-non-empty $i;			\
	fi;								\
done


