use lib qw(. c c/blib/arch);

use lang;
use keyboard;

my $prefix = $ENV{DEST};

sub md { if (-d $_[0]) { `install -d $prefix/$_[0]`; 1 } else { 0 } }
sub install { `cp -f $_[0] $prefix/$_[0]`; die if $? }

sub locale {
    foreach (map { lang::text2lang($_) } lang::list()) {
	md(my $d = "/usr/share/locale/$_") or next;
	foreach (<$d/*>) {
	    install $_ if -f $_;
	}
	{
	    md(my $lc = "$d/LC_MESSAGES") or next;
	    $lc = "$lc/SYS_LC_MESSAGES";
	    install $lc if -f $lc;
	}
    }
    my $Xlocale = "/usr/X11R6/lib/X11/locale";
    foreach ('C', 'iso8859-1', 'koi8-r', 'iso8859-9', map { lang::text2lang($_) } lang::list()) {
	md(my $d = "$Xlocale/$_") or next;
	$d = "$d/XLC_LOCALE";
	install $d if -f $d;
    }
    install "$Xlocale/locale.alias";
    install "$Xlocale/locale.dir";
}

sub xmodmap {
    md(my $d = "/usr/share/xmodmap") or return;
    install "$d/xmodmap.$_" foreach keyboard::xmodmaps();
}

1;
