]> CyberLeo.Net >> Repos - FreeBSD/releng/10.3.git/blob - share/mk/bsd.progs.mk
Fix multiple small kernel memory disclosures. [EN-18:04.mem]
[FreeBSD/releng/10.3.git] / share / mk / bsd.progs.mk
1 # $FreeBSD$
2 # $Id: progs.mk,v 1.11 2012/11/06 17:18:54 sjg Exp $
3 #
4 #       @(#) Copyright (c) 2006, Simon J. Gerraty
5 #
6 #       This file is provided in the hope that it will
7 #       be of use.  There is absolutely NO WARRANTY.
8 #       Permission to copy, redistribute or otherwise
9 #       use this file is hereby granted provided that 
10 #       the above copyright notice and this notice are
11 #       left intact. 
12 #      
13 #       Please send copies of changes and bug-fixes to:
14 #       sjg@crufty.net
15 #
16
17 .MAIN: all
18
19 .if defined(PROGS) || defined(PROGS_CXX)
20 # we really only use PROGS below...
21 PROGS += ${PROGS_CXX}
22
23 # In meta mode, we can capture dependenices for _one_ of the progs.
24 # if makefile doesn't nominate one, we use the first.
25 .if defined(.PARSEDIR)
26 .ifndef UPDATE_DEPENDFILE_PROG
27 UPDATE_DEPENDFILE_PROG = ${PROGS:[1]}
28 .export UPDATE_DEPENDFILE_PROG
29 .endif
30 .else
31 UPDATE_DEPENDFILE_PROG?= no
32 .endif
33
34 .ifndef PROG
35 # They may have asked us to build just one
36 .for t in ${PROGS}
37 .if make($t)
38 .if ${PROGS_CXX:U:M${t}}
39 PROG_CXX ?= $t
40 .endif
41 PROG ?= $t
42 .endif
43 .endfor
44 .endif
45
46 .if defined(PROG)
47 # just one of many
48 PROG_OVERRIDE_VARS +=   BINDIR BINGRP BINOWN BINMODE DPSRCS MAN NO_WERROR \
49                         PROGNAME SRCS WARNS
50 PROG_VARS +=    CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD LINKS \
51                 LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
52 .for v in ${PROG_VARS:O:u}
53 .if empty(${PROG_OVERRIDE_VARS:M$v})
54 .if defined(${v}.${PROG})
55 $v += ${${v}.${PROG}}
56 .elif defined(${v}_${PROG})
57 $v += ${${v}_${PROG}}
58 .endif
59 .else
60 $v ?=
61 .endif
62 .endfor
63
64 # for meta mode, there can be only one!
65 .if ${PROG} == ${UPDATE_DEPENDFILE_PROG}
66 UPDATE_DEPENDFILE ?= yes
67 .endif
68 UPDATE_DEPENDFILE ?= NO
69
70 # ensure that we don't clobber each other's dependencies
71 DEPENDFILE?= .depend.${PROG}
72 # prog.mk will do the rest
73 .else # !defined(PROG)
74 all: ${PROGS}
75
76 # We cannot capture dependencies for meta mode here
77 UPDATE_DEPENDFILE = NO
78 # nor can we safely run in parallel.
79 .NOTPARALLEL:
80 .endif
81 .endif  # PROGS || PROGS_CXX
82
83 # These are handled by the main make process.
84 .ifdef _RECURSING_PROGS
85 _PROGS_GLOBAL_VARS= CLEANFILES CLEANDIRS FILESGROUPS SCRIPTS
86 .for v in ${_PROGS_GLOBAL_VARS}
87 $v =
88 .endfor
89 .endif
90
91 # handle being called [bsd.]progs.mk
92 .include <bsd.prog.mk>
93
94 .if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)
95 # tell progs.mk we might want to install things
96 PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install
97
98 # Find common sources among the PROGS and depend on them before building
99 # anything.  This allows parallelization without them each fighting over
100 # the same objects.
101 _PROGS_COMMON_SRCS=
102 _PROGS_ALL_SRCS=
103 .for p in ${PROGS}
104 .for s in ${SRCS.${p}}
105 .if ${_PROGS_ALL_SRCS:M${s}} && !${_PROGS_COMMON_SRCS:M${s}}
106 _PROGS_COMMON_SRCS+=    ${s}
107 .else
108 _PROGS_ALL_SRCS+=       ${s}
109 .endif
110 .endfor
111 .endfor
112 .if !empty(_PROGS_COMMON_SRCS)
113 _PROGS_COMMON_OBJS=     ${_PROGS_COMMON_SRCS:M*.[dhly]}
114 .if !empty(_PROGS_COMMON_SRCS:N*.[dhly])
115 _PROGS_COMMON_OBJS+=    ${_PROGS_COMMON_SRCS:N*.[dhly]:R:S/$/.o/g}
116 .endif
117 ${PROGS}: ${_PROGS_COMMON_OBJS}
118 .endif
119
120 .for p in ${PROGS}
121 .if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p)
122 # bsd.prog.mk may need to know this
123 x.$p= PROG_CXX=$p
124 .endif
125
126 # Main PROG target
127 $p ${p}_p: .PHONY .MAKE
128         (cd ${.CURDIR} && \
129             NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
130             PROG=$p \
131             DEPENDFILE=.depend.$p .MAKE.DEPENDFILE=.depend.$p \
132             ${x.$p})
133
134 # Pseudo targets for PROG, such as 'install'.
135 .for t in ${PROGS_TARGETS:O:u}
136 $p.$t: .PHONY .MAKE
137         (cd ${.CURDIR} && \
138             NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
139             PROG=$p \
140             DEPENDFILE=.depend.$p .MAKE.DEPENDFILE=.depend.$p \
141             ${x.$p} ${@:E})
142 .endfor
143 .endfor
144
145 # Depend main pseudo targets on all PROG.pseudo targets too.
146 .for t in ${PROGS_TARGETS:O:u}
147 $t: ${PROGS:%=%.$t}
148 .endfor
149 .endif  # !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)