# 
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This software is dual-licensed to you under the MIT License (MIT) and the Universal Permissive License (UPL).  See the LICENSE file in the root directory for license terms.  You may choose
# either license, or both.
#

#
#  Base configuration options:
#
#     PORT              set default platform port
#     CC_CFG            set default platform compiler configuration
#     LIB_CFG           set default library configuration
#
#  Targets:
#
#     all               calls 'build' and 'doc' targets
#     build             builds library
#     doc               creates API documentation
#     clean             cleans the build
#

override PORT=mbed
CC_CFG?=gcc
ifeq ($(shell uname -s),Darwin)
    CC_CFG=gcc-darwin
endif
LIB_CFG?=ts_md_vs_gw

ifeq ($(PORT),mbed)
	IMPLICIT_EDGE_COMPUTING:=false
endif

CPP_MAKE_DIR=.
C_MAKE_DIR=../../../c/$(PORT)/make
MAKE_DIR=$(C_MAKE_DIR)

include $(C_MAKE_DIR)/config/paths.cfg
include config/paths.cfg
# includes predefined library configuration
include $(LIB_CONFIG)
# includes additional custom library configurations
include $(LIB_SHARED_CUSTOM_CONFIG)
include $(LIB_PORT_CUSTOM_CONFIG)
# includes architecture configuration
include $(COMPILER_CONFIG)
# includes library common definitions
include $(CPP_LIB_COMMON_DEFS)
# includes platform depended targets implementation and definitions
include $(LIB_PORT_DEFS)
include $(LIB_PORT_IMPL)

.DEFAULT_GOAL := all
.PHONY: all
all: build doc

.PHONY: build
# BUILD_SUFFIX used for build library settings set, like set/all.cfg
build: .pre_build$(BUILD_SUFFIX) .build_impl$(BUILD_SUFFIX) .post_build$(BUILD_SUFFIX)
	
.PHONY: doc
doc:  .pre_doc_cpp .doc_impl_cpp .post_doc_cpp

.PHONY: clean
clean: # .pre_clean .clean_impl .post_clean
	rm -R ../build

.PHONY: bootstrapper
bootstrapper: # Stub for bootstrapper targets
