blob: 2433e250e4aa4d3981398aa5592f115ca21fddcf (
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
64
65
66
67
68
69
70
71
|
BIN = qbe
V = @
OBJDIR = obj
SRC = main.c util.c parse.c cfg.c mem.c ssa.c alias.c load.c copy.c \
fold.c live.c spill.c rega.c gas.c
AMD64SRC = amd64/targ.c amd64/sysv.c amd64/isel.c amd64/emit.c
SRCALL = $(SRC) $(AMD64SRC)
AMD64OBJ = $(AMD64SRC:%.c=$(OBJDIR)/%.o)
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(AMD64OBJ)
CFLAGS += -Wall -Wextra -std=c99 -g -pedantic
$(OBJDIR)/$(BIN): $(OBJ) $(OBJDIR)/timestamp
@test -z "$(V)" || echo "ld $@"
$(V)$(CC) $(LDFLAGS) $(OBJ) -o $@
$(OBJDIR)/%.o: %.c $(OBJDIR)/timestamp
@test -z "$(V)" || echo "cc $<"
$(V)$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/timestamp:
@mkdir -p $(OBJDIR)
@mkdir -p $(OBJDIR)/amd64
@touch $@
$(OBJ): all.h ops.h
$(AMD64OBJ): amd64/all.h
obj/main.o: config.h
config.h:
@case `uname` in \
*Darwin*) \
echo "#define Defasm Gasmacho"; \
echo "#define Deftgt T_amd64_sysv"; \
;; \
*) \
echo "#define Defasm Gaself"; \
echo "#define Deftgt T_amd64_sysv"; \
;; \
esac > $@
install: $(OBJDIR)/$(BIN)
mkdir -p "$(DESTDIR)/$(PREFIX)/bin/"
cp $< "$(DESTDIR)/$(PREFIX)/bin/"
uninstall:
rm -f "$(DESTDIR)/$(PREFIX)/bin/$(BIN)"
clean:
rm -fr $(OBJDIR)
clean-gen: clean
rm -f config.h
check: $(OBJDIR)/$(BIN)
tools/unit.sh all
80:
@for F in $(SRCALL); \
do \
awk "{ \
gsub(/\\t/, \" \"); \
if (length(\$$0) > $@) \
printf(\"$$F:%d: %s\\n\", NR, \$$0); \
}" < $$F; \
done
.PHONY: clean clean-gen check 80 install uninstall
|