#!/usr/bin/perl
# psmerge: use Ghostscript to merge PostScript files produced by same application and setup
#
# (c) Reuben Thomas 2012
# (c) Angus J. C. Duggan 1991-1997
# See file LICENSE for details.

use strict;
use warnings;
use File::Basename;
use Getopt::Std;
{
  no warnings 'once';
  $GetOpt::Std::STANDARD_HELP_VERSION = 1;
}

my $prog = basename($0);

sub usage {
  print STDERR "Usage: $prog [-oOUT-FILE] FILE...\n";
  exit 1;
}

our ($opt_o);
usage() unless @ARGV and getopts('o:');
$opt_o ||= '-';

exec +(qw(gs -q -dNOPAUSE -dBATCH -sDEVICE=ps2write), "-sOutputFile=$opt_o", '-f', @ARGV);
die "$prog: Couldn't find Ghostscript (is it installed?), or it failed\n";
