2
# makemake: script to generate Makefile from Makefile.in
3
# -r: process recursively all subdirectories
4
# -o DIR: use DIR as MOZ_OBJDIR
5
# Usage: makemake [-o @TOPSRCDIR@/somedir] [-r]
7
my $makelist="./Makefile.in.ipc";
16
open(MAKEFILE, $makelist) || die ("Could not open '$makelist'\n");
17
while (my $l = <MAKEFILE>) {
19
if ($l =~ /^\s*DEPTH\s*=/) {
20
$l =~ s/(^\s*DEPTH\s*=\s*)(.*)$/$2/;
27
while ( (length($topdir)>0) && ( basename($topdir) ne "mozilla" )) {
28
$topdir=dirname($topdir);
32
chdir($depth) || die "Directory '$depth' not found\n";
37
print "INFO: found toplevel source directory $topdir\n";
39
if (open(MOZCONFIG, "$topdir/.mozconfig")) {
40
while (my $l = <MOZCONFIG>) {
42
if ($l =~ /^\s*mk_add_options\s+MOZ_OBJDIR\s*=/) {
43
$l =~ s/(^\s*mk_add_options\s+MOZ_OBJDIR\s*=\s*)(.*)$/$2/;
50
print "INFO: no .mozconfig file found\n";
54
while ( $#ARGV >= 0 ) {
55
if ($ARGV[0] eq "-o") {
59
if ($ARGV[0] eq "-r") {
60
$makelist=`find . -name Makefile.in.ipc -print`;
67
$mozObjDir =~ s/\@TOPSRCDIR\@/$topdir/;
69
if ($mozObjDir eq ".") {
70
print "INFO: no MOZ_OBJDIR used\n";
73
print "INFO: using MOZ_OBJDIR=$mozObjDir\n\n";
76
foreach $makefile (split(/[ \n\r]+/, $makelist)) {
77
$makefile =~ s/^\.\///;
78
my $dir=dirname("$cwd/$makefile");
81
print "Processing: $wd\n";
83
my $newMakefile = $makefile;
84
$newMakefile =~ s/.in.ipc$//;
86
if ($mozObjDir eq ".") {
89
while ( (length($wd)>0) && (basename($wd) ne "mozilla") ) {
90
if (length($top_srcdir) == 0) {
94
$top_srcdir="../$top_srcdir";
107
while ( (length($wd)>0) && (basename($wd) ne "mozilla") ) {
116
my $targetDir=$srcdir;
117
$targetDir =~ s/$top_srcdir/$mozObjDir/x;
118
system("mkdir -p '$targetDir'");
119
$newMakefile=sprintf("%s/%s", $targetDir, basename($newMakefile));
122
open(INFILE, $makefile) || die ("cannot open input file '$makefile'\n");
123
open(OUTFILE, ">$newMakefile") || die ("cannot open output file '$newMakefile'\n");
126
while ($line = <INFILE>) {
127
$line =~ s/\@srcdir\@/$srcdir/g;
128
$line =~ s/\@top_srcdir\@/$top_srcdir/g;
135
if ($mozObjDir eq ".") {
140
$newWd =~ s/$topdir/$mozObjDir/x;
141
print "Done. The code can now be compiled from $newWd\n\n";
146
$fn =~ s/^(.*)\/(.*)$/$2/;
152
$dn =~ s/^(.*)\/(.*)$/$1/;