bits=64
srcdir=$(CURDIR)/source
tmpdir=$(CURDIR)/temp
compdir=C:/Program Files (x86)/Intel/Compiler/11.1/067
vcdir=C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC
ifort_64="$(compdir)/bin/intel64/ifort.exe"
link_64="$(vcdir)/bin/amd64/link.exe"
ifort_flags=/c /heap-arrays0 /I"$(compdir)/mkl/include/fftw" /Qmkl:parallel /object:$(tmpdir)/
link_flags=/DLL /SUBSYSTEM:console /MAP:$(tmpdir)/helloworld.map /def:$(tmpdir)/helloworldmodule.def
link_out="/out:helloworld.pyd"
link_paths_32=/libpath:"$(compdir)/lib/ia32" /libpath:"$(vcdir)/lib" /libpath:"$(vcdir)/platformsdk/lib"
link_paths_64=/libpath:"$(compdir)/lib/intel64" /libpath:"$(compdir)/mkl/em64t/lib" /libpath:"$(vcdir)/lib/amd64" /libpath:"$(vcdir)/platformsdk/lib/x64"
cc="c:/mingw_64/bin/x86_64-w64-mingw32-gcc.exe"
cc_flags=-g -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DUPPERCASE_FORTRAN -DNO_APPEND_FORTRAN -DF2PY_REPORT_ON_ARRAY_COPY=1
cc_include=-IC:/Python27/lib/site-packages/numpy/core/include -IC:/Python27/include -IC:/Python27/PCBuild -I$(srcdir)
LIBPYTHON=C:/Python27/libs/Python27.lib
DLLTOOLexe=c:/python27/scripts/dlltool.exe
SEDexe=c:/cygwin/bin/sed.exe
PYTHONexe=c:/Python27/python.exe
F2PYexe=c:/Python27/Scripts/f2py.exe
ifeq ($(bits),64)
ifort=$(ifort_64)
link=$(link_64)
link_paths=$(link_paths_64)
else
ifort=$(ifort_32)
link=$(link_32)
link_paths=$(link_paths_32)
endif
#Targets
all: helloworld.pyd
helloworld.pyd: helloworldmodule.o fortranobject.o helloworldmodule.def f90objs
$(link) $(link_flags) $(link_paths) $(tmpdir)/*.obj $(tmpdir)/*.o $(LIBPYTHON) $(link_out)
$(PYTHONexe) rename_mkl.py helloworld.pyd
helloworldmodule.o: helloworldmodule.c
# #$(cc) $(cc_flags) $(cc_include) -c $(tmpdir)/helloworldmodule.c -o $(tmpdir)/helloworldmodule.o
cd $(tmpdir) && $(cc) $(cc_flags) $(cc_include) -c helloworldmodule.c -o helloworldmodule.o
helloworldmodule.c: $(srcdir)/helloworld.f90
$(F2PYexe) -m helloworld --build-dir $(tmpdir) $(srcdir)/helloworld.f90
fortranobject.o: $(srcdir)/fortranobject.c
$(cc) $(cc_flags) $(cc_include) -c $(srcdir)/fortranobject.c -o $(tmpdir)/fortranobject.o
helloworldmodule.def: helloworldmodule.o
$(DLLTOOLexe) -v -z $(tmpdir)/helloworldmodule.def $(tmpdir)/helloworldmodule.o
$(SEDexe) -i"bak" "s/\"//g" $(tmpdir)/helloworldmodule.def
f90objs: $(wildcard $(tmpdir)/*.f90) $(wildcard $(srcdir)/*.f90)
$(ifort) $(ifort_flags) $(srcdir)/*.f90 $(tmpdir)/*.f90
clean:
rm -f *.pyd
rm -f $(tmpdir)/*.*