#!/usr/bin/env perl

# Copyright © 2017 Jakub Wilk <jwilk@jwilk.net>
#
# This file is part of pdf2djvu.
#
# pdf2djvu is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# pdf2djvu is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

use strict;
use warnings;

use Cwd qw(getcwd realpath);
use File::Spec qw();
use FindBin qw();

my $here = $FindBin::Bin;
my $root = realpath("$here/../src");

sub relativize
{
    my ($path) = @_;
    if ($path =~ m{\A\Q$root\E/}) {
        $path = File::Spec->abs2rel($path)
    }
    return $path;
}

my @argv = map { relativize($_); } @ARGV;
exec { $argv[0] } @argv or die;

# vim:ts=4 sts=4 sw=4 et
