Makefile 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. PYTHON=`which python`
  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 python_ext_mp - Create miltiprecision Python extension using C++ code"
  14. @echo "make cython_ext - Create Python extension using Cython code"
  15. @echo "make install - Install Python extension on local system"
  16. @echo "make buildrpm - Generate a rpm package for Python extension"
  17. @echo "make builddeb - Generate a deb package for Python extension"
  18. @echo "make builddebmp - Generate a deb package for Python extension with multiprecision"
  19. @echo "make standalone - Create standalone programs (scattnlay and fieldnlay)"
  20. @echo "make standalonemp - Create standalone programs (scattnlay and fieldnlay) with multiprecision"
  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. $(CYTHON) --cplus scattnlay.pyx
  27. mv scattnlay.cpp $(SRCDIR)/
  28. python_ext: $(SRCDIR)/nmie.cc $(SRCDIR)/py_nmie.cc $(SRCDIR)/scattnlay.cpp
  29. export CFLAGS='-std=c++11' && $(PYTHON) setup.py build_ext --inplace
  30. python_ext_mp: $(SRCDIR)/nmie.cc $(SRCDIR)/py_nmie.cc $(SRCDIR)/scattnlay.cpp
  31. export CFLAGS='-std=c++11 -DMULTI_PRECISION=$(MULTIPREC)' && $(PYTHON) setup-mp.py build_ext --inplace
  32. cython_ext: $(SRCDIR)/nmie.cc $(SRCDIR)/py_nmie.cc scattnlay.pyx
  33. export CFLAGS='-std=c++11' && $(PYTHON) setup.py build_ext --inplace
  34. install:
  35. $(PYTHON) setup.py install --root $(DESTDIR) $(COMPILE)
  36. buildrpm:
  37. #$(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall
  38. $(PYTHON) setup.py bdist_rpm --dist-dir=../
  39. builddeb:
  40. # build the source package in the parent directory
  41. # then rename it to project_version.orig.tar.gz
  42. $(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../ --prune
  43. rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../*
  44. # build the package
  45. export CFLAGS='-std=c++11' && dpkg-buildpackage -i -I -rfakeroot
  46. #builddebmp:
  47. # build the source package in the parent directory
  48. # then rename it to project_version.orig.tar.gz
  49. # $(PYTHON) setup-mp.py sdist $(COMPILE) --dist-dir=../ --prune
  50. # rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../*
  51. # build the package
  52. # export CFLAGS='-std=c++11 -DMULTI_PRECISION=$(MULTIPREC)' && dpkg-buildpackage -i -I -rfakeroot
  53. standalone: $(SRCDIR)/farfield.cc $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc
  54. export CFLAGS='-std=c++11' && c++ -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc -lm -o scattnlay
  55. mv scattnlay ../
  56. export CFLAGS='-std=c++11' && c++ -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc -lm -o fieldnlay
  57. mv fieldnlay ../
  58. standalonemp: $(SRCDIR)/farfield.cc $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc
  59. export CFLAGS='-std=c++11' && c++ -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc -lm -o scattnlay-mp
  60. mv scattnlay-mp ../
  61. export CFLAGS='-std=c++11' && c++ -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc -lm -o fieldnlay-mp
  62. mv fieldnlay-mp ../
  63. clean:
  64. $(PYTHON) setup.py clean
  65. $(MAKE) -f $(CURDIR)/debian/rules clean
  66. rm -rf build/ MANIFEST
  67. find . -name '*.pyc' -delete
  68. find . -name '*.o' -delete
  69. find . -name '*.so' -delete