Makefile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. PYTHON=`which python`
  2. PYTHON3=`which python3`
  3. CYTHON=`which cython`
  4. DESTDIR=/
  5. PROJECT=python-scattnlay
  6. VERSION=2.2 # compare with nmie.hpp and setup.py
  7. BUILDIR=$(CURDIR)/debian/$(PROJECT)
  8. SRCDIR=$(CURDIR)/src
  9. MULTIPREC=100
  10. all:
  11. @echo "make source - Create source package for Python extension"
  12. @echo "make cython - Convert Cython code to C++"
  13. @echo "make python_ext - Create Python extension using C++ code"
  14. @echo "make cython_ext - Create Python extension using Cython code"
  15. @echo "make python3_ext - Create Python3 extension using C++ code"
  16. @echo "make cython3_ext - Create Python3 extension using Cython code"
  17. @echo "make install - Install Python extension on local system"
  18. @echo "make buildrpm - Generate a rpm package for Python extension"
  19. @echo "make builddeb - Generate a deb package for Python extension"
  20. @echo "make standalone - Create standalone programs (scattnlay and fieldnlay)"
  21. @echo "make clean - Delete temporal files"
  22. # make standalone
  23. source:
  24. $(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../
  25. cython: scattnlay.pyx
  26. # create c++ code for double precision module
  27. $(CYTHON) --cplus scattnlay.pyx -o $(SRCDIR)/scattnlay.cpp
  28. # create c++ code for MP module
  29. ln -s scattnlay.pyx scattnlay_mp.pyx
  30. $(CYTHON) --cplus scattnlay_mp.pyx -o $(SRCDIR)/scattnlay_mp.cpp
  31. rm scattnlay_mp.pyx
  32. python_ext: $(SRCDIR)/nmie.cc $(SRCDIR)/py_nmie.cc $(SRCDIR)/scattnlay.cpp $(SRCDIR)/scattnlay_mp.cpp
  33. $(PYTHON) setup.py build_ext --inplace
  34. cython_ext: cython python_ext
  35. python3_ext: $(SRCDIR)/nmie.cc $(SRCDIR)/py_nmie.cc $(SRCDIR)/scattnlay.cpp $(SRCDIR)/scattnlay_mp.cpp
  36. $(PYTHON3) setup.py build_ext --inplace
  37. cython3_ext: cython python3_ext
  38. install:
  39. $(PYTHON) setup.py install --root $(DESTDIR) $(COMPILE)
  40. buildrpm:
  41. #$(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall
  42. $(PYTHON) setup.py bdist_rpm --dist-dir=../
  43. builddeb:
  44. # build the source package in the parent directory
  45. # then rename it to project_version.orig.tar.gz
  46. $(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../ --prune
  47. rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../*
  48. # build the package
  49. dpkg-buildpackage -i -I -rfakeroot
  50. standalone: $(SRCDIR)/farfield.cc $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc
  51. # create standalone programs with DP
  52. c++ -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc -lm -o ../scattnlay
  53. c++ -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc -lm -o ../fieldnlay
  54. # create standalone programs with MP
  55. c++ -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc -lm -o ../scattnlay-mp
  56. c++ -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc -lm -o ../fieldnlay-mp
  57. clean:
  58. $(PYTHON) setup.py clean
  59. $(MAKE) -f $(CURDIR)/debian/rules clean
  60. rm -rf build/ MANIFEST
  61. find . -name '*.pyc' -delete
  62. find . -name '*.o' -delete
  63. find . -name '*.so' -delete