#!/usr/bin/perl -w

=head1 NAME

dh_ocamlld - add calls to ocaml-ldconf in maintainer scripts

=cut

use strict;
use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

B<dh_ocamlld> [S<I<debhelper options>>] [B<-A>] [B<-n>] S<I<dir ...>>

=head1 DESCRIPTION

dh_ocamlld is a debhelper program that automatically adds calls to
C<ocaml-ldconf> in maintainer scripts.

=head1 OPTIONS

=over 4

=item B<-A>, B<--all>

Change maintainer scripts for ALL packages acted on, not just the first.

=item B<-n>, B<--noscripts>

Do nothing.

=item I<dir ...>

Specify directories to pass through C<ocaml-ldconf>.

=back

=cut

init();

foreach my $package (@{$dh{DOPACKAGES}}) {
	my (@dirs, $DIR);

	if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
		push @dirs, @ARGV;
	}
	if (@dirs && ! $dh{NOSCRIPTS}) {
		$DIR = join(' -a ', @dirs);
		autoscript($package,"postinst","postinst-ocamlld", "s:#DIR#:$DIR:;s/#PACKAGE#/$package/");
		my $DIR = join(' -r ', @dirs);
		autoscript($package,"postrm","postrm-ocamlld", "s:#DIR#:$DIR:;s/#PACKAGE#/$package/");
	}
}

=head1 AUTHOR

Denis Barbier E<lt>barbier@debian.orgE<gt>

=cut
