2 # - config.mk parsing functions
4 # Copyright (C) Stefan (metze) Metzmacher 2004
5 # Copyright (C) Jelmer Vernooij 2005
6 # Released under the GNU GPL
9 package smb_build::config_mk;
23 "OBJ_FILES" => "list",
25 "REQUIRED_SUBSYSTEMS" => "list",
30 "MANPAGE" => "string",
32 "PUBLIC_PROTO_HEADER" => "string",
33 "PRIVATE_PROTO_HEADER" => "string"
36 "SUBSYSTEM" => "string",
38 "INIT_FUNCTION" => "string",
39 "OBJ_FILES" => "list",
41 "REQUIRED_SUBSYSTEMS" => "list",
46 "MANPAGE" => "string",
47 "PRIVATE_PROTO_HEADER" => "string"
50 "OBJ_FILES" => "list",
52 "REQUIRED_SUBSYSTEMS" => "list",
57 "MANPAGE" => "string",
58 "INSTALLDIR" => "string",
59 "PRIVATE_PROTO_HEADER" => "string"
62 "MAJOR_VERSION" => "string",
63 "MINOR_VERSION" => "string",
64 "RELEASE_VERSION" => "string",
66 "OBJ_FILES" => "list",
68 "DESCRIPTION" => "string",
70 "REQUIRED_SUBSYSTEMS" => "list",
75 "MANPAGE" => "string",
77 "PUBLIC_HEADERS" => "list",
79 "PUBLIC_PROTO_HEADER" => "string",
80 "PRIVATE_PROTO_HEADER" => "string"
84 use vars qw(@parsed_files);
88 ###########################################################
89 # The parsing function which parses the file
91 # $result = _parse_config_mk($filename)
93 # $filename - the path of the config.mk file
94 # which should be parsed
95 sub run_config_mk($$$)
97 sub run_config_mk($$$);
98 my ($input, $srcdir, $filename) = @_;
102 my $section = "GLOBAL";
105 push (@parsed_files, $srcdir."/".$filename);
107 open(CONFIG_MK, $srcdir."/".$filename) or die("Can't open `$srcdir/$filename'\n");
108 my @lines = <CONFIG_MK>;
117 # lines beginning with '#' are ignored
128 if ($line =~ /^\[([a-zA-Z0-9_:]+)\][\t ]*$/)
136 if ($line =~ /^include (.*)$/) {
137 $makefile .= run_config_mk($input, $srcdir, dirname($filename)."/$1");
142 if ($line =~ /^[ \t]*$/) {
144 if ($infragment) { $makefile.="\n"; }
148 # global stuff is considered part of the makefile
149 if ($section eq "GLOBAL") {
157 if ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/) {
158 $result->{$section}{$1}{VAL} = $2;
159 $result->{$section}{$1}{KEY} = $1;
164 die("$srcdir."/".$filename:$linenum: Bad line while parsing $srcdir."/".$filename");
167 foreach my $section (keys %{$result}) {
168 my ($type, $name) = split(/::/, $section, 2);
170 my $sectype = $section_types->{$type};
171 if (not defined($sectype)) {
172 die($srcdir."/".$filename.":[".$section."] unknown section type \"".$type."\"!");
175 $input->{$name}{NAME} = $name;
176 $input->{$name}{TYPE} = $type;
177 $input->{$name}{BASEDIR} = dirname($filename);
179 foreach my $key (values %{$result->{$section}}) {
180 $key->{VAL} = smb_build::input::strtrim($key->{VAL});
181 my $vartype = $sectype->{$key->{KEY}};
182 if (not defined($vartype)) {
183 die($srcdir."/".$filename.":[".$section."]: unknown attribute type \"$key->{KEY}\"!");
185 if ($vartype eq "string") {
186 $input->{$name}{$key->{KEY}} = $key->{VAL};
187 } elsif ($vartype eq "list") {
188 $input->{$name}{$key->{KEY}} = [smb_build::input::str2array($key->{VAL})];
189 } elsif ($vartype eq "bool") {
190 if (($key->{VAL} ne "YES") and ($key->{VAL} ne "NO")) {
191 die("Invalid value for bool attribute $key->{KEY}: $key->{VAL} in section $section");
193 $input->{$name}{$key->{KEY}} = $key->{VAL};