GCC = gcc 
CFLAGS = -Wall -O3 -g 
LINK = -lm -lpthread
MEMWATCH = #-DMEMWATCH -DMW_STDIO
DEFINES = -DTHREADS -D_XOPEN_SOURCE=500
REDUCE_DIR = src/reduce.3.10.070818
REDUCE_SRC_DIR = src/reduce.3.10.070818/reduce_src

INCLUDE = -Isrc/common  -Isrc/memwatch  -Isrc/phipsi  -Isrc/get_angles 
COMMON = src/common/pdbfile.c src/common/util.c src/common/vec3D.c src/common/main.c 

all: phipsi reduce get_angles

clean: cleanO
	rm  phipsi reduce get_angles

cleanO:
	find . -name "*.o" | xargs rm -f
	rm -f src/reduce.3.10.070818/toolclasses/libtoolclasses.a src/reduce.3.10.070818/libpdb/libpdb++.a
# These .a files may cause reduce compilation to fail if they were compiled on a different system.

# The library needs to be placed after the files that use it. SO place "-lm" on after .c/.cpp files
 phipsi: src/phipsi/phipsi.c $(COMMON) src/common/*.h src/phipsi/phipsi.h
	$(GCC) $(CFLAGS) $(LINK) $(INCLUDE) -DPHIPSI src/phipsi/phipsi.c $(COMMON) -lm -o phipsi

reduce:
	$(MAKE) -C $(REDUCE_DIR)
	mv $(REDUCE_SRC_DIR)/reduce .
	cp $(REDUCE_DIR)/reduce_wwPDB_het_dict.txt .

get_angles: src/phipsi/phipsi.c $(COMMON) src/common/*.h src/phipsi/phipsi.h src/get_angles/get_angles.c src/get_angles/get_angles.h 
	$(GCC) $(CFLAGS) $(LINK) $(INCLUDE) -DGET_ANGLES src/get_angles/get_angles.c src/phipsi/phipsi.c $(COMMON) -lm -o get_angles

