499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
9bff67898d55cddfcec9ce30cc2b1bb6211ec691David Lawrence# Permission is hereby granted, free of charge, to any person obtaining a
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# copy of this software and associated documentation files (the "Software"),
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# to deal in the Software without restriction, including without limitation
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# the rights to use, copy, modify, merge, publish, distribute, sublicense,
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# and/or sell copies of the Software, and to permit persons to whom the
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# Software is furnished to do so, subject to the following conditions:
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# The above copyright notice and this permission notice (including the next
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# paragraph) shall be included in all copies or substantial portions of the
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# DEALINGS IN THE SOFTWARE.
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff###############################################################################
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# Primary Makefile to build the components in open-src/kernel
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff###############################################################################
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# Definitions that are similar to other Makefiles
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# MACH will be either "sparc" or "i386"
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# This is used for setting pkg attributes, so save for later.
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# Variables to always pass down to subdirs
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael GraffPASSDOWN_VARS = V="$(V)" TOP="$(TOP)" CDEBUGFLAGS="$(CDEBUGFLAGS)"
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff $(MAKE) -e $(MAKEFLAGS) $(PASSDOWN_VARS) subdirs OS_TARGET=$@
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# debug isn't working quite right yet.
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# World: clean all debug install
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff $(MAKE) $(MAKEFLAGS) $(PASSDOWN_VARS) subdirs OS_TARGET=clean
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff $(MAKE) $(MAKEFLAGS) $(PASSDOWN_VARS) subdirs OS_TARGET=clobber
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff print "## making debug" $(OS_TARGET) "in open-src/kernel/$(DIRNAME)$@..."; \
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff $(MAKE) $(MAKEFLAGS) $(PASSDOWN_VARS) $(DEBUGPASSDOWN) $(OS_TARGET)
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff @case '${MAKEFLAGS}' in *[ik]*) set +e;; esac; \
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff print "## making" $(OS_TARGET) "in open-src/kernel/$(DIRNAME)$@..."; \
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff $(MAKE) $(MAKEFLAGS) $(PASSDOWN_VARS) $(OS_TARGET)
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff if [[ -d $$i ]] ; then \
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff $(MAKE) $(MAKEFLAGS) subdirs OS_TARGET=clean OS_SUBDIRS=$$i ; \
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff print "## removing obsolete build directories in open-src/$(DIRNAME)$$i..."; \
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff ($(START_CMD_ECHO) ; cd $$i && rm -rf build* .checksum* ) ; \
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# Build various x-ref's
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff @find sys $(OS_SUBDIRS_i386) $(OS_SUBDIRS_sparc) -name "Make*" -o -name "*.[ch]" > $@
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff @rm -f cscope.files cscope.in.out cscope.out cscope.out.in cscope.out.po cscope.po.out
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# Dummy target to force another target to always be run, even if a file
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# or directory with the same name already exists (as it will for subdirs)
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# Tell dmake it can build subdirs in parallel
b75dc2a3d82c0ad078b5155057e66e5b694faeb7Michael Graff# Dependencies between modules