https://github.com/ljdursi/make_pattern_rules
Tutorial for using Makefile pattern rules
https://github.com/ljdursi/make_pattern_rules
makefile tutorial
Last synced: about 2 months ago
JSON representation
Tutorial for using Makefile pattern rules
- Host: GitHub
- URL: https://github.com/ljdursi/make_pattern_rules
- Owner: ljdursi
- Created: 2018-02-21T02:59:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-25T19:28:07.000Z (almost 8 years ago)
- Last Synced: 2025-03-12T16:16:51.345Z (11 months ago)
- Topics: makefile, tutorial
- Language: Makefile
- Size: 27.3 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Programming Make, part I: Pattern Rules
[](https://travis-ci.org/ljdursi/make_pattern_rules)
A short walk-through of pattern rules in Makefile, targetted at
people who have a little scripting experience. Notionally, at this
point we have:
- Introduced a motivating problem (comparing AirBnB prices in two similar-sized cities in different countries, Toronto and Chicago)
- Talked about the reasons for wanting reproducibility/automation and Make in particular
- Gone through the process of translating a bash script into Make in two steps (literally, then breaking out each output-file individually) and seen the advantage of incremental rebuilds; this introduces
- targets
- dependencies
- order dependencies
- SECONDARY: for keeping intermediate targets
- Multi-line commands; each line is run in a different shell
- Added some canonical targets (clean and all) and introduced PHONY
Now we're taking that and introducing pattern rules for DRY - maintainability and extensibility.
The worked example uses python, with seaborn and pandas, although
no python experience is necessary; for our purposes, they are just
command line tools we're running. However, you'll have to make sure
the modules are installed:
```
virtualenv make_pattern
source make_pattern/bin/activate
pip install -r requirements.txt
```
and make sure you have **GNU**, not BSD, Make installed; the precise version shouldn't matter:
```
$ make -v
GNU Make 3.81
...
```