Makefile 2.2 KB

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