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
| | This patch modifies the QBE makefile to add a TARGET variable that allows us to support
cross-compiling it. We modify the case...esac in the config.h target to use this variable
instead of TARGET.
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,8 @@ OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ)
CFLAGS += -Wall -Wextra -std=c99 -g -pedantic
+TARGET = unknown
+
$(OBJDIR)/$(BIN): $(OBJ) $(OBJDIR)/timestamp
@test -z "$(V)" || echo "ld $@"
$(V)$(CC) $(LDFLAGS) $(OBJ) -o $@
@@ -39,26 +41,21 @@ $(RV64OBJ): rv64/all.h
$(OBJDIR)/main.o: config.h
config.h:
- @case `uname` in \
- *Darwin*) \
- echo "#define Defasm Gasmacho"; \
- echo "#define Deftgt T_amd64_sysv"; \
- ;; \
- *) \
- echo "#define Defasm Gaself"; \
- case `uname -m` in \
- *aarch64*) \
- echo "#define Deftgt T_arm64"; \
- ;; \
- *riscv64*) \
- echo "#define Deftgt T_rv64"; \
- ;; \
- *) \
- echo "#define Deftgt T_amd64_sysv";\
- ;; \
- esac \
- ;; \
- esac > $@
+ @echo "#define Defasm Gaself" >> $@
+ @case $(TARGET) in \
+ *x86_64*) \
+ echo "#define Deftgt T_amd64_sysv"; \
+ ;; \
+ *aarch64*) \
+ echo "#define Deftgt T_arm64"; \
+ ;; \
+ *riscv64*) \
+ echo "#define Deftgt T_rv64"; \
+ ;; \
+ *) \
+ echo "#error target not set to x86_64, aarch64, or riscv64 in makefile"; \
+ ;; \
+ esac >> $@
install: $(OBJDIR)/$(BIN)
mkdir -p "$(DESTDIR)/$(PREFIX)/bin/"
|