Skip to content

Commit

Permalink
build:fix makefiles, add boot target to root makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
saursin committed Oct 15, 2023
1 parent 0b89785 commit d9bfafd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
30 changes: 23 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ include common.mk
soctarget ?= atombones

# Directories
sim_dir := sim
scar_dir := test/scar
elfdump_dir := tools/elfdump
lib_dir := sw/lib
doxy_dir := sim/docs
sim_dir := sim
scar_dir := test/scar
elfdump_dir := tools/elfdump
bootloader_dir := sw/bootloader
lib_dir := sw/lib
doxy_dir := sim/docs

# Flags to the makefiles
MKFLAGS := -s
Expand All @@ -46,12 +47,13 @@ endif
# Recepies
#======================================================================

default: sim lib ## Build sim, elfdump, and libs
default: sim lib boot ## Build sim, elfdump, and libs
@printf "\n$(CLR_GR)==============================\n"
@printf " Build Succesful!\n"
@printf "==============================$(CLR_NC)\n"
@printf " - atomsim [$(soctarget)]\n"
@printf " - software libraries\n"
@printf " - bootloader [$(soctarget)]\n"

all : doxy-pdf default ## Build default with docs
@printf " - doxygen-docs in latex, html & pdf\n"
Expand Down Expand Up @@ -93,6 +95,20 @@ clean-sim: ## Clean atomsim build files
test: ## Test the build using banner example
cd sw/examples && make ex=banner sim=true clean compile run


# ======== Bootloader ========
.PHONY : boot
boot: ## Build bootloader for given target [default: atombones]
@printf "$(CLR_GR)>> Building bootloader [soctarget:$(soctarget)] $(CLR_NC)\n"
make $(MKFLAGS) -C $(bootloader_dir) soctarget=$(soctarget)


.PHONY: clean-boot
clean-boot: ## Clean bootloader build files
@printf "$(CLR_GR)>> Cleaning bootloader build files $(CLR_NC)\n"
make $(MKFLAGS) -C $(bootloader_dir) soctarget=$(soctarget) clean


# ======== SCAR ========
.PHONY: scar
scar: $(bin_dir)/$(sim_executable) ## Verify target using scar
Expand Down Expand Up @@ -156,4 +172,4 @@ clean: clean-sim clean-lib ## Alias for clean-sim, clean-lib


.PHONY: clean-all
clean-all: clean-sim clean-scar clean-elfdump clean-lib clean-doxy ## Clean all build files
clean-all: clean-sim clean-boot clean-scar clean-elfdump clean-lib clean-doxy ## Clean all build files
6 changes: 3 additions & 3 deletions sw/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ endif

RVPREFIX := riscv64-unknown-elf
CFLAGS := -Wall
CFLAGS += -mabi=ilp32 -march=rv32i -nostartfiles -ffreestanding -Os
CFLAGS += -mabi=ilp32 -march=rv32i -nostartfiles -ffreestanding -Os -g
CFLAGS += -I $(RVATOM_LIB)/include -L $(RVATOM_LIB)

LINKERSCRIPT := None
Expand All @@ -104,7 +104,7 @@ ifeq ($(__check_soctarget),true)
# check for validity of soctarget & select compile script
ifeq ($(soctarget),atombones)
CFLAGS += -DTARGET_ATOMBONES
LINKERSCRIPT:= $(RVATOM_LIB)/link/link.ld
LINKERSCRIPT:= $(RVATOM_LIB)/link/link_atombones.ld
else
ifeq ($(soctarget),hydrogensoc)
CFLAGS += -DTARGET_HYDROGENSOC
Expand Down Expand Up @@ -204,7 +204,7 @@ $(ex)/$(executable): $(SRC_FILES)
cd $(ex) && $(RVPREFIX)-gcc $(CFLAGS) $(src_files) -o $(executable) $(LFLAGS)

ifeq ($(objdump), true)
$(RVPREFIX)-objdump -htd $@ > [email protected]
$(RVPREFIX)-objdump -Shtd $@ > [email protected]
endif

ifeq ($(bin), true)
Expand Down
9 changes: 6 additions & 3 deletions sw/lib/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
##################################################
# ******** Makefile for Building libcatom ********




include ../../common.mk
##################################################
soctarget?=None
Expand All @@ -15,6 +12,8 @@ soctarget?=None
# user application to enable gcc garbage collection
OPT = true

DEBUG ?= 1

##################################################
# targets for which we don't need soctarget to be defined
__check_soctarget := true
Expand Down Expand Up @@ -58,6 +57,10 @@ ifeq ($(OPT), true) # For optimized code
CFLAGS+= -fdata-sections -ffunction-sections
endif

ifeq ($(DEBUG), 1)
CFLAGS += -g -O0
endif

# Common sources
C_SRCS := $(wildcard $(SRC_DIR)/*.c)
S_SRCS := $(wildcard $(SRC_DIR)/*.S)
Expand Down

0 comments on commit d9bfafd

Please sign in to comment.