CC	= gcc
CFLAGS	= -g

INCLUDE = -I. -I $(ROOT)/include -I $(HOME)/include

NEWTON  = .

all : build archive

build: $(NEWTON)/FunCstr.o $(NEWTON)/FunTree.o $(NEWTON)/FiaInterval.o

$(NEWTON)/FunCstr.o: $(NEWTON)/FiaMath.h $(NEWTON)/FiaInterval.h $(NEWTON)/FiaInterval.c \
$(NEWTON)/FunTree.h $(NEWTON)/FunTree.c $(NEWTON)/FunCstr.h $(NEWTON)/FunCstr.c
	$(CC) $(CFLAGS) $(INCLUDE) -c $(NEWTON)/FunCstr.c -o $(NEWTON)/FunCstr.o

$(NEWTON)/FunTree.o: $(NEWTON)/FiaMath.h $(NEWTON)/FiaInterval.h $(NEWTON)/FiaInterval.c \
$(NEWTON)/FunTree.h $(NEWTON)/FunTree.c
	$(CC) $(CFLAGS) $(INCLUDE) -c $(NEWTON)/FunTree.c -o $(NEWTON)/FunTree.o


$(NEWTON)/FiaInterval.o: $(NEWTON)/FiaMath.h $(NEWTON)/FiaInterval.h
	$(CC) $(CFLAGS) $(INCLUDE) -c $(NEWTON)/FiaInterval.c -o $(NEWTON)/FiaInterval.o

archive:
	ar r libnewt.a $(NEWTON)/FunCstr.o $(NEWTON)/FunTree.o $(NEWTON)/FiaInterval.o;\
	if [ ! -d $(ROOT)/include/newton ]; then\
	  mkdir $(ROOT)/include/newton;\
	fi;\
	cp *.h $(ROOT)/include/newton;\
	cp libnewt.a $(ROOT)/lib

clean:
	rm -f *.o *.a core
