targetdir = ~/public_html/Courses/P2200_16F/downloads CC = clang LDFLAGS = -O2 CFLAGS = -Weverything -Wextra -pedantic $(LDFLAGS) LDLIBS = $(shell gsl-config --libs) INDENT = astyle --style=allman --add-brackets GNUPLOT = gnuplot PDFVIEWER = evince LATEX = pdflatex EDITOR = /usr/bin/emacs -fn 9x15 -g 90x30+100+40 .SUFFIXES: .SUFFIXES: .c .o .h .res .gp .PHONY: clean veryclean indent pdf target = lotka-volterra latexfile = $(target) sources = $(target).c objects = $(sources:.c=.o) result = $(target).res pdf = $(target).pdf figs = $(target)-fig1.pdf $(target)-fig2.pdf ## help : Default action is to show what commands are available. help: Makefile @sed -n 's/^##//p' $< ## lotka-volterra: Compile and link the executable $(target) : $(objects) $(CC) $(LDFLAGS) $(objects) -o $@ $(LDLIBS) ## res : Run the calculations res: $(result) $(result): $(target) ./$(target) > $(target).res ## pdf : Run pdflatex, bibtex, and mkindex necessary many times ## to generate the pdf document pdf: $(pdf) $(pdf): $(latexfile).tex while ($(LATEX) $(latexfile) ; \ grep -q "Rerun to get cross" $(latexfile).log ) do true ; \ done ## edit : Open the latex file in the editor edit : $(latexfile).tex $(EDITOR) $(latexfile).tex 2> /dev/null & ## figs : Graph the results figs: $(figs) $(figs): $(result) $(target).gp $(GNUPLOT) $(target).gp ## view : Open the graph in a pdf viewer view: $(pdf) $(PDFVIEWER) $(pdf) 2> /dev/null & ## figview : Open the graph in a pdf viewer figview: $(figs) $(PDFVIEWER) $(figs) 2> /dev/null & ## indent : Indent the source code indent: $(INDENT) $(sources) ## clean : Remove the auto-generated files clean : rm -f *.o rm -f *.*~ rm -f *.*.orig rm -f $(target) rm -f $(target).log rm -f $(target).out rm -f $(latexfile).aux ## veryclean : Remove the auto-generated files, ## the tests results, and the graph veryclean : clean rm -f $(pdf) $(figs) $(result) ## upload : Upload the pdf and clean the auto-generated files upload: pdf clean chmod go+r $(pdf) mv $(pdf) $(targetdir) ## settings : Show variables and settings. settings: @echo ' ' @echo 'latexfile :' $(latexfile) @echo 'sources :' $(sources) @echo 'objects :' $(objects) @echo 'target :' $(target) @echo 'result :' $(result) @echo 'pdf :' $(pdf) @echo 'figs :' $(figs) @echo ' ' @echo 'INDENT :' $(INDENT) @echo 'GNUPLOT :' $(GNUPLOT) @echo ' ' @echo 'CC :' $(CC) @echo 'LDFLAGS :' $(LDFLAGS) @echo 'CFLAGS :' $(CFLAGS) @echo 'LDLIBS :' $(LDLIBS) @echo ' '