1,885
edits
Changes
no edit summary
Running the <code>make</code> command by itself will execute the makefile script named <code>Makefile</code> or <code>makefile</code> in the current directory.
== Targets and Dependencies ==
Picture a very simple build, where the file <code>test.c</code> is compiled by ''gcc'' into the executable binary named <code>test</code>.
This is because the timestamp on the target (<code>test</code>) is later than the timestamp on the dependency (<code>test.c</code>). If the dependency has been changed since the target was built, though, then ''make'' will rebuild the target.
=== Complex Dependencies ===
A more complicated build will involve a number of targets and dependencies. C programs, for example, can be compiled into intermediate files, called object files (.o extension), which can then be combined to produce executables.
On a large programming project, a binary may be comprised of hundreds or even thousands of source files, and compiling all of those files may take hours. If a software developer edits just one file, it's a waste of time to rebuild everything, so ''make'' can save a lot of time -- especially when the software is rebuilt many thousand times.
=== Fake Targets ===
It is not uncommon to include "fake" targets in a Makefile -- targets which never get built, but which perform a useful operation. For example, a target of "all" never produces an actual file named "all". Typical fake targets include:
* all: build all binaries
* docs: builts all documentation (e.g., generates PDFs, HTML, manpages, etc)
* install: install all files, building binaries, documentation, etc if required
* clean: erases all built intermediate and binary files
* dist-clean (or distclean): erases all files not included in the original distribution of the source
* check (or test): tests the software
== Examples ==
* [http://matrix.senecacollege.ca/osd600/makefile-examples.tgz A tarball of simple Makefile examples]