Makefile tuning
This commit is contained in:
parent
9ff42d8fbc
commit
e681b848d5
1 changed files with 15 additions and 5 deletions
20
makefile
20
makefile
|
@ -10,8 +10,10 @@ SIZE = ${CROSS}-size
|
||||||
TARGET = bin.elf
|
TARGET = bin.elf
|
||||||
|
|
||||||
# QEMU command and flags
|
# QEMU command and flags
|
||||||
QEMU = qemu-riscv64-static
|
# QEMU = qemu-riscv64-static
|
||||||
QEMU_FLAGS =
|
QEMU = qemu-system-riscv64
|
||||||
|
QEMU_FLAGS += --machine virt# # Use the virt machine
|
||||||
|
QEMU_FLAGS += --nographic# # No graphical output
|
||||||
|
|
||||||
# Flags for compiler and assembler
|
# Flags for compiler and assembler
|
||||||
CFLAGS += -static# # Use static linking
|
CFLAGS += -static# # Use static linking
|
||||||
|
@ -23,6 +25,13 @@ CFLAGS += -march=rv64i # Use RV64I ISA, i.e., integer only
|
||||||
CFLAGS += -mabi=lp64 # Use LP64 ABI, i.e., 64-bit longs and pointers, 32-bit ints
|
CFLAGS += -mabi=lp64 # Use LP64 ABI, i.e., 64-bit longs and pointers, 32-bit ints
|
||||||
CFLAGS += -Os# # Optimize for size
|
CFLAGS += -Os# # Optimize for size
|
||||||
|
|
||||||
|
LDFLAGS += -T link.ld # Use the linker script
|
||||||
|
LDFLAGS += --no-dynamic-linker
|
||||||
|
LDFLAGS += -m elf64lriscv
|
||||||
|
LDFLAGS += -static
|
||||||
|
LDFLAGS += -nostdlib
|
||||||
|
LDFLAGS += -s
|
||||||
|
|
||||||
# Use GC=0 to disable garbage collection
|
# Use GC=0 to disable garbage collection
|
||||||
ifneq ($(GC), 0)
|
ifneq ($(GC), 0)
|
||||||
CFLAGS += -ffreestanding
|
CFLAGS += -ffreestanding
|
||||||
|
@ -43,7 +52,7 @@ OBJS := $(AS_SRCS:.s=.o)
|
||||||
|
|
||||||
# Default target
|
# Default target
|
||||||
all: $(OBJS)
|
all: $(OBJS)
|
||||||
@$(CC) $(CFLAGS) -o $(TARGET) $(OBJS)
|
@$(LD) $(LDFLAGS) -o $(TARGET) $(OBJS)
|
||||||
@echo "LD $(OBJS)"
|
@echo "LD $(OBJS)"
|
||||||
|
|
||||||
# Compile assembly sources
|
# Compile assembly sources
|
||||||
|
@ -52,8 +61,9 @@ all: $(OBJS)
|
||||||
@echo "CC $<"
|
@echo "CC $<"
|
||||||
|
|
||||||
# Run the binary in QEMU
|
# Run the binary in QEMU
|
||||||
run: all
|
run: all
|
||||||
$(QEMU) $(QEMU_FLAGS) ./$(TARGET)
|
@echo "To exit: Ctrl+A, X"
|
||||||
|
@$(QEMU) $(QEMU_FLAGS) -bios $(TARGET)
|
||||||
|
|
||||||
# View the text section of the binary
|
# View the text section of the binary
|
||||||
inspect: all
|
inspect: all
|
||||||
|
|
Loading…
Reference in a new issue