-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
411 lines (379 loc) · 9.16 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
#
# Copyright (C) 2017-2018 Sébastien Vaucher
# Copyright (C) 2013-2018 Canonical, Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
VERSION=0.09.10
#
# Codename "portable pressure producer"
#
CFLAGS += -Wall -Wextra -DVERSION='"$(VERSION)"' -O2 -std=gnu99
SGX_SDK ?= /opt/intel/sgxsdk
SGX_MODE ?= HW
SGX_DEBUG ?= 1
SGX_PRERELEASE ?= 0
#
# Pedantic flags
#
ifeq ($(PEDANTIC),1)
CFLAGS += -Wabi -Wcast-qual -Wfloat-equal -Wmissing-declarations \
-Wmissing-format-attribute -Wno-long-long -Wpacked \
-Wredundant-decls -Wshadow -Wno-missing-field-initializers \
-Wno-missing-braces -Wno-sign-compare -Wno-multichar
endif
#
# Static flags, only to be used when using GCC
#
ifeq ($(STATIC),1)
LDFLAGS += -static
CFLAGS += -DBUILD_STATIC
endif
BINDIR=/usr/bin
MANDIR=/usr/share/man/man1
JOBDIR=/usr/share/stress-ng/example-jobs
#
# Stressors
#
STRESS_SRC = \
stress-affinity.c \
stress-af-alg.c \
stress-aio.c \
stress-aio-linux.c \
stress-apparmor.c \
stress-atomic.c \
stress-bigheap.c \
stress-bind-mount.c \
stress-branch.c \
stress-brk.c \
stress-bsearch.c \
stress-cache.c \
stress-cap.c \
stress-chdir.c \
stress-chmod.c \
stress-chown.c \
stress-chroot.c \
stress-clock.c \
stress-clone.c \
stress-context.c \
stress-copy-file.c \
stress-cpu.c \
stress-cpu-online.c \
stress-crypt.c \
stress-cyclic.c \
stress-daemon.c \
stress-dccp.c \
stress-dentry.c \
stress-dev.c \
stress-dir.c \
stress-dirdeep.c \
stress-dnotify.c \
stress-dup.c \
stress-epoll.c \
stress-eventfd.c \
stress-exec.c \
stress-fallocate.c \
stress-fanotify.c \
stress-fault.c \
stress-fcntl.c \
stress-fiemap.c \
stress-fifo.c \
stress-filename.c \
stress-flock.c \
stress-fork.c \
stress-fp-error.c \
stress-fstat.c \
stress-full.c \
stress-funccall.c \
stress-futex.c \
stress-get.c \
stress-getrandom.c \
stress-getdent.c \
stress-handle.c \
stress-hdd.c \
stress-heapsort.c \
stress-hrtimers.c \
stress-hsearch.c \
stress-icache.c \
stress-icmp-flood.c \
stress-inode-flags.c \
stress-inotify.c \
stress-iomix.c \
stress-ioport.c \
stress-ioprio.c \
stress-iosync.c \
stress-itimer.c \
stress-kcmp.c \
stress-key.c \
stress-kill.c \
stress-klog.c \
stress-lease.c \
stress-lsearch.c \
stress-link.c \
stress-lockbus.c \
stress-locka.c \
stress-lockf.c \
stress-lockofd.c \
stress-longjmp.c \
stress-madvise.c \
stress-malloc.c \
stress-matrix.c \
stress-membarrier.c \
stress-memcpy.c \
stress-memfd.c \
stress-memrate.c \
stress-memthrash.c \
stress-mergesort.c \
stress-mincore.c \
stress-mknod.c \
stress-mlock.c \
stress-mmap.c \
stress-mmapfork.c \
stress-mmapmany.c \
stress-mmapaddr.c \
stress-mremap.c \
stress-msg.c \
stress-msync.c \
stress-mq.c \
stress-netdev.c \
stress-netlink-proc.c \
stress-nice.c \
stress-nop.c \
stress-null.c \
stress-numa.c \
stress-oom-pipe.c \
stress-opcode.c \
stress-open.c \
stress-personality.c \
stress-physpage.c \
stress-pipe.c \
stress-poll.c \
stress-procfs.c \
stress-pthread.c \
stress-ptrace.c \
stress-pty.c \
stress-quota.c \
stress-qsort.c \
stress-radixsort.c \
stress-rawdev.c \
stress-rdrand.c \
stress-readahead.c \
stress-remap-file-pages.c \
stress-rename.c \
stress-resources.c \
stress-rlimit.c \
stress-rmap.c \
stress-rtc.c \
stress-sctp.c \
stress-schedpolicy.c \
stress-seal.c \
stress-seccomp.c \
stress-seek.c \
stress-sem.c \
stress-sem-sysv.c \
stress-sendfile.c \
stress-sgx.c \
stress-sgx-vm.c \
stress-shm.c \
stress-shm-sysv.c \
stress-sigfd.c \
stress-sigfpe.c \
stress-sigpending.c \
stress-sigsegv.c \
stress-sigsuspend.c \
stress-sigq.c \
stress-sleep.c \
stress-socket.c \
stress-socket-diag.c \
stress-socket-fd.c \
stress-socketpair.c \
stress-softlockup.c \
stress-spawn.c \
stress-splice.c \
stress-stack.c \
stress-stackmmap.c \
stress-str.c \
stress-stream.c \
stress-swap.c \
stress-switch.c \
stress-sync-file.c \
stress-sysinfo.c \
stress-sysfs.c \
stress-tee.c \
stress-timer.c \
stress-timerfd.c \
stress-tlb-shootdown.c \
stress-tmpfs.c \
stress-tree.c \
stress-tsc.c \
stress-tsearch.c \
stress-udp.c \
stress-udp-flood.c \
stress-unshare.c \
stress-urandom.c \
stress-userfaultfd.c \
stress-utime.c \
stress-vecmath.c \
stress-vforkmany.c \
stress-vm.c \
stress-vm-rw.c \
stress-vm-splice.c \
stress-wait.c \
stress-wcstr.c \
stress-xattr.c \
stress-yield.c \
stress-zero.c \
stress-zlib.c \
stress-zombie.c \
#
# Stress core
#
CORE_SRC = \
affinity.c \
cache.c \
helper.c \
ignite-cpu.c \
io-priority.c \
job.c \
limit.c \
log.c \
madvise.c \
mincore.c \
mlock.c \
mmap.c \
mounts.c \
mwc.c \
net.c \
out-of-memory.c \
parse-opts.c \
perf.c \
sched.c \
setting.c \
shim.c \
thermal-zone.c \
time.c \
thrash.c \
stress-ng.c
SRC = $(STRESS_SRC) $(CORE_SRC)
OBJS = $(SRC:.c=.o)
APPARMOR_PARSER=/sbin/apparmor_parser
LIB_APPARMOR := -lapparmor
LIB_BSD := -lbsd
LIB_Z := -lz
LIB_CRYPT := -lcrypt
LIB_RT := -lrt
LIB_PTHREAD := -lpthread
LIB_AIO = -laio
LIB_SCTP = -lsctp
#
# Load in current config; use 'make clean' to clear this
#
-include config
ifneq ("$(wildcard config)","")
all: all_config
.PHONY: all_config enclave_cpu.signed.so enclave_vm.signed.so
all_config:
$(MAKE) -f Makefile.config
$(MAKE) stress-ng
endif
CFLAGS += $(CONFIG_CFLAGS)
CFLAGS += -I$(SGX_SDK)/include
LDFLAGS += $(CONFIG_LDFLAGS)
ifneq ($(SGX_MODE), HW)
LDFLAGS += -L$(SGX_SDK)/lib64 -lsgx_urts_sim -lsgx_uae_service_sim
else
LDFLAGS += -L$(SGX_SDK)/lib64 -lsgx_urts
endif
OBJS += $(CONFIG_OBJS)
.SUFFIXES: .c .o
.o: stress-ng.h Makefile
.c.o: sgx/utils.h stress-ng.h Makefile $(SRC)
@echo $(CC) $(CFLAGS) -c -o $@ $<
@$(CC) $(CFLAGS) -c -o $@ $<
sgx/utils.o: sgx/utils.c sgx/utils.h
$(CC) $(CFLAGS) -c -o $@ sgx/utils.c
enclave_cpu.signed.so enclave_vm.signed.so sgx/enclave_*/untrusted/enclave_u.o:
$(MAKE) -f sgx/Makefile SGX_MODE=$(SGX_MODE) SGX_DEBUG=$(SGX_DEBUG) SGX_PRERELEASE=$(SGX_PRERELEASE)
cp --preserve=all --reflink=auto sgx/enclave_cpu/enclave_cpu.signed.so enclave_cpu.signed.so
cp --preserve=all --reflink=auto sgx/enclave_vm/enclave_vm.signed.so enclave_vm.signed.so
stress-ng: sgx/utils.o enclave_cpu.signed.so enclave_vm.signed.so $(OBJS)
$(CC) $(CPPFLAGS) $(CFLAGS) $(OBJS) sgx/utils.o sgx/enclave_cpu/untrusted/enclave_u.o sgx/enclave_vm/untrusted/vm_u.o -lm $(LDFLAGS) -lc -o $@
#
# generate apparmor data using minimal core utils tools from apparmor
# parser output
#
apparmor-data.o: usr.bin.pulseaudio.eg
@$(APPARMOR_PARSER) -Q usr.bin.pulseaudio.eg -o apparmor-data.bin
@echo "#include <stddef.h>" > apparmor-data.c
@echo "char g_apparmor_data[]= { " >> apparmor-data.c
@od -tx1 -An -v < apparmor-data.bin | \
sed 's/[0-9a-f][0-9a-f]/0x&,/g' | \
sed '$$ s/.$$//' >> apparmor-data.c
@echo "};" >> apparmor-data.c
@echo "const size_t g_apparmor_data_len = sizeof(g_apparmor_data);" >> apparmor-data.c
$(CC) -c apparmor-data.c -o apparmor-data.o
@rm -rf apparmor-data.c
#
# extract the PER_* personality enums
#
personality.h:
@$(CPP) personality.c | grep -e "PER_[A-Z0-9]* =.*," | cut -d "=" -f 1 \
| sed "s/.$$/,/" > personality.h
stress-personality.c: personality.h
perf.o: perf.c perf-event.c
@gcc -E perf-event.c | grep "PERF_COUNT" | sed 's/,/ /' | awk {'print "#define _SNG_" $$1 " (1)"'} > perf-event.h
@echo $(CC) $(CFLAGS) -c -o $@ $<
@$(CC) $(CFLAGS) -c -o $@ $<
stress-vecmath.o: stress-vecmath.c
@echo $(CC) $(CFLAGS) -fno-builtin -c -o $@ $<
@$(CC) $(CFLAGS) -fno-builtin -c -o $@ $<
@touch stress-ng.c
$(OBJS): stress-ng.h Makefile
stress-ng.1.gz: stress-ng.1
gzip -c $< > $@
.PHONY: dist
dist:
rm -rf stress-ng-$(VERSION)
mkdir stress-ng-$(VERSION)
cp -rp Makefile Makefile.config $(SRC) stress-ng.h stress-ng.1 \
personality.c COPYING syscalls.txt mascot README \
README.Android test snapcraft smatchify.sh config TODO \
perf-event.c usr.bin.pulseaudio.eg stress-version.h \
example-jobs stress-ng-$(VERSION)
tar -Jcf stress-ng-$(VERSION).tar.xz stress-ng-$(VERSION)
rm -rf stress-ng-$(VERSION)
.PHONY: pdf
pdf:
man -t ./stress-ng.1 | ps2pdf - > stress-ng.pdf
.PHONY: clean
clean:
$(MAKE) -f sgx/Makefile clean
@rm -f stress-ng $(OBJS) stress-ng.1.gz stress-ng.pdf
@rm -f stress-ng-$(VERSION).tar.xz
@rm -f personality.h
@rm -f perf-event.h
@rm -f *.o
@:> config
.PHONY: fast-test-all
fast-test-all: stress-ng
STRESS_NG=./stress-ng debian/tests/fast-test-all
.PHONY: install
install: stress-ng stress-ng.1.gz
mkdir -p ${DESTDIR}${BINDIR}
cp stress-ng ${DESTDIR}${BINDIR}
mkdir -p ${DESTDIR}${MANDIR}
cp stress-ng.1.gz ${DESTDIR}${MANDIR}
mkdir -p ${DESTDIR}${JOBDIR}
cp -rp example-jobs/*.job ${DESTDIR}${JOBDIR}