-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
59 lines (44 loc) · 1.75 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
OBJCOPY ?= llvm-objcopy
P := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
LIBDIR ?= $(P)/../tkey-libs
CC = clang
INCLUDE=$(LIBDIR)/include
# If you want the qemu_*() functions to print stuff on the QEMU debug port, add
# -DQEMU_DEBUG to these flags. Do this also in $(LIBDIR)/Makefile before
# building there.
CFLAGS = -target riscv32-unknown-none-elf -march=rv32iczmmul -mabi=ilp32 -mcmodel=medany \
-static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf \
-fno-builtin-putchar -nostdlib -mno-relax -flto -g \
-Wall -Werror=implicit-function-declaration \
-I $(INCLUDE) -I $(LIBDIR)
LDFLAGS=-T $(LIBDIR)/app.lds -L $(LIBDIR) -lcrt0 -lcommon
.PHONY: all
all: x25519/app.bin check-x25519-hash
show-%-hash: %/app.bin
cd $$(dirname $^) && sha512sum app.bin
check-x25519-hash:
@(cd x25519; echo "file:$$(pwd)/app.bin hash:$$(sha512sum app.bin | cut -c1-16)… expected:$$(cut -c1-16 <app.bin.sha512)…"; sha512sum -cw app.bin.sha512)
x25519/app.bin: x25519/app.elf
$(OBJCOPY) --input-target=elf32-littleriscv --output-target=binary $^ $@
chmod a-x $@
X25519OBJS=x25519/main.o x25519/app_proto.o
x25519/app.elf: $(X25519OBJS)
$(CC) $(CFLAGS) $(X25519OBJS) $(LDFLAGS) -L $(LIBDIR)/monocypher -lmonocypher -I $(LIBDIR) -o $@
$(X25519OBJS): x25519/app_proto.h
# .PHONY to let go-build handle deps and rebuilds
.PHONY: testx25519
testx25519:
cp -af x25519/app.bin ./cmd/testx25519/
go build ./cmd/testx25519
.PHONY: clean
clean:
rm -f x25519/app.bin x25519/app.elf $(X25519OBJS) testx25519
# Uses ../.clang-format
FMTFILES=x25519/*.[ch]
.PHONY: fmt
fmt:
clang-format --dry-run --ferror-limit=0 $(FMTFILES)
clang-format --verbose -i $(FMTFILES)
.PHONY: checkfmt
checkfmt:
clang-format --dry-run --ferror-limit=0 --Werror $(FMTFILES)