
# To compile the C and Fortran examples in this directory, just type 'make'.

# NOTE: fortran$(DLL) requires GNU Fortran to build.
examples = poor$(EXE) sort$(DLL) fortran$(DLL)

EXE=
DLL=.so
CC = gcc
FC = gfortran
host = x86_64-redhat-linux-gnu
shared = -shared

# OSX
ifneq "$(findstring -darwin,$(host))" ""
shared = -dynamiclib
endif

# 64 bit, needs -fPIC flag
ifneq "$(findstring x86_64-,$(host))" ""
PIC = -fPIC
endif

all: $(examples)

poor$(EXE): poor.c
	$(CC) -o $@ $^ -lpure

sort$(DLL): sort.c
	$(CC) $(shared) $(PIC) -o $@ $^ -lpure

# GNU Fortran example.

fortran$(DLL): fortran.f90
	$(FC) $(shared) $(PIC) -o $@ $^

clean:
	rm -f $(examples) *.o *~
