#******************************************************************************
#
# Makefile - Rules for building the libraries, examples and docs.
#
# ${copyright}
#
# This is part of revision ${version} of the AmbiqSuite Development Package.
#
#******************************************************************************
TARGET := pdm_opus
COMPILERNAME := Keil
PROJECT := pdm_opus_Keil
CONFIG := bin

SHELL:=/bin/bash
#### Required Executables ####
K := $(shell type -p UV4.exe)
RM := $(shell which rm 2>/dev/null)

ifeq ($(K),)
all clean:
	$(info Tools w/$(COMPILERNAME) not installed.)
	$(RM) -rf bin
else

#### BUILD BEGIN ####
LIBDEPS = ../../../../../mcu/apollo3p/hal/keil/bin/libam_hal.lib
LIBDEPS+= ../../../../../boards/apollo3p_evb/bsp/keil/bin/libam_bsp.lib
LIBDEPS+= ../../../../../CMSIS/ARM/Lib/ARM/arm_cortexM4lf_math.lib
all: $(LIBDEPS)
	$(MAKE) project

.PHONY: project
project: directories binary
ifeq ('not', 'equal')
#### BUILD END ####
all: directories binary
#### BUILD BEGIN ####
endif
#### BUILD END ####

.PHONY: binary
binary:
	UV4.exe -b -t "pdm_opus" pdm_opus.uvprojx -j0 || [ $$? -eq 1 ]

directories: $(CONFIG)

$(CONFIG):
	@mkdir -p $@

clean:
	@echo Cleaning... ;\
	$(RM) -rf $(CONFIG)


../../../../../mcu/apollo3p/hal/keil/bin/libam_hal.lib:
	$(MAKE) -C ../../../../../mcu/apollo3p/hal

../../../../../boards/apollo3p_evb/bsp/keil/bin/libam_bsp.lib:
	$(MAKE) -C ../../../../../boards/apollo3p_evb/bsp

endif
.PHONY: all clean directories

