.\" .\" Copyright (C) 2000--2003 Erik Edelmann .\" .\" This program is free software; you can redistribute it .\" and/or modify it under the terms of the GNU General Public .\" License version as published by the Free Software .\" Foundation. .\" .\" This program is distributed in the hope that it will be .\" useful, but WITHOUT ANY WARRANTY; without even the implied .\" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR .\" PURPOSE. See the GNU General Public License for more .\" details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this program; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, .\" Boston, MA 02111-1307 USA .\" .\" $Format: ".TH makedepf90 1 \"$Date$\""$ .TH makedepf90 1 "Thu, 06 Dec 2001 23:28:54 +0200" .SH NAME makedepf90 \- creates Makefile dependency list for Fortran source files. .SH SYNOPSIS .B makedepf90 .RB [ \-h ] .RB [ \-V ] .RB [ \-W | -Wmissing ] .RB [ \-Wconfused ] .RB [ \-m .IR fmt ] .RB [ \-u .IR modulename ] .RB [ \-d .IR file ] .RB [ \-r .IR rule ] .RB [ \-R .IR "file rule" ] .RB [ \-fixed | \-free ] .RB [ \-o .IR "name-of-executable" ] .RB [ \-coco ] .RB [ \-D .IR NAME ] .RB [ \-b .IR "path" ] .RB [ \-I .IR "PATH1:PATH2:..." ] .RB [ \-nosrc ] .I sourcefile(s) .SH DESCRIPTION .PP \fImakedepf90\fP is a program for automatic creation of dependency lists and compilation rules for Makefiles. .PP The original idea was to provide the same functionality for Fortran as .RS .PP .ft CW gcc -MM *.c .ft R .RE .PP does for C. Nowadays makedepf90 actually supersedes this functionality, making me wonder if I should extend makedepf90 to support C and C++ too ;-). .PP \fImakedepf90\fP supports both \fBmodules\fP, \fBinclude\fP:s, \fBcpp\fP(1) \fB#include\fP:s, \fBf90ppr\fP(1) \fB$include\fP:s and \fBcoco\fP(1) \fB??includes\fP and set-files. .PP \fImakedepf90\fP reads Fortran source files given on the command line, and writes a dependency list to stdout; for every file it writes a line with the following format: .RS .PP .IR targets " : " prerequisites .RE .PP \fITargets\fP are the files that will be the result of compiling the file with the \fB-c\fP option, and \fIprerequisites\fP are files that are needed to compile the file. In addition, \fImakedepf90\fP can optionally create the dependency line and make-rule needed to link the final executable. .SS "Fortran dependencies" .PP The files needed to compile a file, i.e the \fIprerequisites\fP of the file are: .TP .B \(em The source file itself .TP .B \(em Files with interface information about USEd modules, created by the compiler while compiling the modules (often named \fImodulename\fP.mod or something similar, hereafter called \fImod-files\fP). .TP .B \(em Include-files (including files included and mod-files of modules USEd from these include-files). .TP .B \(em \fBCoco\fP set-files, if \fBcoco\fP(1) is being used and set-files exist. .PP Since different compilers use different naming conventions for the mod-files, listing them in the dependency list results in non-portable makefiles. Therefore it's common practise to list the object file (\fIfilename\fP.o) corresponding to the sourcefile containing the USEd modules instead. This is the default behaviour of \fImakedepf90\fP. To change this, use the \fB\-m\fP option (e.g \fB\-m "%m.mod"\fP if your compiler names the mod files \fImodulename\fP.mod) .PP Include files not found in the working directory will not be listed in the dependency list, assuming they are part of a (seldom changing) library not part of the program. Neither will mod-files of modules whose definitions aren't found be listed by the same reason. .SH OPTIONS .PP These options may be given anywhere, in any order, on the command line. Space between an option and its argument is optional. Options may not be grouped (\fB\-hW\fP is not the same thing as \fB\-h \-W\fP). .TP .BR \-h " or " \-\-help Print a short help message to stdout and quit. .TP .BR \-V " or " \-\-version Print version and copyright information to stdout and quit .TP .BR \-W " or " \-Wmissing Print warnings about missing modules and include files .TP .B \-Wconfused Print warnings when confused (either because of bugs in makedepf90 itself, or because of wierd things in your source files). If makedepf90 misses some dependencies, or do other wierd things, this option might give some idea on whats going on. .TP .BI \-m " fmt" Tell \fImakedepf90\fP that mod-files will have names of the format \fIfmt\fP. \fIfmt\fP may contain the modifiers \fB%f\fP for \fIfilename\fP (without file name .suffix), \fB%m\fP for \fImodulename\fP (in lowercase), \fB%M\fP for \fIMODULENAME\fP (in uppercase) and \fB%%\fP for '%'. Default is "%f.o". .TP .BI \-u " modulename" Ignore all modules named \fImodulename\fP. .TP .BI \-d " file" Make all targets dependent on \fIfile\fP. .TP .BI \-r " rule" Add \fIrule\fP (indented by a tab) to all dependency lines except lines given rule(s) with the \fB\-R\fP option. .PP .RS +7 \fIrule\fP may contains the following modifiers: \fB%f\fP for the name of the source file (without suffix) the dependency line is created for, and \fB%%\fP for '%'. .RS -7 .TP .BI \-R " 'pattern' 'rule'" Compile files matching the shell pattern \fIpattern\fP using the rule \fIrule\fP. In \fIpattern\fP, the following wildcards can be used: \fB*\fP = any number of any characters, \fB?\fP = any character and \fB[abc]\fP = any of \fBa\fP, \fBb\fP or \fBc\fP. Note that the patter-matching is to be performed by \fImakedepf90\fP, not the shell. Therefore \fIpattern\fP should be enclosed in quotes (\fB"\fP or \fB'\fP). For \fIrule\fP applies the same rules as for \fB\-r\fP above. .PP .RS +7 Note that there is a subtle difference between "\fB\-r\fP \fIrule\fP" and "\fB\-R\fP '*' \fIrule\fP". In the former case \fIrule\fP will be applied only to lines not given any rule using \fB\-R\fP, while in the latter case, \fIrule\fP will be applied to \fIall\fP lines. .RS -7 .TP .BR \-fixed " / " \-free Treat the files as fixed/free source format. If both options are given, the latter is used. Default: Files with suffixes .BR ".f, .F, .for, .FOR " or " .ftn" are treated as fixed format and .BR ".f90, .F90, .f95 " or " .F95" are treated as free format. .TP .BI \-o " name" This option will cause \fImakedepf90\fP to define the Makefile macro \fBFOBJ\fP=\fIobjectfiles\fP, and a dependency line + rule for the final linking process to create the executable \fIname\fP. To set the linking rule, use the option \fB\-l\fP. .TP .BI \-l " rule" Use \fIrule\fP when linking the executable. The default is .br \fB$(FC) -o $@ $(FFLAGS) $(LDFLAGS) $(FOBJ) $(LIBS)\fP. .br This option has no effect unless \fB\-o\fP is used. .TP .B \-coco Look for \fBcoco\fP(1) set-files (\fBcoco\fP ??include:s are supported automatically). This option implies \fB\-free\fP. .TP .BI \-D " NAME" Define the pre-processor symbol \fINAME\fP. .TP .BI \-b " path" Dependency tree and link rule will assume objects are placed in \fIpath\fP. This is useful if the build places object files in a different directory than the source files. .TP .BI \-I " list-of-paths" Look for source/include files in the \fIlist-of-paths\fP, if not found in current working directory. Here, \fIlist-of-paths\fP is a colon separated list of path names. .TP .B \-nosrc Don't list the source file among the prerequisites. .SH "EXAMPLES" .SS "Basic Usage" Here's an example of basic \fImakedepf90\fP usage together with \fBmake\fP(1). Create a file named \fBMakefile\fP with the following contents: .PP .ft CW ---------------------- # FC = the compiler to use FC=f90 .br # Compiler options FFLAGS=\-O .br # List libraries used by the program here LIBS= # Suffix-rules: Begin by throwing away all old suffix- # rules, and then create new ones for compiling # *.f90-files. .SUFFIXES: .SUFFIXES: .f90 .o .f90.o: .br $(FC) \-c $(FFLAGS) $< # Include the dependency-list created by makedepf90 below include .depend # target 'clean' for deleting object- *.mod- and other # unwanted files clean: .br rm \-f *.o *.mod core .br # Create a dependency list using makedepf90. All files # that needs to be compiled to build the program, # i.e all source files except include files, should # be given on the command line to makedepf90. # # The argument to the '\-o' option will be the name of the # resulting program when running 'make', in this case # 'foobar' depend .depend: .br makedepf90 \-o foobar *.f90 > .depend ----------------------- .ft R .PP (Note that all the indented lines should be indented with tabs, not spaces) .PP With this makefile, the command \fBmake\fP should perform all the commands needed to compile and link the program \fIfoobar\fP out of all *.f90 files in the working directory. .PP The dependency list \fI.depend\fP will be (re)created if \fI.depend\fP doesn't exist, or if the command \fBmake depend\fP is run. This should be done every time changes has been made to the program that affect the dependencies of the files (e.g if new source files has been added to the project). .SS "Example With Coco" If you are using a pre-processor, things might get more complicated. If you are lucky, your compiler supports your pre-processor and runs it on your code automatically, but if it doesn't, you have to give the commands to run the pre-processor yourself. Below is an example of an Makefile for \fBcoco\fP(1)-users. .PP .ft CW ----------------------- FC=f90 .br FFLAGS=\-O .br PREPROCESSOR=coco .br .SUFFIXES: .SUFFIXES: .f .f90 .o # Files ending in .f90 are compiled directly ... .f90.o: .br $(FC) \-c $(FFLAGS) $< # ... while those ending in .f are preprocessed first. .f.o: .br $(PREPROCESSOR) $*; $(FC) \-c $(FFLAGS) $*.f90 include .depend clean: .br rm \-f *.o *.mod core depend .depend: .br makedepf90 \-coco \-o foobar *.f90 *.f > .depend ----------------------- .ft R .PP .B NOTE: Some implementations of .BR make (1) will not execute any commands \(em not even \fBmake depend\fP \(em with the Makefiles above unless there exists a file named \fI.depend\fP. To overcome this problem, either run \fImakedepf90\fP manually, or begin by creating an empty .I .depend file with the command \fBtouch .depend\fP. .SH DIAGNOSTICS .PP Most error and warning messages are self explanatory, but some of them might need some further explanations: .TP .BI "WARNING: recursion limit reached in file " filename When recursively parsing include files, makedepf90 has reached the recursion limit. Possible reasons are: either you have some \fIreally\fP complicated systems of include files, or you have recursive includes (e.g an include file that includes itself). In the latter case; fix it, your Fortran compiler will not like it either. .SH "BUGS AND LIMITATIONS" .PP Makedepf90's support for pre processor conditionals and macro expension (#if:s, #define:s etc) is rather weak, but should work well enough for most cases. The include file search algorithm is broken. I may fix it some day. .SH "SEE ALSO" .BR make (1), .BR f90 (1), .BR cpp (1), .BR fpp (1), .BR f90ppr (1), .BR coco (1) .PP The makedepf90 web site is found at .br .UR http://www.iki.fi/erik.edelmann/makedepf90 .UE .SH COPYING .PP This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. .PP This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. .PP You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA .SH AUTHOR Erik Edelmann