1b6209a9bSSimon J. Gerraty# $FreeBSD$ 2b6209a9bSSimon J. Gerraty 34938741aSAndriy Voskoboinyk# This is the top-level makefile - derived from the Junos version 4b6209a9bSSimon J. Gerraty# 5b6209a9bSSimon J. Gerraty# If a subdir that matches the requested target exists, we assume 6b6209a9bSSimon J. Gerraty# a build target and initialize DIRDEPS, dirdeps.mk does the rest. 7b6209a9bSSimon J. Gerraty# 8b6209a9bSSimon J. Gerraty# Otherwise we include Makefile.xtras and hope it knows what to do. 9b6209a9bSSimon J. Gerraty# 10b6209a9bSSimon J. Gerraty 11b6209a9bSSimon J. Gerraty# Copyright (c) 2010-2012, Juniper Networks, Inc. 12b6209a9bSSimon J. Gerraty# 13b6209a9bSSimon J. Gerraty# Redistribution and use in source and binary forms, with or without 14b6209a9bSSimon J. Gerraty# modification, are permitted provided that the following conditions 15b6209a9bSSimon J. Gerraty# are met: 16b6209a9bSSimon J. Gerraty# 1. Redistributions of source code must retain the above copyright 17b6209a9bSSimon J. Gerraty# notice, this list of conditions and the following disclaimer. 18b6209a9bSSimon J. Gerraty# 2. Redistributions in binary form must reproduce the above copyright 19b6209a9bSSimon J. Gerraty# notice, this list of conditions and the following disclaimer in the 20b6209a9bSSimon J. Gerraty# documentation and/or other materials provided with the distribution. 21b6209a9bSSimon J. Gerraty# 22b6209a9bSSimon J. Gerraty# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23b6209a9bSSimon J. Gerraty# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24b6209a9bSSimon J. Gerraty# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25b6209a9bSSimon J. Gerraty# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26b6209a9bSSimon J. Gerraty# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27b6209a9bSSimon J. Gerraty# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28b6209a9bSSimon J. Gerraty# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29b6209a9bSSimon J. Gerraty# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30b6209a9bSSimon J. Gerraty# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31b6209a9bSSimon J. Gerraty# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32b6209a9bSSimon J. Gerraty# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33b6209a9bSSimon J. Gerraty 34b6209a9bSSimon J. Gerraty.if ${.MAKE.LEVEL} == 0 35b6209a9bSSimon J. Gerraty 36b6209a9bSSimon J. Gerraty# this is our top-level makefile 37b6209a9bSSimon J. Gerraty.if make(pkg-*) 3861ad1ff5SSimon J. GerratyDIRDEPS_FILTER = Mtargets/* 39b6209a9bSSimon J. Gerraty.endif 40b6209a9bSSimon J. Gerraty 41b6209a9bSSimon J. Gerraty 42b6209a9bSSimon J. Gerraty.if !empty(build_options) 43b6209a9bSSimon J. Gerratybuild_options := ${build_options:O:u} 44b6209a9bSSimon J. Gerraty.for v in ${build_options} 45b6209a9bSSimon J. Gerraty$v = yes 46b6209a9bSSimon J. Gerraty.endfor 47b6209a9bSSimon J. Gerraty.export ${build_options} 48b6209a9bSSimon J. Gerraty.endif 49b6209a9bSSimon J. Gerraty 50*312809feSSimon J. Gerraty# this does the work 51*312809feSSimon J. Gerraty.include <dirdeps-targets.mk> 52*312809feSSimon J. Gerraty 53b6209a9bSSimon J. Gerraty.if !empty(DIRDEPS) 54b6209a9bSSimon J. Gerraty# This is printed as we read the makefile 55b6209a9bSSimon J. Gerraty# so provides a useful clue as to when we really started. 56b6209a9bSSimon J. Gerraty# This allows us to work out how long reading 57b6209a9bSSimon J. Gerraty# Makefile.depend* takes. 58b6209a9bSSimon J. Gerraty.if ${.MAKEFLAGS:M-V} == "" 5998e0ffaeSSimon J. Gerraty.if ${BUILD_DIRDEPS_CACHE:Uno} == "no" 60b6209a9bSSimon J. Gerraty.info ${.newline}${TIME_STAMP} Start ${.TARGETS} 6198e0ffaeSSimon J. Gerraty.endif 62b6209a9bSSimon J. Gerratynow_utc = ${%s:L:gmtime} 63b6209a9bSSimon J. Gerratystart_utc := ${now_utc} 64b6209a9bSSimon J. Gerraty.endif 65b6209a9bSSimon J. Gerraty 6698e0ffaeSSimon J. Gerraty_begin = 6798e0ffaeSSimon J. Gerraty.if ${BUILD_DIRDEPS_CACHE:Uno} == "no" 6861ad1ff5SSimon J. Gerraty__DEFAULT_YES_OPTIONS+= \ 6961ad1ff5SSimon J. Gerraty CLEAN_ERROR_LOGS 7061ad1ff5SSimon J. Gerraty 7161ad1ff5SSimon J. Gerraty.include <bsd.mkopt.mk> 7261ad1ff5SSimon J. Gerraty 7361ad1ff5SSimon J. Gerraty.if ${MK_CLEAN_ERROR_LOGS} == "yes" 74b6209a9bSSimon J. Gerraty_begin += clean-error-logs 75b6209a9bSSimon J. Gerraty.endif 7661ad1ff5SSimon J. Gerraty 77b6209a9bSSimon J. Gerraty.if !empty(_begin) && !make(clean*) 78b6209a9bSSimon J. Gerratydirdeps: ${_begin} .WAIT 79b6209a9bSSimon J. Gerraty.endif 8098e0ffaeSSimon J. Gerraty.endif 81b6209a9bSSimon J. Gerraty 82b6209a9bSSimon J. Gerraty.include "Makefile.inc" 83b6209a9bSSimon J. Gerraty 84b6209a9bSSimon J. Gerraty.include <dirdeps.mk> 85b6209a9bSSimon J. Gerraty 86b6209a9bSSimon J. Gerraty.for t in ${.TARGETS:Nall:Nclean*:${_begin:Uall:${M_ListToSkip}}} 87b6209a9bSSimon J. Gerraty$t: dirdeps 88b6209a9bSSimon J. Gerraty.endfor 89b6209a9bSSimon J. Gerraty 90b6209a9bSSimon J. Gerratyelapsed_time= seconds=`expr ${now_utc} - ${start_utc}` 91b6209a9bSSimon J. Gerraty 9298e0ffaeSSimon J. Gerraty.if ${BUILD_DIRDEPS_CACHE:Uno} == "no" 93b6209a9bSSimon J. Gerraty.END: _build_finish 94b6209a9bSSimon J. Gerraty_build_finish: .NOMETA 95b6209a9bSSimon J. Gerraty @echo "${TIME_STAMP} Finished ${.TARGETS} ${elapsed_time}" 9698e0ffaeSSimon J. Gerraty.endif 97b6209a9bSSimon J. Gerraty 98b6209a9bSSimon J. Gerraty.ERROR: _build_failed 99b6209a9bSSimon J. Gerraty_build_failed: .NOMETA 100b6209a9bSSimon J. Gerraty @echo "${TIME_STAMP} Failed ${.TARGETS} ${elapsed_time}" 101b6209a9bSSimon J. Gerraty 102b6209a9bSSimon J. Gerraty.endif # !empty(DIRDEPS) 103b6209a9bSSimon J. Gerraty 104b6209a9bSSimon J. Gerratyclean-error-logs: .NOMETA 105b6209a9bSSimon J. Gerraty @test ! -d ${meta_error_log:H} || rm -f ${meta_error_log:H}/*log 106b6209a9bSSimon J. Gerraty 107b6209a9bSSimon J. Gerraty.if !target(_DIRDEP_USE) 108b6209a9bSSimon J. Gerraty# we did not read dirdeps.mk above, the target may be here 109b6209a9bSSimon J. Gerraty.include "Makefile.xtras" 110b6209a9bSSimon J. Gerraty.endif 111b6209a9bSSimon J. Gerraty 112b6209a9bSSimon J. Gerraty.else 113b6209a9bSSimon J. Gerraty# dirdeps does it all 114b6209a9bSSimon J. Gerratyall: 115b6209a9bSSimon J. Gerraty.endif # .MAKE.LEVEL == 0 116b6209a9bSSimon J. Gerraty 117