Makefile (1217B)
1 ARCH=wasm32 2 TARGET=${ARCH} 3 CC:=$(shell command -v clang clang-10 clang-8; true) 4 LC:=$(shell command -v llc llc-10 llc-8; true) 5 LD:=$(shell command -v wasm-ld wasm-ld-10; true) 6 7 LIBS:= 8 SRC:= 9 10 SRC+=src/supercop.c 11 12 CFLAGS?=-Wall -O2 -D__WORDSIZE=32 13 LDFLAGS?= 14 15 INCLUDES:= 16 INCLUDES+=-I src 17 18 include lib/.dep/config.mk 19 20 SRC:=$(filter-out lib/orlp/ed25519/src/seed.c, $(SRC)) 21 OBJ:=$(SRC:.c=.o) 22 LLO:=$(SRC:.c=.ll) 23 24 CFLAGS+=$(INCLUDES) 25 26 default: src/supercop.wasm.ts 27 28 .PHONY: clean 29 clean: 30 rm -rf $(OBJ) 31 rm -rf $(LLO) 32 33 %.o: %.c 34 ${CC} ${CFLAGS} \ 35 --target=${TARGET} \ 36 -emit-llvm \ 37 -fvisibility=hidden \ 38 -c \ 39 -S \ 40 -Os \ 41 -o $(@:.o=.ll) \ 42 $(@:.o=.c) || exit 1 43 $(LC) \ 44 -march=${ARCH} \ 45 -filetype=obj \ 46 -O3 \ 47 -o $@ \ 48 $(@:.o=.ll) || exit 1 49 50 supercop.wasm: $(OBJ) 51 echo $(SRC) 52 ${LD} ${LDFLAGS} \ 53 --no-entry \ 54 --import-memory \ 55 --export-dynamic \ 56 --strip-all \ 57 -o $@ \ 58 $(OBJ) || exit 1 59 60 src/supercop.wasm.ts: supercop.wasm 61 printf "// Built on " > $@ 62 LC_TIME=en_US date >> $@ 63 printf "export const binary = Buffer.from('" >> $@ 64 base64 < supercop.wasm | tr -d \\n | tr -d \\r >> $@ 65 printf "', 'base64');" >> $@