forked from SynoCommunity/spksrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspksrc.install.mk
85 lines (72 loc) · 2.92 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
### 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.
# Target are executed in the following order:
# install_msg_target
# $(PRE_INSTALL_PLIST)
# pre_install_target (override with PRE_INSTALL_TARGET)
# install_target (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 instll files, in extenso.
# 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
$(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)
find $(INSTALL_DIR)/$(INSTALL_PREFIX)/ \! -type d -printf '%P\n' | sort > $@
pre_install_target: install_msg_target $(PRE_INSTALL_PLIST)
install_target: $(PRE_INSTALL_TARGET)
$(RUN) $(MAKE) install prefix=$(STAGING_INSTALL_PREFIX)
post_install_target: $(INSTALL_TARGET)
$(INSTALL_PLIST):
find $(INSTALL_DIR)/$(INSTALL_PREFIX)/ \! -type d -printf '%P\n' | sort | \
diff $(PRE_INSTALL_PLIST) - | grep '>' | cut -d' ' -f2- > $@
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 -i -e 's#\($(INSTALL_PREFIX)\)#$(INSTALL_DIR)\1#g' \
-e 's#$$(libdir)#$${libdir}#g' $(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