SHELL=/bin/sh

# makefile for EDAC program and module
#
# the EDAC source code is not included in the public distribution.
# please obtain it from the original author,
# copy it to this directory,
# and apply the edac_all.patch patch 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 edac

FC?=gfortran
FCCOPTS?=
F2PY?=f2py
F2PYOPTS?=
CXX?=g++
CXXOPTS?=-Wno-write-strings
PYTHON?=python
PYTHONOPTS?=

all: edac

edac: edac.exe _edac.so edac.py

edac.exe: edac_all.cpp
	$(CXX) $(CXXOPTS) -o edac.exe edac_all.cpp

edac.py _edac.so: edac_all.cpp edac_all.i setup.py	
	$(PYTHON) $(PYTHONOPTS) setup.py build_ext --inplace

revision.py: _edac.so
	git log --pretty=format:"code_rev = 'Code revision %h, %ad'" --date=iso -1 > $@ || echo "code_rev = 'Code revision unknown, "`date +"%F %T %z"`"'" > $@
	echo "" >> revision.py

revision.txt: _edac.so	edac.exe
	git log --pretty=format:"Code revision %h, %ad" --date=iso -1 > $@ || echo "Code revision unknown, "`date +"%F %T %z"` > $@
	echo "" >> revision.txt

clean:
	rm -f *.so *.o *.exe *.pyc
	rm -f edac.py edac_all_wrap.*
	rm -f revision.*

