CPP		=g++
CC		=gcc
CFLAGS		=-s
OBJS		=src/write_mpi.o src/convert.o src/display.o src/main.o

# If you are using GMP, set this to the directory that "gmp.h" is in
GMP_INCLUDE	=-I$(HOME)/vol/lib/gmp-2.0.2

# If you are using GMP, either set this to libgmp.a or have your
# environment set properly so gcc knows where libgmp.a is
GMP_LIB		=-lgmp				# libgmp.a is in LIBPATH
#GMP_LIB	=$(HOME)/vol/lib/gmp-2.0.2/libgmp.a


##################################################################
default:
	make plain
help options:
	@echo "Usage:  make [target]"
	@echo "For [target] choose one of:"
	@echo "    hex   -- will always work"
	@echo "    plain -- will always work (recommended)"
	@echo "    gmp   -- needs gmp library, see README"
	@echo "    class -- use abstract Integer class, see README"
	@echo
	@echo "    clean -- cleans up the mess"

plain: clean_mpi
	@make CC=$(CC) CFLAGS=$(CFLAGS) DEFINE=-DMPI_NO_HEX \
	    INCLUDE=$(INCLUDE) src/write_mpi.o
	@make LCC=$(CC) pgpview

hex: clean_mpi
	@make CC=$(CC) CFLAGS=$(CFLAGS) DEFINE=-DMPI_USE_HEX \
	    INCLUDE=$(INCLUDE) src/write_mpi.o
	@make LCC=$(CC) pgpview

gmp: clean_mpi
	@make CC=$(CC) CFLAGS=$(CFLAGS) DEFINE=-DMPI_USE_GMP \
	    INCLUDE=$(GMP_INCLUDE) src/write_mpi.o
	@make LCC=$(CC) LIBS=$(GMP_LIB) pgpview

class: clean_mpi
	@make CC=$(CPP) CFLAGS=$(CFLAGS) DEFINE=-DMPI_USE_CLASS \
	    INCLUDE=$(GMP_INCLUDE) src/write_mpi.o
	@make LCC=$(CPP) LIBS=$(GMP_LIB) pgpview

################################################

.c.o:
	$(CC) $(CFLAGS) $(DEFINE) $(INCLUDE) -c $< -o $@
.cc.o:
	$(CPP) $(CFLAGS) $(DEFINE) $(INCLUDE) -c $< -o $@

pgpview: $(OBJS)
	$(LCC) $(CFLAGS) -o$@ $(OBJS) $(LIBS)

clean: clean.o
	rm -f core pgpview
clean.o:
	rm -f $(OBJS)

clean_mpi:
	@rm -f src/write_mpi.o
