#!	/usr/bin/perl
$|=1;	# Un-buffer standard output

sub ask {
	print @_,"? [No] ";
	$answer=<STDIN>;
	return ( $answer =~ /^[yY].*/ );
}

sub fail {
	print @_,".\n";
	exit -1;
}

print "\nYou'll have to configure the kernel, and select the AX.25 and SLIP\n";
print "drivers, along with whatever other drivers your system needs.\n\n";

while ( ask "Configure the kernel now" ) {
	if ( chdir "/usr/src/linux" != 1 ) {
		fail "Can't change directory to /usr/src/linux";
	}
	print "\n\nAgain, Be sure to select AX.25 and SLIP.\n";
	print "Starting kernel configuration.\n\n\n";
	if ( system("make config") != 0 ) {
		print "\nKernel configuration failed.\n";
	}
	else {
		print "\nThe kernel configuration succeeded.\n";
		print "If you aren't satisfied with that configuration run,\n";
		print "you can try it again now. ";
	}
}

print "\nNow you can build the kernel. This might take hours, and will\n";
print "be done in the background. When it's finished, if the build has\n";
print "succeeded, LILO will be run to install the new kernel on your hard\n";
print "disk. The log from the \"make\" command will be left in the file\n";
print "/usr/src/linux/MAKE.LOG .\n\n";

if ( ask "Build the kernel now" ) {
	if ( chdir "/usr/src/linux" != 1 ) {
		fail "Can't change directory to /usr/src/linux";
	}
	if ( system("(make clean;make dep;make zlilo) 2>1 >&MAKE.LOG &") != 0 ) {
		fail "Make failed";
	}
}
