Skip to content

Commit

Permalink
Merge pull request #5 from coderefinery/blindij/motivation
Browse files Browse the repository at this point in the history
Add a dependency graph
  • Loading branch information
blindij authored Oct 7, 2024
2 parents 8165741 + f79ac8b commit 37859ea
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 72 deletions.
51 changes: 0 additions & 51 deletions doc/another-feature.md

This file was deleted.

6 changes: 3 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'Example'
copyright = 'workshop participant'
author = 'workshop participant'
project = 'A lesson about make'
copyright = 'Coderefinery'
author = 'Bjoern Lindi'
release = '0.1'


Expand Down
Binary file added doc/img/dependency_graph.001.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Makefile's documentation!
Welcome to a lesson about `make`!
===================================

.. toctree::
:maxdepth: 2
:caption: Contents:

simple-makefile.md
motivation.md
rules.md
other_makefiles.md
exercise.md
Expand Down
19 changes: 17 additions & 2 deletions doc/simple-makefile.md → doc/motivation.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# A simple Makefile
# Motivation
The `make` program is intended to automate the mundane aspects of transforming source code into an executable.
The advantages of `make` over scripts is that you can specify relationships between the elements of your program
to `make`. With the knowledge of the relationships and timestamps it figures out the necessary steps to be
redone to produce the desired program each time.

## A simple Makefile
The specification that `make` uses is saved in a file named _makefile_. Here is a _makefile_ to build the
traditional "Hello, World" program.

Expand All @@ -23,15 +24,29 @@ A _makefile_ contains a set of rules to build an application. The first rule see
_default rule_. A _rule_ consists of three parts: the target, its prerequisites, and the command(s) to peform:

```makefile
target: prerequisite1 prerequisite2
target1: prerequisite1 prerequisite2
command1
command2

target2(=prerequisite1): prerequisite3 prerequisite4 prerequisite5
command3

target3(=prerequisite2): prerequisite6 prerequisite7
command4

target4(=prerequisite3): prerequisite8 prerequisite9
command5

target5(=prerequisite4): prerequisite10 prerequisite11
command6
```

The _target_ is the file that must be made. The _prerequisites_ or _dependents_ are those files that must
exist before the target can be successfully created. And _commands_ are those shell commands that will
create the target from the prerequisites.

## A Dependecy Graph
![A Dependency Graph](img/dependency_graph.001.jpeg)
When `make` evaluates a rule, it begins by finding the files indicated by the prerequisites and target.
If any of the prerequisites has an associated rule, `make` attempts to update those first. Next, the target
file is considered. If any prerequisite is newer than the target, the target is remade by executing the
Expand Down
14 changes: 0 additions & 14 deletions doc/some-feature.md

This file was deleted.

0 comments on commit 37859ea

Please sign in to comment.