Skip to content

example Makefile dependencies #43

@tkphd

Description

@tkphd

Commit a01bf6b removed the core MMSP includes as dependencies from the example Makefiles. This was erroneous in most cases: as a result of this commit, running make will not rebuild the binaries when the MMSP includes change, only when the example code changes. Proper usage defines a core variable containing the external files necessary to build an up-to-date binary, and including those files on the dependency line.

To clarify, using one of the anisotropic vector-valued grain growth codes as an example:

Current Makefile

graingrowth: graingrowth.cpp
    $(compiler) $(flags) $< -o $@ -lz

Former Makefile

core = $(incdir)/MMSP.hpp \
       $(incdir)/MMSP.main.hpp \
       $(incdir)/MMSP.utility.hpp \
       $(incdir)/MMSP.grid.hpp \
       $(incdir)/MMSP.vector.hpp
graingrowth: graingrowth.cpp anisotropy.hpp
    $(compiler) $(flags) $< -I$(core) -o $@ -lz

Correct Makefile

core = $(incdir)/MMSP.hpp \
       $(incdir)/MMSP.main.hpp \
       $(incdir)/MMSP.utility.h \
       $(incdir)/MMSP.utility.cpp \
       $(incdir)/MMSP.grid.h \
       $(incdir)/MMSP.grid.cpp \
       $(incdir)/MMSP.vector.h \
       $(incdir)/MMSP.vector.cpp
graingrowth: graingrowth.cpp graingrowth.hpp anisotropy.hpp $(core)
    $(compiler) $(flags) $< -o $@ -lz

Protip: $< denotes the first prerequisite, which in this example is graingrowth.cpp, not the whole slew of dependencies. The first item is critical, but order makes no difference for the remainder.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions