-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
180 lines (153 loc) · 5.31 KB
/
Makefile
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# ====================================================================
# Copyright oVirt Authors
# SPDX-License-Identifier: Apache-2.0
# ====================================================================
#
# CUSTOMIZATION-BEGIN
#
BUILD_DEV=0
PACKAGE_NAME=ovirt-engine-extension-aaa-ldap
PACKAGE_VERSION=master
PACKAGE_DISPLAY_NAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION)
PREFIX=/usr/local
LOCALSTATE_DIR=$(PREFIX)/var
BIN_DIR=$(PREFIX)/bin
SYSCONF_DIR=$(PREFIX)/etc
DATAROOT_DIR=$(PREFIX)/share
MAN_DIR=$(DATAROOT_DIR)/man
DOC_DIR=$(DATAROOT_DIR)/doc
DATA_DIR=$(DATAROOT_DIR)/$(PACKAGE_NAME)
JAVA_DIR=$(DATAROOT_DIR)/java
BUILD_FILE=tmp.built
PYTHON=$(shell which python3 2> /dev/null)
PYTHON_SYS_DIR:=$(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib as f;print(f())")
DEV_PYTHON_DIR=
DEVMODE=0
#
# CUSTOMIZATION-END
#
# Don't use any of the bultin rules, in particular don't use the rule
# for .sh files, as that means that we can't generate .sh files from
# templates:
.SUFFIXES:
.SUFFIXES: .in
# Rule to generate files from templates:
.in:
GENERATED_FILE_LIST=$$(echo "$(GENERATED)" | sed -e "s/ /\\\n/g"); \
sed \
-e "s|@MODULEPATH@|$(DATA_DIR)/modules|g" \
-e "s|@DEV_PYTHON_DIR@|$(DEV_PYTHON_DIR)|g" \
-e "s|@DEVMODE@|$(DEVMODE)|g" \
-e "s|@PACKAGE_NAME@|$(PACKAGE_NAME)|g" \
-e "s|@PACKAGE_VERSION@|$(PACKAGE_VERSION)|g" \
-e "s|@PACKAGE_DISPLAY_NAME@|$(PACKAGE_DISPLAY_NAME)|g" \
-e "s|@BIN_DIR@|$(BIN_DIR)|g" \
-e "s|@SYSCONF_DIR@|$(SYSCONF_DIR)|g" \
-e "s|@PROFILES_DIR@|$(DATA_DIR)/profiles|g" \
$< > $@
# List of files that will be generated from templates:
# Once add new template file, if required chmod, add it in generated-files target.
GENERATED = \
packaging/etc/ovirt-engine/engine.conf.d/50-ovirt-engine-extension-aaa-ldap.conf \
packaging/setup/bin/ovirt-engine-extension-aaa-ldap-setup.env \
packaging/setup/ovirt_engine_extension_aaa_ldap_setup/config.py \
src/main/resources/org/ovirt/engine/extension/aaa/ldap/config.properties \
$(NULL)
build: \
$(BUILD_FILE) \
$(NULL)
# support force run of maven
maven:
mvn -Pdevenv install
touch "$(BUILD_FILE)"
$(BUILD_FILE):
$(MAKE) maven
clean:
# Clean maven generated stuff:
mvn clean
rm -rf $(BUILD_FILE) tmp.dev.flist
# Clean files generated from templates:
rm -rf $$(echo $(GENERATED))
install: \
install-layout \
$(NULL)
# copy SOURCEDIR to TARGETDIR
# exclude EXCLUDEGEN a list of files to exclude with .in
# exclude EXCLUDE a list of files.
copy-recursive:
( cd "$(SOURCEDIR)" && find . -type d -printf '%P\n' ) | while read d; do \
install -d -m 755 "$(TARGETDIR)/$${d}"; \
done
( \
cd "$(SOURCEDIR)" && find . -type f -printf '%P\n' | \
while read f; do \
exclude=false; \
for x in $(EXCLUDE_GEN); do \
if [ "$(SOURCEDIR)/$${f}" = "$${x}.in" ]; then \
exclude=true; \
break; \
fi; \
done; \
for x in $(EXCLUDE); do \
if [ "$(SOURCEDIR)/$${f}" = "$${x}" ]; then \
exclude=true; \
break; \
fi; \
done; \
$${exclude} || echo "$${f}"; \
done \
) | while read f; do \
src="$(SOURCEDIR)/$${f}"; \
dst="$(TARGETDIR)/$${f}"; \
[ -x "$${src}" ] && MASK=0755 || MASK=0644; \
[ -n "$(DEV_FLIST)" ] && echo "$${dst}" | sed 's#^$(PREFIX)/##' >> "$(DEV_FLIST)"; \
install -T -m "$${MASK}" "$${src}" "$${dst}"; \
done
generate-files: \
$(GENERATED) \
$(NULL)
install-packaging-files:
$(MAKE) copy-recursive SOURCEDIR=packaging/etc TARGETDIR="$(DESTDIR)$(SYSCONF_DIR)" EXCLUDE_GEN="$(GENERATED)"
for d in bin examples modules profiles setup; do \
$(MAKE) copy-recursive SOURCEDIR="packaging/$${d}" TARGETDIR="$(DESTDIR)$(DATA_DIR)/$${d}" EXCLUDE_GEN="$(GENERATED)"; \
done
install -d -m 755 "$(DESTDIR)$(DOC_DIR)"
install -d -m 755 "$(DESTDIR)$(DOC_DIR)/$(PACKAGE_NAME)"
install -m 644 README.md "$(DESTDIR)$(DOC_DIR)/$(PACKAGE_NAME)/README.md"
install -m 644 README.profile "$(DESTDIR)$(DOC_DIR)/$(PACKAGE_NAME)/README.profile"
install -m 644 README.unboundid-ldapsdk "$(DESTDIR)$(DOC_DIR)/$(PACKAGE_NAME)/README.unboundid-ldapsdk"
install-layout: \
install-packaging-files \
$(NULL)
install -d -m 755 "$(DESTDIR)$(BIN_DIR)"
ln -sf "$(DATA_DIR)/setup/bin/ovirt-engine-extension-aaa-ldap-setup" "$(DESTDIR)$(BIN_DIR)/ovirt-engine-extension-aaa-ldap-setup"
ln -sf "$(JAVA_DIR)/$(PACKAGE_NAME)/$(PACKAGE_NAME).jar" "$(DESTDIR)$(DATA_DIR)/modules/org/ovirt/engine/extension/aaa/ldap/main/$(PACKAGE_NAME).jar"
ln -sf "$(JAVA_DIR)/unboundid-ldapsdk.jar" "$(DESTDIR)$(DATA_DIR)/modules/org/ovirt/engine/extension/aaa/ldap/main/unboundid-ldapsdk.jar"
install-artifacts: \
build \
$(NULL)
install -d -m 755 "$(DESTDIR)$(JAVA_DIR)"
install -d -m 755 "$(DESTDIR)$(JAVA_DIR)/$(PACKAGE_NAME)"
install -m 644 "target/$(PACKAGE_NAME).jar" "$(DESTDIR)$(JAVA_DIR)/$(PACKAGE_NAME)/$(PACKAGE_NAME).jar"
install-dev-custom: \
generate-files \
install-layout \
install-artifacts \
$(NULL)
if [ -f "$(DESTDIR)$(PREFIX)/dev.$(PACKAGE_NAME).flist" ]; then \
cat "$(DESTDIR)$(PREFIX)/dev.$(PACKAGE_NAME).flist" | while read f; do \
rm -f "$(DESTDIR)$(PREFIX)/$${f}"; \
done; \
rm -f "$(DESTDIR)$(PREFIX)/dev.$(PACKAGE_NAME).flist"; \
fi
rm -f tmp.dev.flist
$(MAKE) \
install \
DEV_FLIST=tmp.dev.flist \
$(NULL)
cp tmp.dev.flist "$(DESTDIR)$(PREFIX)/dev.$(PACKAGE_NAME).flist"
install-dev:
$(MAKE) install-dev-custom \
DEVMODE=1 \
DEV_PYTHON_DIR="$(PREFIX)$(PYTHON_SYS_DIR)" \
$(NULL)