2002-02-28 11:11:51 +03:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
#
|
|
|
|
# First attempt at using module-graph.pl to generate
|
|
|
|
# a cvs checkout list, and building the resulting tree.
|
|
|
|
#
|
2002-04-03 04:48:03 +04:00
|
|
|
# bootstrap.pl starts with an "all.dot" requires map file
|
|
|
|
# and nothing else, and does the following:
|
|
|
|
# * Figures out the module dependencies for the module
|
|
|
|
# you want to build, via module-graph.pl.
|
|
|
|
# * Creates a list of directories from the modules via
|
|
|
|
# modules2dir.pl.
|
|
|
|
# * Checks out core config files, nspr, and module directories.
|
|
|
|
# * Based on this resulting tree, allmakefiles.sh is generated
|
2002-05-09 12:39:46 +04:00
|
|
|
# on the fly with a module name "bootstrap". modules.mk file
|
|
|
|
# generated with DIRS in leaf-first order.
|
2002-05-10 05:28:44 +04:00
|
|
|
# * A build is attempted with this configure option:
|
|
|
|
# --enable-standalone-modules=bootstrap --disable-ldap --disable-tests
|
2002-04-03 04:48:03 +04:00
|
|
|
#
|
2002-05-10 05:28:44 +04:00
|
|
|
# Example usage, to build xpcom:
|
|
|
|
#
|
|
|
|
# cvs co mozilla/tools/module-deps/bootstrap.pl
|
|
|
|
# mozilla/tools/module-deps/bootstrap.pl --module=xpcom
|
2002-04-03 04:48:03 +04:00
|
|
|
#
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-05-10 05:28:44 +04:00
|
|
|
|
2002-03-30 07:29:40 +03:00
|
|
|
use strict;
|
2002-05-21 07:46:41 +04:00
|
|
|
use English;
|
2002-04-03 03:13:35 +04:00
|
|
|
use File::Find();
|
2002-10-25 08:09:13 +04:00
|
|
|
use File::Copy;
|
2002-03-30 07:29:40 +03:00
|
|
|
|
|
|
|
# For --option1, --option2, ...
|
|
|
|
use Getopt::Long;
|
|
|
|
Getopt::Long::Configure("bundling_override");
|
|
|
|
Getopt::Long::Configure("auto_abbrev");
|
|
|
|
|
2002-02-28 11:11:51 +03:00
|
|
|
use Cwd;
|
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
my $debug = 0;
|
2002-03-30 07:29:40 +03:00
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
sub PrintUsage {
|
|
|
|
die <<END_USAGE
|
2002-10-25 08:09:13 +04:00
|
|
|
usage: $0 --modules=mod1,mod2,.. [--topsrcdir topsrcdir] [--skip-cvs] [--skip-core-cvs] [--module-file-only]
|
2002-05-09 12:27:52 +04:00
|
|
|
(Assumes you can check out a new cvs tree here)
|
2002-03-02 03:04:47 +03:00
|
|
|
END_USAGE
|
2002-02-28 11:11:51 +03:00
|
|
|
}
|
|
|
|
|
2002-04-03 03:13:35 +04:00
|
|
|
# Globals.
|
2002-04-02 03:43:44 +04:00
|
|
|
my $root_modules = 0; # modules we want to build.
|
2002-05-18 01:32:20 +04:00
|
|
|
my $skip_cvs = 0; # Skip all cvs checkouts.
|
|
|
|
my $skip_core_cvs = 0; # Only skip core cvs checkout, useful for hacking.
|
2002-10-25 08:09:13 +04:00
|
|
|
my $modfile_only = 0; # Only generate module.mk
|
|
|
|
my $topsrcdir = 0;
|
|
|
|
my $toolsdir;
|
|
|
|
|
|
|
|
sub get_system_cwd {
|
|
|
|
my $a = Cwd::getcwd()||`pwd`;
|
|
|
|
chomp($a);
|
|
|
|
return $a;
|
|
|
|
}
|
2002-03-30 07:29:40 +03:00
|
|
|
|
|
|
|
sub parse_args() {
|
|
|
|
PrintUsage() if $#ARGV < 0;
|
|
|
|
|
|
|
|
# Stuff arguments into variables.
|
|
|
|
# Print usage if we get an unknown argument.
|
2002-05-09 12:27:52 +04:00
|
|
|
PrintUsage() if !GetOptions('module=s' => \$root_modules,
|
|
|
|
'modules=s' => \$root_modules,
|
2002-05-18 01:32:20 +04:00
|
|
|
'skip-cvs' => \$skip_cvs,
|
2002-10-25 08:09:13 +04:00
|
|
|
'skip-core-cvs' => \$skip_core_cvs,
|
|
|
|
'module-file-only' => \$modfile_only,
|
|
|
|
'topsrcdir=s' => \$topsrcdir);
|
2002-04-02 03:43:44 +04:00
|
|
|
if ($root_modules) {
|
|
|
|
print "root_modules = $root_modules\n";
|
|
|
|
|
|
|
|
# Test for last tree, or remember what tree we're doing.
|
|
|
|
if (-e "last_module.txt") {
|
|
|
|
open LAST_MODULE, "last_module.txt";
|
|
|
|
|
|
|
|
while(<LAST_MODULE>) {
|
|
|
|
# Assume module name is first line
|
|
|
|
unless($_ eq $root_modules) {
|
|
|
|
print "Error: Last module pulled ($_) doesn't match \"$root_modules\", remove last_module.txt and mozilla tree, then try again.\n";
|
|
|
|
exit 1;
|
|
|
|
} else {
|
|
|
|
print "Checking out same module...\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close LAST_MODULE;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
# Save off file to remember which tree we're using
|
|
|
|
open LAST_MODULE, ">last_module.txt";
|
|
|
|
print LAST_MODULE $root_modules;
|
|
|
|
close LAST_MODULE;
|
|
|
|
}
|
|
|
|
}
|
2002-10-25 08:09:13 +04:00
|
|
|
$topsrcdir = "mozilla" if (!$topsrcdir);
|
|
|
|
chdir($topsrcdir) || die("chdir($topsrcdir): $!\n");
|
|
|
|
$topsrcdir = get_system_cwd();
|
|
|
|
$toolsdir = "$topsrcdir/tools/module-deps";
|
2002-03-30 07:29:40 +03:00
|
|
|
}
|
2002-02-28 11:11:51 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
# Run shell command, return output string.
|
|
|
|
sub run_shell_command {
|
2002-03-30 07:29:40 +03:00
|
|
|
my ($shell_command, $echo) = @_;
|
2002-03-02 03:04:47 +03:00
|
|
|
local $_;
|
|
|
|
|
|
|
|
my $status = 0;
|
|
|
|
my $output = "";
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
chomp($shell_command);
|
2002-03-30 07:29:40 +03:00
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
print "cmd = $shell_command\n" if ($debug);
|
2002-03-30 07:29:40 +03:00
|
|
|
|
2002-05-10 03:23:10 +04:00
|
|
|
open CMD, "$shell_command 2>&1|" or die "command failed: $!";
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
while(<CMD>) {
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-03-30 07:29:40 +03:00
|
|
|
if($echo) {
|
2002-03-02 03:04:47 +03:00
|
|
|
print $_;
|
|
|
|
}
|
|
|
|
chomp($_);
|
|
|
|
$output .= "$_ ";
|
|
|
|
}
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
close CMD or $status = 1;
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
if($status) {
|
2002-05-10 03:19:05 +04:00
|
|
|
print "Warning, cmd exited with status $status.\n";
|
2002-03-02 03:04:47 +03:00
|
|
|
}
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
return $output;
|
|
|
|
}
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-04-20 06:15:40 +04:00
|
|
|
# Global and Compare routines for Find()
|
2002-04-03 03:13:35 +04:00
|
|
|
my @foundMakefiles;
|
|
|
|
|
2002-04-20 06:15:40 +04:00
|
|
|
sub FindMakefiles {
|
|
|
|
# Don't descend into CVS dirs.
|
|
|
|
/CVS/ and $File::Find::prune = 1;
|
|
|
|
|
|
|
|
if($_ eq "Makefile.in") {
|
|
|
|
#print "$File::Find::dir $_\n";
|
2002-04-03 03:13:35 +04:00
|
|
|
|
2002-04-20 06:15:40 +04:00
|
|
|
$_ =~ s/.in//; # Strip off the ".in"
|
|
|
|
|
|
|
|
$File::Find::dir =~ s/^mozilla\///; # Strip off mozilla/
|
|
|
|
|
|
|
|
#$_ =~ s/mozilla//;
|
|
|
|
push(@foundMakefiles, "$File::Find::dir/$_");
|
|
|
|
} else {
|
|
|
|
#print " $File::Find::dir $_\n";
|
|
|
|
}
|
|
|
|
}
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
# Return directory list for module
|
|
|
|
sub get_dirs_for_module($) {
|
|
|
|
|
|
|
|
my ($root_modules, $silence) = @_;
|
|
|
|
# Figure out the modules list.
|
|
|
|
my @modules;
|
|
|
|
my $modules_string = "";
|
|
|
|
my $num_modules = 0;
|
|
|
|
my $modules_cmd = "$toolsdir/module-graph\.pl --file $toolsdir/meta\.dot --start-module $root_modules --list-only --force-order $toolsdir/force_order\.txt";
|
|
|
|
$modules_string = run_shell_command($modules_cmd, 0);
|
|
|
|
$silence = 0 if (!defined($silence));
|
|
|
|
|
|
|
|
@modules = split(' ', $modules_string);
|
|
|
|
#$num_modules = $#modules + 1;
|
|
|
|
print "modules = $num_modules\n" if (!$silence);
|
|
|
|
|
|
|
|
# Map modules list to directories list.
|
|
|
|
my @dirs;
|
|
|
|
my $dirs_string = "";
|
|
|
|
my $dirs_string_no_mozilla = ""; # dirs_string, stripping off mozilla/
|
|
|
|
|
2003-08-16 02:37:25 +04:00
|
|
|
my $dirs_cmd = "echo $modules_string | $topsrcdir/config/module2dir\.pl --list-only --mapfile $toolsdir/module2dir\.map";
|
2002-10-25 08:09:13 +04:00
|
|
|
|
|
|
|
print "\nGenerating directories list for $root_modules\n" if (!$silence);
|
|
|
|
$dirs_string = run_shell_command($dirs_cmd, 0);
|
|
|
|
print "dirs_string = $dirs_string\n" if ($debug);
|
|
|
|
|
|
|
|
return $dirs_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Create stub version of modules.mk
|
|
|
|
sub create_stub_modules_mk() {
|
|
|
|
|
|
|
|
# Look for previously generated modules.mk file.
|
|
|
|
my $generated_modulesmk_file = 0;
|
|
|
|
if(-e "$topsrcdir/build/unix/modules.mk" && !$modfile_only) {
|
|
|
|
open MODULESMK, "$topsrcdir/build/unix/modules.mk";
|
|
|
|
while(<MODULESMK>) {
|
|
|
|
if(/# Generated by bootstrap.pl/) {
|
|
|
|
$generated_modulesmk_file = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close MODULESMK;
|
|
|
|
|
|
|
|
if($generated_modulesmk_file == 0) {
|
|
|
|
print "Error: non-generated $topsrcdir/build/unix/modules.mk found.\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Stomp on generated file, or open a new one.
|
|
|
|
print "\nGenerating stub modules.mk ...\n";
|
|
|
|
copy("$toolsdir/modules.mk.stub", "$topsrcdir/build/unix/modules.mk");
|
|
|
|
}
|
|
|
|
|
|
|
|
sub add_modules_mk_footer() {
|
|
|
|
print "Adding modules.mk footer\n";
|
|
|
|
open(FOOTER, "$toolsdir/modules.mk.footer") || die ("modules.mk.footer: $!\n");
|
|
|
|
open(MK, ">>$topsrcdir/build/unix/modules.mk") || die ("modules.mk: $!\n");
|
|
|
|
while (<FOOTER>) {
|
|
|
|
print MK $_;
|
|
|
|
}
|
|
|
|
close(MK);
|
|
|
|
close(FOOTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generate modules.mk with all modules
|
|
|
|
sub create_full_modules_mk ($) {
|
|
|
|
|
|
|
|
my ($basedir) = @_;
|
|
|
|
my ($cmd, @modlist, $modules_string, $module, @dirlist, $tmpmod);
|
|
|
|
my $tooldir = "$topsrcdir/tools/module-deps";
|
|
|
|
my %module_dirs;
|
|
|
|
|
|
|
|
# Get the list of modules
|
|
|
|
$cmd = "$tooldir/module-graph.pl --file $tooldir/meta.dot --force-order $tooldir/force_order.txt --list-only --start-module ALL";
|
|
|
|
$modules_string = run_shell_command($cmd, 0);
|
|
|
|
@modlist = sort(split(/\s+/, $modules_string));
|
|
|
|
print "There are $#modlist modules\n";
|
|
|
|
|
|
|
|
# Get directory list of each module
|
|
|
|
print "Generating directory lists for all modules\n";
|
|
|
|
foreach $module (@modlist) {
|
|
|
|
$module_dirs{$module} = &get_dirs_for_module($module, 1);
|
|
|
|
$module_dirs{$module} =~ s/mozilla\///g;
|
|
|
|
# print "$module: $module_dirs{$module}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
&create_stub_modules_mk();
|
|
|
|
|
|
|
|
# Add new module entries to modules.mk
|
|
|
|
print "Adding module entries to modules.mk\n";
|
|
|
|
open(MK, ">>$topsrcdir/build/unix/modules.mk") || die ("modules.mk: $!\n");
|
|
|
|
print MK "# Available modules are:\n";
|
|
|
|
print MK "# @modlist\n";
|
|
|
|
foreach $module (@modlist) {
|
|
|
|
print MK "\n";
|
|
|
|
print MK "BM_DIRS_$module\t= $module_dirs{$module}\n";
|
|
|
|
print MK "BM_CVS_$module\t= $module_dirs{$module}\n";
|
|
|
|
print MK "\n";
|
|
|
|
}
|
|
|
|
close(MK);
|
|
|
|
|
|
|
|
&add_modules_mk_footer;
|
|
|
|
|
|
|
|
# Re-write allmakefiles.sh
|
|
|
|
print "Rewritting allmakefiles.sh\n";
|
|
|
|
open(ALLMK, "$topsrcdir/allmakefiles.sh") || die("allmakefiles.sh: $!\n");
|
|
|
|
open(NEWMK, ">$topsrcdir/allmakefiles.sh.new") || die("allmakefile.sh.new: $!\n");
|
|
|
|
while (<ALLMK>) {
|
|
|
|
if (/^# Standalone modules go here/) {
|
|
|
|
print NEWMK $_;
|
|
|
|
print NEWMK "\n";
|
|
|
|
foreach $module (@modlist) {
|
|
|
|
($tmpmod = $module) =~ s/\-/_/g;
|
|
|
|
@dirlist = map "$_/Makefile", split(/\s+/,$module_dirs{$module});
|
|
|
|
print NEWMK "MAKEFILES_$tmpmod=\"@dirlist\"\n\n";
|
|
|
|
}
|
|
|
|
print NEWMK " for mod in \$BUILD_MODULES; do\n";
|
|
|
|
print NEWMK " case \$mod in\n";
|
|
|
|
foreach $module (@modlist) {
|
|
|
|
($tmpmod = $module) =~ s/\-/_/g;
|
|
|
|
print NEWMK " $module\) add_makefiles \"\$MAKEFILES_$tmpmod\" ;;\n";
|
|
|
|
}
|
|
|
|
print NEWMK " esac\n";
|
|
|
|
print NEWMK " done\n";
|
|
|
|
print NEWMK "\nfi\n";
|
|
|
|
last;
|
|
|
|
} else {
|
|
|
|
print NEWMK $_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(NEWMK);
|
|
|
|
close(ALLMK);
|
|
|
|
move("$topsrcdir/allmakefiles.sh.new", "$topsrcdir/allmakefiles.sh") ||
|
|
|
|
die("move failed for $topsrcdir/allmakefiles.sh\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
2002-02-28 11:11:51 +03:00
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
# main
|
|
|
|
{
|
|
|
|
my $rv = 0; # 0 = success.
|
|
|
|
|
2002-03-30 07:29:40 +03:00
|
|
|
# Get options.
|
|
|
|
parse_args();
|
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
# Module map file is currently $toolsdir/all.dot
|
|
|
|
|
|
|
|
chdir("$topsrcdir/..");
|
|
|
|
my $basedir = get_system_cwd();
|
|
|
|
print "basedir = $basedir\n";
|
2002-03-02 03:04:47 +03:00
|
|
|
|
|
|
|
# Pull core build stuff.
|
2002-10-25 08:09:13 +04:00
|
|
|
unless($skip_cvs || $skip_core_cvs || $modfile_only) {
|
2002-04-03 03:13:35 +04:00
|
|
|
print "\n\nPulling core build files...\n";
|
2002-04-04 11:48:26 +04:00
|
|
|
my $core_build_files = "mozilla/client.mk mozilla/config mozilla/configure mozilla/configure.in mozilla/aclocal.m4 mozilla/Makefile.in mozilla/build mozilla/include mozilla/tools/module-deps";
|
2002-04-03 03:13:35 +04:00
|
|
|
$rv = run_shell_command("cvs co $core_build_files");
|
|
|
|
}
|
2002-03-02 03:04:47 +03:00
|
|
|
|
|
|
|
# Pull nspr
|
2002-10-25 08:09:13 +04:00
|
|
|
unless($skip_cvs || $modfile_only) {
|
2002-04-03 03:13:35 +04:00
|
|
|
print "\n\nPulling nspr...\n";
|
|
|
|
my $nspr_cvs_cmd = "cvs co -rNSPRPUB_PRE_4_2_CLIENT_BRANCH mozilla/nsprpub";
|
|
|
|
$rv = run_shell_command("$nspr_cvs_cmd");
|
|
|
|
}
|
2002-03-02 03:04:47 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Pull modules.
|
2002-03-30 07:29:40 +03:00
|
|
|
# Only one root/start module to start.
|
2002-03-02 03:04:47 +03:00
|
|
|
#
|
|
|
|
print "\n\nPulling modules...\n";
|
2002-04-03 03:13:35 +04:00
|
|
|
|
2002-05-22 02:54:05 +04:00
|
|
|
#
|
|
|
|
# Add in virtual dependencies from extra.dot
|
|
|
|
# meta.dot = all.dot + extra.dot
|
|
|
|
#
|
|
|
|
|
|
|
|
# Create meta.dot
|
2002-10-25 08:09:13 +04:00
|
|
|
if (-e "$toolsdir/meta.dot") {
|
|
|
|
unlink("$toolsdir/meta.dot");
|
2002-05-22 02:54:05 +04:00
|
|
|
}
|
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
print "Creating meta.dot\n";
|
|
|
|
copy("$toolsdir/all.dot", "$toolsdir/meta.dot");
|
2002-05-22 02:54:05 +04:00
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
open METADOT, ">>$toolsdir/meta.dot";
|
2002-05-22 02:54:05 +04:00
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
open EXTRADOT, "$toolsdir/extra.dot";
|
2002-05-22 02:54:05 +04:00
|
|
|
while (<EXTRADOT>) {
|
|
|
|
print METADOT $_;
|
|
|
|
}
|
|
|
|
close EXTRADOT;
|
|
|
|
|
|
|
|
close METADOT;
|
2002-03-02 03:04:47 +03:00
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
# If we only want the updated modules.mk, turn left at Albuquerque
|
|
|
|
if ($modfile_only) {
|
|
|
|
&create_full_modules_mk();
|
|
|
|
exit(0);
|
|
|
|
}
|
2002-06-01 11:30:35 +04:00
|
|
|
|
|
|
|
# Print out module dependency tree.
|
|
|
|
print "\nDependency tree:\n";
|
2002-10-25 08:09:13 +04:00
|
|
|
my $tree_cmd = "$toolsdir/module-graph\.pl --file $toolsdir/meta\.dot --start-module $root_modules --force-order $toolsdir/force_order\.txt --skip-dep-map --skip-list";
|
2002-06-01 11:30:35 +04:00
|
|
|
system("$tree_cmd");
|
|
|
|
print "\n";
|
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
my @dirs;
|
2002-10-25 08:09:13 +04:00
|
|
|
my $dirs_string;
|
|
|
|
my $dirs_string_no_mozilla;
|
2002-04-03 03:13:35 +04:00
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
$dirs_string = get_dirs_for_module($root_modules);
|
|
|
|
|
|
|
|
# Yank modules we know we don't want.
|
|
|
|
#$modules_string =~ s/mozldap //; # no ldap.
|
2002-03-02 03:04:47 +03:00
|
|
|
|
2002-04-03 03:13:35 +04:00
|
|
|
@dirs = split(' ', $dirs_string); # Create dirs array for find command.
|
2002-03-02 03:04:47 +03:00
|
|
|
|
2002-04-20 06:15:40 +04:00
|
|
|
$dirs_string_no_mozilla = $dirs_string;
|
|
|
|
$dirs_string_no_mozilla =~ s/mozilla\/+//g;
|
|
|
|
|
2002-06-01 12:00:14 +04:00
|
|
|
print "\ndirs_string_no_mozilla = $dirs_string_no_mozilla\n";
|
2002-04-20 06:15:40 +04:00
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
|
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
# Checkout directories.
|
2002-04-03 03:13:35 +04:00
|
|
|
unless($skip_cvs) {
|
|
|
|
print "\nChecking out directories...\n";
|
|
|
|
my $dirs_cvs_cmd = "cvs co $dirs_string";
|
|
|
|
run_shell_command($dirs_cvs_cmd);
|
|
|
|
}
|
2002-03-02 03:05:54 +03:00
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
# Try a build.
|
|
|
|
|
2002-03-30 07:29:40 +03:00
|
|
|
#
|
2002-04-03 03:13:35 +04:00
|
|
|
# Construct an allmakefiles.sh file
|
2002-03-30 07:29:40 +03:00
|
|
|
#
|
2002-04-03 03:13:35 +04:00
|
|
|
|
|
|
|
# Look for previously generated allmakefiles.sh file.
|
|
|
|
my $generated_allmakefiles_file = 0;
|
2002-10-25 08:09:13 +04:00
|
|
|
if(-e "$topsrcdir/allmakefiles.sh") {
|
|
|
|
open ALLMAKEFILES, "$topsrcdir/allmakefiles.sh";
|
2002-04-03 03:13:35 +04:00
|
|
|
while(<ALLMAKEFILES>) {
|
|
|
|
if(/# Generated by bootstrap.pl/) {
|
|
|
|
$generated_allmakefiles_file = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close ALLMAKEFILES;
|
|
|
|
|
|
|
|
if($generated_allmakefiles_file == 0) {
|
2002-10-25 08:09:13 +04:00
|
|
|
print "Error: non-generated $topsrcdir/allmakefiles.sh found.\n";
|
2002-04-03 03:13:35 +04:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Stomp on generated file, or open a new one.
|
2002-04-20 06:15:40 +04:00
|
|
|
print "\nGenerating allmakefiles.sh ...\n";
|
2002-10-25 08:09:13 +04:00
|
|
|
copy("$toolsdir/allmakefiles.stub", "$topsrcdir/allmakefiles.sh");
|
2002-04-06 04:27:40 +04:00
|
|
|
|
|
|
|
# Open copy of stub file.
|
2002-10-25 08:09:13 +04:00
|
|
|
open ALLMAKEFILES, ">>$topsrcdir/allmakefiles.sh";
|
2002-04-03 03:13:35 +04:00
|
|
|
|
|
|
|
# Add in our hack
|
|
|
|
print ALLMAKEFILES "MAKEFILES_bootstrap=\"\n";
|
|
|
|
|
|
|
|
# Recursively decend the tree looking for Makefiles
|
|
|
|
File::Find::find(\&FindMakefiles, @dirs);
|
|
|
|
|
|
|
|
# Write Makefiles out to allmakefiles.sh.
|
|
|
|
foreach (@foundMakefiles) {
|
|
|
|
print ALLMAKEFILES "$_\n";
|
|
|
|
}
|
2002-03-30 07:29:40 +03:00
|
|
|
|
2002-04-04 12:49:14 +04:00
|
|
|
print ALLMAKEFILES "\"\n\n";
|
|
|
|
print ALLMAKEFILES "add_makefiles \"\$MAKEFILES_bootstrap\"";
|
2002-04-03 03:13:35 +04:00
|
|
|
close ALLMAKEFILES;
|
2002-03-30 07:29:40 +03:00
|
|
|
|
2002-03-02 03:04:47 +03:00
|
|
|
#print "Configuring nspr ... \n";
|
2002-04-05 06:08:37 +04:00
|
|
|
#chdir("$basedir/mozilla/nsprpub");
|
2002-06-18 05:18:46 +04:00
|
|
|
#my $nspr_configure_cmd = "sh ./configure";
|
2002-03-02 03:04:47 +03:00
|
|
|
#system("$nspr_configure_cmd");
|
|
|
|
|
2002-04-20 06:15:40 +04:00
|
|
|
print "\nConfiguring ... \n";
|
2002-04-05 06:08:37 +04:00
|
|
|
unlink("$basedir/mozilla/config.cache");
|
2002-10-25 08:09:13 +04:00
|
|
|
chdir("$topsrcdir");
|
2002-06-18 05:18:46 +04:00
|
|
|
my $configure_cmd = "sh ./configure --enable-standalone-modules=$root_modules --disable-ldap --disable-tests --disable-installer";
|
2002-03-02 03:04:47 +03:00
|
|
|
$rv = run_shell_command("$configure_cmd");
|
|
|
|
|
2002-04-20 06:15:40 +04:00
|
|
|
#
|
|
|
|
# Construct a build/unix/modules.mk file, this let's us do
|
2002-05-21 07:46:41 +04:00
|
|
|
# a top-level build instead of n $makecmd -C <dir> commands.
|
2002-04-20 06:15:40 +04:00
|
|
|
#
|
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
&create_stub_modules_mk();
|
|
|
|
|
|
|
|
# Open copy of custom modules.mk.
|
|
|
|
open MODULESMK, ">>$topsrcdir/build/unix/modules.mk";
|
|
|
|
|
|
|
|
# Add in our hack
|
|
|
|
print MODULESMK "BUILD_MODULE_DIRS += $dirs_string_no_mozilla\n";
|
|
|
|
|
|
|
|
close MODULESMK;
|
|
|
|
|
|
|
|
&add_modules_mk_footer;
|
|
|
|
|
2002-05-21 07:46:41 +04:00
|
|
|
my $makecmd = "gmake";
|
|
|
|
if( "$OSNAME" eq "cygwin" ) {
|
|
|
|
# Cygwin likes to use "make" for win32.
|
|
|
|
$makecmd = "make";
|
|
|
|
}
|
|
|
|
|
2002-04-05 06:08:37 +04:00
|
|
|
# Now try and build.
|
|
|
|
# Not a top-level build, but build each directory.
|
2002-04-20 06:15:40 +04:00
|
|
|
print "\nBuilding ... \n";
|
2002-04-05 06:08:37 +04:00
|
|
|
|
|
|
|
chdir($basedir);
|
|
|
|
my $dir;
|
|
|
|
|
2002-04-06 04:27:40 +04:00
|
|
|
#
|
|
|
|
# Inherent build dependencies, we need to build some inital
|
|
|
|
# tools & directories first before attacking the modules.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Build nspr
|
2002-05-21 07:46:41 +04:00
|
|
|
print "$makecmd -C mozilla/nsprpub\n";
|
|
|
|
system("$makecmd -C mozilla/nsprpub");
|
2002-04-06 04:27:40 +04:00
|
|
|
|
|
|
|
# Build config
|
2002-05-21 07:46:41 +04:00
|
|
|
print "$makecmd -C mozilla/config\n";
|
|
|
|
system("$makecmd -C mozilla/config");
|
2002-04-06 04:27:40 +04:00
|
|
|
|
|
|
|
# Build xpidl
|
2002-05-21 07:46:41 +04:00
|
|
|
print "$makecmd -C mozilla/xpcom/typelib\n";
|
|
|
|
system("$makecmd -C mozilla/xpcom/typelib");
|
2002-05-07 11:05:10 +04:00
|
|
|
|
2002-04-06 04:27:40 +04:00
|
|
|
# Now try the modules.
|
2002-04-05 06:08:37 +04:00
|
|
|
|
2002-10-25 08:09:13 +04:00
|
|
|
chdir("$topsrcdir");
|
2002-04-05 06:08:37 +04:00
|
|
|
|
2002-05-07 11:05:10 +04:00
|
|
|
# Export-phase first. Export IDL stuff first to avoid IDL order problems.
|
2002-06-12 02:26:27 +04:00
|
|
|
system("$makecmd export-idl"); # workaround for idl order problems.
|
|
|
|
system("$makecmd export"); # run_shell_command("$makecmd export");
|
2002-04-05 06:08:37 +04:00
|
|
|
|
2002-05-07 11:05:10 +04:00
|
|
|
# Libs-phase next.
|
2002-05-21 07:46:41 +04:00
|
|
|
system("$makecmd libs"); # run_shell_command("$makecmd libs");
|
2002-02-28 11:11:51 +03:00
|
|
|
}
|