# Count words script. COUNT_SRC=wordcount.py COUNT_EXE=python $(COUNT_SRC) # Plot word counts script. PLOT_SRC=plotcount.py PLOT_EXE=python $(PLOT_SRC) TXT_FILES=$(wildcard books/*.txt) DAT_FILES=$(patsubst books/%.txt, %.dat, $(TXT_FILES)) PNG_FILES=$(patsubst books/%.txt, %.png, $(TXT_FILES)) ## all : Generate Zipf summary table and plots of word counts. .PHONY : all all : results.txt $(PNG_FILES) ## results.txt : Generate Zipf summary table. results.txt : $(ZIPF_SRC) $(DAT_FILES) $(ZIPF_EXE) $(DAT_FILES) > $@ ## dats : Count words in text files. .PHONY : dats dats : $(DAT_FILES) %.dat : books/%.txt $(COUNT_SRC) $(COUNT_EXE) $< $@ ## pngs : Plot word counts. .PHONY : pngs pngs : $(PNG_FILES) %.png : %.dat $(PLOT_SRC) $(PLOT_EXE) $< $@ ## clean : Remove auto-generated files. .PHONY : clean clean : rm -f $(DAT_FILES) rm -f $(PNG_FILES) rm -f results.txt ## variables : Print variables. .PHONY : variables variables: @echo TXT_FILES: $(TXT_FILES) @echo DAT_FILES: $(DAT_FILES) @echo PNG_FILES: $(PNG_FILES) .PHONY : help help : Makefile @sed -n 's/^##//p' $<