Commit 2b405a62 authored by Radovan Bast's avatar Radovan Bast
Browse files

we provide the final Makefile

since building a Makefile is not anymore an exercise
the exercise is rather to experiment and discuss the Makefile
parent 5c46d1fb
# Build both steps required for executing the character count example SRCDIR := data
all: processed_data/abyss.dat results/abyss.png results/results.txt TMPDIR := processed_data
RESDIR := results
# Count words (Step 1) SRCS = $(wildcard $(SRCDIR)/*.txt)
processed_data/abyss.dat: data/abyss.txt source/wordcount.py OBJS = $(patsubst $(SRCDIR)/%.txt,$(TMPDIR)/%.dat,$(SRCS))
python source/wordcount.py data/abyss.txt processed_data/abyss.dat OBJS += $(patsubst $(SRCDIR)/%.txt,$(RESDIR)/%.png,$(SRCS))
OBJS += $(RESDIR)/results.txt
DATA = $(patsubst $(SRCDIR)/%.txt,$(TMPDIR)/%.dat,$(SRCS))
# Create Bar chart (Step 2) all: $(OBJS)
results/abyss.png: processed_data/abyss.dat source/plotcount.py
python source/plotcount.py processed_data/abyss.dat results/abyss.png
# Test Zipf's law $(TMPDIR)/%.dat: $(SRCDIR)/%.txt source/wordcount.py
results/results.txt: processed_data/abyss.dat source/zipf_test.py python source/wordcount.py $< $@
python source/zipf_test.py processed_data/abyss.dat > results/results.txt
$(RESDIR)/%.png: $(TMPDIR)/%.dat source/plotcount.py
python source/plotcount.py $< $@
$(RESDIR)/results.txt: $(DATA) source/zipf_test.py
python source/zipf_test.py $(DATA) > $@
clean:
@$(RM) $(TMPDIR)/*
@$(RM) $(RESDIR)/*
.PHONY: clean directories
SRCDIR := data
TMPDIR := processed_data
RESDIR := results
SRCS = $(wildcard $(SRCDIR)/*.txt)
OBJS = $(patsubst $(SRCDIR)/%.txt,$(TMPDIR)/%.dat,$(SRCS))
OBJS += $(patsubst $(SRCDIR)/%.txt,$(RESDIR)/%.png,$(SRCS))
OBJS += $(RESDIR)/results.txt
DATA = $(patsubst $(SRCDIR)/%.txt,$(TMPDIR)/%.dat,$(SRCS))
all: $(OBJS)
$(TMPDIR)/%.dat: $(SRCDIR)/%.txt source/wordcount.py
python source/wordcount.py $< $@
$(RESDIR)/%.png: $(TMPDIR)/%.dat source/plotcount.py
python source/plotcount.py $< $@
$(RESDIR)/results.txt: $(DATA) source/zipf_test.py
python source/zipf_test.py $(DATA) > $@
clean:
@$(RM) $(TMPDIR)/*
@$(RM) $(RESDIR)/*
.PHONY: clean directories
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment