-
Notifications
You must be signed in to change notification settings - Fork 1
/
makemake.pl
executable file
·89 lines (81 loc) · 2.43 KB
/
makemake.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/perl
#
# parses COMPILER file for compiler flags and changes them
# appropriately in all of the Makefiles
#
# There are probably much better (shorter) ways of doing this, but it works!
#
# Flags are only changed if they are UNCOMMENTED in the Makefiles
#
use strict;
my $flag;
my $flagsetting;
my $f90C;
my $f90flags;
my $ldflags;
my $compilerfile = 'COMPILER';
my $line;
my $crap;
my @makefiles = ("./utils/Makefile","./evplot/Makefile","./plot/Makefile","./multi/Makefile","./src/Makefile");
#
# open the file COMPILER and read the flag settings
#
open(FILE,"< $compilerfile") || die("can't open file $compilerfile") ;
foreach $line (<FILE>) {
if ($line!~/^#/) {
my( $flag, $flagsetting ) = split '=',$line;
if ($flag=~/^(F90C)/) {
$f90C = $flagsetting;
#print "F90C = $f90C";
} elsif ($flag=~/^(F90FLAGS)/) {
$f90flags = $flagsetting;
#print "F90FLAGS = $f90flags"
} elsif ($flag=~/^(LDFLAGS)/) {
$ldflags = $flagsetting;
#print "LDFLAGS = $ldflags"
}
}
}
close(FILE);
#
# check that all appropriate flags have been input
#
print "------------- new flag settings ------------------- \n";
print "F90C = $f90C";
print "F90FLAGS = $f90flags";
print "LDFLAGS = $ldflags";
#
# Now go through all the Makefiles and replace the appropriate flags
#
my $makefile;
my $date = `date`;
print $date;
foreach $makefile(@makefiles) {
print "------------------------------------------------------ \n";
## make backup copy of each file
my $oldmakefile = "$makefile.old";
print "copying $makefile to $oldmakefile \n";
system "cp $makefile $oldmakefile" || die("can't write $oldmakefile");
open(OLDMAKEFILE,"< $oldmakefile") || die("can't open $oldmakefile") ;
open(MAKEFILE,"> $makefile") || die("can't open $makefile") ;
print "changing flag settings in $makefile...";
foreach $line (<OLDMAKEFILE>) {
if ($line!~/^#/) {
my( $flag, $flagsetting ) = split '=',$line;
if ($flag=~/^(F90C)/) {
print MAKEFILE "F90C = $f90C";
} elsif ($flag=~/^(F90FLAGS)/) {
print MAKEFILE "F90FLAGS = $f90flags";
} elsif ($flag=~/^(LDFLAGS)/) {
print MAKEFILE "LDFLAGS = $ldflags";
} else {
print MAKEFILE $line;
}
} else {
print MAKEFILE $line;
}
}
print " done\n";
close(OLDMAKEFILE);
close(NEWMAKEFILE);
}