45 lines
873 B
Makefile
45 lines
873 B
Makefile
CC = arm-none-eabi-gcc
|
|
AS = arm-none-eabi-as
|
|
LD = arm-none-eabi-ld
|
|
CPU = -mcpu=cortex-m4
|
|
THUMB = -mthumb
|
|
|
|
LDFLAGS = -T linker.ld
|
|
CFLAGS = $(CPU) $(THUMB) -I libc/
|
|
|
|
QEMU = qemu-system-arm
|
|
BOARD = netduino2
|
|
|
|
# Output file
|
|
TARGET = main.elf
|
|
# Source files
|
|
SRCS = os/main.c os/process.c os/scheduler.c os/alloc.c libc/library.c tasks/tasks.c
|
|
# Object files
|
|
OBJS = $(SRCS:.c=.o)
|
|
|
|
debug: CFLAGS += -g
|
|
debug: all
|
|
|
|
run: debug
|
|
$(QEMU) -M $(BOARD) -nographic -kernel $(TARGET)
|
|
|
|
gdb: debug
|
|
$(QEMU) -M $(BOARD) -nographic -kernel $(TARGET) -s -S
|
|
|
|
# Default target to build the ELF file
|
|
all: $(TARGET)
|
|
|
|
$(TARGET): $(OBJS) startup.o
|
|
$(LD) $(LDFLAGS) startup.o $(OBJS) -o $(TARGET)
|
|
|
|
startup.o: startup.s
|
|
$(AS) $(CPU) -g startup.s -o startup.o
|
|
|
|
# Rule to compile source files into object files
|
|
%.o: %.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
clean:
|
|
rm -f *.elf *.o *.i
|
|
rm -f os/*.o tasks/*.o
|