diff mbox series

[bug#53833] gnu: patches: Add qbe-makefile-add-target.patch.

Message ID 20220507171104.13861-1-paren@disroot.org
State Accepted
Headers show
Series [bug#53833] gnu: patches: Add qbe-makefile-add-target.patch. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

\( May 7, 2022, 5:11 p.m. UTC
* gnu/packages/patches/qbe-makefile-add-target.patch: New variable.

Signed-off-by: (unmatched-parenthesis <paren@disroot.org>
---
 .../patches/qbe-makefile-add-target.patch     | 56 +++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 gnu/packages/patches/qbe-makefile-add-target.patch
diff mbox series

Patch

diff --git a/gnu/packages/patches/qbe-makefile-add-target.patch b/gnu/packages/patches/qbe-makefile-add-target.patch
new file mode 100644
index 0000000000..e87559c3fa
--- /dev/null
+++ b/gnu/packages/patches/qbe-makefile-add-target.patch
@@ -0,0 +1,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/"