SHELL = /bin/sh
CC = gcc
CFLAGS = -O3 -m32 -g -L./lib
INCLUDE = -I./include -I/usr/include
AR = ar
ARCHIVES = lib/libmvcd.a lib/libmatrixSHEN.a lib/libadaptivebrain.a
LIBS =  -lmvcd -lmatrixSHEN -ladaptivebrain -lm

EXEC = bin/resample bin/cortexgmlabelcorrection bin/nucleus bin/comparevectorfields bin/cropslices bin/performdeformationusingvectorfield bin/splitfile bin/transform3dvectorfield bin/transform3dimg bin/fslmat2mymat bin/rigidtransform bin/ravens bin/nucleus3 bin/changelinevalueinimg bin/extractventricle bin/3dregiongrowing bin/maskout3dimg bin/stack2edgemap bin/makeavwheader bin/printavwheader bin/closingholesinbinaryimg bin/imageinfo bin/usimageinfo bin/twoimgop bin/ustwoimgop bin/ftwoimgop bin/avimgvol


src/%.o: src/%.c
	$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@

all : $(ARCHIVES) $(EXEC)

lib/libmvcd.a :  src/mvcd.o
	ar -rv $@ $^
	ranlib $@

lib/libmatrixSHEN.a :  src/matrixSHEN.o
	ar -rv $@ $^
	ranlib $@

lib/libadaptivebrain.a :  src/adaptivebrain.o
	ar -rv $@ $^
	ranlib $@

bin/resample : src/resample.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 

bin/cortexgmlabelcorrection : src/cortexgmlabelcorrection.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 

bin/nucleus : src/nucleus.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 

bin/comparevectorfields : src/comparevectorfields.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 	

bin/cropslices : src/cropslices.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 
	
bin/performdeformationusingvectorfield : src/performdeformationusingvectorfield.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 	

bin/splitfile : src/splitfile.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 
	
bin/transform3dvectorfield : src/transform3dvectorfield.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 

bin/transform3dimg : src/transform3dimg.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 	

bin/fslmat2mymat : src/fslmat2mymat.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 	
	
bin/rigidtransform : src/rigidtransform.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 	

bin/ravens : src/ravens.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 	
	
bin/nucleus3 : src/nucleus3.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 	

bin/changelinevalueinimg : src/changelinevalueinimg.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 

bin/extractventricle : src/extractventricle.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 
	
bin/makeavwheader : src/makeavwheader.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 

bin/printavwheader : src/printavwheader.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 

bin/3dregiongrowing : src/3dregiongrowing.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 

bin/maskout3dimg : src/maskout3dimg.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS)

bin/stack2edgemap : src/stack2edgemap.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS) 

bin/closingholesinbinaryimg : src/closingholesinbinaryimg.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS)

bin/imageinfo : src/imageinfo.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS)

bin/usimageinfo : src/usimageinfo.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS)

bin/twoimgop : src/twoimgop.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS)

bin/ustwoimgop : src/ustwoimgop.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS)

bin/ftwoimgop : src/ftwoimgop.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS)

bin/avimgvol: src/avimgvol.o
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS)

clean :
	rm -rf src/*~ src/*.o $(EXEC)

clobber :
	rm -rf src/*~ src/*.o $(EXEC) $(ARCHIVES)
