#!/usr/bin/perl

$config = shift(@ARGV);
$image = "vmlinux";
if ($config eq "-i") {
	print "Installing ...\n";
	$config = shift(@ARGV);
	$image = "install";
}
if ($config eq "-z") {
	print "Installing ...\n";
	$config = shift(@ARGV);
	$image = "bzImage";
}

die "config file $config does not exist" unless (-f $config);

print("... make mrproper\n");
system("make -j32 mrproper > /dev/null");
print("... cp $config .config\n");
system("cp $config .config");
print("... make oldconfig\n");
system("yes '' | make oldconfig > /dev/null");
print("... make dep\n");
system("make dep > /dev/null");
print("... make $image\n");
system("make -j32 $image > /dev/null");