OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [examples/] [isrdemo/] [makefiles/] [make_example] - Rev 5

Compare with Previous | Blame | View Log

include util.mak

CC=riscv64-unknown-elf-gcc
CPP=riscv64-unknown-elf-gcc
OBJDUMP=riscv64-unknown-elf-objdump

CFLAGS= -c -fPIC -g -O2
LDFLAGS=-static -T app.ld -nostartfiles
INCL_KEY=-I
DIR_KEY=-B


# include sub-folders list
INCL_PATH=\
        $(TOP_DIR)common \
        $(TOP_DIR)isrdemo/src

# source files directories list:
SRC_PATH = \
        $(TOP_DIR)isrdemo/src

LIB_NAMES = \
        gcc \
        stdc++ \
        c \
        m

VPATH = $(SRC_PATH)

SOURCES = \
        main \
        isr_example \
        helloworld

OBJ_FILES = $(addsuffix .o,$(SOURCES))
EXECUTABLE = isrdemo
DUMPFILE = $(EXECUTABLE).dump
HEXFILE = $(EXECUTABLE).hex

all: example

.PHONY: $(EXECUTABLE)


example: $(HEXFILE) $(EXECUTABLE) $(DUMPFILE)

$(HEXFILE): $(EXECUTABLE)
        echo elf2raw64 $(addprefix $(ELF_DIR)/,$<) -h -f 262144 -o $(addprefix $(ELF_DIR)/,$(EXECUTABLE).hex)
        elf2raw64 $(addprefix $(ELF_DIR)/,$<) -h -f 262144 -l 8 -o $(addprefix $(ELF_DIR)/,$(EXECUTABLE).hex)

$(EXECUTABLE): $(OBJ_FILES)
        echo $(CPP) $(LDFLAGS) $(addprefix $(OBJ_DIR)/,$(OBJ_FILES)) -o $(addprefix $(ELF_DIR)/,$@) $(addprefix -l,$(LIB_NAMES))
        $(CPP) $(LDFLAGS) $(addprefix $(OBJ_DIR)/,$(OBJ_FILES)) -o $(addprefix $(ELF_DIR)/,$@) $(addprefix -l,$(LIB_NAMES))
        $(ECHO) "\n  helloworld has been built successfully.\n"

$(DUMPFILE): $(EXECUTABLE)
        echo $(OBJDUMP) --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data $(addprefix $(ELF_DIR)/,$<) > $(addprefix $(ELF_DIR)/,$@)
        $(OBJDUMP) --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data $(addprefix $(ELF_DIR)/,$<) > $(addprefix $(ELF_DIR)/,$@)

%.o: %.cpp
        echo $(CPP) $(CFLAGS) $(addprefix $(INCL_KEY),$(INCL_PATH)) $< -o $(addprefix $(OBJ_DIR)/,$@)
        $(CPP) $(CFLAGS) $(addprefix $(INCL_KEY),$(INCL_PATH)) $< -o $(addprefix $(OBJ_DIR)/,$@)

%.o: %.c
        echo $(CC) $(CFLAGS) $(addprefix $(INCL_KEY),$(INCL_PATH)) $< -o $(addprefix $(OBJ_DIR)/,$@)
        $(CC) $(CFLAGS) $(addprefix $(INCL_KEY),$(INCL_PATH)) $< -o $(addprefix $(OBJ_DIR)/,$@)

%.o: %.S
        echo $(CC) $(CFLAGS) -D__ASSEMBLY__=1 $(addprefix $(INCL_KEY),$(INCL_PATH)) $< -o $(addprefix $(OBJ_DIR)/,$@)
        $(CC) $(CFLAGS) -D__ASSEMBLY__=1 $(addprefix $(INCL_KEY),$(INCL_PATH)) $< -o $(addprefix $(OBJ_DIR)/,$@)


Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.