risc-v-tlm/tests/C/func1/Makefile

51 lines
1.0 KiB
Makefile
Raw Normal View History

2018-10-07 04:19:29 +08:00
TARGET = func1
TARGET_ARCH=riscv32
2019-01-10 06:03:08 +08:00
CC = riscv32-unknown-elf-gcc
2018-10-07 04:19:29 +08:00
# compiling flags here
2019-01-10 06:03:08 +08:00
CFLAGS = -Wall -L. -O0 -g -static
2018-10-07 04:19:29 +08:00
LINKER = riscv32-unknown-linux-gnu-gcc
# linking flags here
LFLAGS = -I. --entry main
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)
# $(LINKER) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
riscv32-unknown-linux-gnu-objdump -d $< > dump
objcopy -Oihex $< $(TARGET).hex
# @echo "Linking complete!"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@echo "Compiling "$<" ..."
# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
$(CC) $(CFLAGS) $(INCDIR) $< -o $@
@echo "Done!"
.PHONY: clean
clean:
@$(rm) $(OBJECTS)
@echo "Cleanup complete!"
.PHONY: remove
remove: clean
@$(rm) $(BINDIR)/$(TARGET)
@echo "Executable removed!"