ifneq (,$(wildcard *.sbd))
include $(wildcard *.sbd)
endif
SDETOP ?= ../..

PROG	=mini
SRCS	=minimon.c

CFLAGS += -Os -g -ffunction-sections

LDFLAGS += -Wl,--gc-sections

# Request remote debug support in ROM
RDEBUG	=yes

# Request all optional kit features, except PCI support
FEATURES = all -pci%

EXTRATARGETS += dso
EXTRACLEAN += dso

include $(SDETOP)/examples/make.mk

#
# Compile and link an example position-independent Dynamic Shared Object 
# to be loaded and run by the minimon "boot" command.
#

# remove --gc-sections linker option which breaks a shared object link
comma := ,
DSO_LINK := $(filter-out -Wl$(comma)--gc-sections -p%,$(LINK.o))
dso: dso_a.o dso_b.o
	$(DSO_LINK) -o $@ -shared -nostdlib $^

# remove -mips16 option which doesn't support PIC
DSO_COMPILE := $(filter-out -mips16% -p%,$(COMPILE.c))
dso_a.o dso_b.o:
	$(DSO_COMPILE) -fpic $*.c -o $@
