# Makefile generated by Xilinx.

DRIVER_LIB_VERSION = 1.0
PROCESSOR = psv_psm_0
LIBRARIES = ${PROCESSOR}/lib/libxil.a
BSP_MAKEFILES := $(wildcard $(PROCESSOR)/libsrc/*/src/Makefile)
SUBDIRS := $(patsubst %/Makefile, %, $(BSP_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))
COMPILER := mb-gcc
ARCHIVER := mb-ar
ASSEMBLER := mb-as

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

all:
	$(MAKE) -j1 --no-print-directory seq_libs
	$(MAKE) -j --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:
	$(ARCHIVER) -r  $(LIBRARIES) $(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=$(COMPILER)" "ASSEMBLER=$(ASSEMBLER)" "ARCHIVER=$(ARCHIVER)" "COMPILER_FLAGS=  -O2 -c -mcpu=v10.0 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare" "EXTRA_COMPILER_FLAGS=-g -ffunction-sections -fdata-sections -Wall -Wextra"

%/make.libs: include
	@echo "Running Make libs in $(subst /make.libs,,$@)"
	$(MAKE) -C $(subst /make.libs,,$@) -s libs  "SHELL=$(SHELL)" "COMPILER=$(COMPILER)" "ASSEMBLER=$(ASSEMBLER)" "ARCHIVER=$(ARCHIVER)" "COMPILER_FLAGS=  -O2 -c -mcpu=v10.0 -mlittle-endian -mxl-barrel-shift -mxl-pattern-compare" "EXTRA_COMPILER_FLAGS=-g -ffunction-sections -fdata-sections -Wall -Wextra"

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