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