-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (38 loc) · 1.47 KB
/
Makefile
File metadata and controls
46 lines (38 loc) · 1.47 KB
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
# CC = clang
CFLAGS ?= -Wall -Wextra -Wstrict-aliasing=2 -Wno-override-init -std=c99 -ggdb
# -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -fno-optimize-sibling-calls
LDFLAGS ?=
.PHONY: all
all: examples
.PHONY: examples
examples: examples/01_dynamic_array \
examples/01_inline_dynamic_array \
examples/02_hashmap \
examples/02_inline_hashmap \
examples/03_arena \
examples/03_arena.wasm \
examples/04_cat \
examples/05_ls
examples/%: examples/%.c extlib.h
$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
examples/03_arena.wasm: examples/03_arena.c extlib.h
clang $(CFLAGS) \
-std=c99 -fno-builtin --target=wasm32 --no-standard-libraries \
-Wl,--no-entry \
-Wl,--allow-undefined \
-Wl,--export=eval_expr \
-Wl,--export=ext_temp_alloc \
-Wl,--export=ext_temp_reset \
$< -o $@
.PHONY: test
test: test/test
./test/test
test/test: ./test/test.c ./test/ctest.h extlib.h
$(CC) $(CFLAGS) -Wno-attributes -Wno-pragmas -std=c99 $(LDFLAGS) -I./test/ ./test/test.c -o test/test
.PHONY: clean
clean:
rm -rf test/test
find ./examples -type f -executable -exec rm {} \;
.PHONY: format
format:
find . -type f -iname '*.[ch]' -exec clang-format -i {} \;