Makefile revision 1.74 1 # $NetBSD: Makefile,v 1.74 2009/12/10 05:15:28 uebayasi 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 print_mkvars: .PHONY
71 @env SETS_SUBR_DEBUG=dumpmkvars sh sets.subr
72
73 #
74 # METALOG MANIPULATION TARGETS
75 #
76 # METALOG is the name of a metadata log file, and is set in <bsd.own.mk>
77 # if MKUNPRIVED is not "no".
78 #
79 # METALOG.unpriv is a command line option passed to various scripts;
80 # it is either blank or "-M ${METALOG}.sanitised", depending on the
81 # MKUNPRIVED flag.
82 #
83 # The sanitise_METALOG target creates METALOG.sanitised from METALOG,
84 # without modifying METALOG itself. METALOG.sanitised is sorted, and
85 # has duplicates merged. This is used near the end of a build, after
86 # build products have been installed in DESTDIR and corresponding lines
87 # have been added to METALOG, but before METALOG.sanitised is used in
88 # the creation of sets in RELEASEDIR.
89 #
90 # The clean_METALOG either deletes METALOG or replaces METALOG with
91 # a sanitised version of itself, depending on the MKUPDATE flag, and
92 # deletes old METALOG.* files. This is intended to be used at the start
93 # of a build, to ensure that repeated MKUPDATE builds do not cause
94 # unbounded growth of METALOG.
95 #
96
97 .if ${MKUNPRIVED} == "no"
98 METALOG.unpriv=
99 sanitise_METALOG: .PHONY
100 @true
101 clean_METALOG: .PHONY
102 @true
103 .else # MKUNPRIVED
104 METALOG.unpriv= -M ${METALOG}.sanitised
105 sanitise_METALOG: .PHONY ${METALOG}.sanitised
106 ${METALOG}.sanitised: ${METALOG}
107 ${TOOL_MTREE} -CSM -k all -N ${NETBSDSRCDIR}/etc <${METALOG} \
108 >${METALOG}.new
109 mv ${METALOG}.new ${METALOG}.sanitised
110 .if ${MKUPDATE} == "no" || !exists(${METALOG})
111 clean_METALOG: .PHONY
112 rm -f ${METALOG} ${METALOG}.*
113 .else # MKUPDATE
114 clean_METALOG: .PHONY ${METALOG}.sanitised
115 mv ${METALOG}.sanitised ${METALOG}
116 rm -f ${METALOG}.*
117 .endif # MKUPDATE
118 .endif # MKUNPRIVED
119
120 #
121 # FILE LIST TARGETS
122 #
123
124 # This target has debugging value only, really.
125 makeflist: .PHONY .PRECIOUS check_DESTDIR
126 ${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS}
127
128 checkflist: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG
129 ${SETSCMD} ${.CURDIR}/checkflist \
130 ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv}
131
132 checkflist-x11: .PHONY check_DESTDIR
133 ${SETSCMD} ./checkflist -x ${CHECKFLIST_FLAGS}
134
135 checkflist-extsrc: .PHONY check_DESTDIR
136 ${SETSCMD} ./checkflist -y ${CHECKFLIST_FLAGS}
137
138 .if defined(DESTDIR) && ${DESTDIR} != ""
139 checkflist_if_DESTDIR: checkflist
140 .else
141 checkflist_if_DESTDIR:
142 .endif
143
144 #
145 # SET BUILDING TARGETS
146 #
147
148 TARDIR= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
149 SOURCETARDIR= ${RELEASEDIR}/source/sets
150
151 # If MAKETARS_SERIAL is set to "YES" or "yes", then the tar sets will be
152 # made in series, even if make's "-j" flag requests multiple parallel
153 # jobs. This is useful on systems that exhibit poor performance when
154 # running multiple parallel disk-intensive operations. The default is
155 # MAKETARS_SERIAL=NO, which will obey the "-j" flag passed to the make
156 # command.
157 #
158 MAKETARS_SERIAL?= NO
159 .if empty(MAKETARS_SERIAL:M[Yy][Ee][Ss])
160 _MAKETARS_WAIT= # empty
161 .else
162 _MAKETARS_WAIT= .WAIT
163 .endif
164
165 maketars: .PRECIOUS .PHONY check_DESTDIR check_RELEASEDIR \
166 sanitise_METALOG checkflist_if_DESTDIR .WAIT \
167 maketarsetup .WAIT \
168 ${MAKETARSETS:@.TARS.@${_MAKETARS_WAIT} do-${.TARS.}@}
169 @true
170
171 maketarsetup: .EXEC
172 .if defined(DESTDIR) && ${DESTDIR} != ""
173 ${_MKMSG} "execute checkflist"
174 ${MAKE} checkflist
175 .endif
176 mkdir -p ${TARDIR}
177 for i in MD5 SHA512; do \
178 rm -f ${TARDIR}/$$i ${TARDIR}/$$i.tmp; \
179 done
180
181 makesetfiles: .PHONY sanitise_METALOG
182 ${_MKMSG_CREATE} "set lists"
183 ${SETSCMD} ./maketars -S -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
184 ${METALOG.unpriv} \
185 -N ${NETBSDSRCDIR}/etc ${MAKEFLIST_FLAGS} -t ${TARDIR}
186
187 .for tar in ${MAKETARSETS}
188 do-${tar}: .PHONY sanitise_METALOG
189 ${_MKMSG_CREATE} "${tar}.tgz"
190 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
191 ${METALOG.unpriv} \
192 -N ${NETBSDSRCDIR}/etc -t ${TARDIR} ${tar} \
193 || { rm -f ${TARDIR}/${tar}.tgz; false; }
194 .endfor
195
196
197 makesrctars: .PRECIOUS .PHONY check_RELEASEDIR
198 ${_MKMSG_CREATE} "source tar files"
199 mkdir -p ${SOURCETARDIR}
200 ${SETSCMD} ./makesrctars ${MAKESRCTARS_FLAGS} \
201 ${MAKESRCTARS_X11_FLAGS} ${MAKESRCTARS_EXTSRC_FLAGS} \
202 ${NETBSDSRCDIR} ${SOURCETARDIR}
203
204
205 makesums: .PRECIOUS .PHONY check_RELEASEDIR .WAIT \
206 ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@}
207 for i in MD5 SHA512; do \
208 mv ${TARDIR}/$$i.tmp ${TARDIR}/$$i; \
209 done
210
211 .for tar in ${MAKETARSETS}
212 do-sum-${tar}: .PHONY do-${tar}
213 ${_MKMSG_CREATE} "${tar} checksums"
214 ${MAKESUMS} -t ${TARDIR} ${tar}.tgz
215 for i in MD5 SHA512; do \
216 ${TOOL_CAT} ${TARDIR}/$$i >> ${TARDIR}/$$i.tmp; \
217 done
218 .endfor
219 .ORDER: ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@}
220
221
222 installsets: .PHONY check_DESTDIR sanitise_METALOG
223 .if !defined(INSTALLDIR)
224 @echo "setenv INSTALLDIR before doing that!"
225 @false
226 .endif
227 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
228 ${METALOG.unpriv} -N ${NETBSDSRCDIR}/etc \
229 ${MAKEFLIST_FLAGS} -i ${INSTALLDIR} ${INSTALLSETS}
230
231 # Should we ignore errors like extra or missing files in the flists?
232 SLOPPY_FLIST?= NO
233 .if !empty(SLOPPY_FLIST:M[Yy][Ee][Ss])
234 CHECKFLIST_FLAGS+= -e -m
235 REGPKG.sloppy= -m
236 .endif
237
238 .if ${MAKEVERBOSE} == 0
239 REGPKG.verbose?= -q
240 .elif ${MAKEVERBOSE} == 1
241 REGPKG.verbose?=
242 .else # MAKEVERBOSE >= 2
243 REGPKG.verbose?= -v
244 .endif
245 REGPKG.force?= # -f, or empty
246 REGPKG.cache?= -c # -c, or empty
247 REGPKG.update:= ${MKUPDATE:tl:Nno:C/..*/-u/}
248 SYSPKGSETS?= all
249 makesyspkgs: .PHONY check_DESTDIR check_RELEASEDIR \
250 sanitise_METALOG checkflist_if_DESTDIR
251 mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
252 ${SETSCMD} ${.CURDIR}/regpkgset \
253 ${REGPKG.verbose} ${REGPKG.force} ${REGPKG.sloppy} \
254 ${REGPKG.cache} ${REGPKG.update} \
255 -d ${DESTDIR:S,^$,/,} ${METALOG.unpriv} \
256 -N ${NETBSDSRCDIR}/etc \
257 -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs ${SYSPKGSETS}
258
259 makesyspkgsums: .PHONY check_RELEASEDIR
260 ${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
261
262 # Update the "deps" file.
263 # XXX: Why is "deps" checked in to the source tree, instead of
264 # just being created as necessary?
265 makedeps: .PHONY
266 ${SETSCMD} ./syspkgdeps all >${.CURDIR}/deps
267
268 #
269 # MAIN ENTRY POINTS
270 #
271
272 syspkgs: .PHONY makesyspkgs .WAIT makesyspkgsums
273 @true
274
275 sets: .PHONY maketars .WAIT makesums
276 @true
277
278 sourcesets: .PHONY makesrctars
279 @true
280
281 .include <bsd.sys.mk>
282