-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
28 lines (18 loc) · 1.15 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
BROTLI=third_party/brotli
SYSROOT=$$HOME/opt/wasi-sdk-5.0/opt/wasi-sdk/share/sysroot
TARGET=wasm32-unknown-wasi
COMMA:=,
SOURCES=$(wildcard ${BROTLI}/c/common/*.c) $(wildcard ${BROTLI}/c/dec/*.c) \
$(wildcard ${BROTLI}/c/enc/*.c) main.o
OBJECTS=$(SOURCES:.c=.o)
EXPORTS=BrotliDecoderSetParameter BrotliDecoderCreateInstance BrotliDecoderDestroyInstance BrotliDecoderDecompress BrotliDecoderDecompressStream BrotliDecoderHasMoreOutput BrotliDecoderTakeOutput BrotliDecoderIsUsed BrotliDecoderIsFinished BrotliDecoderGetErrorCode BrotliDecoderErrorString BrotliDecoderVersion BrotliEncoderSetParameter BrotliEncoderCreateInstance BrotliEncoderDestroyInstance BrotliEncoderMaxCompressedSize BrotliEncoderCompress BrotliEncoderCompressStream BrotliEncoderIsFinished BrotliEncoderHasMoreOutput BrotliEncoderTakeOutput BrotliEncoderVersion _start malloc
EXPORT_FLAGS=$(addprefix -Wl$(COMMA)--export=,$(EXPORTS))
CFLAGS=-I${BROTLI}/c/include --sysroot $(SYSROOT) --target=$(TARGET)
.PHONY: all clean
all: brotli.wasm
clean:
rm -f brotli.wasm $(OBJECTS)
brotli.wasm: $(OBJECTS)
clang -Wl,--no-entry $(EXPORT_FLAGS) $(CFLAGS) -o $@ $^
%.o: %.c
clang $(CFLAGS) -o $@ -c $<