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