install with install -m755
[qbe.git] / Makefile
blob8813bd67a131ff03eed058fb36b607ce4f4d65f7
1 .POSIX:
2 .SUFFIXES: .o .c
4 PREFIX = /usr/local
5 BINDIR = $(PREFIX)/bin
7 SRC = main.c util.c parse.c cfg.c mem.c ssa.c alias.c load.c copy.c \
8 fold.c live.c spill.c rega.c gas.c
9 AMD64SRC = amd64/targ.c amd64/sysv.c amd64/isel.c amd64/emit.c
10 ARM64SRC = arm64/targ.c arm64/abi.c arm64/isel.c arm64/emit.c
11 RV64SRC = rv64/targ.c rv64/abi.c rv64/isel.c rv64/emit.c
12 SRCALL = $(SRC) $(AMD64SRC) $(ARM64SRC) $(RV64SRC)
14 AMD64OBJ = $(AMD64SRC:.c=.o)
15 ARM64OBJ = $(ARM64SRC:.c=.o)
16 RV64OBJ = $(RV64SRC:.c=.o)
17 OBJ = $(SRC:.c=.o) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ)
19 CFLAGS = $(CPPFLAGS) -Wall -Wextra -std=c99 -g -Wpedantic
21 qbe: $(OBJ)
22 $(CC) $(LDFLAGS) $(OBJ) -o $@
24 .c.o:
25 $(CC) $(CFLAGS) -c $< -o $@
27 $(OBJ): all.h ops.h
28 $(AMD64OBJ): amd64/all.h
29 $(ARM64OBJ): arm64/all.h
30 $(RV64OBJ): rv64/all.h
31 main.o: config.h
33 config.h:
34 @case `uname` in \
35 *Darwin*) \
36 echo "#define Defasm Gasmacho"; \
37 echo "#define Deftgt T_amd64_sysv"; \
38 ;; \
39 *) \
40 echo "#define Defasm Gaself"; \
41 case `uname -m` in \
42 *aarch64*) \
43 echo "#define Deftgt T_arm64"; \
44 ;; \
45 *riscv64*) \
46 echo "#define Deftgt T_rv64"; \
47 ;; \
48 *) \
49 echo "#define Deftgt T_amd64_sysv";\
50 ;; \
51 esac \
52 ;; \
53 esac > $@
55 install: qbe
56 mkdir -p "$(DESTDIR)$(BINDIR)"
57 install -m755 qbe "$(DESTDIR)$(BINDIR)/qbe"
59 uninstall:
60 rm -f "$(DESTDIR)$(BINDIR)/qbe"
62 clean:
63 rm -f *.o */*.o qbe
65 clean-gen: clean
66 rm -f config.h
68 check: qbe
69 tools/test.sh all
71 check-arm64: qbe
72 TARGET=arm64 tools/test.sh all
74 check-rv64: qbe
75 TARGET=rv64 tools/test.sh all
77 src:
78 @echo $(SRCALL)
80 80:
81 @for F in $(SRCALL); \
82 do \
83 awk "{ \
84 gsub(/\\t/, \" \"); \
85 if (length(\$$0) > $@) \
86 printf(\"$$F:%d: %s\\n\", NR, \$$0); \
87 }" < $$F; \
88 done
90 .PHONY: clean clean-gen check check-arm64 src 80 install uninstall