LIFA = $(findstring lifa, $(shell hostname))
CFLAGS += -Wall -O
LDLIBS += -lm -lgc # extra libraries to link
LDFLAGS += $(if $(LIFA), -L/usr/users/fedorov/lib)
GRAPH = graph
CC = gcc --std=c99
#CC = tcc

obj = main.o qspline.o polinterp.o

all: plot.png test1.png

plot.png: points.dat
	$(GRAPH) \
		--width 0.7 --height 0.7 \
		--output-format png \
		--x-label "x" --y-label "y" \
		--top-label "Polynomial vs. Quadratic Spline" \
		$< > $@

points.dat: main
	./$< > $@

main.c: qspline.h

main: $(obj)

test1.png: test1.dat
	$(GRAPH) \
		--width 0.7 --height 0.7 \
		--output-format png \
		--x-label "x" --y-label "y" \
		--top-label "test1" \
		$< > $@
test1.dat: test1 ; ./$< > $@
test1: test1.o linterp.o cspline.o qspline.o

clean1:
	rm -f test1.png test1 test1.o linterp.o cspline.o

clean: clean1
	rm -f $(obj) main *.png *.dat

