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