1.  
  2. bits=64
  3.  
  4. srcdir=$(CURDIR)/source
  5. tmpdir=$(CURDIR)/temp
  6.  
  7. compdir=C:/Program Files (x86)/Intel/Compiler/11.1/067
  8. vcdir=C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC
  9.  
  10. ifort_64="$(compdir)/bin/intel64/ifort.exe"
  11. link_64="$(vcdir)/bin/amd64/link.exe"
  12.  
  13. ifort_flags=/c /heap-arrays0 /I"$(compdir)/mkl/include/fftw" /Qmkl:parallel /object:$(tmpdir)/
  14.  
  15. link_flags=/DLL /SUBSYSTEM:console /MAP:$(tmpdir)/helloworld.map /def:$(tmpdir)/helloworldmodule.def
  16. link_out="/out:helloworld.pyd"
  17.  
  18. link_paths_32=/libpath:"$(compdir)/lib/ia32" /libpath:"$(vcdir)/lib" /libpath:"$(vcdir)/platformsdk/lib"
  19. link_paths_64=/libpath:"$(compdir)/lib/intel64"  /libpath:"$(compdir)/mkl/em64t/lib" /libpath:"$(vcdir)/lib/amd64" /libpath:"$(vcdir)/platformsdk/lib/x64"
  20.  
  21. cc="c:/mingw_64/bin/x86_64-w64-mingw32-gcc.exe"
  22. cc_flags=-g -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DUPPERCASE_FORTRAN -DNO_APPEND_FORTRAN -DF2PY_REPORT_ON_ARRAY_COPY=1
  23. cc_include=-IC:/Python27/lib/site-packages/numpy/core/include -IC:/Python27/include -IC:/Python27/PCBuild -I$(srcdir)
  24.  
  25. LIBPYTHON=C:/Python27/libs/Python27.lib
  26.  
  27. DLLTOOLexe=c:/python27/scripts/dlltool.exe
  28. SEDexe=c:/cygwin/bin/sed.exe
  29. PYTHONexe=c:/Python27/python.exe
  30. F2PYexe=c:/Python27/Scripts/f2py.exe
  31.  
  32. ifeq ($(bits),64)
  33.     ifort=$(ifort_64)
  34.     link=$(link_64)
  35.     link_paths=$(link_paths_64)
  36. else
  37.     ifort=$(ifort_32)
  38.     link=$(link_32)
  39.     link_paths=$(link_paths_32)
  40. endif
  41.  
  42. #Targets
  43.  
  44. all: helloworld.pyd
  45.  
  46. helloworld.pyd: helloworldmodule.o fortranobject.o helloworldmodule.def f90objs
  47.     $(link) $(link_flags) $(link_paths) $(tmpdir)/*.obj $(tmpdir)/*.o $(LIBPYTHON) $(link_out)
  48.     $(PYTHONexe) rename_mkl.py helloworld.pyd
  49.  
  50. helloworldmodule.o: helloworldmodule.c
  51. #   #$(cc) $(cc_flags) $(cc_include) -c $(tmpdir)/helloworldmodule.c -o $(tmpdir)/helloworldmodule.o
  52.     cd $(tmpdir) && $(cc) $(cc_flags) $(cc_include) -c helloworldmodule.c -o helloworldmodule.o
  53.  
  54. helloworldmodule.c: $(srcdir)/helloworld.f90
  55.     $(F2PYexe) -m helloworld --build-dir $(tmpdir) $(srcdir)/helloworld.f90
  56.  
  57. fortranobject.o: $(srcdir)/fortranobject.c
  58.     $(cc) $(cc_flags) $(cc_include) -c $(srcdir)/fortranobject.c -o $(tmpdir)/fortranobject.o
  59.  
  60. helloworldmodule.def: helloworldmodule.o
  61.     $(DLLTOOLexe) -v -z $(tmpdir)/helloworldmodule.def $(tmpdir)/helloworldmodule.o
  62.     $(SEDexe) -i"bak" "s/\"//g" $(tmpdir)/helloworldmodule.def
  63.    
  64. f90objs: $(wildcard $(tmpdir)/*.f90) $(wildcard $(srcdir)/*.f90)
  65.     $(ifort) $(ifort_flags) $(srcdir)/*.f90 $(tmpdir)/*.f90
  66.  
  67. clean:
  68.     rm -f *.pyd
  69.     rm -f $(tmpdir)/*.*