	#assumes existence of environment variable $MYLIBS which points to a user writable folder that is also included in the $LD_LIBRARY_PATH	
	#example for Ale: export MYLIBS="~apauly/mylibs"

	# use "gcc" to compile source files.
	CC = @g++ -c
	# the linker is also "gcc". It might be something else with other compilers.
	LD = @g++
	# Compiler flags go here.
	CFLAGS = -ggdb -fpic -Wall
	#locations maybe not in path to include
	INCLUDE = -I ../vector
	# Linker flags go here. 
	LDFLAGS =
	# use this command to erase files.
	RM = @/bin/rm -f
	#sources
	SRCSEXC = divisionbyzeroexception.cpp zerodenominatorexception.cpp
	SRCSINT = integer.cpp integerImpl.cpp
	SRCSRAT = rational.cpp rationalImpl.cpp
	SRCS = $(SRCSEXC) $(SRCSINT) $(SRCSRAT)
	# list of generated object files.
	OBJSEXC = divisionbyzeroexception.o zerodenominatorexception.o
	OBJSINT = integer.o integerImpl.o
	OBJSRAT = rational.o  rationalImpl.o
	OBJS = $(OBJSEXC) $(OBJSINT) $(OBJSRAT)
	# program executable file name.
	PROGINT = runint.out
	PROGRAT = runrat.out
	LIBNUM	= libnum.a
	LIBNUMS	= libnums.so
	LIBNUMSMAC = libnums.dylib
	ARCHIVE = @ar cru
	INDEX	= @ranlib
	CP = @cp
	
integer:
	@echo "Compiling..."
	$(CC) $(CFLAGS) $(INCLUDE) $(SRCSEXC) $(SRCSINT) intTest.cpp
	@echo "Linking into $(PROGINT)..."
	$(LD) -o $(PROGINT) $(OBJSEXC) $(OBJSINT) intTest.o
	@echo "Done, now you can execute $(PROGINT)"

rational:
	@echo "Compiling..."
	$(CC) $(CFLAGS) $(INCLUDE) $(SRCSEXC) $(SRCSINT) $(SRCSRAT) ratTest.cpp
	@echo "Linking into $(PROGRAT)..."
	$(LD) -o $(PROGRAT) $(OBJSEXC) $(OBJSINT) $(OBJSRAT) ratTest.o
	@echo "Done, now you can execute $(PROGRAT)"
	
lib:
	@echo .
	@echo "Use 'make libs' to build shared library."
	@echo .
#$(CC) $(CFLAGS) $(INCLUDE) $(SRCSEXC) $(SRCSINT) $(SRCSRAT)
#$(ARCHIVE) $(LIBNUM) $(OBJS)
#$(INDEX) $(LIBNUM)	

libs:
	@echo "Compiling..."
	$(CC) $(CFLAGS) $(INCLUDE) $(SRCSEXC) $(SRCSINT) $(SRCSRAT)
	@echo "Linking into shared library..."
	$(LD) -shared -o $(LIBNUMS)  $(OBJSEXC) $(OBJSINT) $(OBJSRAT)
	@echo "Copying library into $(MYLIBS)"
	$(CP) $(LIBNUMS) $(MYLIBS)
	@echo "Done."

maclibs:
	@echo "Compiling..."
	$(CC) $(CFLAGS) $(INCLUDE) $(SRCSEXC) $(SRCSINT) $(SRCSRAT)
	@echo "Linking into shared library..."
	$(LD) -dynamiclib -o $(LIBNUMSMAC)  $(OBJSEXC) $(OBJSINT) $(OBJSRAT)
	@echo "Copying library into $(MYLIBS)"
	$(CP) $(LIBNUMSMAC) $(MYLIBS)
	@echo "Done."
	
clean:	
	@echo "Removing files..."
	-rm *.o
	-rm *.out
	-rm *.so
	-rm *.a
	@echo "Done."
