summaryrefslogtreecommitdiff
path: root/makefiles/gmake/install.mk
blob: ac6d49d5629ea1702b2ed4264f772d6843f11e29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# install
#
# requires:
# - DESTDIR: temporary or final destination dir for installation
# - prefix:  prefix for the directory root (e.g. /usr)
#
# provides:
# - target: install
# - target: uninstall

# default values
DESTDIR=
prefix=/usr

# standard directories following FHS
execdir=$(DESTDIR)$(prefix)
bindir=$(execdir)/bin
sbindir=$(execdir)/sbin
libdir=$(execdir)/lib
sysconfdir=$(execdir)/etc
includedir=$(execdir)/include
datadir=$(execdir)/share
localedir=$(datadir)/locale

.PHONY: install_recursive install local_install

install_recursive:
	@test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \
	  (set -e; $(MAKE) -C $$d install || exit 1); done)

install: install_recursive local_install install_po
	@test -d "$(libdir)" || mkdir -p "$(libdir)"
	@test -z "$(STATIC_LIB)" || ( \
		$(INSTALL) -m 644 $(STATIC_LIB) $(libdir)/$(STATIC_LIB) )
	@test -z "$(DYNAMIC_LIB)" || ( \
		$(INSTALL) -m 755 $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) \
			$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) )
	@test -z "$(DYNAMIC_LIB)" || ( \
		rm -f "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" && \
		ln -s "$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" \
			"$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" )
	@test -z "$(DYNAMIC_LIB)" || ( \
		rm -f "$(libdir)/$(DYNAMIC_LIB)" && \
		ln -s "$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" \
			"$(libdir)/$(DYNAMIC_LIB)" )

.PHONY: uninstall_recursive uninstall local_uninstall

uninstall_recursive:
	@test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \
	  (set -e; $(MAKE) -C $$d uninstall || exit 1); done)

uninstall: uninstall_recursive local_uninstall uninstall_po
	test -z "$(DYNAMIC_LIB)" || ( \
		test ! -f "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" || \
			rm "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" )
	test -z "$(DYNAMIC_LIB)" || ( \
		test ! -h "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" || \
			rm "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" )
	test -z "$(DYNAMIC_LIB)" || ( \
		test ! -h "$(libdir)/$(DYNAMIC_LIB)" || \
			rm "$(libdir)/$(DYNAMIC_LIB)" )
	test -z "$(STATIC_LIB)" || ( \
		test ! -f "$(libdir)/$(STATIC_LIB)" || rm "$(libdir)/$(STATIC_LIB)" )