#	for the gnu fortran compiler
#	uncomment the following two lines
FC = g77
OPT = -fno-second-underscore -w -O2

#	for the portland group compiler
#	uncomment the following two lines
#FC = pgf77
#OPT = -fastsse


# -----------------------------------------------
# choose the correct architecture for you system
ARCH := $(shell uname -i)
ARCH32 = i386
ARCH64 = x86_64
ifeq ($(ARCH),$(ARCH64))
  $(shell cp -f lib/include_64.inc lib/include.inc )
else
  $(shell cp -f lib/include_32.inc lib/include.inc )
endif


MAIN = LANLstar_GEO

all: LANLstar_GEO.so LANLstar_GEO.a example



LANLstar_GEO.so: lib/*.o lib/libtemp.a
	$(FC) $(OPT) -o $(MAIN).so lib/$(MAIN).o -Llib/. -ltemp -shared

# static library
LANLstar_GEO.a: lib/*.o
	ar -r $(MAIN).a lib/*.o
	ranlib $(MAIN).a


lib/libtemp.a: lib/*.o
	ar -r libtemp.a lib/Lmax*.o lib/Lstar*.o lib/ffnet.o
	ranlib libtemp.a
	mv libtemp.a lib/


lib/*.o: lib/*.f
	$(FC) $(OPT) -c lib/*.f -fPIC
	mv *.o lib/



example: example.f
	$(FC) $(OPT) example.f $(MAIN).a -o example

clean:
	rm -f $(MAIN).o lib/*.o example.o lib/libtemp.a /lib/include.inc

cleanall: 
	rm -f  $(MAIN).o lib/*.o example.o lib/libtemp.a /lib/include.inc *.so *.a example


.PHONY: clean







