aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile
blob: c377d62cacad163d6d4f9c643ff545e6677649ae (plain) (blame)
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
60
61
62
63
OUT?=antcc
BUILDDIR?=build
SRC=main.c io.c mem.c c/c.c c/lex.c c/eval.c c/builtin.c type.c targ.c \
	ir/ir.c ir/builder.c ir/fold.c ir/dump.c ir/ssa.c ir/cfg.c ir/intrin.c ir/abi0.c ir/mem2reg.c ir/regalloc.c ir/simpl.c ir/stack.c \
	ir/cse.c ir/inliner.c \
	x86_64/sysv.c x86_64/isel.c x86_64/emit.c \
	aarch64/aapcs.c aarch64/isel.c aarch64/emit.c \
	obj/obj.c obj/elf.c \
	embedfilesdir.c
OBJ=$(patsubst %.c,build/%.o,$(SRC))
DEP=$(OBJ:.o=.d)

CFLAGS=-Wall -std=c11 -pedantic
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin

-include config.mk

HOSTCC ?= $(CC)

ifdef V
	V=
else
	V=@
endif

all: CFLAGS += -g -Og
all: $(OUT)

opt: CFLAGS += -g -O2
opt: $(OUT)

dbg: CFLAGS += -g -fsanitize=address,undefined
dbg: CC:=clang
dbg: $(OUT)

tool/depgen: tool/depgen.c
	$(CC) -Wall -g -o $@ $<

$(OUT): tool/depgen $(OBJ)
	$(CC) $(CFLAGS) -o $@ $(OBJ)

hostconfig.h:
	./configure

$(BUILDDIR)/%.o: %.c hostconfig.h
	$Vmkdir -p `dirname $@`
	$Vtool/depgen -MP -MF $(BUILDDIR)/$*.d -MT $@ $<
	$(CC) $(CFLAGS) -c -o $@ $<

clean:
	$(RM) -r -- $(BUILDDIR)/ test/build/ $(OUT) *.o a.out tool/depgen

clean-config: clean
	$(RM) -r config.mk hostconfig.h

install: all
	@mkdir -p "$(DESTDIR)$(BINDIR)"
	install -m755 $(OUT) -T "$(DESTDIR)$(BINDIR)/antcc"

.PHONY: clean clean-config install

-include $(DEP)