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