2 # This is the top-level makefile - derived from the Junos version
4 # If a subdir that matches the requested target exists, we assume
5 # a build target and initialize DIRDEPS, dirdeps.mk does the rest.
7 # Otherwise we include Makefile.xtras and hope it knows what to do.
10 # Copyright (c) 2010-2012, Juniper Networks, Inc.
12 # Redistribution and use in source and binary forms, with or without
13 # modification, are permitted provided that the following conditions
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.
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.
33 .if ${.MAKE.LEVEL} == 0
35 # this is our top-level makefile
37 DIRDEPS_FILTER = Mtargets/*
41 .if !empty(build_options)
42 build_options := ${build_options:O:u}
43 .for v in ${build_options}
46 .export ${build_options}
50 .include <dirdeps-targets.mk>
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}
61 now_utc = ${%s:L:gmtime}
62 start_utc := ${now_utc}
66 .if ${BUILD_DIRDEPS_CACHE:Uno} == "no"
67 __DEFAULT_YES_OPTIONS+= \
70 .include <bsd.mkopt.mk>
72 .if ${MK_CLEAN_ERROR_LOGS} == "yes"
73 _begin += clean-error-logs
76 .if !empty(_begin) && !make(clean*)
77 dirdeps: ${_begin} .WAIT
81 .include "Makefile.inc"
85 .for t in ${.TARGETS:Nall:Nclean*:${_begin:Uall:${M_ListToSkip}}}
89 elapsed_time= seconds=`expr ${now_utc} - ${start_utc}`
91 .if ${BUILD_DIRDEPS_CACHE:Uno} == "no"
93 _build_finish: .NOMETA
94 @echo "${TIME_STAMP} Finished ${.TARGETS} ${elapsed_time}"
98 _build_failed: .NOMETA
99 @echo "${TIME_STAMP} Failed ${.TARGETS} ${elapsed_time}"
101 .endif # !empty(DIRDEPS)
103 clean-error-logs: .NOMETA
104 @test ! -d ${meta_error_log:H} || rm -f ${meta_error_log:H}/*log
106 .if !target(_DIRDEP_USE)
107 # we did not read dirdeps.mk above, the target may be here
108 .include "Makefile.xtras"
112 # dirdeps does it all
114 .endif # .MAKE.LEVEL == 0