11# 用户指定的架构,默认使用 `x86_64`,可选 `x86_64`,`arm64`
2- ARCH ?= arm64
2+ ARCH ?= x86_64
33VALID_ARCHS := x86_64 arm64
44ifneq ($(filter $(ARCH ) ,$(VALID_ARCHS ) ) ,)
55ARCH := $(ARCH )
3939DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJ_DIR ) /$* .d
4040
4141# 路径配置
42- BIN := bin
42+ BINARY := bin
4343SRC_DIR := usr-code
4444BIN_DIR := rootfs/bin
4545OBJ_DIR := usr-code/obj
@@ -91,7 +91,7 @@ $(addprefix build-,$(PROJECTS)): build-%:
9191initramfs : $(TARGET )
9292 @echo " ===== 生成 initramfs (ARCH=$( ARCH) ) ====="
9393 @mkdir -p $(BUILD_DIR ) initramfs/bin
94- @cp $(BIN ) /busybox/busybox-$(ARCH ) initramfs/bin/busybox
94+ @cp $(BINARY ) /busybox/busybox-$(ARCH ) initramfs/bin/busybox
9595 cd initramfs && find . -print0 | cpio --null -ov --format=newc | gzip -9 \
9696 > ../$(BUILD_DIR ) /initramfs.cpio.gz
9797 @echo " ===== initramfs 已成功生成至 $( BUILD_DIR) /initramfs.cpio.gz ====="
@@ -118,14 +118,14 @@ run-bridge:
118118 echo "[SUCCESS] 网桥 br0 创建成功"; \
119119 sleep 3; \
120120 fi
121- sudo sh -c "bash ./tools/run-qemu.sh --display nographic --bios legacy --bridge --ext4"
121+ sudo sh -c "bash ./tools/run-qemu.sh --arch $(ARCH) -- display nographic --bios legacy --bridge --ext4"
122122
123123# # sudo ln ~/linux/vmlinuz_debug ~/path/to/Linux-minimal/bin/vmlinuz/vmlinuz_my4debug-ln
124124# gdb bin/vmlinuz/vmlinuz_my4debug-ln -ex 'target remote localhost:1234'
125125# (gdb) info r # CPU RESET
126126# (gdb) b *0x1000000
127127debug :
128- sh -c " bash ./tools/run-qemu.sh --display nographic --ext4 --debug"
128+ sh -c " bash ./tools/run-qemu.sh --arch $( ARCH ) -- display nographic --ext4 --debug"
129129
130130bridge :
131131 sudo ./tools/bridge-setup.sh
@@ -148,7 +148,7 @@ clean:
148148 @echo " ===== 清理完成 ====="
149149
150150info :
151- @echo " 当前架构: $( ARCH) "
151+ @echo " 当前架构: $( ARCH) "
152152 @echo " 当前shell: $( MYSHELL_SRC_DIR) "
153153
154154help :
@@ -162,4 +162,5 @@ help:
162162 @echo " make run-nographic 启动 QEMU (无图形界面)"
163163 @echo " make run-bridge 检测并创建 br0 网桥后启动 QEMU"
164164 @echo " make debug 启动 QEMU 内核调试模式"
165- @echo " make clean 清理构建文件"
165+ @echo " make clean 清理构建文件"
166+ @echo " make ARCH=arm64 build && make ARCH=arm64 run-nographic 手动指定架构"
0 commit comments