"CPPFLAGS" => "list",
"LDFLAGS" => "list",
},
+ "PYTHON" => {
+ "LIBRARY_REALNAME" => "string",
+ "PRIVATE_DEPENDENCIES" => "list",
+ "PUBLIC_DEPENDENCIES" => "list",
+ "ENABLE" => "bool",
+ "LDFLAGS" => "list",
+ },
"SUBSYSTEM" => {
- "OBJ_FILES" => "list",
-
- "REQUIRED_SUBSYSTEMS" => "list",
+ "PRIVATE_DEPENDENCIES" => "list",
+ "PUBLIC_DEPENDENCIES" => "list",
"ENABLE" => "bool",
- "NOPROTO" => "bool",
-
- "MANPAGE" => "string",
-
- "PUBLIC_PROTO_HEADER" => "string",
- "PRIVATE_PROTO_HEADER" => "string",
-
- "PUBLIC_HEADERS" => "list",
- "EXTRA_CFLAGS" => "string",
-
- "DEFAULT_VISIBILITY" => "string"
+ "CFLAGS" => "list",
+ "LDFLAGS" => "list",
+ "STANDARD_VISIBILITY" => "string",
+ "INIT_FUNCTION_SENTINEL" => "string"
},
"MODULE" => {
"SUBSYSTEM" => "string",
"INIT_FUNCTION" => "string",
- "OBJ_FILES" => "list",
- "REQUIRED_SUBSYSTEMS" => "list",
+ "PRIVATE_DEPENDENCIES" => "list",
- "ENABLE" => "bool",
- "NOPROTO" => "bool",
+ "ALIASES" => "list",
- "OUTPUT_TYPE" => "string",
+ "ENABLE" => "bool",
- "MANPAGE" => "string",
- "PRIVATE_PROTO_HEADER" => "string",
+ "OUTPUT_TYPE" => "list",
- "EXTRA_CFLAGS" => "string"
+ "CFLAGS" => "list"
},
"BINARY" => {
- "OBJ_FILES" => "list",
- "REQUIRED_SUBSYSTEMS" => "list",
+ "PRIVATE_DEPENDENCIES" => "list",
"ENABLE" => "bool",
- "NOPROTO" => "bool",
- "MANPAGE" => "string",
"INSTALLDIR" => "string",
- "PRIVATE_PROTO_HEADER" => "string",
- "PUBLIC_HEADERS" => "string",
+ "LDFLAGS" => "list",
+ "STANDARD_VISIBILITY" => "string",
- "EXTRA_CFLAGS" => "string"
+ "USE_HOSTCC" => "bool"
},
"LIBRARY" => {
- "MAJOR_VERSION" => "string",
- "MINOR_VERSION" => "string",
- "RELEASE_VERSION" => "string",
-
- "INIT_FUNCTION_TYPE" => "string",
-
- "OBJ_FILES" => "list",
+ "LIBRARY_REALNAME" => "string",
- "DESCRIPTION" => "string",
+ "INIT_FUNCTION_TYPE" => "string",
+ "INIT_FUNCTION_SENTINEL" => "string",
+ "OUTPUT_TYPE" => "list",
- "REQUIRED_SUBSYSTEMS" => "list",
+ "PRIVATE_DEPENDENCIES" => "list",
+ "PUBLIC_DEPENDENCIES" => "list",
"ENABLE" => "bool",
- "NOPROTO" => "bool",
-
- "MANPAGE" => "string",
-
- "PUBLIC_HEADERS" => "list",
- "PUBLIC_PROTO_HEADER" => "string",
- "PRIVATE_PROTO_HEADER" => "string",
-
- "EXTRA_CFLAGS" => "string",
-
- "DEFAULT_VISIBILITY" => "string"
+ "CFLAGS" => "list",
+ "LDFLAGS" => "list",
+ "STANDARD_VISIBILITY" => "string"
}
};
@parsed_files = ();
+sub _read_config_file($$$)
+{
+ use Cwd;
+
+ my ($srcdir, $builddir, $filename) = @_;
+ my @dirlist;
+
+ # We need to change our working directory because config.mk files can
+ # give shell commands as the argument to "include". These shell
+ # commands can take arguments that are relative paths and we don't have
+ # a way of sensibly rewriting these.
+ my $cwd = getcwd;
+ chomp $cwd;
+
+ if ($srcdir ne $builddir) {
+ # Push the builddir path on the front, so we prefer builddir
+ # to srcdir when the file exists in both.
+ @dirlist = ($builddir, $srcdir);
+ } else {
+ @dirlist = ($srcdir);
+ }
+
+ foreach my $d (@dirlist) {
+ my @lines;
+ my $basedir;
+
+ chdir $cwd;
+ chdir $d;
+
+ # We need to catch the exception from open in the case where
+ # the filename is actually a shell pipeline. Why is this
+ # different to opening a regular file? Because this is perl!
+ eval {
+ open(CONFIG_MK, "./$filename");
+ @lines = <CONFIG_MK>;
+ close(CONFIG_MK);
+ };
+
+ chdir $cwd;
+ next unless (@lines);
+
+ # I blame abartlett for this crazy hack -- jpeach
+ if ($filename =~ /\|$/) {
+ $basedir = $builddir;
+ } else {
+ $basedir = dirname($filename);
+ push(@parsed_files, $filename);
+ }
+ $basedir =~ s!^($builddir|$srcdir)[/]!!;
+ return ($filename, $basedir, @lines);
+ }
+
+ chdir $cwd;
+ return;
+}
+
###########################################################
# The parsing function which parses the file
#
-# $result = _parse_config_mk($filename)
+# $result = _parse_config_mk($input, $srcdir, $builddir, $filename)
#
# $filename - the path of the config.mk file
# which should be parsed
-sub run_config_mk($$$)
+sub run_config_mk($$$$)
{
- sub run_config_mk($$$);
- my ($input, $srcdir, $filename) = @_;
+ sub run_config_mk($$$$);
+ my ($input, $srcdir, $builddir, $filename) = @_;
my $result;
my $linenum = -1;
my $infragment = 0;
my $section = "GLOBAL";
my $makefile = "";
- push (@parsed_files, $srcdir."/".$filename);
-
- open(CONFIG_MK, $srcdir."/".$filename) or die("Can't open `$srcdir/$filename'\n");
- my @lines = <CONFIG_MK>;
- close(CONFIG_MK);
+ my $basedir;
+
+ my $parsing_file;
+ my @lines;
+
+ $ENV{builddir} = $builddir;
+ $ENV{srcdir} = $srcdir;
+
+ ($parsing_file, $basedir, @lines) =
+ _read_config_file($srcdir, $builddir, $filename);
+
+ die ("$0: can't open '$filename'")
+ unless ($parsing_file and $basedir and @lines);
my $line = "";
my $prev = "";
+ # Emit a line that lets us match up final makefile output with the
+ # corresponding input files. The curlies are so you can match the
+ # BEGIN/END pairs in a text editor.
+ $makefile .= "# BEGIN{ $parsing_file\n";
+
foreach (@lines) {
$linenum++;
$prev = "";
}
- if ($line =~ /^\[([a-zA-Z0-9_:]+)\][\t ]*$/)
+ if ($line =~ /^\[([-a-zA-Z0-9_.:]+)\][\t ]*$/)
{
$section = $1;
$infragment = 0;
+
+ $result->{$section}{EXISTS}{KEY} = "EXISTS";
+ $result->{$section}{EXISTS}{VAL} = 1;
next;
}
# include
- if ($line =~ /^include (.*)$/) {
- $makefile .= run_config_mk($input, $srcdir, dirname($filename)."/$1");
+ if ($line =~ /^mkinclude (.*)$/) {
+ my $subfile= $1;
+ my $subdir = dirname($filename);
+ $subdir =~ s/^\.$//g;
+ $subdir =~ s/^\.\///g;
+ $subdir .= "/" if ($subdir ne "");
+ $makefile .= "basedir := $subdir\n";
+ $makefile .= run_config_mk($input, $srcdir, $builddir, $subdir.$subfile);
next;
}
$infragment = 1;
next;
}
-
# Assignment
if ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/) {
next;
}
- die("$srcdir."/".$filename:$linenum: Bad line while parsing $srcdir."/".$filename");
+ die("$parsing_file:$linenum: Bad line");
}
+ $makefile .= "# }END $parsing_file\n";
+
foreach my $section (keys %{$result}) {
my ($type, $name) = split(/::/, $section, 2);
my $sectype = $section_types->{$type};
if (not defined($sectype)) {
- die($srcdir."/".$filename.":[".$section."] unknown section type \"".$type."\"!");
+ die($parsing_file.":[".$section."] unknown section type \"".$type."\"!");
}
$input->{$name}{NAME} = $name;
$input->{$name}{TYPE} = $type;
- $input->{$name}{BASEDIR} = dirname($filename);
+ $input->{$name}{MK_FILE} = $parsing_file;
+ $input->{$name}{BASEDIR} = $basedir;
foreach my $key (values %{$result->{$section}}) {
+ next if ($key->{KEY} eq "EXISTS");
$key->{VAL} = smb_build::input::strtrim($key->{VAL});
my $vartype = $sectype->{$key->{KEY}};
if (not defined($vartype)) {
- die($srcdir."/".$filename.":[".$section."]: unknown attribute type \"$key->{KEY}\"!");
+ die($parsing_file.":[".$section."]: unknown attribute type \"$key->{KEY}\"!");
}
if ($vartype eq "string") {
$input->{$name}{$key->{KEY}} = $key->{VAL};