# Makefile generated by Xilinx.

DRIVER_LIB_VERSION = 1.0
PROCESSOR = microblaze_0
LIBRARIES = ${PROCESSOR}/lib/libxil.a
BSP_MAKEFILES := $(wildcard $(PROCESSOR)/libsrc/*/src/Makefile)
SUBDIRS := $(patsubst %/Makefile, %, $(BSP_MAKEFILES))
BSP_SEQUENTIAL_MAKEFILES := 
BSP_PARALLEL_MAKEFILES := $(filter-out $(BSP_SEQUENTIAL_MAKEFILES),$(BSP_MAKEFILES))
SEQ_SUBDIRS := $(patsubst %/Makefile, %, $(BSP_SEQUENTIAL_MAKEFILES))
PAR_SUBDIRS := $(patsubst %/Makefile, %, $(BSP_PARALLEL_MAKEFILES))

ifneq (,$(findstring win,$(RDI_PLATFORM)))
 SHELL = CMD
endif

all: 
	$(MAKE) --no-print-directory seq_libs
	$(MAKE) -j 14 --no-print-directory par_libs
	$(MAKE) --no-print-directory archive
	@echo 'Finished building libraries'

include: $(addsuffix /make.include,$(SUBDIRS))

seq_libs: $(addsuffix /make.libs,$(SEQ_SUBDIRS))
	@echo 'Finished building libraries sequentially.'

par_libs: $(addsuffix /make.libs,$(PAR_SUBDIRS))
	@echo 'Finished building libraries parallelly.'

archive:
	mb-ar -r  $(LIBRARIES) $(sort $(wildcard $(PROCESSOR)/lib/*.o))

clean: $(addsuffix /make.clean,$(SUBDIRS))
	rm -f ${PROCESSOR}/lib/libxil.a

$(PROCESSOR)/lib/libxil.a: $(PROCESSOR)/lib/libxil_init.a
	cp -f $< $@

%/make.include: $(if $(wildcard $(PROCESSOR)/lib/libxil_init.a),$(PROCESSOR)/lib/libxil.a,)
	@echo "Running Make include in $(subst /make.include,,$@)"
	$(MAKE) -C $(subst /make.include,,$@) -s include  "SHELL=$(SHELL)" "COMPILER=mb-gcc" "ASSEMBLER=mb-as" "ARCHIVER=mb-ar" "COMPILER_FLAGS=  -O2 -c -mcpu=v11.0 -mhard-float -mlittle-endian -mno-xl-soft-div -mno-xl-soft-mul -mxl-barrel-shift -mxl-pattern-compare" "EXTRA_COMPILER_FLAGS=-g -ffunction-sections -fdata-sections -Wall -Wextra -fno-tree-loop-distribute-patterns"

%/make.libs: include
	@echo "Running Make libs in $(subst /make.libs,,$@)"
	$(MAKE) -C $(subst /make.libs,,$@) -s libs  "SHELL=$(SHELL)" "COMPILER=mb-gcc" "ASSEMBLER=mb-as" "ARCHIVER=mb-ar" "COMPILER_FLAGS=  -O2 -c -mcpu=v11.0 -mhard-float -mlittle-endian -mno-xl-soft-div -mno-xl-soft-mul -mxl-barrel-shift -mxl-pattern-compare" "EXTRA_COMPILER_FLAGS=-g -ffunction-sections -fdata-sections -Wall -Wextra -fno-tree-loop-distribute-patterns"

%/make.clean: 
	$(MAKE) -C $(subst /make.clean,,$@) -s clean 
