1 |
|
#!/usr/bin/perl -w |
2 |
– |
|
3 |
– |
package FileEntry; |
4 |
– |
|
5 |
– |
sub new { |
6 |
– |
my $type = shift; |
7 |
– |
my $filename = shift; |
8 |
– |
my $path = shift; |
9 |
– |
my $self = {}; |
10 |
– |
$self->{'source_file'} = $filename; |
11 |
– |
$self->{'filepath'} = $path; |
12 |
– |
$self->{'includes'} = {}; |
13 |
– |
$self->{'uses'} = {}; |
14 |
– |
$self->{'modules'} = {}; |
15 |
– |
bless $self; |
16 |
– |
} |
17 |
– |
|
2 |
|
######################################################################## |
3 |
|
# |
4 |
|
# filepp is free software; you can redistribute it and/or modify |
21 |
|
# Filename : $RCSfile: filepp,v $ |
22 |
|
# Author : $Author: tim $ |
23 |
|
# Maintainer : Darren Miller: darren@cabaret.demon.co.uk |
24 |
< |
# File version : $Revision: 1.1 $ |
25 |
< |
# Last changed : $Date: 2004-10-01 21:11:29 $ |
24 |
> |
# File version : $Revision: 1.3 $ |
25 |
> |
# Last changed : $Date: 2004-10-06 22:19:33 $ |
26 |
|
# Description : Main program |
27 |
|
# Licence : GNU copyleft |
28 |
|
# |
296 |
|
# |
297 |
|
my %f90ModList = (); |
298 |
|
|
299 |
< |
# |
299 |
> |
# suffix of fortran object file |
300 |
|
my $objExt = '.o'; |
301 |
+ |
|
302 |
+ |
# suffix of fortran 90 module |
303 |
+ |
my $modSuffix = "mod"; |
304 |
+ |
|
305 |
+ |
# case of basename of fortran 90 module |
306 |
+ |
my $modBasenameCase = "lower"; |
307 |
|
############################################################################## |
308 |
|
# SetDebug - controls debugging level |
309 |
|
############################################################################## |
2443 |
|
my $file; |
2444 |
|
if ($modulename !~ /^procedure/){ |
2445 |
|
|
2446 |
< |
$parsedModList{uc($modulename) . ".mod"} = Filepp::GetDefine('__FILE__'); |
2446 |
> |
$modulename =~ s/\s+$//; |
2447 |
> |
$parsedModList{GetModBasename($modulename) . "." . $modSuffix} |
2448 |
> |
= Filepp::GetDefine('__FILE__'); |
2449 |
|
|
2450 |
|
#$modulefile = Filepp::GetDefine('__BASE_FILE__'); |
2451 |
|
#print $modulefile; |
2466 |
|
my $line = shift; |
2467 |
|
$line =~ /^(\w+).*/; |
2468 |
|
my $f90module = $1; |
2469 |
+ |
$f90module =~ s/\s+$//; |
2470 |
|
$f90module = uc($f90module); |
2471 |
|
|
2472 |
< |
print " " . $objDir . $f90module . '.mod \\', "\n"; |
2480 |
< |
#addModule($f90module); |
2472 |
> |
print " " . $objDir . GetModBasename($f90module) . "." . $modSuffix . "\\\n"; |
2473 |
|
} |
2474 |
|
|
2475 |
|
############################################################################## |
2483 |
|
Filepp::AddKeyword("include", "Filepp::Include"); |
2484 |
|
|
2485 |
|
############################################################################## |
2486 |
< |
# add RecordFileInfo info Filepp. Every time a file is opened, an entry |
2495 |
< |
# of this file is created |
2486 |
> |
# test whether a file is visited or not |
2487 |
|
############################################################################## |
2497 |
– |
|
2498 |
– |
sub RecordFileInfo{ |
2499 |
– |
my $file = Filepp::GetDefine('__FILE__'); |
2500 |
– |
# dependenyGraph->add_vertex(new ); |
2501 |
– |
|
2502 |
– |
#if it is not base file, we need to add an edge |
2503 |
– |
if ($include_level > 0) { |
2504 |
– |
|
2505 |
– |
} |
2506 |
– |
|
2507 |
– |
} |
2508 |
– |
|
2509 |
– |
Filepp::AddOpenInputFunc("Filepp::RecordFileInfo"); |
2510 |
– |
|
2488 |
|
sub IsVisited { |
2489 |
|
my $fullfile = shift; |
2490 |
|
|
2508 |
|
|
2509 |
|
} |
2510 |
|
|
2511 |
< |
|
2511 |
> |
############################################################################## |
2512 |
> |
# Generate rules for fortran 90 module |
2513 |
> |
############################################################################## |
2514 |
|
sub printModule { |
2515 |
|
my $modname; |
2516 |
|
my $objname; |
2521 |
|
} |
2522 |
|
} |
2523 |
|
|
2524 |
+ |
############################################################################## |
2525 |
+ |
# Get the object file name |
2526 |
+ |
############################################################################## |
2527 |
|
sub GetObjFile { |
2528 |
|
use File::Basename; |
2529 |
|
my $fullname = shift; |
2533 |
|
($filename, $dir, $suffix) = fileparse($fullname, '\.[^.]*'); |
2534 |
|
return $filename . $objExt; |
2535 |
|
} |
2536 |
+ |
|
2537 |
|
############################################################################## |
2538 |
+ |
# Get the base name of fortran 90 module |
2539 |
+ |
############################################################################## |
2540 |
+ |
sub GetModBasename { |
2541 |
+ |
my $modname = shift; |
2542 |
+ |
|
2543 |
+ |
if ($modBasenameCase eq "lower") { |
2544 |
+ |
$modname = lc($modname); |
2545 |
+ |
|
2546 |
+ |
} elsif ($modBasenameCase eq "upper") { |
2547 |
+ |
$modname = uc($modname); |
2548 |
+ |
} elsif ($modBasenameCase eq "mixed") { |
2549 |
+ |
$modname = ucfirst(lc($modname)); |
2550 |
+ |
} |
2551 |
+ |
|
2552 |
+ |
return $modname; |
2553 |
+ |
} |
2554 |
+ |
|
2555 |
+ |
############################################################################## |
2556 |
|
# Main routine |
2557 |
|
############################################################################## |
2558 |
|
|
2747 |
|
} |
2748 |
|
UseModule($ARGV[++$i]); |
2749 |
|
} |
2750 |
< |
|
2750 |
> |
|
2751 |
> |
#case of basename of fortran module |
2752 |
> |
elsif($ARGV[$i] eq "-mc") { |
2753 |
> |
my $tempVar = lc($ARGV[++$i]); |
2754 |
> |
if ($modBasenameCase ne 'lower' && $modBasenameCase ne 'upper' |
2755 |
> |
&& $modBasenameCase ne 'mixed'){ |
2756 |
> |
Error("Valid argument for `-om' are lower, upper or mixed"); |
2757 |
> |
} |
2758 |
> |
$modBasenameCase = $tempVar; |
2759 |
> |
} |
2760 |
> |
|
2761 |
> |
#the suffix of fortran module |
2762 |
> |
elsif($ARGV[$i] eq "-ms") { |
2763 |
> |
$modSuffix = $ARGV[++$i]; |
2764 |
> |
} |
2765 |
> |
|
2766 |
|
# set macro prefix |
2767 |
|
elsif($ARGV[$i] eq "-mp") { |
2768 |
|
if($i+1 >= $argc) { |
2780 |
|
# module files will be built in a separate directory from the sources. |
2781 |
|
elsif($ARGV[$i] eq "-od") { |
2782 |
|
$objDir = $ARGV[++$i]; |
2783 |
< |
} |
2783 |
> |
} |
2784 |
> |
|
2785 |
|
# turn on overwrite mode |
2786 |
|
elsif($ARGV[$i] eq "-ov") { |
2787 |
|
$overwrite = 1; |