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