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