-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
executable file
·165 lines (128 loc) · 4.1 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
VERSION=$(shell git describe --tags --always --dirty)
export TMPDIR = /tmp
ifeq ($(BUILD_ENV),jt-wine)
COMPILE_USING_WINE=1
endif
TRANS_SRC := drbd/
TRANS_DEST := converted-sources/
WIN4LIN := windrbd/
TRANSFORMATIONS := $(sort $(wildcard transform.d/*))
ORIG := $(shell find $(TRANS_SRC) -name "*.[ch]" | egrep -v 'drbd/drbd-kernel-compat|drbd_transport_template.c|drbd_buildtag.c|compat.h|drbd_polymorph_printk.h')
TRANSFORMED := $(patsubst $(TRANS_SRC)%,$(TRANS_DEST)%,$(ORIG))
export SHELL=bash
all: build
# can not regenerate those scripts
$(TRANSFORMATIONS): ;
# can not regenerate the originals
$(ORIG): ;
$(TRANSFORMED): $(TRANSFORMATIONS) Makefile transform
$(TRANS_DEST)% : $(TRANS_SRC)%
@./transform $< $@
$(TRANS_DEST).generated: $(ORIG)
echo $(TRANSFORMED) > $(TRANS_DEST).generated
trans: $(TRANSFORMED) $(TRANS_DEST).generated
CP := cp --preserve=timestamps
copy:
$(CP) ./Makefile.win $(TRANS_DEST)/drbd/Makefile
$(CP) ./ms-cl*.cmd $(TRANS_DEST)/drbd/
deps: copy trans
cd $(TRANS_DEST)/drbd && $(MAKE) deps
patch: trans versioninfo copy
.PHONY: versioninfo
versioninfo:
./versioninfo.sh $(TRANS_DEST) || true
ifeq ($(shell uname -o),Cygwin)
build:
@if test -d $(TRANS_DEST); then \
cd $(TRANS_DEST)/drbd/ && $(MAKE); \
else \
echo "Please run 'make' first on a Linux system with spatch installed"; \
fi
install: build
@if test -d $(TRANS_DEST); then \
cd $(TRANS_DEST)/drbd/ && $(MAKE) install; \
else \
echo "Please run 'make' first on a Linux system with spatch installed"; \
fi
package: build
@if test -d $(TRANS_DEST); then \
cd $(TRANS_DEST)/drbd/ && $(MAKE) package; \
else \
echo "Please run 'make' first on a Linux system with spatch installed"; \
fi
upload:
@if test -d $(TRANS_DEST); then \
cd $(TRANS_DEST)/drbd/ && $(MAKE) upload; \
else \
echo "Please run 'make' first on a Linux system with spatch installed"; \
fi
signed-package:
@if test -d $(TRANS_DEST); then \
cd $(TRANS_DEST)/drbd/ && $(MAKE) signed-package; \
else \
echo "Please run 'make' first on a Linux system with spatch installed"; \
fi
clean:
for d in $(TRANS_DEST) $(WIN4LIN); do \
find $$d -name "*.pdb" -delete; \
find $$d -name "*.obj" -delete; \
find $$d -name "windrbd.sys" -delete; \
find $$d -name "windrbd.cat" -delete; \
find $$d -name "_windrbd.ilk" -delete; \
done
make -C converted-sources/drbd/ clean
# Those 4 targets are for running static code verifiers
.PHONY: sdv dvl code-analysis codeql
sdv:
cd $(TRANS_DEST)/drbd/ && $(MAKE) sdv
dvl:
cd $(TRANS_DEST)/drbd/ && $(MAKE) dvl
code-analysis:
cd $(TRANS_DEST)/drbd/ && $(MAKE) code-analysis
codeql:
cd $(TRANS_DEST)/drbd/ && $(MAKE) codeql
# This is the target to procude a .DVL.XML suitable for Static
# tools logo test for Windows Server 2019 (and older systems)
server2019-dvl-rebuild:
cd $(TRANS_DEST)/drbd/ && $(MAKE) server2019-dvl-rebuild
else
build: patch
ifdef COMPILE_USING_WINE
cd $(TRANS_DEST)/drbd/ && $(MAKE)
else
@echo "Now please run 'make' in the Windows VM."
endif
compile:
cd $(TRANS_DEST)/drbd/ && $(MAKE)
# TODO: also regenerate sources?
package: compile
cd $(TRANS_DEST)/drbd/ && $(MAKE) package; \
install:
@echo "This is not a Windows machine. Since we are building a Windows"
@echo "kernel driver, execute make install on your Windows box (as"
@echo "Administrator)"
clean:
if test -f $(TRANS_DEST)/.generated; then \
rm -f $(shell cat $(TRANS_DEST).generated) $(TRANS_DEST).generated; \
for d in $(TRANS_DEST) $(WIN4LIN); do \
find $$d -name "*.tmp.bak" -delete; \
find $$d -name "*.pdb" -delete; \
find $$d -name "*.obj" -delete; \
find $$d -name "*.orig" -delete; \
find $$d -name "*.tmpe" -delete; \
done; \
fi
endif
tarball:
rm -rf $(TRANS_DEST) && mkdir $(TRANS_DEST)
make trans # regenerate cocci-cache
rm -rf $(TRANS_DEST) && mkdir $(TRANS_DEST)
make versioninfo
git ls-files > .filelist
find $(TRANS_DEST) -print >> .filelist
find transform.d/cocci-cache -print >> .filelist
sed -i "s/^/wdrbd-$(VERSION)\//" .filelist
ln -s . wdrbd-$(VERSION)
tar --owner=0 --group=0 -czf - -T .filelist > wdrbd-$(VERSION).tar.gz
rm wdrbd-$(VERSION)
# vim: set ts=8 sw=8 noet :