summary refs log tree commit diff
path: root/Makefile
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2024-02-19 17:47:30 +0900
committerNguyễn Gia Phong <cnx@loang.net>2024-03-01 05:14:50 +0900
commitc9dff9cb9c9bb9ac685d59d12f7f991c30a1cd94 (patch)
tree58adb87b7d1449b47df9168475bd102694a798c6 /Makefile
parent0711a8360c18ac45756ae773a1c0e326f6de4789 (diff)
downloadroux-c9dff9cb9c9bb9ac685d59d12f7f991c30a1cd94.tar.gz
Build with Zig
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile63
1 files changed, 10 insertions, 53 deletions
diff --git a/Makefile b/Makefile
index f5e8a76..71d5065 100644
--- a/Makefile
+++ b/Makefile
@@ -4,56 +4,16 @@
 PREFIX = /usr/local
 BINDIR = $(PREFIX)/bin
 
-COMMOBJ  = main.o util.o parse.o abi.o cfg.o mem.o ssa.o alias.o load.o \
-           copy.o fold.o simpl.o live.o spill.o rega.o emit.o
-AMD64OBJ = amd64/targ.o amd64/sysv.o amd64/isel.o amd64/emit.o
-ARM64OBJ = arm64/targ.o arm64/abi.o arm64/isel.o arm64/emit.o
-RV64OBJ  = rv64/targ.o rv64/abi.o rv64/isel.o rv64/emit.o
-OBJ      = $(COMMOBJ) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ)
+COMMSRC  = main.c util.c parse.c abi.c cfg.c mem.c ssa.c alias.c load.c \
+           copy.c fold.c simpl.c live.c spill.c rega.c emit.c
+AMD64SRC = amd64/targ.c amd64/sysv.c amd64/isel.c amd64/emit.c
+ARM64SRC = arm64/targ.c arm64/abi.c arm64/isel.c arm64/emit.c
+RV64SRC  = rv64/targ.c rv64/abi.c rv64/isel.c rv64/emit.c
+SRCALL   = $(COMMSRC) $(AMD64SRC) $(ARM64SRC) $(RV64SRC)
 
-SRCALL   = $(OBJ:.o=.c)
-
-CC       = cc
-CFLAGS   = -std=c99 -g -Wall -Wextra -Wpedantic
-
-qbe: $(OBJ)
-	$(CC) $(LDFLAGS) $(OBJ) -o $@
-
-.c.o:
-	$(CC) $(CFLAGS) -c $< -o $@
-
-$(OBJ): all.h ops.h
-$(AMD64OBJ): amd64/all.h
-$(ARM64OBJ): arm64/all.h
-$(RV64OBJ): rv64/all.h
-main.o: config.h
-
-config.h:
-	@case `uname` in                               \
-	*Darwin*)                                      \
-		case `uname -m` in                     \
-		*arm64*)                               \
-			echo "#define Deftgt T_arm64_apple";\
-			;;                             \
-		*)                                     \
-			echo "#define Deftgt T_amd64_apple";\
-			;;                             \
-		esac                                   \
-		;;                                     \
-	*)                                             \
-		case `uname -m` in                     \
-		*aarch64*|*arm64*)                     \
-			echo "#define Deftgt T_arm64"; \
-			;;                             \
-		*riscv64*)                             \
-			echo "#define Deftgt T_rv64";  \
-			;;                             \
-		*)                                     \
-			echo "#define Deftgt T_amd64_sysv";\
-			;;                             \
-		esac                                   \
-		;;                                     \
-	esac > $@
+qbe: $(SRCALL) all.h ops.h amd64/all.h arm64/all.h rv64/all.h
+	zig build
+	ln -fs zig-out/bin/qbe qbe
 
 install: qbe
 	mkdir -p "$(DESTDIR)$(BINDIR)"
@@ -63,10 +23,7 @@ uninstall:
 	rm -f "$(DESTDIR)$(BINDIR)/qbe"
 
 clean:
-	rm -f *.o */*.o qbe
-
-clean-gen: clean
-	rm -f config.h
+	rm -fr qbe zig-cache zig-out
 
 check: qbe
 	tools/test.sh all