2 .\" Copyright (C) 2000--2003 Erik Edelmann <eedelman@acclab.helsinki.fi>
4 .\" This program is free software; you can redistribute it
5 .\" and/or modify it under the terms of the GNU General Public
6 .\" License version as published by the Free Software
9 .\" This program is distributed in the hope that it will be
10 .\" useful, but WITHOUT ANY WARRANTY; without even the implied
11 .\" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 .\" PURPOSE. See the GNU General Public License for more
15 .\" You should have received a copy of the GNU General Public
16 .\" License along with this program; if not, write to the Free
17 .\" Software Foundation, Inc., 59 Temple Place, Suite 330,
18 .\" Boston, MA 02111-1307 USA
20 .\" $Format: ".TH makedepf90 1 \"$Date$\""$
21 .TH makedepf90 1 "Thu, 06 Dec 2001 23:28:54 +0200"
24 makedepf90 \- creates Makefile dependency list for Fortran source files.
30 .RB [ \-W | -Wmissing ]
42 .RB [ \-fixed | \-free ]
44 .IR "name-of-executable" ]
51 .IR "PATH1:PATH2:..." ]
57 \fImakedepf90\fP is a program for automatic creation of dependency lists
58 and compilation rules for Makefiles.
60 The original idea was to provide the same functionality for Fortran as
68 does for C. Nowadays makedepf90 actually supersedes this functionality,
69 making me wonder if I should extend makedepf90 to support C and C++ too
72 \fImakedepf90\fP supports both \fBmodules\fP, \fBinclude\fP:s,
73 \fBcpp\fP(1) \fB#include\fP:s, \fBf90ppr\fP(1) \fB$include\fP:s and
74 \fBcoco\fP(1) \fB??includes\fP and set-files.
76 \fImakedepf90\fP reads Fortran source files given on the command line, and
77 writes a dependency list to stdout; for every file it writes a line
78 with the following format:
81 .IR targets " : " prerequisites
84 \fITargets\fP are the files that will be the result of compiling the file
85 with the \fB-c\fP option, and \fIprerequisites\fP are files that are needed
87 In addition, \fImakedepf90\fP can optionally create the dependency line and
88 make-rule needed to link the final executable.
89 .SS "Fortran dependencies"
91 The files needed to compile a file, i.e the \fIprerequisites\fP of the file
95 The source file itself
98 Files with interface information about USEd modules, created by the
99 compiler while compiling the modules (often named \fImodulename\fP.mod or
100 something similar, hereafter called \fImod-files\fP).
103 Include-files (including files included and mod-files of modules USEd from
104 these include-files).
107 \fBCoco\fP set-files, if \fBcoco\fP(1) is being used and set-files exist.
109 Since different compilers use different naming conventions for the
110 mod-files, listing them in the dependency list results in non-portable
111 makefiles. Therefore it's common practise to list the object file
112 (\fIfilename\fP.o) corresponding to the sourcefile containing the USEd
113 modules instead. This is the default behaviour of
114 \fImakedepf90\fP. To change this, use the \fB\-m\fP option (e.g \fB\-m
115 "%m.mod"\fP if your compiler names the mod files \fImodulename\fP.mod)
117 Include files not found in the working directory will not be listed in the
118 dependency list, assuming they are part of a (seldom changing) library not
119 part of the program. Neither will mod-files of modules whose definitions
120 aren't found be listed by the same reason.
124 These options may be given anywhere, in any order, on the command line.
125 Space between an option and its argument is optional. Options may not be
126 grouped (\fB\-hW\fP is not the same thing as \fB\-h \-W\fP).
128 .BR \-h " or " \-\-help
129 Print a short help message to stdout and quit.
131 .BR \-V " or " \-\-version
132 Print version and copyright information to stdout and quit
134 .BR \-W " or " \-Wmissing
135 Print warnings about missing modules and include files
138 Print warnings when confused (either because of bugs in makedepf90 itself,
139 or because of wierd things in your source files). If makedepf90 misses
140 some dependencies, or do other wierd things, this option might give some
141 idea on whats going on.
144 Tell \fImakedepf90\fP that mod-files will have names of the format
145 \fIfmt\fP. \fIfmt\fP may contain the modifiers \fB%f\fP for
146 \fIfilename\fP (without file name .suffix), \fB%m\fP for \fImodulename\fP
147 (in lowercase), \fB%M\fP for \fIMODULENAME\fP (in uppercase) and \fB%%\fP
148 for '%'. Default is "%f.o".
150 .BI \-u " modulename"
151 Ignore all modules named \fImodulename\fP.
154 Make all targets dependent on \fIfile\fP.
157 Add \fIrule\fP (indented by a tab) to all dependency lines except lines
158 given rule(s) with the \fB\-R\fP option.
161 \fIrule\fP may contains the following modifiers: \fB%f\fP for the name of
162 the source file (without suffix) the dependency line is created for, and \fB%%\fP for '%'.
165 .BI \-R " 'pattern' 'rule'"
166 Compile files matching the shell pattern \fIpattern\fP using the rule \fIrule\fP.
167 In \fIpattern\fP, the following wildcards can be used: \fB*\fP = any number
168 of any characters, \fB?\fP = any character and \fB[abc]\fP = any of
169 \fBa\fP, \fBb\fP or \fBc\fP. Note that the patter-matching is to be
170 performed by \fImakedepf90\fP, not the shell. Therefore \fIpattern\fP
171 should be enclosed in quotes (\fB"\fP or \fB'\fP). For \fIrule\fP applies
172 the same rules as for \fB\-r\fP above.
175 Note that there is a subtle difference between "\fB\-r\fP \fIrule\fP" and
176 "\fB\-R\fP '*' \fIrule\fP". In the former case \fIrule\fP will be applied
177 only to lines not given any rule using \fB\-R\fP, while in the latter case,
178 \fIrule\fP will be applied to \fIall\fP lines.
181 .BR \-fixed " / " \-free
182 Treat the files as fixed/free source format. If both options are given,
183 the latter is used. Default: Files with suffixes
184 .BR ".f, .F, .for, .FOR " or " .ftn"
185 are treated as fixed format and
186 .BR ".f90, .F90, .f95 " or " .F95"
187 are treated as free format.
190 This option will cause \fImakedepf90\fP to define the Makefile macro
191 \fBFOBJ\fP=\fIobjectfiles\fP, and a dependency line + rule for the final linking
192 process to create the executable \fIname\fP. To set the linking rule, use
193 the option \fB\-l\fP.
196 Use \fIrule\fP when linking the executable. The default is
198 \fB$(FC) -o $@ $(FFLAGS) $(LDFLAGS) $(FOBJ) $(LIBS)\fP.
200 This option has no effect unless \fB\-o\fP is used.
203 Look for \fBcoco\fP(1) set-files (\fBcoco\fP ??include:s are supported
204 automatically). This option implies \fB\-free\fP.
207 Define the pre-processor symbol \fINAME\fP.
210 Dependency tree and link rule will assume objects are placed in \fIpath\fP.
211 This is useful if the build places object files in a different directory than
214 .BI \-I " list-of-paths"
215 Look for source/include files in the \fIlist-of-paths\fP, if not found in
216 current working directory. Here, \fIlist-of-paths\fP is a colon separated
220 Don't list the source file among the prerequisites.
224 Here's an example of basic \fImakedepf90\fP usage together with
225 \fBmake\fP(1). Create a file named \fBMakefile\fP with the following
229 ----------------------
231 # FC = the compiler to use
239 # List libraries used by the program here
242 # Suffix-rules: Begin by throwing away all old suffix-
243 # rules, and then create new ones for compiling
250 $(FC) \-c $(FFLAGS) $<
252 # Include the dependency-list created by makedepf90 below
255 # target 'clean' for deleting object- *.mod- and other
259 rm \-f *.o *.mod core
262 # Create a dependency list using makedepf90. All files
263 # that needs to be compiled to build the program,
264 # i.e all source files except include files, should
265 # be given on the command line to makedepf90.
267 # The argument to the '\-o' option will be the name of the
268 # resulting program when running 'make', in this case
272 makedepf90 \-o foobar *.f90 > .depend
274 -----------------------
277 (Note that all the indented lines should be indented with tabs, not spaces)
279 With this makefile, the command \fBmake\fP should perform all the commands
280 needed to compile and link the program \fIfoobar\fP out of all *.f90 files
281 in the working directory.
283 The dependency list \fI.depend\fP will be (re)created if \fI.depend\fP
284 doesn't exist, or if the command \fBmake depend\fP is run.
285 This should be done every time changes has been made to the program that
286 affect the dependencies of the files (e.g if new source files has been
287 added to the project).
288 .SS "Example With Coco"
289 If you are using a pre-processor, things might get more complicated. If
290 you are lucky, your compiler supports your pre-processor and runs it on
291 your code automatically, but if it doesn't, you have to give the commands
292 to run the pre-processor yourself. Below is an example of an Makefile for
296 -----------------------
305 .SUFFIXES: .f .f90 .o
307 # Files ending in .f90 are compiled directly ...
310 $(FC) \-c $(FFLAGS) $<
312 # ... while those ending in .f are preprocessed first.
315 $(PREPROCESSOR) $*; $(FC) \-c $(FFLAGS) $*.f90
322 rm \-f *.o *.mod core
326 makedepf90 \-coco \-o foobar *.f90 *.f > .depend
328 -----------------------
332 Some implementations of
334 will not execute any commands \(em not even \fBmake depend\fP \(em with the
335 Makefiles above unless there exists a file named \fI.depend\fP. To overcome
336 this problem, either run \fImakedepf90\fP manually, or begin by creating an
339 file with the command \fBtouch .depend\fP.
343 Most error and warning messages are self explanatory, but some of them might
344 need some further explanations:
346 .BI "WARNING: recursion limit reached in file " filename
347 When recursively parsing include files, makedepf90 has reached the
348 recursion limit. Possible reasons are: either you have some
349 \fIreally\fP complicated systems of include files, or you have
350 recursive includes (e.g an include file that includes itself). In the
351 latter case; fix it, your Fortran compiler will not like it either.
353 .SH "BUGS AND LIMITATIONS"
355 Makedepf90's support for pre processor conditionals and macro expension
356 (#if:s, #define:s etc) is rather weak, but should work well enough for most
359 The include file search algorithm is broken. I may fix it some day.
369 The makedepf90 web site is found at
372 http://www.iki.fi/erik.edelmann/makedepf90
378 This program is free software; you can redistribute it and/or
379 modify it under the terms of the GNU General Public License version 2 as
380 published by the Free Software Foundation.
382 This program is distributed in the hope that it will be useful, but
383 WITHOUT ANY WARRANTY; without even the implied warranty of
384 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
385 General Public License for more details.
387 You should have received a copy of the GNU General Public License
388 along with this program; if not, write to the Free Software
389 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
392 Erik Edelmann <Erik.Edelmann@iki.fi>