# $Id: Makefile 199 2011-07-07 18:14:33Z townsend $

# Variables

TARGETS=texmex_pulse

# Flags

#OMP=yes
#MPI=yes
DOUBLE_PRECISION=yes
#DEBUG=yes
DEBUG_NOTRAP=yes
HDF5=yes

LDFLAGS=`mesasdk_hdf5_link` `mesasdk_lapack95_link`

# Include other makefiles

SUBDIRS=core:base:astro

include ../Make.inc

# Add c interoperability of texmex_pulse

C_COMPILER=/usr/bin/gcc
C_FLAGS=-O3 -std=c99
CF_FLAGS=-lgfortran

F_COMPILER=${MESASDK_ROOT}/bin/gfortran

OBJS := texmex_c.o texmex_py.o core_kinds.o core_constants.o core_hgroup.o texmex_map.o texmex_map_set.o texmex_mode.o texmex_hough.o texmex_legendre.o texmex_hough_matrix.o

c_interop: texmex_c.so

texmex_c.so: $(OBJS)	
	$(C_COMPILER) -fPIC -std=c99 -shared -L${MESASDK_ROOT}/lib $(C_FLAGS) -o $@ $(OBJS) $(CF_FLAGS) ${LDFLAGS} -lpython2.7 -lm -lhdf5 -lz -lc -fPIC -DUNIX

%_c.o: %_c.c
	$(C_COMPILER) -fPIC -std=c99 -I/. -I${MESASDK_ROOT}/include -I/usr/lib64/python2.7/site-packages/numpy/core/include/ -c $*_c.c

%_py.o: %_py.f90
	$(F_COMPILER) -fPIC -I/. -I${MESASDK_ROOT}/include -c $*_py.f90

py_clean:
	rm -rf *_py.o *_c.o texmex_c
