Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example Makefile dependencies #43

Open
tkphd opened this issue Jun 15, 2017 · 1 comment
Open

example Makefile dependencies #43

tkphd opened this issue Jun 15, 2017 · 1 comment
Assignees

Comments

@tkphd
Copy link
Contributor

tkphd commented Jun 15, 2017

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.

@tkphd
Copy link
Contributor Author

tkphd commented Jun 15, 2017

Proper specification of dependencies in the Makefile and source files would resolve #37 as well.

@tkphd tkphd self-assigned this Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant