📄 sfmakedepend
字号:
my @list = $ref->inc_mods(); @mod_list = (@mod_list, @list); } }# add them to the uses list (hash ensures uniqueness) foreach $modname (@mod_list) { $self->{'uses'}{$modname} = 1; } # now find the filename that contains the module information foreach $modname (keys %{$self->{'uses'}}) { if ($main::depend eq "obj") { if ($file = $main::mod_files{$modname}) { my $base = main::basename($file, @main::suffixes); $file = $base . "." . $main::obj_ext; push(@module_files, $file); } else { warn "Don't know where module $modname lives.\n"; } } else { if ($main::libdeps or defined($main::mod_files{$modname})) { $modname .= "." . $main::mod_ext; push(@module_files, $modname); } else { warn "Couldn't locate source for module $modname\n"; } } } sort(@module_files);}sub print { my $self = shift; my $source = $self->{'Source_File'}; my $compile_string = "\t" . '$(F90) $(F90FLAGS) -c'; my($base, $object, $modname, $flag, $target, $ftarget); $base = main::basename($source, @main::suffixes); $target = $base . "." . $main::obj_ext; if ($main::cpp) { $ftarget = $base . "." . $main::ext; } $flag = $main::obj_dep_flag; # print out "include" dependencies if (%{$self->{'includes'}}) { my $len_sum = length($target) + 1; if ($main::add_ext) { print "$base.$main::add_ext "; $len_sum += length($base) + length($main::add_ext) + 2; } print "$target:"; $self->print_includes($target, $len_sum); print "\n"; if ($main::cpp) { $len_sum = length($ftarget) + 1; print "$ftarget:"; $self->print_includes($ftarget, $len_sum); print "\n"; } }# clean out "use" of modules in own file my $mod; foreach $mod ( keys %{$self->{'uses'}} ) { if ( ${$self->{'modules'}}{$mod} ) { delete ${$self->{'uses'}}{$mod}; } }# print out "use" dependencies if (%{$self->{'uses'}} || %{$self->{'includes'}}) { my @module_files = $self->find_mods();#rch my $len_sum = length($target) + 1;#rch print "$target:"; my $len_sum = 0; my $file; foreach $file (@module_files) { $file = $main::mod_dir . '/' . $file if $main::mod_dir; if( $len_sum < 1 ) { $len_sum = length($target) + 1; print "$target:"; } my $len = length($file) + 1; if (($len_sum + $len > $ll) && (length($target) + 1 < $len_sum)) { print "\n$target:"; $len_sum = length($target) + 1; } $len_sum += $len; print " " . $file; } if ($main::need_f) { my $len = length($ftarget) + 1; if (($len_sum + $len > $ll) && (length($target) + 1 < $len_sum)) { print "\n$target:"; $len_sum = length($target) + 1; } print " " . $ftarget if $len_sum; } print "\n" if $len_sum;# extra Cray / Parasoft stuff if ($flag) { print $compile_string; foreach $file (@module_files) { print $flag . $file; } if ($main::cpp) { print " " . $ftarget . "\n"; } else { print " " . $source . "\n"; } } }}__END__sfmakedepend - Fortran Dependency Checker=head1 SYNOPSISsfmakedepend [--help] [--man] [--file=file] [-I dir] [--srcdir dir] [--moddir dir] [--fext ext] [--objext ext] [--modext ext] [--addext ext] [--case=up|down|asis] [--compiler=crayold|cray|sgiold|sgi|nag|ibm| parasoft|hp|absoft|sun] [--depend=mod|obj] [--cpp] [--libdeps] [--drop] file ...=head1 DESCRIPTIONThis is a makedepend script for Fortran, including Fortran 90.It searches for Fortran style includes, C preprocessor includes,and module dependencies to the extent that I understand them.Your files must have an extension listed in the @suffixes listin the code. You might also want to modify $compile_string;the compiler is called $(F90).=head1 OPTIONS AND ARGUMENTS=over 4=item I<--help>Print more details about the arguments.=item I<--man>Print a full man page.=item I<--file file>Change the name of the current Makefile (default is Makefile).Use "--file -" to write to stdout.=item I<-I dir>Look in alternate directories for the include files. There can beseveral "-I dir" options used at once. The current directory isstill searched first.=item I<--srcdir dir>Look in alternate directories for the source files, much like VPATH.It can be used multiple times to search in more than one directory.=item I<--moddir dir>Tells sfmakedepend to prepend moddir to all module references. Thisis required if you use a common module library directory for amulti-directory project (+moddir= .. option on HP, eg.).=item I<--fext>This is used with the --cpp switch for compilerswhich expect an extension other than .f on source files. Forinstance, one might choose to use "--fext f90".=item I<--objext ext>Tells sfmakedepend what extension to use for object files. Thedefault is "o", but "obj", for instance, isappropriate on MS-DOG etc.=item I<--modext ext>Specifies the extension to use for Fortran 90 module files. The defaultextension is "mod" since this seems to be an emerging standard. Letme know if other compilers use a different filename for the moduleinformation (keep that --compiler option up to date).=item I<--addext ext>Tells sfmakedepend to add targets with extension add_ext to the rulesfor object files. For instance, to operate with (f77) ftnchek .prjfiles, you could use`--addext prj' to get rules like:foo.prj foo.o: ... =item I<--case up|down|asis>Controls case of module names when generating module file names. Onlyrelevant where the module file name is named after the module ratherthan after the source file.=item I<--compiler=crayold|cray|sgiold|sgi|nag|ibm|parasoft|hp|absoft|sun>Controls the type of target compiler, setting the module name and otheroptions appropriately. The cray option assumes that FFLAGS includes-e m for creating the .mod file, while crayold refers to the default ofincluding that information in the object file.=item I<--depend=mod|obj>Whether to use the module information file or the module object filein dependencies.=item I<--cpp>There are times when one might choose to run .F files through cpp andto keep the .f files (for the debugger or for a custom preprocessor).In that case, make must be told about the cpp include dependencies ofthe .f files. This option will provide those dependencies.=item I<--libdeps>Generate dependencies on modules for which source code is notavailable. Otherwise a warning is issued, but the dependency is notlisted.=item I<--drop>Drop module dependencies (my_mod.mod: my_mod.o). This is also done when--depend=obj.=item I<[file ...]>The list of source files to search for dependencies.=back=head1 EXAMPLESearch for include files in /usr/local/include: sfmakedepend --cpp --fext=f90 -I /usr/local/include *.FExample usage in gnuMakefile: SRCDIRS= srcdir1 srcdir2 srcdir3 ... FSRCS0 := $(foreach DIR, . $(SRCDIRSH),$(wildcard $(DIR)/*.f)) FSRCS := $(sort $(notdir $(FSRCS0))) F_makedepend=sfmakedepend --file - $(addprefix --srcdir ,$(SRCDIRSH)) \ $(subst -I,-I ,$(Includes)) depend $(MAKEFILE_INC): $(F_makedepend) $(FSRCS) >> $(MAKEFILE_INC) include $(MAKEFILE_INC)=head1 AUTHORKate Hedstrom (kate@arsc.edu) First Perl 5 Fortran 90 version November 1994.=head1 CONTRIBUTORS Dave Love (d.love@dl.ac.uk) Added the --objext and --addext options (1996). Patrick Jessee Added hp support (1997, now in --compiler option). Sergio Gelato (gelato@tac.dk) Added the --compiler, --depend, --case options, and --(no)libdeps (1998). Tobias Buchal (buchal@ifh.bau-verm.uni-karlsruhe.de) Added the --srcdir and --file - options (1999). Klaus Ramstock (klaus@tdm234.el.utwente.nl) Added the --moddir option (1999). Sandra Schroedter (sandra@fsg-ship.de) Fix to preserve Makefile links (1999). Holger Bauer (bauer@itsm.uni-stuttgart.de) Added the --drop option (2000).Others I've doubtless forgotten.=cut## NOTES# This makedepend script is my first attempt at using perl 5# objects. Therefore, it may not be the best example of how# to do this. Also, it requires perl 5 and will die if you# to use it with an older perl. The latest version is# available from:## http://www.arsc.edu/~kate/Perl/# ftp://ahab.rutgers.edu/pub/perl/sfmakedepend## Fortran 90 introduces some interesting dependencies. Two# compilers I have access to (NAG f90 and IBM xlf) produce a# private "mod_name.mod" file if you define "module mod_name"# in your code. This file is used by the compiler when you# use the module as a consistency check (type-safe). On the# other hand, the Cray and Parasoft compilers store the module# information in the object file and then files which use the# modules need to be compiled with extra flags pointing to the# module object files.## This script assumes that all the files using and defining# modules are in the same directory and are all in the list of# files to be searched. It seems that the industry has not# settled on a practical way to deal with a separate modules# directory, anyway.## I sometimes include non-existent files as a compile time# consistency check:## #ifndef PLOTS# #include "must_define_PLOTS" /* bogus include */# #endif## This program warns about include files it can't find, but# not if there is a "bogus" on the same line.## * The f90 module dependencies can confuse some versions of# make, especially of the System V variety. We use gnu# make because it has no problems with these dependencies.## BUGS# It can sometimes produce duplicate dependencies.## It treats C preprocessor includes the same as Fortran# includes. This can add unnecessary dependencies if you# use the -s flag and both kinds of includes.## Please let me know if you find any others.# Kate Hedstrom# kate@arsc.edu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -