#
# PMBS top level Makefile
#
# SPDX-FileType: SOURCE
# SPDX-FileCopyrightText: Michael Bäuerle
# SPDX-License-Identifier: BSD-2-Clause
#
# Please read the documentation in the file "INSTALL.make".
#
# Switch 'make' into POSIX compliant mode (must be the first non-comment line)
.POSIX:

# Build directory
# Must be a single name, not a path (created at top level in source tree)
# The target "clean" will delete this directory.
PMBS_BUILD_DIR=build

# Clear suffix list for inference rules
.SUFFIXES:

# If no target was specified, first rule is used (.DEFAULT does not work here)
first:
	@$(MAKE) all

# Delete build directory
# This should work without any special environment setup
# Use system search path to get a POSIX rm utility
clean:
	@printf '\n%s\n' 'Deleting build directory ...'
	(command -p rm -rf "./$(PMBS_BUILD_DIR)")

# Map anything else to PMBS build system
.DEFAULT:
	@printf '\nBuilding target "%s" ...\n' '$@'
	export LC_ALL=POSIX ; \
            $(MAKE) -f ./pmbs/frontend.mk PMBS_BUILD_DIR="$(PMBS_BUILD_DIR)" $@
