3
# **** BEGIN LICENSE BLOCK *****
4
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
# The contents of this file are subject to the Mozilla Public
7
# License Version 1.1 (the "MPL"); you may not use this file
8
# except in compliance with the MPL. You may obtain a copy of
9
# the MPL at http://www.mozilla.org/MPL/
11
# Software distributed under the MPL is distributed on an "AS
12
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13
# implied. See the MPL for the specific language governing
14
# rights and limitations under the MPL.
16
# The Original Code is Enigmail.
18
# The Initial Developer of the Original Code is Patrick Brunschwig.
19
# Portions created by Patrick Brunschwig <patrick@mozilla-enigmail.org> are
20
# Copyright (C) 2005 Patrick Brunschwig. All Rights Reserved.
24
# Alternatively, the contents of this file may be used under the terms of
25
# either the GNU General Public License Version 2 or later (the "GPL"), or
26
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
# in which case the provisions of the GPL or the LGPL are applicable instead
28
# of those above. If you wish to allow use of your version of this file only
29
# under the terms of either the GPL or the LGPL, and not to allow others to
30
# use your version of this file under the terms of the MPL, indicate your
31
# decision by deleting the provisions above and replace them with the notice
32
# and other provisions required by the GPL or the LGPL. If you do not delete
33
# the provisions above, a recipient may use your version of this file under
34
# the terms of any one of the MPL, the GPL or the LGPL.
35
# ***** END LICENSE BLOCK *****
37
# makemake: script to generate Makefile from Makefile.in
38
# -r: process recursively all subdirectories
39
# -o DIR: use DIR as MOZ_OBJDIR
40
# Usage: makemake [-o @TOPSRCDIR@/somedir] [-r]
42
my $makelist="./Makefile.in";
51
open(MAKEFILE, $makelist) || die ("Could not open '$makelist'\n");
52
while (my $l = <MAKEFILE>) {
54
if ($l =~ /^\s*DEPTH\s*=/) {
55
$l =~ s/(^\s*DEPTH\s*=\s*)(.*)$/$2/;
62
while ( (length($topdir)>0) && ( basename($topdir) ne "mozilla" )) {
63
$topdir=dirname($topdir);
67
chdir($depth) || die "Directory '$depth' not found\n";
72
print "INFO: found toplevel source directory $topdir\n";
74
if (open(MOZCONFIG, "$topdir/.mozconfig")) {
75
while (my $l = <MOZCONFIG>) {
77
if ($l =~ /^\s*mk_add_options\s+MOZ_OBJDIR\s*=/) {
78
$l =~ s/(^\s*mk_add_options\s+MOZ_OBJDIR\s*=\s*)(.*)$/$2/;
85
print "INFO: no .mozconfig file found\n";
89
while ( $#ARGV >= 0 ) {
90
if ($ARGV[0] eq "-o") {
94
if ($ARGV[0] eq "-r") {
95
$makelist=`find . -name Makefile.in -print`;
102
$mozObjDir =~ s/\@TOPSRCDIR\@/$topdir/;
104
if ($mozObjDir eq ".") {
105
print "INFO: no MOZ_OBJDIR used\n";
108
print "INFO: using MOZ_OBJDIR=$mozObjDir\n\n";
111
foreach $makefile (split(/[ \n\r]+/, $makelist)) {
112
$makefile =~ s/^\.\///;
113
my $dir=dirname("$cwd/$makefile");
116
print "Processing: $wd\n";
118
my $newMakefile = $makefile;
119
$newMakefile =~ s/.in$//;
121
if ($mozObjDir eq ".") {
122
# no OBJDIR specified
124
while ( (length($wd)>0) && (basename($wd) ne "mozilla") ) {
125
if (length($top_srcdir) == 0) {
129
$top_srcdir="../$top_srcdir";
142
while ( (length($wd)>0) && (basename($wd) ne "mozilla") ) {
151
my $targetDir=$srcdir;
152
$targetDir =~ s/$top_srcdir/$mozObjDir/x;
153
system("mkdir -p '$targetDir'");
154
$newMakefile=sprintf("%s/%s", $targetDir, basename($newMakefile));
157
my $enigMakefile = $makefile;
158
$enigMakefile =~ s/\.in$/.enig/;
159
if (-e $enigMakefile) {
160
$makefile = $enigMakefile;
162
open(INFILE, $makefile) || die ("cannot open input file '$makefile'\n");
163
open(OUTFILE, ">$newMakefile") || die ("cannot open output file '$newMakefile'\n");
166
while ($line = <INFILE>) {
167
$line =~ s/\@srcdir\@/$srcdir/g;
168
$line =~ s/\@top_srcdir\@/$top_srcdir/g;
175
if ($mozObjDir eq ".") {
180
$newWd =~ s/$topdir/$mozObjDir/x;
181
print "Done. The code can now be compiled from $newWd\n\n";
186
$fn =~ s/^(.*)\/(.*)$/$2/;
192
$dn =~ s/^(.*)\/(.*)$/$1/;