#!/usr/bin/env perl

# Generates Makefiles for different systems and packages

use strict;
use warnings;
use utf8;
use File::Basename;
use lib 'perllib';
use Greenstone::Helpers;
use Greenstone::Package;

my $USAGE = "Usage: " . basename($0) . " <distros> <packages>
    distros: A comma separated list of the distros defined in distros/
               Or 'all' (for all distros)
    packages:  A comma separated list of the packages defined in packages/
               Or 'all' (for all packages)
";

$#ARGV == 1 or die $USAGE;

my @distros  = lsfiles "distros",  shift;
my @packages = lsfiles "packages", shift;

for my $distro (@distros) {
    print $distro, "\n";
    for my $package (@packages) {
        print "  - ", $package, "\n";
        makepkg (
            package => $package,
            distro  => $distro
        );
    }
}
