diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-09-02 17:12:49 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-09-02 17:12:49 +0200 |
commit | 9b58cb92208c37298085ff10a28e0795896af394 (patch) | |
tree | c8781b4e6634aaaab6c92aabb951ce6887bdc39b | |
parent | compile python files (diff) | |
download | pylibgamma-1.0.tar.gz pylibgamma-1.0.tar.bz2 pylibgamma-1.0.tar.xz |
add install and uninstall rules1.0
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | Makefile | 80 |
1 files changed, 73 insertions, 7 deletions
@@ -6,12 +6,12 @@ # The package path prefix, if you want to install to another root, set DESTDIR to that root PREFIX ?= /usr -# The command path excluding prefix -BIN ?= /bin +# The library path excluding prefix +LIB ?= /lib # The resource path excluding prefix DATA ?= /share -# The command path including prefix -BINDIR ?= $(PREFIX)$(BIN) +# The library path including prefix +LIBDIR ?= $(PREFIX)$(LIB) # The resource path including prefix DATADIR ?= $(PREFIX)$(DATA) # The generic documentation path including prefix @@ -33,6 +33,9 @@ PY_VER = $(PY_MAJOR)$(PY_MINOR) # The version number of the current Python installation with a dot PY_VERSION = $(PY_MAJOR).$(PY_MINOR) +# The directory for python modules +PYTHONDIR = $(LIBDIR)/python$(PY_VERSION) + # The name of the package as it should be installed PKGNAME = pylibgamma @@ -41,10 +44,12 @@ PKGNAME = pylibgamma PKGCONFIG ?= pkg-config # The installed cython command CYTHON ?= cython +# The installed python command +PYTHON = python$(PY_MAJOR) # Libraries to link with using pkg-config -LIBS = python3 +LIBS = python$(PY_MAJOR) # The C standard for C code compilation STD = c99 @@ -69,6 +74,7 @@ PYTHON_SRC = libgamma_error libgamma_facade libgamma_method libgamma CYTHON_SRC = libgamma_native_error libgamma_native_facade libgamma_native_method + .PHONY: all pyx-files py-files all: pyc-files pyo-files so-files pyc-files: $(foreach M,$(PYTHON_SRC),src/__pycache__/$(M).cpython-$(PY_VER).pyc) @@ -104,10 +110,70 @@ obj/libgamma_native_error.pyx: src/libgamma_native_error.pyx endif src/__pycache__/%.cpython-$(PY_VER).pyc: src/%.py - python -m compileall $< + $(PYTHON) -m compileall $< src/__pycache__/%.cpython-$(PY_VER).pyo: src/%.py - python -OO -m compileall $< + $(PYTHON) -OO -m compileall $< + + +.PHONY: install +install: install-base + +.PHONY: install-all +install-all: install-base + +.PHONY: install-base +install-base: install-lib install-copyright + + +.PHONY: install-lib +install-lib: install-source install-compiled install-optimised install-native + +.PHONY: install-source +install-source: $(foreach M,$(PYTHON_SRC),src/$(M).py) + install -dm755 -- "$(DESTDIR)$(PYTHONDIR)" + install -m644 $^ -- "$(DESTDIR)$(PYTHONDIR)" + +.PHONY: install-compiled +install-compiled: $(foreach M,$(PYTHON_SRC),src/__pycache__/$(M).cpython-$(PY_VER).pyc) + install -dm755 -- "$(DESTDIR)$(PYTHONDIR)/__pycache__" + install -m644 $^ -- "$(DESTDIR)$(PYTHONDIR)/__pycache__" + +.PHONY: install-optimised +install-optimised: $(foreach M,$(PYTHON_SRC),src/__pycache__/$(M).cpython-$(PY_VER).pyo) + install -dm755 -- "$(DESTDIR)$(PYTHONDIR)/__pycache__" + install -m644 $^ -- "$(DESTDIR)$(PYTHONDIR)/__pycache__" + +.PHONY: install-native +install-native: $(foreach M,$(CYTHON_SRC),bin/$(M).so) + install -dm755 -- "$(DESTDIR)$(PYTHONDIR)" + install -m755 $^ -- "$(DESTDIR)$(PYTHONDIR)" + + +.PHONY: install-copyright +install-copyright: install-copying install-license + +.PHONY: install-copying +install-copying: COPYING + install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + install -m644 $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + +.PHONY: install-license +install-license: LICENSE + install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + install -m644 $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + + + +.PHONY: uninstall +uninstall: + -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE" + -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING" + -rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + -rm -- $(foreach M,$(PYTHON_SRC),"$(DESTDIR)$(PYTHONDIR)/__pycache__/$(M).cpython-$(PY_VER).pyo") + -rm -- $(foreach M,$(PYTHON_SRC),"$(DESTDIR)$(PYTHONDIR)/__pycache__/$(M).cpython-$(PY_VER).pyc") + -rm -- $(foreach M,$(PYTHON_SRC),"$(DESTDIR)$(PYTHONDIR)/$(M).py") + -rm -- $(foreach M,$(CYTHON_SRC),"$(DESTDIR)$(PYTHONDIR)/$(M).so") .PHONY: clean |