Makefile revision 1.73 1 # $NetBSD: Makefile,v 1.73 2009/12/04 12:43:56 apb Exp $
2
3 # The `all' target must appear before bsd.own.mk is pulled in.
4 all:
5 @echo "Please understand what you are doing, first."
6 @false
7
8 .include <bsd.own.mk>
9 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
10
11 SETSCMD= cd ${.CURDIR} && \
12 DESTDIR=${DESTDIR:Q} \
13 MACHINE=${MACHINE:Q} MACHINE_ARCH=${MACHINE_ARCH:Q} \
14 AWK=${TOOL_AWK:Q} \
15 CKSUM=${TOOL_CKSUM:Q} \
16 DB=${TOOL_DB:Q} \
17 HOST_SH=${HOST_SH:Q} \
18 MAKE=${MAKE:Q} \
19 MKTEMP=${TOOL_MKTEMP:Q} \
20 MTREE=${TOOL_MTREE:Q} \
21 PAX=${TOOL_PAX:Q} \
22 PKG_CREATE=${TOOL_PKG_CREATE:Q} \
23 SED=${TOOL_SED:Q} \
24 TSORT=${TSORT:Q} \
25 ${HOST_SH}
26
27 MAKETARS_FLAGS=
28 .if ${MKX11} != "no"
29 MAKESRCTARS_X11_FLAGS= -x ${X11SRCDIR}
30 .endif
31 .if ${MKEXTSRC} != "no"
32 MAKESRCTARS_EXTSRC_FLAGS= -y ${EXTSRCSRCDIR}
33 .endif
34 .if ${MKX11} != "no"
35 MAKEFLIST_X11_FLAGS= ,x
36 .endif
37 .if ${MKEXTSRC} != "no"
38 MAKEFLIST_EXTSRC_FLAGS= ,ext
39 .endif
40 MAKEFLIST_FLAGS= -L base${MAKEFLIST_X11_FLAGS}${MAKEFLIST_EXTSRC_FLAGS}
41 MAKESRCTARS_FLAGS= -N ${NETBSDSRCDIR}/etc
42
43 .if ${MAKEVERBOSE} < 2
44 MAKETARS_FLAGS+= -q
45 MAKESRCTARS_FLAGS+= -q
46 .endif
47
48 .if !defined(MAKETARSETS)
49 MAKETARSETS!= ${SETSCMD} ./makeflist -l ${MAKEFLIST_FLAGS}
50 .endif
51
52 print_have_gcc: .PHONY
53 @echo ${HAVE_GCC}
54
55 print_machine: .PHONY
56 @echo ${MACHINE}
57
58 print_machine_arch: .PHONY
59 @echo ${MACHINE_ARCH}
60
61 print_machine_cpu: .PHONY
62 @echo ${MACHINE_CPU}
63
64 print_object_fmt: .PHONY
65 @echo ${OBJECT_FMT}
66
67 print_toolchain_missing: .PHONY
68 @echo "${TOOLCHAIN_MISSING}"
69
70 #
71 # METALOG MANIPULATION TARGETS
72 #
73 # METALOG is the name of a metadata log file, and is set in <bsd.own.mk>
74 # if MKUNPRIVED is not "no".
75 #
76 # METALOG.unpriv is a command line option passed to various scripts;
77 # it is either blank or "-M ${METALOG}.sanitised", depending on the
78 # MKUNPRIVED flag.
79 #
80 # The sanitise_METALOG target creates METALOG.sanitised from METALOG,
81 # without modifying METALOG itself. METALOG.sanitised is sorted, and
82 # has duplicates merged. This is used near the end of a build, after
83 # build products have been installed in DESTDIR and corresponding lines
84 # have been added to METALOG, but before METALOG.sanitised is used in
85 # the creation of sets in RELEASEDIR.
86 #
87 # The clean_METALOG either deletes METALOG or replaces METALOG with
88 # a sanitised version of itself, depending on the MKUPDATE flag, and
89 # deletes old METALOG.* files. This is intended to be used at the start
90 # of a build, to ensure that repeated MKUPDATE builds do not cause
91 # unbounded growth of METALOG.
92 #
93
94 .if ${MKUNPRIVED} == "no"
95 METALOG.unpriv=
96 sanitise_METALOG: .PHONY
97 @true
98 clean_METALOG: .PHONY
99 @true
100 .else # MKUNPRIVED
101 METALOG.unpriv= -M ${METALOG}.sanitised
102 sanitise_METALOG: .PHONY ${METALOG}.sanitised
103 ${METALOG}.sanitised: ${METALOG}
104 ${TOOL_MTREE} -CSM -k all -N ${NETBSDSRCDIR}/etc <${METALOG} \
105 >${METALOG}.new
106 mv ${METALOG}.new ${METALOG}.sanitised
107 .if ${MKUPDATE} == "no" || !exists(${METALOG})
108 clean_METALOG: .PHONY
109 rm -f ${METALOG} ${METALOG}.*
110 .else # MKUPDATE
111 clean_METALOG: .PHONY ${METALOG}.sanitised
112 mv ${METALOG}.sanitised ${METALOG}
113 rm -f ${METALOG}.*
114 .endif # MKUPDATE
115 .endif # MKUNPRIVED
116
117 #
118 # FILE LIST TARGETS
119 #
120
121 # This target has debugging value only, really.
122 makeflist: .PHONY .PRECIOUS check_DESTDIR
123 ${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS}
124
125 checkflist: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG
126 ${SETSCMD} ${.CURDIR}/checkflist \
127 ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv}
128
129 checkflist-x11: .PHONY check_DESTDIR
130 ${SETSCMD} ./checkflist -x ${CHECKFLIST_FLAGS}
131
132 checkflist-extsrc: .PHONY check_DESTDIR
133 ${SETSCMD} ./checkflist -y ${CHECKFLIST_FLAGS}
134
135 .if defined(DESTDIR) && ${DESTDIR} != ""
136 checkflist_if_DESTDIR: checkflist
137 .else
138 checkflist_if_DESTDIR:
139 .endif
140
141 #
142 # SET BUILDING TARGETS
143 #
144
145 TARDIR= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
146 SOURCETARDIR= ${RELEASEDIR}/source/sets
147
148 # If MAKETARS_SERIAL is set to "YES" or "yes", then the tar sets will be
149 # made in series, even if make's "-j" flag requests multiple parallel
150 # jobs. This is useful on systems that exhibit poor performance when
151 # running multiple parallel disk-intensive operations. The default is
152 # MAKETARS_SERIAL=NO, which will obey the "-j" flag passed to the make
153 # command.
154 #
155 MAKETARS_SERIAL?= NO
156 .if empty(MAKETARS_SERIAL:M[Yy][Ee][Ss])
157 _MAKETARS_WAIT= # empty
158 .else
159 _MAKETARS_WAIT= .WAIT
160 .endif
161
162 maketars: .PRECIOUS .PHONY check_DESTDIR check_RELEASEDIR \
163 sanitise_METALOG checkflist_if_DESTDIR .WAIT \
164 maketarsetup .WAIT \
165 ${MAKETARSETS:@.TARS.@${_MAKETARS_WAIT} do-${.TARS.}@}
166 @true
167
168 maketarsetup: .EXEC
169 .if defined(DESTDIR) && ${DESTDIR} != ""
170 ${_MKMSG} "execute checkflist"
171 ${MAKE} checkflist
172 .endif
173 mkdir -p ${TARDIR}
174 for i in MD5 SHA512; do \
175 rm -f ${TARDIR}/$$i ${TARDIR}/$$i.tmp; \
176 done
177
178 makesetfiles: .PHONY sanitise_METALOG
179 ${_MKMSG_CREATE} "set lists"
180 ${SETSCMD} ./maketars -S -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
181 ${METALOG.unpriv} \
182 -N ${NETBSDSRCDIR}/etc ${MAKEFLIST_FLAGS} -t ${TARDIR}
183
184 .for tar in ${MAKETARSETS}
185 do-${tar}: .PHONY sanitise_METALOG
186 ${_MKMSG_CREATE} "${tar}.tgz"
187 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
188 ${METALOG.unpriv} \
189 -N ${NETBSDSRCDIR}/etc -t ${TARDIR} ${tar} \
190 || { rm -f ${TARDIR}/${tar}.tgz; false; }
191 .endfor
192
193
194 makesrctars: .PRECIOUS .PHONY check_RELEASEDIR
195 ${_MKMSG_CREATE} "source tar files"
196 mkdir -p ${SOURCETARDIR}
197 ${SETSCMD} ./makesrctars ${MAKESRCTARS_FLAGS} \
198 ${MAKESRCTARS_X11_FLAGS} ${MAKESRCTARS_EXTSRC_FLAGS} \
199 ${NETBSDSRCDIR} ${SOURCETARDIR}
200
201
202 makesums: .PRECIOUS .PHONY check_RELEASEDIR .WAIT \
203 ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@}
204 for i in MD5 SHA512; do \
205 mv ${TARDIR}/$$i.tmp ${TARDIR}/$$i; \
206 done
207
208 .for tar in ${MAKETARSETS}
209 do-sum-${tar}: .PHONY do-${tar}
210 ${_MKMSG_CREATE} "${tar} checksums"
211 ${MAKESUMS} -t ${TARDIR} ${tar}.tgz
212 for i in MD5 SHA512; do \
213 ${TOOL_CAT} ${TARDIR}/$$i >> ${TARDIR}/$$i.tmp; \
214 done
215 .endfor
216 .ORDER: ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@}
217
218
219 installsets: .PHONY check_DESTDIR sanitise_METALOG
220 .if !defined(INSTALLDIR)
221 @echo "setenv INSTALLDIR before doing that!"
222 @false
223 .endif
224 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
225 ${METALOG.unpriv} -N ${NETBSDSRCDIR}/etc \
226 ${MAKEFLIST_FLAGS} -i ${INSTALLDIR} ${INSTALLSETS}
227
228 # Should we ignore errors like extra or missing files in the flists?
229 SLOPPY_FLIST?= NO
230 .if !empty(SLOPPY_FLIST:M[Yy][Ee][Ss])
231 CHECKFLIST_FLAGS+= -e -m
232 REGPKG.sloppy= -m
233 .endif
234
235 .if ${MAKEVERBOSE} == 0
236 REGPKG.verbose?= -q
237 .elif ${MAKEVERBOSE} == 1
238 REGPKG.verbose?=
239 .else # MAKEVERBOSE >= 2
240 REGPKG.verbose?= -v
241 .endif
242 REGPKG.force?= # -f, or empty
243 REGPKG.cache?= -c # -c, or empty
244 REGPKG.update:= ${MKUPDATE:tl:Nno:C/..*/-u/}
245 SYSPKGSETS?= all
246 makesyspkgs: .PHONY check_DESTDIR check_RELEASEDIR \
247 sanitise_METALOG checkflist_if_DESTDIR
248 mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
249 ${SETSCMD} ${.CURDIR}/regpkgset \
250 ${REGPKG.verbose} ${REGPKG.force} ${REGPKG.sloppy} \
251 ${REGPKG.cache} ${REGPKG.update} \
252 -d ${DESTDIR:S,^$,/,} ${METALOG.unpriv} \
253 -N ${NETBSDSRCDIR}/etc \
254 -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs ${SYSPKGSETS}
255
256 makesyspkgsums: .PHONY check_RELEASEDIR
257 ${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
258
259 # Update the "deps" file.
260 # XXX: Why is "deps" checked in to the source tree, instead of
261 # just being created as necessary?
262 makedeps: .PHONY
263 ${SETSCMD} ./syspkgdeps all >${.CURDIR}/deps
264
265 #
266 # MAIN ENTRY POINTS
267 #
268
269 syspkgs: .PHONY makesyspkgs .WAIT makesyspkgsums
270 @true
271
272 sets: .PHONY maketars .WAIT makesums
273 @true
274
275 sourcesets: .PHONY makesrctars
276 @true
277
278 .include <bsd.sys.mk>
279