2019-02-19 06:28:46 +08:00
|
|
|
TARGET = long_test1
|
|
|
|
|
2019-09-24 17:00:06 +08:00
|
|
|
TARGET_ARCH = riscv32
|
2019-02-19 06:28:46 +08:00
|
|
|
|
|
|
|
CC = riscv32-unknown-elf-gcc
|
|
|
|
|
|
|
|
# compiling flags here
|
|
|
|
CFLAGS = -Wall -I. -O0 -static -march=rv32imac -mabi=ilp32 --specs=nosys.specs
|
2019-09-24 17:00:06 +08:00
|
|
|
# CFLAGS = -Wall -I. -O0 -static -march=rv32imac -mabi=ilp32 --specs=nano.specs
|
2019-02-19 06:28:46 +08:00
|
|
|
|
2019-09-24 17:00:06 +08:00
|
|
|
LINKER = riscv32-unknown-elf-gcc
|
2019-02-19 06:28:46 +08:00
|
|
|
# linking flags here
|
2019-09-24 17:00:06 +08:00
|
|
|
LDFLAGS = -I. -static
|
2019-02-19 06:28:46 +08:00
|
|
|
LIBS = $(EXTRA_LIBS)
|
|
|
|
|
|
|
|
|
|
|
|
# change these to proper directories where each file should be
|
|
|
|
SRCDIR = ./
|
|
|
|
OBJDIR = .
|
|
|
|
BINDIR = ./
|
|
|
|
INCDIR = -I.
|
|
|
|
LIBDIR = -L.
|
|
|
|
|
|
|
|
|
|
|
|
SOURCES := $(wildcard $(SRCDIR)/*.c)
|
|
|
|
INCLUDES := $(wildcard $(INCDIR)/*.h)
|
|
|
|
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
|
|
|
|
|
|
|
|
rm = rm -f
|
|
|
|
|
|
|
|
|
|
|
|
$(BINDIR)/$(TARGET): $(OBJECTS)
|
2019-09-24 17:00:06 +08:00
|
|
|
$(LINKER) $(CFLAGS) $(LDFLAGS) $(LIBS) $(LIBDIR) $(OBJECTS) -o $@
|
|
|
|
riscv32-unknown-elf-objdump -d $@ > dump
|
|
|
|
riscv32-unknown-elf-objcopy -Oihex $@ $(TARGET).hex
|
|
|
|
@echo "Linking complete!"
|
2019-02-19 06:28:46 +08:00
|
|
|
|
|
|
|
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
|
|
|
|
@echo "Compiling "$<" ..."
|
2019-09-24 17:00:06 +08:00
|
|
|
$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
|
2019-02-19 06:28:46 +08:00
|
|
|
@echo "Done!"
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@$(rm) $(OBJECTS) *.hex dump
|
|
|
|
@echo "Cleanup complete!"
|
|
|
|
|
|
|
|
.PHONY: remove
|
|
|
|
remove: clean
|
|
|
|
@$(rm) $(BINDIR)/$(TARGET)
|
|
|
|
@echo "Executable removed!"
|