2025-05-31 14:57:37 -04:00
|
|
|
# Arch Linux s390x Port - Makefile
|
|
|
|
|
|
2025-06-02 09:21:38 -04:00
|
|
|
# Output directories
|
|
|
|
|
OUTPUT_DIR := output
|
|
|
|
|
BOOT_DIR := boot
|
|
|
|
|
|
|
|
|
|
# Output files
|
2025-06-02 15:52:32 -04:00
|
|
|
KERNEL := $(OUTPUT_DIR)/vmlinuz-6.6.10-s390x-arch
|
2025-06-02 09:21:38 -04:00
|
|
|
INITRAMFS := $(OUTPUT_DIR)/initramfs-6.6.10-s390x.img
|
|
|
|
|
BUSYBOX := $(BOOT_DIR)/busybox-s390x-native
|
|
|
|
|
BOOT_KERNEL := $(BOOT_DIR)/vmlinuz-linux
|
|
|
|
|
BOOT_INITRAMFS := $(BOOT_DIR)/initramfs-linux.img
|
|
|
|
|
|
2025-06-02 16:58:16 -04:00
|
|
|
.PHONY: all kernel build-busybox busybox initramfs boot test test-rootfs test-systemd clean help container systemd-zvm systemd
|
2025-05-31 14:57:37 -04:00
|
|
|
|
|
|
|
|
# Default target
|
2025-06-02 09:21:38 -04:00
|
|
|
all: boot
|
2025-05-31 14:57:37 -04:00
|
|
|
|
2025-06-02 15:52:32 -04:00
|
|
|
# Build Arch Linux kernel with patches
|
2025-06-02 09:21:38 -04:00
|
|
|
$(KERNEL): | $(OUTPUT_DIR)
|
2025-06-02 15:52:32 -04:00
|
|
|
@echo "Building Arch Linux kernel for s390x..."
|
|
|
|
|
@./scripts/build-arch-kernel.sh
|
2025-06-02 09:21:38 -04:00
|
|
|
|
|
|
|
|
kernel: $(KERNEL)
|
|
|
|
|
|
|
|
|
|
# Build static busybox on z/VM (manual process)
|
|
|
|
|
build-busybox: | $(BOOT_DIR)
|
|
|
|
|
@if [ ! -f "$(BOOT_DIR)/busybox-s390x-static" ]; then \
|
|
|
|
|
echo "❌ ERROR: Static busybox not found!"; \
|
|
|
|
|
echo ""; \
|
|
|
|
|
echo "To build busybox, you must:"; \
|
|
|
|
|
echo "1. SSH into z/VM: ssh -i zvm.pem -o StrictHostKeyChecking=no linux1@148.100.77.9"; \
|
|
|
|
|
echo "2. Run the build script: ./scripts/build-busybox-zvm.sh"; \
|
|
|
|
|
echo "3. Transfer the resulting busybox binary back to: $(BOOT_DIR)/busybox-s390x-static"; \
|
|
|
|
|
echo ""; \
|
|
|
|
|
echo "The busybox MUST be built natively on s390x hardware for proper static linking."; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
else \
|
|
|
|
|
echo "✅ Static busybox already exists at $(BOOT_DIR)/busybox-s390x-static"; \
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Download busybox fallback (deprecated - use z/VM build)
|
|
|
|
|
download-busybox: | $(OUTPUT_DIR)
|
|
|
|
|
@echo "❌ Dynamic busybox download is deprecated"
|
|
|
|
|
@echo "Use z/VM static compilation instead:"
|
|
|
|
|
@echo " ssh -i zvm.pem linux1@148.100.77.9"
|
|
|
|
|
@echo " # Follow build-busybox-zvm.sh instructions"
|
|
|
|
|
@exit 1
|
|
|
|
|
|
|
|
|
|
# Check busybox binary (prefers static build)
|
|
|
|
|
$(BUSYBOX): | build-busybox
|
|
|
|
|
@if [ -f "$(BOOT_DIR)/busybox-s390x-static" ]; then \
|
|
|
|
|
ln -sf busybox-s390x-static $(BUSYBOX); \
|
|
|
|
|
echo "✅ Using static busybox"; \
|
|
|
|
|
elif [ -f "$(BUSYBOX)" ]; then \
|
|
|
|
|
echo "✅ Using existing busybox"; \
|
|
|
|
|
else \
|
|
|
|
|
echo "ERROR: No busybox binary found"; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
2025-05-31 14:57:37 -04:00
|
|
|
|
2025-06-02 09:21:38 -04:00
|
|
|
busybox: $(BUSYBOX)
|
|
|
|
|
|
|
|
|
|
# Build initramfs (depends on busybox)
|
|
|
|
|
$(INITRAMFS): $(BUSYBOX) | $(OUTPUT_DIR)
|
2025-05-31 14:57:37 -04:00
|
|
|
@echo "Building initramfs with mkinitcpio..."
|
2025-06-02 09:21:38 -04:00
|
|
|
@./scripts/build-initramfs-final.sh
|
|
|
|
|
|
|
|
|
|
initramfs: $(INITRAMFS)
|
2025-05-31 14:57:37 -04:00
|
|
|
|
2025-06-02 09:21:38 -04:00
|
|
|
# Prepare boot files (depends on kernel and initramfs)
|
|
|
|
|
boot: $(KERNEL) $(INITRAMFS) | boot-dir
|
2025-05-31 14:57:37 -04:00
|
|
|
@echo "Preparing boot directory..."
|
|
|
|
|
@./scripts/prepare-boot.sh
|
|
|
|
|
|
2025-06-02 09:21:38 -04:00
|
|
|
# Build container if needed
|
|
|
|
|
container:
|
|
|
|
|
@echo "Building s390x-archlinux-dev container..."
|
|
|
|
|
@./scripts/build-container.sh
|
|
|
|
|
|
|
|
|
|
# Test with QEMU (assumes boot files already exist)
|
2025-05-31 14:57:37 -04:00
|
|
|
test:
|
2025-06-02 09:21:38 -04:00
|
|
|
@if [ ! -f "$(BOOT_DIR)/vmlinuz-linux" ] || [ ! -f "$(BOOT_DIR)/initramfs-linux.img" ]; then \
|
|
|
|
|
echo "Error: Boot files not found. Run 'make all' first"; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
2025-05-31 14:57:37 -04:00
|
|
|
@echo "Testing s390x system with QEMU..."
|
|
|
|
|
@./scripts/run-qemu-initramfs-only.sh
|
|
|
|
|
|
2025-06-02 09:21:38 -04:00
|
|
|
# Test with root filesystem (creates minimal rootfs and boots to it)
|
|
|
|
|
test-rootfs:
|
|
|
|
|
@if [ ! -f "$(BOOT_DIR)/vmlinuz-linux" ] || [ ! -f "$(BOOT_DIR)/initramfs-linux.img" ]; then \
|
|
|
|
|
echo "Error: Boot files not found. Run 'make all' first"; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
|
|
|
|
@echo "Testing s390x system with root filesystem..."
|
|
|
|
|
@./scripts/test-qemu-rootfs.sh
|
|
|
|
|
|
2025-06-02 16:58:16 -04:00
|
|
|
# Test with systemd as init
|
|
|
|
|
test-systemd:
|
|
|
|
|
@if [ ! -f "$(BOOT_DIR)/vmlinuz-linux" ] || [ ! -f "$(BOOT_DIR)/initramfs-linux.img" ]; then \
|
|
|
|
|
echo "Error: Boot files not found. Run 'make all' first"; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
|
|
|
|
@if [ ! -d "output/systemd-root" ]; then \
|
|
|
|
|
echo "Error: Systemd not found. Run 'make systemd' first"; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
|
|
|
|
@echo "Testing s390x system with systemd..."
|
|
|
|
|
@./scripts/test-qemu-systemd.sh
|
|
|
|
|
|
2025-06-02 09:21:38 -04:00
|
|
|
# Create directories
|
|
|
|
|
$(OUTPUT_DIR):
|
|
|
|
|
@mkdir -p $@
|
|
|
|
|
|
|
|
|
|
boot-dir:
|
|
|
|
|
@mkdir -p $(BOOT_DIR)
|
|
|
|
|
|
2025-06-02 16:58:16 -04:00
|
|
|
# Build systemd on z/VM (native s390x compilation)
|
|
|
|
|
systemd-zvm:
|
|
|
|
|
@echo "Building systemd on z/VM..."
|
|
|
|
|
@./scripts/deploy-and-build-systemd-zvm.sh
|
|
|
|
|
|
|
|
|
|
# Build systemd (alias for z/VM build)
|
|
|
|
|
systemd: systemd-zvm
|
|
|
|
|
|
2025-05-31 14:57:37 -04:00
|
|
|
# Clean build artifacts
|
|
|
|
|
clean:
|
|
|
|
|
@echo "Cleaning build artifacts..."
|
2025-06-02 09:21:38 -04:00
|
|
|
@rm -rf $(OUTPUT_DIR)/*
|
|
|
|
|
@rm -f $(BOOT_KERNEL) $(BOOT_INITRAMFS)
|
2025-05-31 14:57:37 -04:00
|
|
|
@echo "Clean complete."
|
|
|
|
|
|
|
|
|
|
# Show help
|
|
|
|
|
help:
|
|
|
|
|
@echo "Arch Linux s390x Port - Build System"
|
|
|
|
|
@echo ""
|
|
|
|
|
@echo "Usage: make [target]"
|
|
|
|
|
@echo ""
|
|
|
|
|
@echo "Targets:"
|
2025-06-02 09:21:38 -04:00
|
|
|
@echo " all - Build everything (kernel + initramfs + boot)"
|
2025-06-02 15:52:32 -04:00
|
|
|
@echo " kernel - Build Arch Linux kernel with patches for s390x"
|
2025-06-02 09:21:38 -04:00
|
|
|
@echo " build-busybox - Check for static s390x busybox (must be built on z/VM)"
|
|
|
|
|
@echo " busybox - Check s390x busybox binary exists"
|
|
|
|
|
@echo " initramfs - Build initramfs only (requires busybox)"
|
|
|
|
|
@echo " boot - Prepare boot directory"
|
|
|
|
|
@echo " container - Build development container"
|
|
|
|
|
@echo " test - Test with QEMU s390x emulation (initramfs only)"
|
|
|
|
|
@echo " test-rootfs - Test with QEMU and minimal root filesystem"
|
2025-06-02 16:58:16 -04:00
|
|
|
@echo " test-systemd - Test with QEMU and systemd as init"
|
|
|
|
|
@echo " systemd - Build minimal systemd on z/VM (native s390x)"
|
|
|
|
|
@echo " systemd-zvm - Build minimal systemd on z/VM (native s390x)"
|
2025-06-02 09:21:38 -04:00
|
|
|
@echo " clean - Remove build artifacts"
|
|
|
|
|
@echo " help - Show this help message"
|
2025-05-31 14:57:37 -04:00
|
|
|
@echo ""
|
|
|
|
|
@echo "Quick start:"
|
2025-06-02 09:21:38 -04:00
|
|
|
@echo " make container - Build development container (first time only)"
|
|
|
|
|
@echo " make all - Build complete system"
|
|
|
|
|
@echo " make test - Test the built system"
|