1 # $NetBSD: Makefile,v 1.90 2013/10/30 15:17:01 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 .if
${USE_PIGZGZIP} != "no"
19 COMPRESS_PROGRAM
=${TOOL_PIGZ
:Q
}
24 SETSENV
= DESTDIR
=${DESTDIR
:Q
} \
25 MACHINE
=${MACHINE
:Q
} \
26 MACHINE_ARCH
=${MACHINE_ARCH
:Q
} \
28 CKSUM
=${TOOL_CKSUM
:Q
} \
30 HOST_SH
=${HOST_SH
:Q
} \
32 MKTEMP
=${TOOL_MKTEMP
:Q
} \
33 MTREE
=${TOOL_MTREE
:Q
} \
35 COMPRESS_PROGRAM
=${COMPRESS_PROGRAM
:Q
} \
36 PKG_CREATE
=${TOOL_PKG_CREATE
:Q
} \
39 SETSCMD
= cd
${.CURDIR
} && \
45 MAKESRCTARS_X11_FLAGS
= -x
${X11SRCDIR}
47 .if
${MKEXTSRC} != "no"
48 MAKESRCTARS_EXTSRC_FLAGS
= -y
${EXTSRCSRCDIR}
51 MAKEFLIST_X11_FLAGS
= ,x
53 .if
${MKEXTSRC} != "no"
54 MAKEFLIST_EXTSRC_FLAGS
= ,ext
56 MAKEFLIST_FLAGS
= -L base
${MAKEFLIST_X11_FLAGS}${MAKEFLIST_EXTSRC_FLAGS}
57 MAKESRCTARS_FLAGS
= -N
${NETBSDSRCDIR}/etc
59 .if
${MAKEVERBOSE} < 2
61 MAKESRCTARS_FLAGS
+= -q
64 .if
!defined
(MAKETARSETS
)
65 MAKETARSETS
!= ${SETSCMD} .
/makeflist
-l
${MAKEFLIST_FLAGS}
68 print_have_gcc
: .PHONY
74 print_machine_arch
: .PHONY
77 print_machine_cpu
: .PHONY
80 print_object_fmt
: .PHONY
83 print_toolchain_missing
: .PHONY
84 @echo
"${TOOLCHAIN_MISSING}"
87 print_set_lists_base print_set_lists_x print_set_lists_ext \
88 list_set_lists_base list_set_lists_x list_set_lists_ext \
89 list_set_files_base list_set_files_x list_set_files_ext \
91 @
${SETSENV}; rundir
="${.CURDIR}"; . .
/sets.subr
; ${.TARGET
}
94 # METALOG MANIPULATION TARGETS
96 # METALOG is the name of a metadata log file, and is set in <bsd.own.mk>
97 # if MKUNPRIVED is not "no".
99 # METALOG.unpriv is a command line option passed to various scripts;
100 # it is either blank or "-M ${METALOG}.sanitised", depending on the
103 # The sanitise_METALOG target creates METALOG.sanitised from METALOG,
104 # without modifying METALOG itself. METALOG.sanitised is sorted, and
105 # has duplicates merged. This is used near the end of a build, after
106 # build products have been installed in DESTDIR and corresponding lines
107 # have been added to METALOG, but before METALOG.sanitised is used in
108 # the creation of sets in RELEASEDIR.
110 # The clean_METALOG either deletes METALOG or replaces METALOG with
111 # a sanitised version of itself, depending on the MKUPDATE flag, and
112 # deletes old METALOG.* files. This is intended to be used at the start
113 # of a build, to ensure that repeated MKUPDATE builds do not cause
114 # unbounded growth of METALOG.
117 .if
${MKUNPRIVED} == "no"
119 sanitise_METALOG
: .PHONY
121 clean_METALOG
: .PHONY
124 METALOG.unpriv
= -M
${METALOG}.sanitised
125 sanitise_METALOG
: .PHONY
${METALOG}.sanitised
126 ${METALOG}.sanitised
: ${METALOG}
127 # We keep only the last entry for update builds, but for clean builds we
128 # want to make sure we install files only once.
129 .if
${MKUPDATE} != "no"
131 '{ a[$$1] = $$0; } END { for (f in a) print a[f]; }' ${METALOG} | \
132 sort |
${TOOL_MTREE} -CSM
-k
all -N
${NETBSDSRCDIR}/etc \
135 sort ${METALOG} |
${TOOL_MTREE} -CSM
-k
all -N
${NETBSDSRCDIR}/etc \
138 mv
${METALOG}.new
${METALOG}.sanitised
139 .if defined
(RCSMETALOG
)
141 xrcs_descr
="build distribution METALOG"; \
142 xrcs_msg
="$$(date)"; \
143 xrcs_cur
=${METALOG}.sanitised
; \
146 .if
${MKUPDATE} == "no" ||
!exists
(${METALOG})
147 clean_METALOG
: .PHONY
148 rm -f
${METALOG} ${METALOG}.
*
150 clean_METALOG
: .PHONY
${METALOG}.sanitised
151 mv
${METALOG}.sanitised
${METALOG}
152 .if defined
(RCSMETALOG
)
153 [ -f
${METALOG}.sanitised
,v
] && mv
${METALOG}.sanitised
,v
${METALOG},v
156 .if defined
(RCSMETALOG
)
157 [ -f
${METALOG},v
] && mv
${METALOG},v
${METALOG}.sanitised
,v
166 # This target has debugging value only, really.
167 makeflist
: .PHONY .PRECIOUS check_DESTDIR
168 ${SETSCMD} .
/makeflist
${MAKEFLIST_FLAGS}
170 checkflist
: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG
171 ${SETSCMD} ${.CURDIR
}/checkflist \
172 ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv
}
174 checkflist-x11
: .PHONY check_DESTDIR
175 ${SETSCMD} .
/checkflist
-x
${CHECKFLIST_FLAGS}
177 checkflist-extsrc
: .PHONY check_DESTDIR
178 ${SETSCMD} .
/checkflist
-y
${CHECKFLIST_FLAGS}
180 .if defined
(DESTDIR
) && ${DESTDIR} != ""
181 checkflist_if_DESTDIR
: checkflist
183 checkflist_if_DESTDIR
:
187 # SET BUILDING TARGETS
190 TARDIR
= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary
/sets
191 SOURCETARDIR
= ${RELEASEDIR}/source
/sets
193 # If MAKETARS_SERIAL is set to "YES" or "yes", then the tar sets will be
194 # made in series, even if make's "-j" flag requests multiple parallel
195 # jobs. This is useful on systems that exhibit poor performance when
196 # running multiple parallel disk-intensive operations. The default is
197 # MAKETARS_SERIAL=NO, which will obey the "-j" flag passed to the make
201 .if empty
(MAKETARS_SERIAL
:M
[Yy
][Ee
][Ss
])
202 _MAKETARS_WAIT
= # empty
204 _MAKETARS_WAIT
= .WAIT
207 maketars
: .PRECIOUS .PHONY check_DESTDIR check_RELEASEDIR \
208 sanitise_METALOG checkflist_if_DESTDIR .WAIT \
210 ${MAKETARSETS
:@.TARS.@
${_MAKETARS_WAIT} do-
${.TARS.
}@
}
214 .if defined
(DESTDIR
) && ${DESTDIR} != ""
215 ${_MKMSG} "execute checkflist"
219 for i in MD5 SHA512
; do \
220 rm -f
${TARDIR}/$$i ${TARDIR}/$$i.tmp
; \
223 makesetfiles
: .PHONY sanitise_METALOG
224 ${_MKMSG_CREATE} "set lists"
225 ${SETSCMD} .
/maketars
-S
-d
${DESTDIR
:S
,^
$,/,} ${MAKETARS_FLAGS} \
227 -N
${NETBSDSRCDIR}/etc
${MAKEFLIST_FLAGS} -t
${TARDIR}
229 .for
tar in
${MAKETARSETS}
230 do-
${tar}: .PHONY sanitise_METALOG
231 ${_MKMSG_CREATE} "${tar}.tgz"
232 ${SETSCMD} .
/maketars
-d
${DESTDIR
:S
,^
$,/,} ${MAKETARS_FLAGS} \
234 -N
${NETBSDSRCDIR}/etc
-t
${TARDIR} ${tar} \
235 ||
{ rm -f
${TARDIR}/${tar}.tgz
; false
; }
239 makesrctars
: .PRECIOUS .PHONY check_RELEASEDIR
240 ${_MKMSG_CREATE} "source tar files"
241 mkdir
-p
${SOURCETARDIR}
242 ${SETSCMD} .
/makesrctars
${MAKESRCTARS_FLAGS} \
243 ${MAKESRCTARS_X11_FLAGS} ${MAKESRCTARS_EXTSRC_FLAGS} \
244 ${NETBSDSRCDIR} ${SOURCETARDIR}
247 makesums
: .PRECIOUS .PHONY check_RELEASEDIR .WAIT \
248 ${MAKETARSETS
:@.TARS.@do-sum-
${.TARS.
}@
}
249 for i in MD5 SHA512
; do \
250 mv
${TARDIR}/$$i.tmp
${TARDIR}/$$i; \
253 .for
tar in
${MAKETARSETS}
254 do-sum-
${tar}: .PHONY do-
${tar}
255 ${_MKMSG_CREATE} "${tar} checksums"
256 ${MAKESUMS} -t
${TARDIR} ${tar}.tgz
257 for i in MD5 SHA512
; do \
258 ${TOOL_CAT} ${TARDIR}/$$i >> ${TARDIR}/$$i.tmp
; \
261 .ORDER
: ${MAKETARSETS
:@.TARS.@do-sum-
${.TARS.
}@
}
264 installsets
: .PHONY check_DESTDIR sanitise_METALOG
265 .if
!defined
(INSTALLDIR
)
266 @echo
"setenv INSTALLDIR before doing that!"
269 ${SETSCMD} .
/maketars
-d
${DESTDIR
:S
,^
$,/,} ${MAKETARS_FLAGS} \
270 ${METALOG.unpriv
} -N
${NETBSDSRCDIR}/etc \
271 ${MAKEFLIST_FLAGS} -i
${INSTALLDIR} ${INSTALLSETS}
273 # Should we ignore errors like extra or missing files in the flists?
275 .if
!empty
(SLOPPY_FLIST
:M
[Yy
][Ee
][Ss
])
276 CHECKFLIST_FLAGS
+= -e
-m
280 .if
${MAKEVERBOSE} == 0
282 .elif
${MAKEVERBOSE} == 1
284 .
else # MAKEVERBOSE >= 2
287 REGPKG.
force?
= # -f, or empty
288 REGPKG.cache?
= -c
# -c, or empty
289 REGPKG.update
:= ${MKUPDATE
:tl
:Nno
:C
/..
*/-u
/}
291 makesyspkgs
: .PHONY check_DESTDIR check_RELEASEDIR \
292 sanitise_METALOG checkflist_if_DESTDIR
293 mkdir
-p
${RELEASEDIR}/${RELEASEMACHINEDIR}/binary
/syspkgs
294 ${SETSCMD} ${.CURDIR
}/regpkgset \
295 ${REGPKG.verbose
} ${REGPKG.
force} ${REGPKG.sloppy
} \
296 ${REGPKG.cache
} ${REGPKG.update
} \
297 -d
${DESTDIR
:S
,^
$,/,} ${METALOG.unpriv
} \
298 -N
${NETBSDSRCDIR}/etc \
299 -t
${RELEASEDIR}/${RELEASEMACHINEDIR}/binary
/syspkgs
${SYSPKGSETS}
301 makesyspkgsums
: .PHONY check_RELEASEDIR
302 ${MAKESUMS} -t
${RELEASEDIR}/${RELEASEMACHINEDIR}/binary
/syspkgs
304 # Update the "deps" file.
305 # XXX: Why is "deps" checked in to the source tree, instead of
306 # just being created as necessary?
308 ${SETSCMD} .
/syspkgdeps
all >${.CURDIR
}/deps
310 # Sort the lists files
312 find
${.CURDIR
}/lists \
! \
( -name CVS
-prune \
) -type f
-print \
313 | while read f
; do \
314 ${_MKSHMSG} "sorting $${f#${.CURDIR}/}" ; \
315 { grep
'^#' "$$f" ; \
316 grep
-v
'^#' "$$f" |
sort ; \
318 if cmp
"$$f" "$$f".tmp
>/dev
/null
; then \
319 : "$$f is unchanged" ; \
322 mv
"$$f".tmp
"$$f" ; \
330 syspkgs
: .PHONY makesyspkgs .WAIT makesyspkgsums
333 sets
: .PHONY maketars .WAIT makesums
336 sourcesets
: .PHONY makesrctars
339 .
include <bsd.sys.mk
>