From 3dd1dc81f0c64f5ce842bfc5830b7e7b4dafbc96 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 4 Sep 2014 02:40:59 +0200 Subject: add install and uninstall rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1e221d3..51ada76 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,14 @@ PREFIX ?= /usr # The library path excluding prefix LIB ?= /lib +# The library header path excluding prefix. +INCLUDE ?= /include # The resource path excluding prefix DATA ?= /share # The library path including prefix LIBDIR ?= $(PREFIX)$(LIB) +# The library header including prefix. +INCLUDEDIR ?= $(PREFIX)$(INCLUDE) # The resource path including prefix DATADIR ?= $(PREFIX)$(DATA) # The generic documentation path including prefix @@ -90,14 +94,28 @@ CXX_FLAGS = $(foreach D,$(DEFS),-D$(D)) -std=$(STD) \ LD_FLAGS = -lgamma -std=$(STD) $(OPTIMISE) $(LDFLAGS) $(WARN) +# Header files +HEADERS = libgamma libgamma-error libgamma-facade libgamma-method libgamma-native -.PHONY: all -all: bin/libgammamm.so bin/test -bin/libgammamm.so: obj/libgamma-error.o obj/libgamma-facade.o obj/libgamma-method.o + +.PHONY: all lib test +all: lib test +lib: bin/libgammamm.$(SO).$(LIB_VERSION) +test: bin/test + +bin/libgammamm.$(SO).$(LIB_VERSION): obj/libgamma-error.o obj/libgamma-facade.o obj/libgamma-method.o @mkdir -p bin $(CXX) $(LD_FLAGS) $(SHARED) $(LDSO) -o $@ $^ +bin/libgammamm.$(SO).$(LIB_MAJOR): + @mkdir -p bin + ln -sf libgammamm.$(SO).$(LIB_VERSION) $@ + +bin/libgammamm.$(SO): + @mkdir -p bin + ln -sf libgammamm.$(SO).$(LIB_VERSION) $@ + bin/test: obj/test.o obj/libgamma-error.o obj/libgamma-facade.o obj/libgamma-method.o $(CXX) $(LD_FLAGS) -o $@ $^ @@ -107,6 +125,56 @@ obj/%.o: src/%.cc src/*.hh +.PHONY: install +install: install-base + +.PHONY: install +install-all: install-base + +.PHONY: install-base +install-base: install-lib install-include install-copyright + + +.PHONY: install-lib +install-lib: bin/libgammamm.$(SO).$(LIB_VERSION) + install -dm755 -- "$(DESTDIR)$(LIBDIR)" + install -m755 $< -- "$(DESTDIR)$(LIBDIR)/libgammamm.$(SO).$(LIB_VERSION)" + ln -sf libgammamm.$(SO).$(LIB_VERSION) -- "$(DESTDIR)$(LIBDIR)/libgammamm.$(SO).$(LIB_MAJOR)" + ln -sf libgammamm.$(SO).$(LIB_VERSION) -- "$(DESTDIR)$(LIBDIR)/libgammamm.$(SO)" + +.PHONY: install-include +install-include: + install -dm755 -- "$(DESTDIR)$(INCLUDEDIR)" + install -m644 $(foreach H,$(HEADERS),src/$(H).hh) -- "$(DESTDIR)$(INCLUDEDIR)" + + +.PHONY: install-copyright +install-copyright: install-copying install-license + +.PHONY: install-copying +install-copying: + install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + install -m644 COPYING -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING" + +.PHONY: install-license +install-license: + install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + install -m644 LICENSE -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE" + + + +.PHONY: uninstall +uninstall: + -rm -- "$(DESTDIR)$(LIBDIR)/libgammamm.$(SO).$(LIB_VERSION)" + -rm -- "$(DESTDIR)$(LIBDIR)/libgammamm.$(SO).$(LIB_MAJOR)" + -rm -- "$(DESTDIR)$(LIBDIR)/libgammamm.$(SO)" + -rm -- $(foreach H,$(HEADERS),"$(DESTDIR)$(INCLUDEDIR)/$(H).hh") + -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING" + -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE" + -rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + + + .PHONY: clean clean: -rm -r obj bin -- cgit v1.2.3-70-g09d2