Makefile 2.5 KB

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