SHELL=/bin/sh

# makefile for PHAGEN program and module
#
# the PHAGEN source code is not included in the public distribution.
# please obtain the PHAGEN code from the original author,
# and copy it to this directory before compilation.
#
# see the top-level makefile for additional information.

.SUFFIXES:
.SUFFIXES: .c .cpp .cxx .exe .f .h .i .o .py .pyf .so
.PHONY: all clean phagen

FC?=gfortran
F2PY?=f2py
F2PYOPTS?=
CC?=gcc
CCOPTS?=
SWIG?=swig
SWIGOPTS?=
PYTHON?=python
PYTHONOPTS?=
PYTHONINC?=
PYTHON_CONFIG = ${PYTHON}-config
PYTHON_CFLAGS ?= $(shell ${PYTHON_CONFIG} --cflags)
PYTHON_EXT_SUFFIX ?= $(shell ${PYTHON_CONFIG} --extension-suffix)

all: phagen

phagen: phagen.exe phagen$(PYTHON_EXT_SUFFIX)

phagen.exe: phagen_scf.f msxas3.inc msxasc3.inc
	$(FC) $(FCOPTS) -o phagen.exe phagen_scf.f

phagen.pyf: | phagen_scf.f
	$(F2PY) -h phagen.pyf -m phagen phagen_scf.f only: libmain

phagen$(PYTHON_EXT_SUFFIX): phagen_scf.f phagen.pyf msxas3.inc msxasc3.inc
	$(F2PY) -c $(F2PYOPTS) -m phagen phagen.pyf phagen_scf.f

clean:
	rm -f *.so *.o *.exe
