-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
192 lines (153 loc) · 5.42 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
180
181
182
183
184
185
186
187
188
189
190
191
192
# all variables used by package builds must be exported.
export BEEGFS_DEBUG
export USER_CXXFLAGS
export USER_LDFLAGS
export BEEGFS_DEBUG_RDMA
export BEEGFS_DEBUG_IP
export KDIR
export KSRCDIR
# Tell makefiles that this is a development build. Don't use config files in /etc/beegfs.
BEEGFS_DEV_BUILD=1
export BEEGFS_DEV_BUILD
BEEGFS_THIRDPARTY_OPTIONAL =
export BEEGFS_THIRDPARTY_OPTIONAL
WITHOUT_COMM_DEBUG = true
# if version is not set, derive from current git.
# debian epoch for unversioned builds (usually dev builds) is 19 because it was 18 previously.
# versioned builds (usually from tags) are set to epoch 20, allowing upgrades from all previous versions.
ifndef BEEGFS_VERSION
BEEGFS_VERSION := $(shell git describe --tags --match '*.*' --abbrev=10)
BEEGFS_EPOCH := 19
else
BEEGFS_EPOCH := 20
endif
# sanitize version strings:
# rpm accepts underscores but not dashes
# deb accepts dashes but not underscores
BEEGFS_VERSION_RPM := $(subst -,_,$(BEEGFS_VERSION))
BEEGFS_VERSION_DEB := $(BEEGFS_EPOCH):$(subst _,-,$(BEEGFS_VERSION))
export BEEGFS_VERSION
ifneq ($(NVFS_INCLUDE_PATH),)
BEEGFS_NVFS=1
endif
export BEEGFS_NVFS
PREFIX ?= /opt/beegfs
DESTDIR ?=
DAEMONS := mgmtd meta storage helperd mon
UTILS := fsck ctl event_listener $(if $(WITHOUT_COMM_DEBUG),,comm_debug)
# exclude components with no runnable tests from `test' and do not provide `ctl-test'.
DO_NOT_TEST := thirdparty event_listener
ALL_COMPONENTS := thirdparty common $(DAEMONS) $(UTILS)
TIDY_COMPONENTS := $(filter-out thirdparty event_listener, $(ALL_COMPONENTS))
all: daemons utils client
.PHONY: daemons
daemons: $(patsubst %,%-all,$(DAEMONS))
@
.PHONY: utils
utils: $(patsubst %,%-all,$(UTILS))
@
.PHONY: $(patsubst %,%-all,$(DAEMONS) $(UTILS))
$(patsubst %,%-all,$(DAEMONS) $(UTILS)): common-all
$(MAKE) -C $(subst -all,,$@)/build all
.PHONY: common-all common
common-all: thirdparty
$(MAKE) -C common/build all
.PHONY: thirdparty
thirdparty:
$(MAKE) -C thirdparty/build all $(BEEGFS_THIRDPARTY_OPTIONAL)
.PHONY: client
client:
$(MAKE) -C client_module/build
.PHONY: tidy
tidy: $(addsuffix -tidy,$(TIDY_COMPONENTS))
@
define tidy_component
.PHONY: $1-tidy
$1-tidy:
+$(MAKE) -C $1/build tidy
endef
$(foreach C,$(TIDY_COMPONENTS),$(eval $(call tidy_component,$(C))))
_tested_components := $(filter-out $(DO_NOT_TEST),$(ALL_COMPONENTS))
.PHONY: test
test: $(patsubst %,%-test,$(_tested_components))
@
define test_component
.PHONY: $1-test
$1-test: $1-all
cd $1/build && ./test-runner --compiler
endef
$(foreach C,$(_tested_components),$(eval $(call test_component,$(C))))
.PHONY: install
install: daemons-install utils-install common-install client-install event_listener-install
@
define install_component
.PHONY: $1-install
$1-install: $1-all
install -t $(DESTDIR)/$(PREFIX)/$2 -D \
$1/build/beegfs-$$(or $$(install_name),$1)
endef
comm_debug-install: install_name=comm-debug
$(foreach D,$(DAEMONS),$(eval $(call install_component,$D,sbin)))
$(foreach U,$(filter-out event_listener,$(UTILS)),$(eval $(call install_component,$U,sbin)))
.PHONY: daemons-install
daemons-install: $(patsubst %,%-install,$(DAEMONS))
@
.PHONY: utils-install
utils-install: $(patsubst %,%-install,$(UTILS))
@
.PHONY: common-install
common-install: common-all
install -t $(DESTDIR)/$(PREFIX)/lib -D \
common/build/libbeegfs_ib.so
.PHONY: client-install
client-install: client
install -t $(DESTDIR)/$(PREFIX)/lib/modules/$(KVER)/kernel/beegfs -D \
client_module/build/beegfs.ko
## Overriding previous generic rule due to non-matching executable name
.PHONY: event_listener-intsall
event_listener-install: event_listener-all
install -t $(DESTDIR)/$(PREFIX)/sbin -D \
event_listener/build/beegfs-event-listener
.PHONY: clean
clean: $(patsubst %,%-clean,$(ALL_COMPONENTS)) client-clean
@
.PHONY: $(patsubst %,%-clean,$(ALL_COMPONENTS))
$(patsubst %,%-clean,$(ALL_COMPONENTS)):
$(MAKE) -C $(subst -clean,,$@)/build clean
.PHONY: client-clean
client-clean:
$(MAKE) -C client_module/build clean
# use DEBUILD_OPTS to pass more options to debuild, eg
# DEBUILD_OPTS='-j32 --prepend-path=/usr/lib/ccache'
# for greater concurrency during build and ccache support
.PHONY: package-deb
package-deb: clean
[ '$(PACKAGE_DIR)' ] || { echo need a PACKAGE_DIR >&2; false; }
! [ -d '$(PACKAGE_DIR)' ] || { echo choose a new directory for PACKAGE_DIR, please >&2; false; }
mkdir -p '$(PACKAGE_DIR)'
cd '$(PACKAGE_DIR)' && \
dpkg-source -I '-I$(PACKAGE_DIR)' -z1 -b '$(dir $(realpath $(firstword $(MAKEFILE_LIST))))' && \
rm -rf build && \
dpkg-source -x *.dsc build && \
( \
cd build; \
sed -i -e 's/beegfs (.*)/beegfs ($(BEEGFS_VERSION_DEB))/' debian/changelog; \
sed -i -e 's/@DATE/$(shell date -R)/' debian/changelog; \
debuild -eBEEGFS_\* $(DEBUILD_OPTS) -us -uc -b \
) && \
rm -rf build *.dsc *.tar.gz
# use RPMBUILD_OPTS to pass more options to rpmuild, eg
# RPMBUILD_OPTS='-D "MAKE_CONCURRENCY 32"'
# for greater concurrency during build
.PHONY: package-rpm
package-rpm: clean
[ '$(PACKAGE_DIR)' ] || { echo need a PACKAGE_DIR >&2; false; }
! [ -d '$(PACKAGE_DIR)' ] || { echo choose a new directory for PACKAGE_DIR, please >&2; false; }
mkdir -p $(PACKAGE_DIR)/SOURCES
tar --exclude $(PACKAGE_DIR) --exclude .git --exclude .ccache \
-cf $(PACKAGE_DIR)/SOURCES/beegfs-$(BEEGFS_VERSION_RPM).tar .
rpmbuild --clean -bb beegfs.spec \
--define '_topdir $(abspath $(PACKAGE_DIR))' \
--define 'EPOCH $(BEEGFS_EPOCH)' \
--define 'BEEGFS_VERSION $(BEEGFS_VERSION_RPM)' \
$(RPMBUILD_OPTS)