forked from SynoCommunity/spksrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspksrc.install.mk
105 lines (91 loc) · 3.76 KB
/
spksrc.install.mk
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
### Install rules
# Install the freshly compiled software, and correct the pkg_config files.
# This installation will be used to configure and compile other pieces of softwares. This is
# not the target directory, theses files are copied in the stating directory.
# Targets are executed in the following order:
# install_msg_target
# $(PRE_INSTALL_PLIST)
# pre_install_target (override with PRE_INSTALL_TARGET)
# install_target (default override with INSTALL_TARGET)
# post_install_target (override with POST_INSTALL_TARGET)
# $(INSTALL_PLIST)
# install_correct_lib_files
# Variables:
# INSTALL_PREFIX Target directory where the software will be run.
# INSTALL_DIR Where to install files. INSTALL_PREFIX will be added.
# STAGING_INSTALL_PREFIX Where to install files, in extenso.
# INSTALL_MAKE_OPTIONS Parameters to add to make command
# (default: install DESTDIR=$(INSTALL_DIR) prefix=$(INSTALL_PREFIX))
# Files:
# $(WORK_DIR)/$(PKG_NAME).plist List of files installed. Can be used to build the PLIST file
# of each software.
INSTALL_COOKIE = $(WORK_DIR)/.$(COOKIE_PREFIX)install_done
INSTALL_PLIST = $(WORK_DIR)/$(PKG_NAME).plist
PRE_INSTALL_PLIST = $(INSTALL_PLIST).tmp
ifeq ($(strip $(INSTALL_MAKE_OPTIONS)),)
INSTALL_MAKE_OPTIONS = install DESTDIR=$(INSTALL_DIR) prefix=$(INSTALL_PREFIX)
endif
# Define find search path for creating plist
ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
ifeq ($(lastword $(subst /, ,$(INSTALL_PREFIX))),target)
PLIST_SEARCH_PATH = $(INSTALL_DIR)/$(INSTALL_PREFIX)/../
endif
endif
ifeq ($(strip $(PLIST_SEARCH_PATH)),)
PLIST_SEARCH_PATH = $(INSTALL_DIR)/$(INSTALL_PREFIX)/
endif
$(PRE_INSTALL_PLIST): install_msg_target
ifeq ($(strip $(PRE_INSTALL_TARGET)),)
PRE_INSTALL_TARGET = pre_install_target
else
$(PRE_INSTALL_TARGET): $(PRE_INSTALL_PLIST)
endif
ifeq ($(strip $(INSTALL_TARGET)),)
INSTALL_TARGET = install_target
else
$(INSTALL_TARGET): $(PRE_INSTALL_TARGET)
endif
ifeq ($(strip $(POST_INSTALL_TARGET)),)
POST_INSTALL_TARGET = post_install_target
else
$(POST_INSTALL_TARGET): $(INSTALL_TARGET)
endif
$(INSTALL_PLIST): $(POST_INSTALL_TARGET)
install_msg_target:
@$(MSG) "Installing for $(NAME)"
$(PRE_INSTALL_PLIST):
$(create_target_dir)
@mkdir -p $(INSTALL_DIR)/$(INSTALL_PREFIX) $(INSTALL_DIR)/$(INSTALL_PREFIX_VAR)
find $(PLIST_SEARCH_PATH) \! -type d -printf '%P\n' | sed 's?^target/??g' | sort > $@
pre_install_target: install_msg_target $(PRE_INSTALL_PLIST)
install_target: $(PRE_INSTALL_TARGET)
$(RUN) $(MAKE) $(INSTALL_MAKE_OPTIONS)
post_install_target: $(INSTALL_TARGET)
ifeq ($(strip $(GCC_NO_DEBUG_INFO)),1)
$(RUN) $(MAKE) distclean
endif
$(INSTALL_PLIST):
find $(PLIST_SEARCH_PATH)/ \! -type d -printf '%P\n' | sed 's?^target/??g' | sort | \
diff $(PRE_INSTALL_PLIST) - | grep '>' | sed 's?> ??g' > $@
install_correct_lib_files: $(INSTALL_PLIST)
@for pc_file in $$(grep -e "^lib/pkgconfig/.*\.pc$$" $(INSTALL_PLIST)) ; \
do \
$(MSG) "Correcting pkg-config file $${pc_file}" ; \
sed -e 's#=\($(INSTALL_PREFIX)\)#=$(INSTALL_DIR)\1#g' \
-e 's#-rpath,\([^ ,]*\)#-rpath,\1,-rpath-link,$(INSTALL_DIR)\1#g' \
-e 's#$$(libdir)#$${libdir}#g' \
-i $(INSTALL_DIR)/$(INSTALL_PREFIX)/$${pc_file} ; \
done
@for la_file in $$(grep -e "^lib/.*\.la$$" $(INSTALL_PLIST)) ; \
do \
$(MSG) "Correcting libtool file $${la_file}" ; \
perl -p -i -e 's#(?<!\Q$(INSTALL_DIR)\E/)$(INSTALL_PREFIX)#$(INSTALL_DIR)/$(INSTALL_PREFIX)#g' $(INSTALL_DIR)/$(INSTALL_PREFIX)/$${la_file} ; \
done
ifeq ($(wildcard $(INSTALL_COOKIE)),)
install: $(INSTALL_COOKIE)
$(INSTALL_COOKIE): install_correct_lib_files
$(create_target_dir)
@touch -f $@
else
install: ;
endif