1 # $NetBSD: Makefile,v 1.98 2014/08/22 10:51:18 apb Exp $
3 # Experimental RCS METALOG versioning
4 # (Needs host's rcs(1) commands)
7 # - In 'build.sh distribution', print diff to previous
10 # The `all' target must appear before bsd.own.mk is pulled in.
12 @echo
"Please understand what you are doing, first."
16 .
include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
18 COMPRESS_PROGRAM
=${TOOL_GZIP}
19 GZIP_FLAGS
= ${GZIP_N_FLAG}
21 SETSENV
= DESTDIR
=${DESTDIR
:Q
} \
22 MACHINE
=${MACHINE
:Q
} \
23 MACHINE_ARCH
=${MACHINE_ARCH
:Q
} \
25 CKSUM
=${TOOL_CKSUM
:Q
} \
27 HOST_SH
=${HOST_SH
:Q
} \
29 MKTEMP
=${TOOL_MKTEMP
:Q
} \
30 MTREE
=${TOOL_MTREE
:Q
} \
32 COMPRESS_PROGRAM
=${COMPRESS_PROGRAM
:Q
} \
33 GZIP
=${GZIP_FLAGS
:Q
} \
34 PKG_CREATE
=${TOOL_PKG_CREATE
:Q
} \
37 SETSCMD
= cd
${.CURDIR
} && \
43 MAKESRCTARS_X11_FLAGS
= -x
${X11SRCDIR}
45 .if
${MKEXTSRC} != "no"
46 MAKESRCTARS_EXTSRC_FLAGS
= -y
${EXTSRCSRCDIR}
49 MAKEFLIST_X11_FLAGS
= ,x
51 .if
${MKEXTSRC} != "no"
52 MAKEFLIST_EXTSRC_FLAGS
= ,ext
54 MAKEFLIST_FLAGS
= -L base
${MAKEFLIST_X11_FLAGS}${MAKEFLIST_EXTSRC_FLAGS}
55 MAKESRCTARS_FLAGS
= -N
${NETBSDSRCDIR}/etc
57 .if
${MAKEVERBOSE} < 2
59 MAKESRCTARS_FLAGS
+= -q
62 .if
!defined
(MAKETARSETS
)
63 MAKETARSETS
!= ${SETSCMD} .
/makeflist
-l
${MAKEFLIST_FLAGS}
66 print_have_gcc
: .PHONY
72 print_machine_arch
: .PHONY
75 print_machine_cpu
: .PHONY
78 print_object_fmt
: .PHONY
81 print_toolchain_missing
: .PHONY
82 @echo
"${TOOLCHAIN_MISSING}"
85 print_set_lists_base print_set_lists_x print_set_lists_ext \
86 list_set_lists_base list_set_lists_x list_set_lists_ext \
87 list_set_files_base list_set_files_x list_set_files_ext \
89 @
${SETSENV}; rundir
="${.CURDIR}"; . .
/sets.subr
; ${.TARGET
}
92 # METALOG MANIPULATION TARGETS
94 # METALOG is the name of a metadata log file, and is set in <bsd.own.mk>
95 # if MKUNPRIVED is not "no".
97 # METALOG.unpriv is a command line option passed to various scripts;
98 # it is either blank or "-M ${METALOG}.sanitised", depending on the
101 # The sanitise_METALOG target creates METALOG.sanitised from METALOG,
102 # without modifying METALOG itself. This is used near the end of
103 # a build, after build products have been installed in DESTDIR
104 # and corresponding lines have been added to METALOG, but before
105 # METALOG.sanitised is used in the creation of sets in RELEASEDIR.
106 # For update builds, METALOG.sanitised has duplicates merged (keeping
107 # only the last of multiple entries for the same item), but for clean
108 # builds it's an error if a file or directory name appears twice.
109 # METALOG.sanitised is always sorted and has timestamps removed.
111 # The clean_METALOG target either deletes METALOG, or replaces METALOG with
112 # a sanitised version of itself, depending on the MKUPDATE flag, and
113 # deletes old METALOG.* files. This is intended to be used at the start
114 # of a build, to ensure that repeated MKUPDATE builds do not cause
115 # unbounded growth of METALOG.
118 METALOG_REMOVE_DUPLICATES
= \
119 ${TOOL_AWK} '{ a[$$1] = $$0; } END { for (f in a) print a[f]; }'
121 .if
${MKUNPRIVED} == "no"
123 sanitise_METALOG
: .PHONY
125 clean_METALOG
: .PHONY
128 METALOG.unpriv
= -M
${METALOG}.sanitised
129 sanitise_METALOG
: .PHONY
${METALOG}.sanitised
130 ${METALOG}.sanitised
: ${METALOG}
132 ${${MKUPDATE} != "no" :?
${METALOG_REMOVE_DUPLICATES} |
:} \
133 sort |
${TOOL_MTREE} -CSM
-k
all -R time
-N
${NETBSDSRCDIR}/etc \
135 mv
${METALOG}.new
${METALOG}.sanitised
136 .if defined
(RCSMETALOG
)
138 xrcs_descr
="build distribution METALOG"; \
139 xrcs_msg
="$$(date)"; \
140 xrcs_cur
=${METALOG}.sanitised
; \
143 .if
${MKUPDATE} == "no" ||
!exists
(${METALOG})
144 clean_METALOG
: .PHONY
145 rm -f
${METALOG} ${METALOG}.
*
147 clean_METALOG
: .PHONY
${METALOG}.sanitised
148 mv
${METALOG}.sanitised
${METALOG}
149 .if defined
(RCSMETALOG
)
150 [ -f
${METALOG}.sanitised
,v
] && mv
${METALOG}.sanitised
,v
${METALOG},v
153 .if defined
(RCSMETALOG
)
154 [ -f
${METALOG},v
] && mv
${METALOG},v
${METALOG}.sanitised
,v
163 # This target has debugging value only, really.
164 makeflist
: .PHONY .PRECIOUS check_DESTDIR
165 ${SETSCMD} .
/makeflist
${MAKEFLIST_FLAGS}
167 checkflist
: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG
168 ${SETSCMD} ${.CURDIR
}/checkflist \
169 ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv
}
171 checkflist-x11
: .PHONY check_DESTDIR
172 ${SETSCMD} .
/checkflist
-x
${CHECKFLIST_FLAGS}
174 checkflist-extsrc
: .PHONY check_DESTDIR
175 ${SETSCMD} .
/checkflist
-y
${CHECKFLIST_FLAGS}
177 .if defined
(DESTDIR
) && ${DESTDIR} != ""
178 checkflist_if_DESTDIR
: checkflist
180 checkflist_if_DESTDIR
:
184 # SET BUILDING TARGETS
187 TARDIR
= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary
/sets
188 SOURCETARDIR
= ${RELEASEDIR}/source
/sets
190 # If MAKETARS_SERIAL is set to "YES" or "yes", then the tar sets will be
191 # made in series, even if make's "-j" flag requests multiple parallel
192 # jobs. This is useful on systems that exhibit poor performance when
193 # running multiple parallel disk-intensive operations. The default is
194 # MAKETARS_SERIAL=NO, which will obey the "-j" flag passed to the make
198 .if empty
(MAKETARS_SERIAL
:M
[Yy
][Ee
][Ss
])
199 _MAKETARS_WAIT
= # empty
201 _MAKETARS_WAIT
= .WAIT
204 maketars
: .PRECIOUS .PHONY check_DESTDIR check_RELEASEDIR \
205 sanitise_METALOG checkflist_if_DESTDIR .WAIT \
207 ${MAKETARSETS
:@.TARS.@
${_MAKETARS_WAIT} do-
${.TARS.
}@
}
211 .if defined
(DESTDIR
) && ${DESTDIR} != ""
212 ${_MKMSG} "execute checkflist"
213 cd
${.CURDIR
}; ${MAKE} checkflist
216 for i in MD5 SHA512
; do \
217 rm -f
${TARDIR}/$$i ${TARDIR}/$$i.tmp
; \
220 makesetfiles
: .PHONY sanitise_METALOG
221 ${_MKMSG_CREATE} "set lists"
222 ${SETSCMD} .
/maketars
-S
-d
${DESTDIR
:S
,^
$,/,} ${MAKETARS_FLAGS} \
224 -N
${NETBSDSRCDIR}/etc
${MAKEFLIST_FLAGS} -t
${TARDIR}
226 .for
tar in
${MAKETARSETS}
227 do-
${tar}: .PHONY sanitise_METALOG
228 ${_MKMSG_CREATE} "${tar}.tgz"
229 ${SETSCMD} .
/maketars
-d
${DESTDIR
:S
,^
$,/,} ${MAKETARS_FLAGS} \
231 -N
${NETBSDSRCDIR}/etc
-t
${TARDIR} ${tar} \
232 ||
{ rm -f
${TARDIR}/${tar}.tgz
; false
; }
236 makesrctars
: .PRECIOUS .PHONY check_RELEASEDIR
237 ${_MKMSG_CREATE} "source tar files"
238 mkdir
-p
${SOURCETARDIR}
239 ${SETSCMD} .
/makesrctars
${MAKESRCTARS_FLAGS} \
240 ${MAKESRCTARS_X11_FLAGS} ${MAKESRCTARS_EXTSRC_FLAGS} \
241 ${NETBSDSRCDIR} ${SOURCETARDIR}
244 makesums
: .PRECIOUS .PHONY check_RELEASEDIR .WAIT \
245 ${MAKETARSETS
:@.TARS.@do-sum-
${.TARS.
}@
}
246 for i in MD5 SHA512
; do \
247 mv
${TARDIR}/$$i.tmp
${TARDIR}/$$i; \
250 .for
tar in
${MAKETARSETS}
251 do-sum-
${tar}: .PHONY do-
${tar}
252 ${_MKMSG_CREATE} "${tar} checksums"
253 ${MAKESUMS} -t
${TARDIR} ${tar}.tgz
254 for i in MD5 SHA512
; do \
255 ${TOOL_CAT} ${TARDIR}/$$i >> ${TARDIR}/$$i.tmp
; \
258 .ORDER
: ${MAKETARSETS
:@.TARS.@do-sum-
${.TARS.
}@
}
261 installsets
: .PHONY check_DESTDIR sanitise_METALOG
262 .if
!defined
(INSTALLDIR
)
263 @echo
"setenv INSTALLDIR before doing that!"
266 ${SETSCMD} .
/maketars
-d
${DESTDIR
:S
,^
$,/,} ${MAKETARS_FLAGS} \
267 ${METALOG.unpriv
} -N
${NETBSDSRCDIR}/etc \
268 ${MAKEFLIST_FLAGS} -i
${INSTALLDIR} ${INSTALLSETS}
270 # Should we ignore errors like extra or missing files in the flists?
272 .if
!empty
(SLOPPY_FLIST
:M
[Yy
][Ee
][Ss
])
273 CHECKFLIST_FLAGS
+= -e
-m
277 .if
${MAKEVERBOSE} == 0
279 .elif
${MAKEVERBOSE} == 1
281 .
else # MAKEVERBOSE >= 2
284 REGPKG.
force?
= # -f, or empty
285 REGPKG.cache?
= -c
# -c, or empty
286 REGPKG.update
:= ${MKUPDATE
:tl
:Nno
:C
/..
*/-u
/}
288 makesyspkgs
: .PHONY check_DESTDIR check_RELEASEDIR \
289 sanitise_METALOG checkflist_if_DESTDIR
290 mkdir
-p
${RELEASEDIR}/${RELEASEMACHINEDIR}/binary
/syspkgs
291 ${SETSCMD} ${.CURDIR
}/regpkgset \
292 ${REGPKG.verbose
} ${REGPKG.
force} ${REGPKG.sloppy
} \
293 ${REGPKG.cache
} ${REGPKG.update
} \
294 -d
${DESTDIR
:S
,^
$,/,} ${METALOG.unpriv
} \
295 -N
${NETBSDSRCDIR}/etc \
296 -t
${RELEASEDIR}/${RELEASEMACHINEDIR}/binary
/syspkgs
${SYSPKGSETS}
298 makesyspkgsums
: .PHONY check_RELEASEDIR
299 ${MAKESUMS} -t
${RELEASEDIR}/${RELEASEMACHINEDIR}/binary
/syspkgs
301 # Update the "deps" file.
302 # XXX: Why is "deps" checked in to the source tree, instead of
303 # just being created as necessary?
305 ${SETSCMD} .
/syspkgdeps
all >${.CURDIR
}/deps
307 # Sort the lists files.
309 # The tricky stuff with awk and sort -k options is to ensure that the
310 # heading remains undisturbed, and on non-heading lines anything before
311 # the first "." is ignored, so that "./dir/file" and "#./dir/file" are
315 find
${.CURDIR
}/lists \
! \
( -name CVS
-prune \
) \
! -name .
#\* \
317 | while read f
; do \
318 ${_MKSHMSG} "sorting $${f#${.CURDIR}/}" ; \
319 awk
'BEGIN { inheader = 1 } \
320 /^#*\.\// { inheader = 0 } \
321 // { tag = (inheader ? NR : 999999); \
322 print tag "." $$0 }' \
324 |
sort -t .
-k
1n
,2 -k
3 \
326 | cat
-s
>"$$f".tmp
; \
327 if cmp
"$$f" "$$f".tmp
>/dev
/null
; then \
328 : "$$f is unchanged" ; \
331 mv
"$$f".tmp
"$$f" ; \
339 syspkgs
: .PHONY makesyspkgs .WAIT makesyspkgsums
342 sets
: .PHONY maketars .WAIT makesums
345 sourcesets
: .PHONY makesrctars
348 .
include <bsd.files.mk
>