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