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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
|
.\"
.\" Copyright (C) 2000--2003 Erik Edelmann <eedelman@acclab.helsinki.fi>
.\" Copyright (C) 2015 Jason Graham <jason.graham@jhuapl.edu>
.\"
.\" 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 "Tue, 17 Nov 2015 23:21:02 -0500"
.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 | \-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 \-B " path"
Dependency tree and link rule will assume objects are placed in \fIpath\fP using
the same directory structure as the source files. This is useful if the build
places object files in a different directory than the source files and the
source directory structure is needed to avoid object name collisions.
.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 <Erik.Edelmann@iki.fi>
|