Support DESTDIR
This commit is contained in:
parent
97f8e9bc76
commit
a210c995cd
3 changed files with 27 additions and 22 deletions
29
install.mk
29
install.mk
|
@ -1,10 +1,11 @@
|
||||||
# Add a rule for creating $(1) as a directory. This template may be
|
# Add a rule for creating $(1) as a directory. This template may be
|
||||||
# called multiple times for the same directory.
|
# called multiple times for the same directory.
|
||||||
define create-dir
|
define create-dir
|
||||||
ifndef $(1)_SEEN
|
_i := $(DESTDIR)$$(strip $(1))
|
||||||
$(1)_SEEN = 1
|
ifndef $$(_i)_SEEN
|
||||||
$(1):
|
$$(_i)_SEEN = 1
|
||||||
$$(trace-mkdir) install -d $(1)
|
$$(_i):
|
||||||
|
$$(trace-mkdir) install -d "$$@"
|
||||||
endif
|
endif
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -13,13 +14,15 @@ endef
|
||||||
# The directory containing $(2) will be created automatically.
|
# The directory containing $(2) will be created automatically.
|
||||||
define install-file-as
|
define install-file-as
|
||||||
|
|
||||||
install: $(2)
|
_i := $(DESTDIR)$$(strip $(2))
|
||||||
|
|
||||||
|
install: $$(_i)
|
||||||
|
|
||||||
|
$$(_i): $(1) | $$(dir $$(_i))
|
||||||
|
$$(trace-install) install -m $(3) $(1) "$$@"
|
||||||
|
|
||||||
$$(eval $$(call create-dir, $$(dir $(2))))
|
$$(eval $$(call create-dir, $$(dir $(2))))
|
||||||
|
|
||||||
$(2): $(1) | $$(dir $(2))
|
|
||||||
$$(trace-install) install -m $(3) $(1) $(2)
|
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,13 +46,15 @@ endef
|
||||||
# Install a symlink from $(2) to $(1). Note that $(1) need not exist.
|
# Install a symlink from $(2) to $(1). Note that $(1) need not exist.
|
||||||
define install-symlink
|
define install-symlink
|
||||||
|
|
||||||
install: $(2)
|
_i := $(DESTDIR)$$(strip $(2))
|
||||||
|
|
||||||
|
install: $$(_i)
|
||||||
|
|
||||||
|
$$(_i): | $$(dir $$(_i))
|
||||||
|
$$(trace-install) ln -sfn $(1) "$$@"
|
||||||
|
|
||||||
$$(eval $$(call create-dir, $$(dir $(2))))
|
$$(eval $$(call create-dir, $$(dir $(2))))
|
||||||
|
|
||||||
$(2): | $$(dir $(2))
|
|
||||||
$$(trace-install) ln -sfn $(1) $(2)
|
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,16 +71,16 @@ define build-library
|
||||||
|
|
||||||
$(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
|
$(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
|
||||||
|
|
||||||
$(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME).$(SO_EXT)
|
$(1)_INSTALL_PATH := $(DESTDIR)$$($(1)_INSTALL_DIR)/$$($(1)_NAME).$(SO_EXT)
|
||||||
|
|
||||||
_libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
|
_libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
|
||||||
|
|
||||||
$$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
|
$$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
|
||||||
|
|
||||||
$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $$($(1)_INSTALL_DIR)
|
$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)
|
||||||
$$(trace-ld) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
|
$$(trace-ld) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
|
||||||
|
|
||||||
$(1)_LDFLAGS_USE_INSTALLED += -L$$($(1)_INSTALL_DIR) -Wl,-rpath,$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
|
$(1)_LDFLAGS_USE_INSTALLED += -L$$(DESTDIR)$$($(1)_INSTALL_DIR) -Wl,-rpath,$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
|
||||||
|
|
||||||
ifdef $(1)_FORCE_INSTALL
|
ifdef $(1)_FORCE_INSTALL
|
||||||
install: $$($(1)_INSTALL_PATH)
|
install: $$($(1)_INSTALL_PATH)
|
||||||
|
|
|
@ -32,18 +32,18 @@ define build-program
|
||||||
|
|
||||||
$$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
|
$$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
|
||||||
|
|
||||||
install: $$($(1)_INSTALL_PATH)
|
install: $(DESTDIR)$$($(1)_INSTALL_PATH)
|
||||||
|
|
||||||
ifeq ($(BUILD_SHARED_LIBS), 1)
|
ifeq ($(BUILD_SHARED_LIBS), 1)
|
||||||
|
|
||||||
_libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
|
_libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
|
||||||
|
|
||||||
$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $$($(1)_INSTALL_DIR)
|
$(DESTDIR)$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)
|
||||||
$$(trace-ld) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
|
$$(trace-ld) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
$$($(1)_INSTALL_PATH): $$($(1)_PATH) | $$($(1)_INSTALL_DIR)
|
$(DESTDIR)$$($(1)_INSTALL_PATH): $$($(1)_PATH) | $(DESTDIR)$$($(1)_INSTALL_DIR)
|
||||||
install -t $$($(1)_INSTALL_DIR) $$<
|
install -t $$($(1)_INSTALL_DIR) $$<
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in a new issue