Selaa lähdekoodia

[makefile] Split config.h out into config/*.h and kill off mkconfig.pl

tags/v0.9.6
Michael Brown 16 vuotta sitten
vanhempi
commit
e817a347fb
7 muutettua tiedostoa jossa 57 lisäystä ja 293 poistoa
  1. 0
    1
      src/Makefile
  2. 0
    8
      src/Makefile.housekeeping
  3. 0
    1
      src/config/.gitignore
  4. 14
    78
      src/config/general.h
  5. 15
    0
      src/config/isa.h
  6. 28
    0
      src/config/serial.h
  7. 0
    205
      src/util/mkconfig.pl

+ 0
- 1
src/Makefile Näytä tiedosto

@@ -33,7 +33,6 @@ NM		:= $(CROSS_COMPILE)nm
33 33
 OBJDUMP		:= $(CROSS_COMPILE)objdump
34 34
 PARSEROM	:= $(PERL) ./util/parserom.pl
35 35
 MAKEROM		:= $(PERL) ./util/makerom.pl
36
-MKCONFIG	:= $(PERL) ./util/mkconfig.pl
37 36
 SYMCHECK	:= $(PERL) ./util/symcheck.pl
38 37
 SORTOBJDUMP	:= $(PERL) ./util/sortobjdump.pl
39 38
 NRV2B		:= ./util/nrv2b

+ 0
- 8
src/Makefile.housekeeping Näytä tiedosto

@@ -232,14 +232,6 @@ ifdef ARCH
232 232
 include arch/$(ARCH)/Makefile
233 233
 endif
234 234
 
235
-###############################################################################
236
-#
237
-# config/%.h files are generated from config.h using mkconfig.pl
238
-#
239
-config/%.h : config*.h
240
-	$(MKCONFIG) config.h
241
-CLEANUP	+= config/*.h
242
-
243 235
 ###############################################################################
244 236
 #
245 237
 # Source file handling

+ 0
- 1
src/config/.gitignore Näytä tiedosto

@@ -1,2 +1 @@
1
-*.h
2 1
 .buildserial.*

src/config.h → src/config/general.h Näytä tiedosto

@@ -1,15 +1,13 @@
1
-/*
2
- * This file defines the configuration for Etherboot.
1
+#ifndef CONFIG_GENERAL_H
2
+#define CONFIG_GENERAL_H
3
+
4
+/** @file
3 5
  *
4
- * The build system splits this file into several individual header
5
- * files of the form config/%.h, so that changing one option doesn't
6
- * necessitate a rebuild of every single object.  For this reason, it
7
- * is important to maintain the strict formatting in this file.
6
+ * General configuration
8 7
  *
9 8
  */
10 9
 
11
-/* @BEGIN general.h
12
- *
10
+/*
13 11
  * Console configuration
14 12
  *
15 13
  * These options specify the console types that Etherboot will use for
@@ -23,36 +21,7 @@
23 21
 #undef	CONSOLE_BTEXT		/* Who knows what this does? */
24 22
 #undef	CONSOLE_PC_KBD		/* Direct access to PC keyboard */
25 23
 
26
-/* @END general.h */
27
-
28
-/* @BEGIN serial.h
29
- *
30
- * Serial port configuration
31
- *
32
- * These options affect the operation of the serial console.  They
33
- * take effect only if the serial console is included using the
34
- * CONSOLE_SERIAL option.
35
- *
36
- */
37
-
38
-#define	COMCONSOLE	0x3f8		/* I/O port address */
39
-
40
-/* Keep settings from a previous user of the serial port (e.g. lilo or
41
- * LinuxBIOS), ignoring COMSPEED, COMDATA, COMPARITY and COMSTOP.
42
- */
43
-#undef	COMPRESERVE
44
-
45
-#ifndef COMPRESERVE
46
-#define	COMSPEED	115200		/* Baud rate */
47
-#define	COMDATA		8		/* Data bits */ 
48
-#define	COMPARITY	0		/* Parity: 0=None, 1=Odd, 2=Even */
49
-#define	COMSTOP		1		/* Stop bits */
50
-#endif
51
-
52
-/* @END serial.h */
53
-
54
-/* @BEGIN general.h
55
- *
24
+/*
56 25
  * Timer configuration
57 26
  *
58 27
  */
@@ -61,33 +30,14 @@
61 30
 #define BANNER_TIMEOUT	20	/* Tenths of a second for which the shell
62 31
 				   banner should appear */
63 32
 
64
-/* @END general.h */
65
-
66
-/* @BEGIN isa.h
67
- *
68
- * ISA probe address configuration
69
- *
70
- * You can override the list of addresses that will be probed by any
71
- * ISA drivers.
72
- *
73
- */
74
-#undef	ISA_PROBE_ADDRS		/* e.g. 0x200, 0x300 */
75
-#undef	ISA_PROBE_ONLY		/* Do not probe any other addresses */
76
-
77
-/* @END isa.h */
78
-
79
-/* @BEGIN general.h
80
- *
33
+/*
81 34
  * Network protocols
82 35
  *
83 36
  */
84 37
 
85 38
 #define	NET_PROTO_IPV4		/* IPv4 protocol */
86 39
 
87
-/* @END general.h */
88
-
89
-/* @BEGIN general.h
90
- *
40
+/*
91 41
  * Download protocols
92 42
  *
93 43
  */
@@ -101,10 +51,7 @@
101 51
 #undef	DOWNLOAD_PROTO_SLAM	/* Scalable Local Area Multicast */
102 52
 #undef	DOWNLOAD_PROTO_FSP	/* FSP? */
103 53
 
104
-/* @END general.h */
105
-
106
-/* @BEGIN general.h
107
- *
54
+/*
108 55
  * Name resolution modules
109 56
  *
110 57
  */
@@ -112,10 +59,7 @@
112 59
 #define	DNS_RESOLVER		/* DNS resolver */
113 60
 #undef	NMB_RESOLVER		/* NMB resolver */
114 61
 
115
-/* @END general.h */
116
-
117
-/* @BEGIN general.h
118
- *
62
+/*
119 63
  * Image types
120 64
  *
121 65
  * Etherboot supports various image formats.  Select whichever ones
@@ -133,10 +77,7 @@
133 77
 #define IMAGE_BZIMAGE		/* Linux bzImage image support */
134 78
 #define IMAGE_COMBOOT		/* SYSLINUX COMBOOT image support */
135 79
 
136
-/* @END general.h */ 
137
-
138
-/* @BEGIN general.h
139
- *
80
+/*
140 81
  * Command-line commands to include
141 82
  *
142 83
  */
@@ -149,10 +90,7 @@
149 90
 #define DHCP_CMD		/* DHCP management commands */
150 91
 #define SANBOOT_CMD		/* SAN boot commands */
151 92
 
152
-/* @END general.h */ 
153
-
154
-/* @BEGIN general.h
155
- *
93
+/*
156 94
  * Obscure configuration options
157 95
  *
158 96
  * You probably don't need to touch these.
@@ -170,6 +108,4 @@
170 108
 #undef	GDBUDP			/* Remote GDB debugging over UDP
171 109
 				 * (both may be set) */
172 110
 
173
-/* @END general.h */
174
-
175
-/* @TRYSOURCE config-local.h */
111
+#endif /* CONFIG_GENERAL_H */

+ 15
- 0
src/config/isa.h Näytä tiedosto

@@ -0,0 +1,15 @@
1
+#ifndef CONFIG_ISA_H
2
+#define CONFIG_ISA_H
3
+
4
+/** @file
5
+ *
6
+ * ISA probe address configuration
7
+ *
8
+ * You can override the list of addresses that will be probed by any
9
+ * ISA drivers.
10
+ *
11
+ */
12
+#undef	ISA_PROBE_ADDRS		/* e.g. 0x200, 0x300 */
13
+#undef	ISA_PROBE_ONLY		/* Do not probe any other addresses */
14
+
15
+#endif /* CONFIG_ISA_H */

+ 28
- 0
src/config/serial.h Näytä tiedosto

@@ -0,0 +1,28 @@
1
+#ifndef CONFIG_SERIAL_H
2
+#define CONFIG_SERIAL_H
3
+
4
+/** @file
5
+ *
6
+ * Serial port configuration
7
+ *
8
+ * These options affect the operation of the serial console.  They
9
+ * take effect only if the serial console is included using the
10
+ * CONSOLE_SERIAL option.
11
+ *
12
+ */
13
+
14
+#define	COMCONSOLE	0x3f8		/* I/O port address */
15
+
16
+/* Keep settings from a previous user of the serial port (e.g. lilo or
17
+ * LinuxBIOS), ignoring COMSPEED, COMDATA, COMPARITY and COMSTOP.
18
+ */
19
+#undef	COMPRESERVE
20
+
21
+#ifndef COMPRESERVE
22
+#define	COMSPEED	115200		/* Baud rate */
23
+#define	COMDATA		8		/* Data bits */
24
+#define	COMPARITY	0		/* Parity: 0=None, 1=Odd, 2=Even */
25
+#define	COMSTOP		1		/* Stop bits */
26
+#endif
27
+
28
+#endif /* CONFIG_SERIAL_H */

+ 0
- 205
src/util/mkconfig.pl Näytä tiedosto

@@ -1,205 +0,0 @@
1
-#!/usr/bin/perl -w
2
-
3
-use File::Spec::Functions qw ( :ALL );
4
-use File::stat;
5
-use strict;
6
-use warnings;
7
-
8
-my $cfgdir = "config";
9
-my $config_h = shift || "config.h";
10
-my @input_files;
11
-
12
-# Read in a whole file
13
-#
14
-sub read_file {
15
-  my $file = shift;
16
-
17
-  open my $fh, "<$file" or die "Could not open file $file: $!\n";
18
-  local $/;
19
-  my $data = <$fh>;
20
-  close $fh;
21
-  return $data;
22
-}
23
-
24
-# Write out a whole file
25
-#
26
-sub write_file {
27
-  my $file = shift;
28
-  my $data = shift;
29
-
30
-  open my $fh, ">$file" or die "Could not write $file: $!\n";
31
-  print $fh $data;
32
-  close $fh;
33
-}
34
-
35
-# Delete a file
36
-#
37
-sub delete_file {
38
-  my $file = shift;
39
-
40
-  unlink $file or die "Could not delete $file: $!\n";
41
-}
42
-
43
-# Get a file modification time
44
-#
45
-sub file_mtime {
46
-  my $file = shift;
47
-
48
-  my $stat = stat ( $file ) or die "Could not stat $file: $!\n";
49
-  return $stat->mtime;
50
-}
51
-
52
-# Read all the .h files in a directory
53
-#
54
-sub read_dir {
55
-  my $dir = shift;
56
-
57
-  opendir my $dh, $dir or die "Could not open directory $dir: $!\n";
58
-  my @entries = grep { /\.h$/ } readdir $dh;
59
-  closedir $dh;
60
-  return @entries;
61
-}
62
-
63
-# Get the current configuration by reading the configuration file
64
-# fragments
65
-#
66
-sub current_config {
67
-  my $dir = shift;
68
-
69
-  my $cfg = {};
70
-  foreach my $file ( read_dir ( $dir ) ) {
71
-    $cfg->{$file} = read_file ( catfile ( $dir, $file ) );
72
-  }
73
-  return $cfg;
74
-}
75
-
76
-# Calculate guard name for a header file
77
-#
78
-sub guard {
79
-  my $name = shift;
80
-
81
-  $name =~ s/\W/_/g;
82
-  return "CONFIG_".( uc $name );
83
-}
84
-
85
-# Calculate preamble for a header file
86
-#
87
-sub preamble {
88
-  my $name = shift;
89
-  my $master = shift;
90
-
91
-  my $guard = guard ( $name );
92
-  my $preamble = <<"EOF";
93
-/*
94
- * This file is automatically generated from $master.  Do not edit this
95
- * file; edit $master instead.
96
- *
97
- */
98
-
99
-#ifndef $guard
100
-#define $guard
101
-EOF
102
-  return $preamble;
103
-}
104
-
105
-# Calculate postamble for a header file
106
-#
107
-sub postamble {
108
-  my $name = shift;
109
-
110
-  my $guard = guard ( $name );
111
-  return "\n#endif /* $guard */\n";
112
-} 
113
-
114
-# Parse one config.h file into an existing configuration
115
-#
116
-sub parse_config {
117
-  my $file = shift;
118
-  my $cfg = shift;
119
-  my $cursor = "";
120
-
121
-  push ( @input_files, $file );
122
-
123
-  open my $fh, "<$file" or die "Could not open $file: $!\n";
124
-  while ( <$fh> ) {
125
-    if ( ( my $newcursor, my $suffix ) = /\@BEGIN\s+(\w+\.h)(.*)$/ ) {
126
-      die "Missing \"\@END $cursor\" before \"\@BEGIN $1\""
127
-	  ." at $file line $.\n" if $cursor;
128
-      $cursor = $newcursor;
129
-      $cfg->{$cursor} = preamble ( $cursor, $file )
130
-	  unless exists $cfg->{$cursor};
131
-      $cfg->{$cursor} .= "\n/*".$suffix."\n";
132
-    } elsif ( ( my $prefix, my $oldcursor ) = /^(.*)\@END\s+(\w+\.h)/ ) {
133
-      die "Missing \"\@BEGIN $oldcursor\" before \"\@END $oldcursor\""
134
-	  ." at $file line $.\n" unless $cursor eq $oldcursor;
135
-      $cfg->{$cursor} .= $prefix."*/\n";
136
-      $cursor = "";
137
-    } elsif ( ( my $newfile ) = /\@TRYSOURCE\s+([\w\-]+\.h)/ ) {
138
-      die "Missing \"\@END $cursor\" before \"\@TRYSOURCE $newfile\""
139
-	  ." at $file line $.\n" if $cursor;
140
-      parse_config ( $newfile, $cfg ) if -e $newfile;
141
-    } else {
142
-      $cfg->{$cursor} .= $_ if $cursor;
143
-    }
144
-  }
145
-  close $fh;
146
-  die "Missing \"\@END $cursor\" in $file\n" if $cursor;
147
-}
148
-
149
-# Get the new configuration by splitting config.h file using the
150
-# @BEGIN/@END tags
151
-#
152
-sub new_config {
153
-  my $file = shift;
154
-  my $cfg = {};
155
-
156
-  parse_config ( $file, $cfg );
157
-
158
-  foreach my $cursor ( keys %$cfg ) {
159
-    $cfg->{$cursor} .= postamble ( $cursor );
160
-  }
161
-
162
-  return $cfg;
163
-}  
164
-
165
-#############################################################################
166
-#
167
-# Main program
168
-
169
-# Read in current config file fragments
170
-#
171
-my $current = current_config ( $cfgdir );
172
-
173
-# Read in config.h and split it into fragments
174
-#
175
-my $new = new_config ( $config_h );
176
-
177
-# Delete any no-longer-wanted config file fragments
178
-#
179
-foreach my $file ( keys %$current ) {
180
-  unlink catfile ( $cfgdir, $file ) unless exists $new->{$file};
181
-}
182
-
183
-# Write out any modified fragments, and find the oldest timestamp of
184
-# any unmodified fragments.
185
-#
186
-my $oldest = time ();
187
-foreach my $file ( keys %$new ) {
188
-  if ( $current->{$file} && $new->{$file} eq $current->{$file} ) {
189
-    # Unmodified
190
-    my $time = file_mtime ( catfile ( $cfgdir, $file ) );
191
-    $oldest = $time if $time < $oldest;
192
-  } else {
193
-    write_file ( catfile ( $cfgdir, $file ), $new->{$file} );
194
-  }
195
-}
196
-
197
-# If we now have fragments that are older than config.h, set the
198
-# timestamp on each input file to match the oldest fragment, to
199
-# prevent make from always attempting to rebuild the fragments.
200
-#
201
-foreach my $file ( @input_files ) {
202
-  if ( $oldest < file_mtime ( $file ) ) {
203
-    utime time(), $oldest, $file or die "Could not touch $file: $!\n";
204
-  }
205
-}

Loading…
Peruuta
Tallenna