forked from ClusterLabs/pcs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
160 lines (143 loc) · 4.88 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
# Compatibility with GNU/Linux [i.e. Debian] based distros
UNAME_OS_GNU := $(shell if uname -o | grep -q "GNU/Linux" ; then echo true; else echo false; fi)
UNAME_KERNEL_DEBIAN := $(shell if uname -v | grep -q "Debian\|Ubuntu" ; then echo true; else echo false; fi)
IS_DEBIAN=false
UNAME_DEBIAN_VER_8=false
ifeq ($(UNAME_OS_GNU),true)
ifeq ($(UNAME_KERNEL_DEBIAN),true)
IS_DEBIAN=true
UNAME_DEBIAN_VER_8 := $(shell if grep -q -i "8" /etc/debian_version ; then echo true; else echo false; fi)
settings_x86_64 := $(shell if uname -m | grep -q -i "x86_64" ; then echo true; else echo false; fi)
settings_i386=false
ifeq ($(settings_x86_64),false)
settings_i386 := $(shell if uname -m | grep -q -i "i386" ; then echo true; else echo false; fi)
endif
endif
endif
ifndef PYTHON_SITELIB
PYTHON_SITELIB=$(shell python2 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
endif
ifeq ($(PYTHON_SITELIB), /usr/lib/python2.6/dist-packages)
EXTRA_SETUP_OPTS="--install-layout=deb"
endif
ifeq ($(PYTHON_SITELIB), /usr/lib/python2.7/dist-packages)
EXTRA_SETUP_OPTS="--install-layout=deb"
endif
# Check for systemd presence, add compatibility with Debian based distros
IS_SYSTEMCTL=false
ifeq ($(IS_DEBIAN),true)
IS_SYSTEMCTL = $(shell if [ -d /var/run/systemd/system ] ; then echo true ; else echo false; fi)
ifeq ($(IS_SYSTEMCTL),false)
ifeq ($(SYSTEMCTL_OVERRIDE),true)
IS_SYSTEMCTL=true
endif
endif
else
ifeq ("$(wildcard /usr/bin/systemctl)","/usr/bin/systemctl")
IS_SYSTEMCTL=true
else
ifeq ("$(wildcard /bin/systemctl)","/usr/bin/systemctl")
IS_SYSTEMCTL=true
endif
endif
endif
# Check for an override for building gems
ifndef BUILD_GEMS
BUILD_GEMS=true
endif
MANDIR=/usr/share/man
ifndef PREFIX
PREFIX=$(shell prefix=`python2 -c "import sys; print(sys.prefix)"` || prefix="/usr"; echo $$prefix)
endif
ifndef systemddir
systemddir=/usr/lib/systemd
endif
ifndef initdir
initdir=/etc/init.d
endif
ifndef install_settings
install_settings=false
else
ifeq ($(install_settings),true)
ifeq ($(settings_x86_64),true)
settings_file=settings.py.x86_64-linux-gnu.debian
settings_file_pcsd=settings.rb.x86_64-linux-gnu.debian
else
ifeq ($(settings_i386),true)
settings_file=settings.py.i386-linux-gnu.debian
settings_file_pcsd=settings.rb.i386-linux-gnu.debian
endif
endif
endif
endif
install: bash_completion
python2 setup.py install --prefix ${DESTDIR}${PREFIX} ${EXTRA_SETUP_OPTS}
mkdir -p ${DESTDIR}${PREFIX}/sbin/
chmod 755 ${DESTDIR}${PYTHON_SITELIB}/pcs/pcs.py
ln -fs ${PYTHON_SITELIB}/pcs/pcs.py ${DESTDIR}${PREFIX}/sbin/pcs
install -D pcs/bash_completion.d.pcs ${DESTDIR}/etc/bash_completion.d/pcs
install -m644 -D pcs/pcs.8 ${DESTDIR}/${MANDIR}/man8/pcs.8
ifeq ($(IS_DEBIAN),true)
ifeq ($(install_settings),true)
rm -f ${DESTDIR}${PYTHON_SITELIB}/pcs/settings.py
install -m755 pcs/${settings_file} ${DESTDIR}${PYTHON_SITELIB}/pcs/settings.py
endif
endif
install_pcsd:
ifeq ($(BUILD_GEMS),true)
make -C pcsd build_gems
endif
mkdir -p ${DESTDIR}/var/log/pcsd
ifeq ($(IS_DEBIAN),true)
mkdir -p ${DESTDIR}/usr/share/
cp -r pcsd ${DESTDIR}/usr/share/
install -m 644 -D pcsd/pcsd.conf ${DESTDIR}/etc/default/pcsd
install -d ${DESTDIR}/etc/pam.d
install pcsd/pcsd.pam.debian ${DESTDIR}/etc/pam.d/pcsd
ifeq ($(install_settings),true)
rm -f ${DESTDIR}/usr/share/pcsd/settings.rb
install -m755 pcsd/${settings_file_pcsd} ${DESTDIR}/usr/share/pcsd/settings.rb
endif
ifeq ($(IS_SYSTEMCTL),true)
install -d ${DESTDIR}/${systemddir}/system/
install -m 644 pcsd/pcsd.service.debian ${DESTDIR}/${systemddir}/system/pcsd.service
else
install -m 755 -D pcsd/pcsd.debian ${DESTDIR}/${initdir}/pcsd
endif
else
mkdir -p ${DESTDIR}${PREFIX}/lib/
cp -r pcsd ${DESTDIR}${PREFIX}/lib/
install -m 644 -D pcsd/pcsd.conf ${DESTDIR}/etc/sysconfig/pcsd
install -d ${DESTDIR}/etc/pam.d
install pcsd/pcsd.pam ${DESTDIR}/etc/pam.d/pcsd
ifeq ($(IS_SYSTEMCTL),true)
install -d ${DESTDIR}/${systemddir}/system/
install -m 644 pcsd/pcsd.service ${DESTDIR}/${systemddir}/system/
else
install -m 755 -D pcsd/pcsd ${DESTDIR}/${initdir}/pcsd
endif
endif
install -m 700 -d ${DESTDIR}/var/lib/pcsd
install -m 644 -D pcsd/pcsd.logrotate ${DESTDIR}/etc/logrotate.d/pcsd
uninstall:
rm -f ${DESTDIR}${PREFIX}/sbin/pcs
rm -rf ${DESTDIR}${PYTHON_SITELIB}/pcs
ifeq ($(IS_DEBIAN),true)
rm -rf ${DESTDIR}/usr/share/pcsd
else
rm -rf ${DESTDIR}${PREFIX}/lib/pcsd
endif
ifeq ($(IS_SYSTEMCTL),true)
rm -f ${DESTDIR}/${systemddir}/system/pcsd.service
else
rm -f ${DESTDIR}/${initdir}/pcsd
endif
rm -f ${DESTDIR}/etc/pam.d/pcsd
rm -rf ${DESTDIR}/var/lib/pcsd
tarball: bash_completion
python2 setup.py sdist --formats=tar
python2 maketarballs.py
newversion:
python2 newversion.py
bash_completion:
cd pcs ; python2 -c 'import usage; usage.sub_generate_bash_completion()' > bash_completion.d.pcs ; cd ..