# Makefile for OYSTER external library, please update IDL and GF paths!
# uname=Linux
# Hint: check !make_dll system variable in IDL for CC and LD choices

# IDL/GDL installation directory
# Ubuntu 20.04 64bit
IDL = /home/chummel/oyster/gdl
# Garching cleese
IDL = /usr/local/itt/idl/idl81
# Garching scigar
IDL = /scisoft/share/idl/idl82
# tucana FC35
IDL = /usr/local/exelis/idl84

# If LD = gcc, there are unresolved symbols from FORTRAN objects
# Ubuntu 16.04 64bit
GF = /usr/lib/gcc/x86_64-linux-gnu/9/libgfortran.so
# Ubuntu 20.04 64bit
GF = /usr/lib/gcc/x86_64-redhat-linux/9/libgfortran.so
# Garching cleese
GF = /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.so
# Garching scigar
GF=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgfortran.so
# Fedora 27 64bit
GF = /usr/lib/gcc/x86_64-redhat-linux/7/libgfortran.so
# Fedora 29 64bit
GF = /usr/lib/gcc/x86_64-redhat-linux/8/libgfortran.so
# Fedora 31 64bit
GF = /usr/lib/gcc/x86_64-redhat-linux/9/libgfortran.so
# Fedora 35 64bit
GF = /usr/lib/gcc/x86_64-redhat-linux/11/libgfortran.so

# Do not change anything below this line --------------------------------------

# f2c/g2c library for FORTRAN objects (now handled by GF)
# G2C = /usr/lib/gcc/i386-redhat-linux/3.4.6/libg2c.a # (Fedora 7)
# G2C = /usr/lib/gcc/i586-redhat-linux/4.4.1/libgcc.a # (Fedora 11)
# G2C = /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libg2c.a # (RedHat 9)
# G2C = /usr/lib/gcc/x86_64-redhat-linux/3.4.6/libg2c.so # (64bit Fedora Core 6)
# G2C = /usr/lib/gcc/i486-linux-gnu/4.3/libgcc.a # (ubuntu)

# C compiler
CC = gcc
CCFLAGS = -c -fPIC -I$(IDL)/external

# Link and load a shared library
LD = gcc -shared
#-------------------------------------------------------------------------------

# Set home directories for static libraries
HDS_HOME=../hds
FITSIO_HOME=../cfitsio
NOVAS_HOME=../novas-c201
ROCHE_HOME=../roche
LCDC_HOME=../lcdc2015

# Static libraries
HDS = -L$(HDS_HOME) -lhds
FITSIO = -L$(FITSIO_HOME) -lcfitsio
NOVAS = -L$(NOVAS_HOME) -lnovas
ROCHE= -L$(ROCHE_HOME) -lroche
LCDC= -L$(LCDC_HOME) -llc15

# External library files
OBJECTS = chameleon.o amoeba.o recipes.o nrutil.o pos_prop.o writefits.o \
	  hichol.o siderostat.o cobra.o swap.o keyinc.o hds_.o

# Static libraries include file locations
INCLUDES = -I$(FITSIO_HOME) -I$(NOVAS_HOME) -I$(HDS_HOME)

oyster : ${OBJECTS}
	$(LD) -o $@.so ${OBJECTS} $(FITSIO) $(NOVAS) $(ROCHE) $(HDS) \
	$(LCDC) $(GF)

.c.o:
	$(CC) $(CCFLAGS) $(INCLUDES) $<

clean : 
	rm -f oyster.so ${OBJECTS}
