-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
57 lines (40 loc) · 983 Bytes
/
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
.SUFFIXES:
.PHONY: clean all doc
CC := clang
CFLAGS += -std=c11
CFLAGS += -Wall -Wextra -Wpedantic
BITS ?= 32
ifeq ($(BITS),32)
CFLAGS += -m32
else
CFLAGS += -m64
endif
SOURCES := $(shell ls -1 *.c)
LL := $(SOURCES:.c=.o0.ll)
LLOPT1 := $(SOURCES:.c=.o1.ll)
LLOPT2 := $(SOURCES:.c=.o2.ll)
LLOPT3 := $(SOURCES:.c=.o3.ll)
ALL_LL := $(LL) $(LLOPT1) $(LLOPT2) $(LLOPT3)
ASM := $(SOURCES:.c=.o0.s)
ASMOPT1 := $(SOURCES:.c=.o1.s)
ASMOPT2 := $(SOURCES:.c=.o2.s)
ASMOPT3 := $(SOURCES:.c=.o3.s)
ALL_ASM := $(ASM) $(ASMOPT1) $(ASMOPT2) $(ASMOPT3)
all: $(ALL_LL) $(ALL_ASM)
%.o0.ll: %.c
$(CC) $(CFLAGS) -S -emit-llvm -O0 -o $@ $<
%.o1.ll: %.c
$(CC) $(CFLAGS) -S -emit-llvm -O1 -o $@ $<
%.o2.ll: %.c
$(CC) $(CFLAGS) -S -emit-llvm -O2 -o $@ $<
%.o3.ll: %.c
$(CC) $(CFLAGS) -S -emit-llvm -O3 -o $@ $<
%.s: %.ll
llc --x86-asm-syntax=intel -o $@ $<
%.ll: %.c
$(CC) $(CFLAGS) -S -emit-llvm -o $@ $<
clean:
rm -rf *.ll *.s *.html
doc: README.html
%.html: %.adoc
asciidoctor $<