# Copyright (C) 2017, 2024  Luke T. Shumaker <lukeshu@parabola.nu>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# This file is part of Parabola Libretools.
#
# Libretools is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Libretools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This file is a hack to let us pass whatever flags we want to Make,
# since adjusting MAKEFLAGS at runtime only half-works.

ifeq ($(filter grouped-target,$(.FEATURES)),)
$(error We need a version of Make that supports 'grouped-target')
endif

# The flags that we actually want to pass to Make.
desired_MAKEFLAGS  = --no-builtin-rules
desired_MAKEFLAGS += --no-builtin-variables
desired_MAKEFLAGS += --warn-undefined-variables
# Setting GNUMAKEFLAGS is important so that --no-builtin-variables
# with --warn-undefined-variables doesn't cause Make (as of 4.4.1) to
# print spurious warnings about it being undefined for internal use.
desired_MAKEFLAGS += GNUMAKEFLAGS=''

# Quiet this parent Make a bit.
MAKEFLAGS += --no-print-directory

# Main.
$(or $(MAKECMDGOALS),default) &:
	@$(MAKE) -f Makefile $(desired_MAKEFLAGS) $(MAKECMDGOALS)
.PHONY: $(or $(MAKECMDGOALS),default)
