add asm diffing in test script
[qbe.git] / Makefile
blob1a0074f67cc606ffb3bf9bf6b66eee3007afe3b3
1 BIN = qbe
3 V = @
4 OBJDIR = obj
6 SRC = main.c util.c parse.c cfg.c mem.c ssa.c alias.c load.c copy.c \
7 fold.c live.c spill.c rega.c gas.c
8 AMD64SRC = amd64/targ.c amd64/sysv.c amd64/isel.c amd64/emit.c
9 ARM64SRC = arm64/targ.c arm64/abi.c arm64/isel.c arm64/emit.c
10 SRCALL = $(SRC) $(AMD64SRC) $(ARM64SRC)
12 AMD64OBJ = $(AMD64SRC:%.c=$(OBJDIR)/%.o)
13 ARM64OBJ = $(ARM64SRC:%.c=$(OBJDIR)/%.o)
14 OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(AMD64OBJ) $(ARM64OBJ)
16 CFLAGS += -Wall -Wextra -std=c99 -g -pedantic
18 $(OBJDIR)/$(BIN): $(OBJ) $(OBJDIR)/timestamp
19 @test -z "$(V)" || echo "ld $@"
20 $(V)$(CC) $(LDFLAGS) $(OBJ) -o $@
22 $(OBJDIR)/%.o: %.c $(OBJDIR)/timestamp
23 @test -z "$(V)" || echo "cc $<"
24 $(V)$(CC) $(CFLAGS) -c $< -o $@
26 $(OBJDIR)/timestamp:
27 @mkdir -p $(OBJDIR)
28 @mkdir -p $(OBJDIR)/amd64
29 @mkdir -p $(OBJDIR)/arm64
30 @touch $@
32 $(OBJ): all.h ops.h
33 $(AMD64OBJ): amd64/all.h
34 $(ARM64OBJ): arm64/all.h
35 $(OBJDIR)/main.o: config.h
37 config.h:
38 @case `uname` in \
39 *Darwin*) \
40 echo "#define Defasm Gasmacho"; \
41 echo "#define Deftgt T_amd64_sysv"; \
42 ;; \
43 *) \
44 echo "#define Defasm Gaself"; \
45 case `uname -m` in \
46 *aarch64*) \
47 echo "#define Deftgt T_arm64"; \
48 ;; \
49 *) \
50 echo "#define Deftgt T_amd64_sysv";\
51 ;; \
52 esac \
53 ;; \
54 esac > $@
56 install: $(OBJDIR)/$(BIN)
57 mkdir -p "$(DESTDIR)/$(PREFIX)/bin/"
58 cp $< "$(DESTDIR)/$(PREFIX)/bin/"
60 uninstall:
61 rm -f "$(DESTDIR)/$(PREFIX)/bin/$(BIN)"
63 clean:
64 rm -fr $(OBJDIR)
66 clean-gen: clean
67 rm -f config.h
69 check: $(OBJDIR)/$(BIN)
70 tools/test.sh all
72 check-arm64: $(OBJDIR)/$(BIN)
73 TARGET=arm64 tools/test.sh all
75 src:
76 @echo $(SRCALL)
78 80:
79 @for F in $(SRCALL); \
80 do \
81 awk "{ \
82 gsub(/\\t/, \" \"); \
83 if (length(\$$0) > $@) \
84 printf(\"$$F:%d: %s\\n\", NR, \$$0); \
85 }" < $$F; \
86 done
88 .PHONY: clean clean-gen check check-arm64 src 80 install uninstall