This repository has been archived by the owner on Sep 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
78 lines (60 loc) · 1.96 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
# Copyright (C) Intel Corporation, 2022
# SPDX-License-Identifier: MIT
#
# Makefile recipies for managing kAFL workspace
# declare all targets in this variable
ALL_TARGETS:=deploy clean env update build prepare
# declare all target as PHONY
.PHONY: $(ALL_TARGETS)
# This small chunk of code allows us to pass arbitrary arguments to our make targets
# see the solution on SO:
# https://stackoverflow.com/a/14061796/3017219
# If the first argument is contained in ALL_TARGETS
ifneq ($(filter $(firstword $(MAKECMDGOALS)), $(ALL_TARGETS)),)
# use the rest as arguments to create a new variable ADD_ARGS
EXTRA_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(EXTRA_ARGS):;@:)
endif
# User targets
#---------------
all: env.sh prepare
env.sh:
$(MAKE) deploy
deploy:
$(MAKE) -C deploy $@ -- $(EXTRA_ARGS)
env: SHELL:=bash
env: env.sh
@echo "Entering environment in sub-shell. Exit with 'Ctrl-d'."
@PROMPT_COMMAND='source env.sh; unset PROMPT_COMMAND' $(SHELL)
auditconf := bkc/kafl/linux_kernel_tdx_guest.config
auditlogs := smatch_warns_annotated.txt
assets := sharedir initrd.cpio.gz disk.img initrd_busybox.cpio.gz
sharedir:
+BASH_ENV=env.sh bash bkc/kafl/userspace/gen_sharedir.sh $@
initrd_buildroot.cpio.gz:
+BASH_ENV=env.sh bash bkc/kafl/userspace/gen_buildroot.sh $@
initrd_busybox.cpio.gz:
+BASH_ENV=env.sh bash bkc/kafl/userspace/gen_initrd.sh $@
initrd.cpio.gz: initrd_busybox.cpio.gz
+BASH_ENV=env.sh ln -sf $^ $@
disk.img:
qemu-img create -f qcow2 $@ 1024M
$(auditlogs): $(auditconf)
+BASH_ENV=env.sh bash bkc/audit/smatch_audit.sh . $^
prepare: env.sh
$(MAKE) $(assets) $(auditlogs)
clean:
rm -rf $(assets)
distclean: clean
$(MAKE) -C deploy -- clean
rm -f $(auditlogs)
rm -f env.sh
# Developer targets
#------------------
# pull the latest changes from all components
update:
$(MAKE) -C deploy $@ -- $(EXTRA_ARGS)
# rebuild all components
build:
$(MAKE) -C deploy $@ -- $(EXTRA_ARGS)