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