xref: /freebsd/targets/Makefile (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
1# $FreeBSD$
2
3# This is the top-level makefile - derived from the Junos version
4#
5# If a subdir that matches the requested target exists, we assume
6# a build target and initialize DIRDEPS, dirdeps.mk does the rest.
7#
8# Otherwise we include Makefile.xtras and hope it knows what to do.
9#
10
11# Copyright (c) 2010-2012, Juniper Networks, Inc.
12#
13# Redistribution and use in source and binary forms, with or without
14# modification, are permitted provided that the following conditions
15# are met:
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.
21#
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.
33
34.if ${.MAKE.LEVEL} == 0
35
36# this is our top-level makefile
37.if make(pkg-*)
38DIRDEPS_FILTER = Mtargets/*
39.endif
40
41
42.if !empty(build_options)
43build_options := ${build_options:O:u}
44.for v in ${build_options}
45$v = yes
46.endfor
47.export ${build_options}
48.endif
49
50# this does the work
51.include <dirdeps-targets.mk>
52
53.if !empty(DIRDEPS)
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}
61.endif
62now_utc = ${%s:L:gmtime}
63start_utc := ${now_utc}
64.endif
65
66_begin =
67.if ${BUILD_DIRDEPS_CACHE:Uno} == "no"
68__DEFAULT_YES_OPTIONS+= \
69	CLEAN_ERROR_LOGS
70
71.include <bsd.mkopt.mk>
72
73.if ${MK_CLEAN_ERROR_LOGS} == "yes"
74_begin += clean-error-logs
75.endif
76
77.if !empty(_begin) && !make(clean*)
78dirdeps: ${_begin} .WAIT
79.endif
80.endif
81
82.include "Makefile.inc"
83
84.include <dirdeps.mk>
85
86.for t in ${.TARGETS:Nall:Nclean*:${_begin:Uall:${M_ListToSkip}}}
87$t: dirdeps
88.endfor
89
90elapsed_time= seconds=`expr ${now_utc} - ${start_utc}`
91
92.if ${BUILD_DIRDEPS_CACHE:Uno} == "no"
93.END: _build_finish
94_build_finish:	.NOMETA
95	@echo "${TIME_STAMP} Finished ${.TARGETS} ${elapsed_time}"
96.endif
97
98.ERROR: _build_failed
99_build_failed: .NOMETA
100	@echo "${TIME_STAMP} Failed ${.TARGETS} ${elapsed_time}"
101
102.endif					# !empty(DIRDEPS)
103
104clean-error-logs: .NOMETA
105	@test ! -d ${meta_error_log:H} || rm -f ${meta_error_log:H}/*log
106
107.if !target(_DIRDEP_USE)
108# we did not read dirdeps.mk above, the target may be here
109.include "Makefile.xtras"
110.endif
111
112.else
113# dirdeps does it all
114all:
115.endif					# .MAKE.LEVEL == 0
116
117