35 lines
620 B
Makefile
35 lines
620 B
Makefile
# Compiler and assembler
|
|
CC = riscv64-linux-gnu-gcc
|
|
AS = riscv64-linux-gnu-as
|
|
LD = riscv64-linux-gnu-ld
|
|
|
|
# Flags for compiler and assembler
|
|
CFLAGS = -static -nostartfiles -nostdlib
|
|
ASFLAGS =
|
|
|
|
# QEMU command and flags
|
|
QEMU = qemu-riscv64-static
|
|
QEMU_FLAGS =
|
|
|
|
# Assembly source files
|
|
AS_SRCS := $(wildcard *.s)
|
|
|
|
# Object files
|
|
OBJS := $(AS_SRCS:.s=.o)
|
|
|
|
# Default target
|
|
all: $(OBJS)
|
|
$(LD) -o program $(OBJS)
|
|
# $(CC) $(CFLAGS) -o program $(OBJS)
|
|
|
|
# Compile assembly sources
|
|
%.o: %.s
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
# Run the program in QEMU
|
|
run: all
|
|
$(QEMU) $(QEMU_FLAGS) ./program
|
|
|
|
# Clean up
|
|
clean:
|
|
rm -f program $(OBJS)
|