~mcf/cproc

ref: 0e9f74cb67f2227f888e9a127624f77d83aee270 cproc/Makefile -rw-r--r-- 2.5 KiB
0e9f74cbMichael Forney Use enum type for expr->builtin.kind 1 year, 11 months ago
                                                                                
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
.POSIX:

BACKEND=qbe

objdir=.
-include config.mk

.PHONY: all
all: $(objdir)/cc $(objdir)/cc-qbe

DRIVER_SRC=\
	driver.c\
	util.c
DRIVER_OBJ=$(DRIVER_SRC:%.c=$(objdir)/%.o)

config.h:
	@cp config.def.h $@

$(objdir)/cc: $(DRIVER_OBJ)
	$(CC) $(LDFLAGS) -o $@ $(DRIVER_OBJ)

SRC=\
	decl.c\
	eval.c\
	expr.c\
	init.c\
	main.c\
	map.c\
	pp.c\
	scan.c\
	scope.c\
	siphash.c\
	stmt.c\
	token.c\
	tree.c\
	type.c\
	util.c\
	$(BACKEND).c
OBJ=$(SRC:%.c=$(objdir)/%.o)

$(objdir)/cc-qbe: $(OBJ)
	$(CC) $(LDFLAGS) -o $@ $(OBJ)

$(objdir)/decl.o    : decl.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ decl.c
$(objdir)/driver.o  : driver.c  $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ driver.c
$(objdir)/eval.o    : eval.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ eval.c
$(objdir)/expr.o    : expr.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ expr.c
$(objdir)/init.o    : init.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ init.c
$(objdir)/main.o    : main.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ main.c
$(objdir)/map.o     : map.c     $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ map.c
$(objdir)/pp.o      : pp.c      $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ pp.c
$(objdir)/qbe.o     : qbe.c     $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ qbe.c
$(objdir)/scan.o    : scan.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ scan.c
$(objdir)/scope.o   : scope.c   $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ scope.c
$(objdir)/siphash.o : siphash.c $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ siphash.c
$(objdir)/stmt.o    : stmt.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ stmt.c
$(objdir)/token.o   : token.c   $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ token.c
$(objdir)/tree.o    : tree.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ tree.c
$(objdir)/type.o    : type.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ type.c
$(objdir)/util.o    : util.c    $(stagedeps) ; $(CC) $(CFLAGS) -c -o $@ util.c

.PHONY: stage2
stage2: all
	@mkdir -p $@
	$(MAKE) objdir=$@ stagedeps='cc cc-qbe' CC=$(objdir)/cc
	strip $@/cc $@/cc-qbe

.PHONY: stage3
stage3: stage2
	@mkdir -p $@
	$(MAKE) objdir=$@ stagedeps='stage2/cc stage2/cc-qbe' CC=$(objdir)/stage2/cc
	strip $@/cc $@/cc-qbe

.PHONY: bootstrap
bootstrap: stage2 stage3
	cmp stage2/cc stage3/cc
	cmp stage2/cc-qbe stage3/cc-qbe

.PHONY: check
check: all
	@CCQBE=./cc-qbe ./runtests

.PHONY: clean
clean:
	rm -rf cc $(DRIVER_OBJ) cc-qbe $(OBJ) stage2 stage3

deps.mk: $(DRIVER_SRC) $(SRC) config.h
	for src in $(DRIVER_SRC) $(SRC); do $(CC) $(CFLAGS) -MM -MT "\$$(objdir)/$${src%.c}.o" "$$src"; done >$@
-include deps.mk