In this section, we provide templates for Makefiles for applications based on the deal.II libraries. They show how to use the information provided by the variables explained above.
At present, we have three Makefiles, one for small projects consisting of only one C++ file, and one for large projects. Furthermore, there is a Makefile in a different style. Have a look at them and see what seem convenient to you. All Makefiles need slight modifications before they will work in your project. The places for modifications are marked.
Small projects: This Makefile is targeted at applications which are written to simply try something, or prove an assumption. Such applications are the step-by-step examples. These small problems are probably not the usual case in real life, but you may want to take a look at this file in order to get an idea on how it works, or you go directly to the large projects file.
You can find this Makefile here.
Large
projects: This file is targeted at larger projects, and
for this file to work, we already assume a certain
subdirectory structure of your project. In particular, it
assumes that in your project directory the following
subdirectories exist (where project
is the
directory in which the whole project is located):
project/source
project/include
project/lib
project/lib/1d
project/lib/2d
project/lib/3d
Include files need to be placed into
project/include
, while implementation files
are to be in project/source
. The executable
will be in project/lib
and the compiled object
files will be in project/lib/?d
, depending on
the dimension for which the project is compiled. Using this
directory structure, it is possible to quickly switch
between dimensions in which a program shall run in,
enabling us to develop applications which run in 1d, 2d, or
3d without long compilation times. Furthermore, placing
object files in different directories prevents cluttering
directories with unnecessarily many files.
The dimension for which the project shall be compiled is not stated in the source code, as in the small projects Makefile, but is determined by a flag which is given in the Makefile. To determine the dimension for which a project is compiled in your source file, use the preprocessor constant `deal_II_dimension' which is set by the Makefile and passed through the compiler.
You can find this Makefile here.
The third
Makefile is common/Makefile.template
in
the deal.II directory tree.
It was designed for several targets in one directory and
makes use of the compilation rules in
common/Make.rules
. All object files and
executables will be in the same directory.