mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-20 06:23:14 +00:00
[makefile] Split config.h out into config/*.h and kill off mkconfig.pl
This commit is contained in:
parent
a2588547f9
commit
e817a347fb
@ -33,7 +33,6 @@ NM := $(CROSS_COMPILE)nm
|
||||
OBJDUMP := $(CROSS_COMPILE)objdump
|
||||
PARSEROM := $(PERL) ./util/parserom.pl
|
||||
MAKEROM := $(PERL) ./util/makerom.pl
|
||||
MKCONFIG := $(PERL) ./util/mkconfig.pl
|
||||
SYMCHECK := $(PERL) ./util/symcheck.pl
|
||||
SORTOBJDUMP := $(PERL) ./util/sortobjdump.pl
|
||||
NRV2B := ./util/nrv2b
|
||||
|
@ -232,14 +232,6 @@ ifdef ARCH
|
||||
include arch/$(ARCH)/Makefile
|
||||
endif
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# config/%.h files are generated from config.h using mkconfig.pl
|
||||
#
|
||||
config/%.h : config*.h
|
||||
$(MKCONFIG) config.h
|
||||
CLEANUP += config/*.h
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Source file handling
|
||||
|
1
src/config/.gitignore
vendored
1
src/config/.gitignore
vendored
@ -1,2 +1 @@
|
||||
*.h
|
||||
.buildserial.*
|
||||
|
@ -1,15 +1,13 @@
|
||||
/*
|
||||
* This file defines the configuration for Etherboot.
|
||||
#ifndef CONFIG_GENERAL_H
|
||||
#define CONFIG_GENERAL_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* The build system splits this file into several individual header
|
||||
* files of the form config/%.h, so that changing one option doesn't
|
||||
* necessitate a rebuild of every single object. For this reason, it
|
||||
* is important to maintain the strict formatting in this file.
|
||||
* General configuration
|
||||
*
|
||||
*/
|
||||
|
||||
/* @BEGIN general.h
|
||||
*
|
||||
/*
|
||||
* Console configuration
|
||||
*
|
||||
* These options specify the console types that Etherboot will use for
|
||||
@ -23,36 +21,7 @@
|
||||
#undef CONSOLE_BTEXT /* Who knows what this does? */
|
||||
#undef CONSOLE_PC_KBD /* Direct access to PC keyboard */
|
||||
|
||||
/* @END general.h */
|
||||
|
||||
/* @BEGIN serial.h
|
||||
*
|
||||
* Serial port configuration
|
||||
*
|
||||
* These options affect the operation of the serial console. They
|
||||
* take effect only if the serial console is included using the
|
||||
* CONSOLE_SERIAL option.
|
||||
*
|
||||
*/
|
||||
|
||||
#define COMCONSOLE 0x3f8 /* I/O port address */
|
||||
|
||||
/* Keep settings from a previous user of the serial port (e.g. lilo or
|
||||
* LinuxBIOS), ignoring COMSPEED, COMDATA, COMPARITY and COMSTOP.
|
||||
*/
|
||||
#undef COMPRESERVE
|
||||
|
||||
#ifndef COMPRESERVE
|
||||
#define COMSPEED 115200 /* Baud rate */
|
||||
#define COMDATA 8 /* Data bits */
|
||||
#define COMPARITY 0 /* Parity: 0=None, 1=Odd, 2=Even */
|
||||
#define COMSTOP 1 /* Stop bits */
|
||||
#endif
|
||||
|
||||
/* @END serial.h */
|
||||
|
||||
/* @BEGIN general.h
|
||||
*
|
||||
/*
|
||||
* Timer configuration
|
||||
*
|
||||
*/
|
||||
@ -61,33 +30,14 @@
|
||||
#define BANNER_TIMEOUT 20 /* Tenths of a second for which the shell
|
||||
banner should appear */
|
||||
|
||||
/* @END general.h */
|
||||
|
||||
/* @BEGIN isa.h
|
||||
*
|
||||
* ISA probe address configuration
|
||||
*
|
||||
* You can override the list of addresses that will be probed by any
|
||||
* ISA drivers.
|
||||
*
|
||||
*/
|
||||
#undef ISA_PROBE_ADDRS /* e.g. 0x200, 0x300 */
|
||||
#undef ISA_PROBE_ONLY /* Do not probe any other addresses */
|
||||
|
||||
/* @END isa.h */
|
||||
|
||||
/* @BEGIN general.h
|
||||
*
|
||||
/*
|
||||
* Network protocols
|
||||
*
|
||||
*/
|
||||
|
||||
#define NET_PROTO_IPV4 /* IPv4 protocol */
|
||||
|
||||
/* @END general.h */
|
||||
|
||||
/* @BEGIN general.h
|
||||
*
|
||||
/*
|
||||
* Download protocols
|
||||
*
|
||||
*/
|
||||
@ -101,10 +51,7 @@
|
||||
#undef DOWNLOAD_PROTO_SLAM /* Scalable Local Area Multicast */
|
||||
#undef DOWNLOAD_PROTO_FSP /* FSP? */
|
||||
|
||||
/* @END general.h */
|
||||
|
||||
/* @BEGIN general.h
|
||||
*
|
||||
/*
|
||||
* Name resolution modules
|
||||
*
|
||||
*/
|
||||
@ -112,10 +59,7 @@
|
||||
#define DNS_RESOLVER /* DNS resolver */
|
||||
#undef NMB_RESOLVER /* NMB resolver */
|
||||
|
||||
/* @END general.h */
|
||||
|
||||
/* @BEGIN general.h
|
||||
*
|
||||
/*
|
||||
* Image types
|
||||
*
|
||||
* Etherboot supports various image formats. Select whichever ones
|
||||
@ -133,10 +77,7 @@
|
||||
#define IMAGE_BZIMAGE /* Linux bzImage image support */
|
||||
#define IMAGE_COMBOOT /* SYSLINUX COMBOOT image support */
|
||||
|
||||
/* @END general.h */
|
||||
|
||||
/* @BEGIN general.h
|
||||
*
|
||||
/*
|
||||
* Command-line commands to include
|
||||
*
|
||||
*/
|
||||
@ -149,10 +90,7 @@
|
||||
#define DHCP_CMD /* DHCP management commands */
|
||||
#define SANBOOT_CMD /* SAN boot commands */
|
||||
|
||||
/* @END general.h */
|
||||
|
||||
/* @BEGIN general.h
|
||||
*
|
||||
/*
|
||||
* Obscure configuration options
|
||||
*
|
||||
* You probably don't need to touch these.
|
||||
@ -170,6 +108,4 @@
|
||||
#undef GDBUDP /* Remote GDB debugging over UDP
|
||||
* (both may be set) */
|
||||
|
||||
/* @END general.h */
|
||||
|
||||
/* @TRYSOURCE config-local.h */
|
||||
#endif /* CONFIG_GENERAL_H */
|
15
src/config/isa.h
Normal file
15
src/config/isa.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef CONFIG_ISA_H
|
||||
#define CONFIG_ISA_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* ISA probe address configuration
|
||||
*
|
||||
* You can override the list of addresses that will be probed by any
|
||||
* ISA drivers.
|
||||
*
|
||||
*/
|
||||
#undef ISA_PROBE_ADDRS /* e.g. 0x200, 0x300 */
|
||||
#undef ISA_PROBE_ONLY /* Do not probe any other addresses */
|
||||
|
||||
#endif /* CONFIG_ISA_H */
|
28
src/config/serial.h
Normal file
28
src/config/serial.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef CONFIG_SERIAL_H
|
||||
#define CONFIG_SERIAL_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Serial port configuration
|
||||
*
|
||||
* These options affect the operation of the serial console. They
|
||||
* take effect only if the serial console is included using the
|
||||
* CONSOLE_SERIAL option.
|
||||
*
|
||||
*/
|
||||
|
||||
#define COMCONSOLE 0x3f8 /* I/O port address */
|
||||
|
||||
/* Keep settings from a previous user of the serial port (e.g. lilo or
|
||||
* LinuxBIOS), ignoring COMSPEED, COMDATA, COMPARITY and COMSTOP.
|
||||
*/
|
||||
#undef COMPRESERVE
|
||||
|
||||
#ifndef COMPRESERVE
|
||||
#define COMSPEED 115200 /* Baud rate */
|
||||
#define COMDATA 8 /* Data bits */
|
||||
#define COMPARITY 0 /* Parity: 0=None, 1=Odd, 2=Even */
|
||||
#define COMSTOP 1 /* Stop bits */
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_SERIAL_H */
|
@ -1,205 +0,0 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use File::Spec::Functions qw ( :ALL );
|
||||
use File::stat;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $cfgdir = "config";
|
||||
my $config_h = shift || "config.h";
|
||||
my @input_files;
|
||||
|
||||
# Read in a whole file
|
||||
#
|
||||
sub read_file {
|
||||
my $file = shift;
|
||||
|
||||
open my $fh, "<$file" or die "Could not open file $file: $!\n";
|
||||
local $/;
|
||||
my $data = <$fh>;
|
||||
close $fh;
|
||||
return $data;
|
||||
}
|
||||
|
||||
# Write out a whole file
|
||||
#
|
||||
sub write_file {
|
||||
my $file = shift;
|
||||
my $data = shift;
|
||||
|
||||
open my $fh, ">$file" or die "Could not write $file: $!\n";
|
||||
print $fh $data;
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Delete a file
|
||||
#
|
||||
sub delete_file {
|
||||
my $file = shift;
|
||||
|
||||
unlink $file or die "Could not delete $file: $!\n";
|
||||
}
|
||||
|
||||
# Get a file modification time
|
||||
#
|
||||
sub file_mtime {
|
||||
my $file = shift;
|
||||
|
||||
my $stat = stat ( $file ) or die "Could not stat $file: $!\n";
|
||||
return $stat->mtime;
|
||||
}
|
||||
|
||||
# Read all the .h files in a directory
|
||||
#
|
||||
sub read_dir {
|
||||
my $dir = shift;
|
||||
|
||||
opendir my $dh, $dir or die "Could not open directory $dir: $!\n";
|
||||
my @entries = grep { /\.h$/ } readdir $dh;
|
||||
closedir $dh;
|
||||
return @entries;
|
||||
}
|
||||
|
||||
# Get the current configuration by reading the configuration file
|
||||
# fragments
|
||||
#
|
||||
sub current_config {
|
||||
my $dir = shift;
|
||||
|
||||
my $cfg = {};
|
||||
foreach my $file ( read_dir ( $dir ) ) {
|
||||
$cfg->{$file} = read_file ( catfile ( $dir, $file ) );
|
||||
}
|
||||
return $cfg;
|
||||
}
|
||||
|
||||
# Calculate guard name for a header file
|
||||
#
|
||||
sub guard {
|
||||
my $name = shift;
|
||||
|
||||
$name =~ s/\W/_/g;
|
||||
return "CONFIG_".( uc $name );
|
||||
}
|
||||
|
||||
# Calculate preamble for a header file
|
||||
#
|
||||
sub preamble {
|
||||
my $name = shift;
|
||||
my $master = shift;
|
||||
|
||||
my $guard = guard ( $name );
|
||||
my $preamble = <<"EOF";
|
||||
/*
|
||||
* This file is automatically generated from $master. Do not edit this
|
||||
* file; edit $master instead.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef $guard
|
||||
#define $guard
|
||||
EOF
|
||||
return $preamble;
|
||||
}
|
||||
|
||||
# Calculate postamble for a header file
|
||||
#
|
||||
sub postamble {
|
||||
my $name = shift;
|
||||
|
||||
my $guard = guard ( $name );
|
||||
return "\n#endif /* $guard */\n";
|
||||
}
|
||||
|
||||
# Parse one config.h file into an existing configuration
|
||||
#
|
||||
sub parse_config {
|
||||
my $file = shift;
|
||||
my $cfg = shift;
|
||||
my $cursor = "";
|
||||
|
||||
push ( @input_files, $file );
|
||||
|
||||
open my $fh, "<$file" or die "Could not open $file: $!\n";
|
||||
while ( <$fh> ) {
|
||||
if ( ( my $newcursor, my $suffix ) = /\@BEGIN\s+(\w+\.h)(.*)$/ ) {
|
||||
die "Missing \"\@END $cursor\" before \"\@BEGIN $1\""
|
||||
." at $file line $.\n" if $cursor;
|
||||
$cursor = $newcursor;
|
||||
$cfg->{$cursor} = preamble ( $cursor, $file )
|
||||
unless exists $cfg->{$cursor};
|
||||
$cfg->{$cursor} .= "\n/*".$suffix."\n";
|
||||
} elsif ( ( my $prefix, my $oldcursor ) = /^(.*)\@END\s+(\w+\.h)/ ) {
|
||||
die "Missing \"\@BEGIN $oldcursor\" before \"\@END $oldcursor\""
|
||||
." at $file line $.\n" unless $cursor eq $oldcursor;
|
||||
$cfg->{$cursor} .= $prefix."*/\n";
|
||||
$cursor = "";
|
||||
} elsif ( ( my $newfile ) = /\@TRYSOURCE\s+([\w\-]+\.h)/ ) {
|
||||
die "Missing \"\@END $cursor\" before \"\@TRYSOURCE $newfile\""
|
||||
." at $file line $.\n" if $cursor;
|
||||
parse_config ( $newfile, $cfg ) if -e $newfile;
|
||||
} else {
|
||||
$cfg->{$cursor} .= $_ if $cursor;
|
||||
}
|
||||
}
|
||||
close $fh;
|
||||
die "Missing \"\@END $cursor\" in $file\n" if $cursor;
|
||||
}
|
||||
|
||||
# Get the new configuration by splitting config.h file using the
|
||||
# @BEGIN/@END tags
|
||||
#
|
||||
sub new_config {
|
||||
my $file = shift;
|
||||
my $cfg = {};
|
||||
|
||||
parse_config ( $file, $cfg );
|
||||
|
||||
foreach my $cursor ( keys %$cfg ) {
|
||||
$cfg->{$cursor} .= postamble ( $cursor );
|
||||
}
|
||||
|
||||
return $cfg;
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Main program
|
||||
|
||||
# Read in current config file fragments
|
||||
#
|
||||
my $current = current_config ( $cfgdir );
|
||||
|
||||
# Read in config.h and split it into fragments
|
||||
#
|
||||
my $new = new_config ( $config_h );
|
||||
|
||||
# Delete any no-longer-wanted config file fragments
|
||||
#
|
||||
foreach my $file ( keys %$current ) {
|
||||
unlink catfile ( $cfgdir, $file ) unless exists $new->{$file};
|
||||
}
|
||||
|
||||
# Write out any modified fragments, and find the oldest timestamp of
|
||||
# any unmodified fragments.
|
||||
#
|
||||
my $oldest = time ();
|
||||
foreach my $file ( keys %$new ) {
|
||||
if ( $current->{$file} && $new->{$file} eq $current->{$file} ) {
|
||||
# Unmodified
|
||||
my $time = file_mtime ( catfile ( $cfgdir, $file ) );
|
||||
$oldest = $time if $time < $oldest;
|
||||
} else {
|
||||
write_file ( catfile ( $cfgdir, $file ), $new->{$file} );
|
||||
}
|
||||
}
|
||||
|
||||
# If we now have fragments that are older than config.h, set the
|
||||
# timestamp on each input file to match the oldest fragment, to
|
||||
# prevent make from always attempting to rebuild the fragments.
|
||||
#
|
||||
foreach my $file ( @input_files ) {
|
||||
if ( $oldest < file_mtime ( $file ) ) {
|
||||
utime time(), $oldest, $file or die "Could not touch $file: $!\n";
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user