packages.install: remove obsolete minix-all pkg.
[minix3.git] / Makefile
blob02ffe19b04c4504f753fa3625069b98aab7dc80e
1 # $NetBSD: Makefile,v 1.299 2012/08/17 16:22:27 joerg Exp $
4 # This is the top-level makefile for building NetBSD. For an outline of
5 # how to build a snapshot or release, as well as other release engineering
6 # information, see http://www.NetBSD.org/developers/releng/index.html
8 # Not everything you can set or do is documented in this makefile. In
9 # particular, you should review the files in /usr/share/mk (especially
10 # bsd.README) for general information on building programs and writing
11 # Makefiles within this structure, and see the comments in src/etc/Makefile
12 # for further information on installation and release set options.
14 # Variables listed below can be set on the make command line (highest
15 # priority), in /etc/mk.conf (middle priority), or in the environment
16 # (lowest priority).
18 # Variables:
19 # DESTDIR is the target directory for installation of the compiled
20 # software. It defaults to /. Note that programs are built against
21 # libraries installed in DESTDIR.
22 # MKMAN, if `no', will prevent building of manual pages.
23 # MKOBJDIRS, if not `no', will build object directories at
24 # an appropriate point in a build.
25 # MKSHARE, if `no', will prevent building and installing
26 # anything in /usr/share.
27 # MKUPDATE, if not `no', will avoid a `make cleandir' at the start of
28 # `make build', as well as having the effects listed in
29 # /usr/share/mk/bsd.README.
30 # NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
31 # of the `make build'.
32 # NOINCLUDES will avoid the `make includes' usually done by `make build'.
34 # See mk.conf(5) for more details.
37 # Targets:
38 # build:
39 # Builds a full release of NetBSD in DESTDIR, except for the
40 # /etc configuration files.
41 # If BUILD_DONE is set, this is an empty target.
42 # distribution:
43 # Builds a full release of NetBSD in DESTDIR, including the /etc
44 # configuration files.
45 # buildworld:
46 # As per `make distribution', except that it ensures that DESTDIR
47 # is not the root directory.
48 # installworld:
49 # Install the distribution from DESTDIR to INSTALLWORLDDIR (which
50 # defaults to the root directory). Ensures that INSTALLWORLDDIR
51 # is not the root directory if cross compiling.
52 # release:
53 # Does a `make distribution', and then tars up the DESTDIR files
54 # into ${RELEASEDIR}/${RELEASEMACHINEDIR}, in release(7) format.
55 # (See etc/Makefile for more information on this.)
56 # regression-tests:
57 # Runs the regression tests in "regress" on this host.
58 # sets:
59 # Populate ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
60 # from ${DESTDIR}
61 # sourcesets:
62 # Populate ${RELEASEDIR}/source/sets from ${NETBSDSRCDIR}
63 # syspkgs:
64 # Populate ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
65 # from ${DESTDIR}
66 # iso-image:
67 # Create CD-ROM image in RELEASEDIR/iso.
68 # RELEASEDIR must already have been populated by `make release'
69 # or equivalent.
70 # iso-image-source:
71 # Create CD-ROM image with source in RELEASEDIR/iso.
72 # RELEASEDIR must already have been populated by
73 # `make release sourcesets' or equivalent.
74 # live-image:
75 # Create bootable live image for emulators or USB stick etc.
76 # in RELEASEDIR/liveimage.
77 # RELEASEDIR must already have been populated by `make release'
78 # or equivalent.
79 # install-image:
80 # Create bootable installation image for USB stick etc.
81 # in RELEASEDIR/installimage.
82 # RELEASEDIR must already have been populated by `make release'
83 # or equivalent.
85 # Targets invoked by `make build,' in order:
86 # cleandir: cleans the tree.
87 # do-top-obj: creates the top level object directory.
88 # do-tools-obj: creates object directories for the host toolchain.
89 # do-tools: builds host toolchain.
90 # obj: creates object directories.
91 # do-distrib-dirs: creates the distribution directories.
92 # includes: installs include files.
93 # do-tools-compat: builds the "libnbcompat" library; needed for some
94 # random host tool programs in the source tree.
95 # do-lib: builds and installs prerequisites from lib
96 # if ${MKCOMPAT} != "no".
97 # do-compat-lib: builds and installs prerequisites from compat/lib
98 # if ${MKCOMPAT} != "no".
99 # do-build: builds and installs the entire system.
100 # do-x11: builds and installs X11 if ${MKX11} != "no"; either
101 # X11R7 from src/external/mit/xorg if ${X11FLAVOUR} == "Xorg"
102 # or X11R6 from src/x11
103 # do-extsrc: builds and installs extsrc if ${MKEXTSRC} != "no".
104 # do-obsolete: installs the obsolete sets (for the postinstall-* targets).
107 .if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
108 .MAKEFLAGS: -m ${.CURDIR}/share/mk
109 .endif
112 # If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may
113 # not be the top level objdir, because "make obj" can happen in the *middle*
114 # of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set
115 # _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}.
117 _SRC_TOP_OBJ_=
119 .include <bsd.own.mk>
122 # Sanity check: make sure that "make build" is not invoked simultaneously
123 # with a standard recursive target.
126 .if make(build) || make(release) || make(snapshot)
127 .for targ in ${TARGETS:Nobj:Ncleandir}
128 .if make(${targ}) && !target(.BEGIN)
129 .BEGIN:
130 @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
131 @false
132 .endif
133 .endfor
134 .endif
137 # _SUBDIR is used to set SUBDIR, after removing directories that have
138 # BUILD_${dir}=no, or that have no ${dir}/Makefile.
140 _SUBDIR= tools lib .WAIT include gnu external crypto/external bin games
141 _SUBDIR+= libexec sbin usr.bin
142 _SUBDIR+= commands man
143 _SUBDIR+= common drivers kernel servers
144 _SUBDIR+= usr.sbin share rescue sys etc test compat .WAIT distrib regress
146 .if defined(__MINIX)
147 _SUBDIR+= benchmarks
148 .endif
150 .for dir in ${_SUBDIR}
151 .if "${dir}" == ".WAIT" \
152 || (${BUILD_${dir}:Uyes} != "no" && exists(${dir}/Makefile))
153 SUBDIR+= ${dir}
154 .endif
155 .endfor
157 .if exists(regress)
158 regression-tests: .PHONY .MAKE
159 @echo Running regression tests...
160 ${MAKEDIRTARGET} regress regress
161 .endif
163 .if ${MKUNPRIVED} != "no"
164 NOPOSTINSTALL= # defined
165 .endif
167 afterinstall: .PHONY .MAKE
168 .if ${MKMAN} != "no"
169 .if !defined(__MINIX)
170 ${MAKEDIRTARGET} share/man makedb
171 .else
172 ${MAKEDIRTARGET} man makedb
173 .endif # !defined(__MINIX)
174 .endif
175 .if !defined(__MINIX)
176 .if (${MKUNPRIVED} != "no" && ${MKINFO} != "no")
177 ${MAKEDIRTARGET} gnu/usr.bin/texinfo/install-info infodir-meta
178 .endif
179 .endif # !defined(__MINIX)
180 .if !defined(NOPOSTINSTALL)
181 ${MAKEDIRTARGET} . postinstall-check
182 .endif
184 _POSTINSTALL= ${.CURDIR}/usr.sbin/postinstall/postinstall
185 _POSTINSTALL_ENV= \
186 AWK=${TOOL_AWK:Q} \
187 DB=${TOOL_DB:Q} \
188 HOST_SH=${HOST_SH:Q} \
189 MAKE=${MAKE:Q} \
190 PWD_MKDB=${TOOL_PWD_MKDB:Q} \
191 STAT=${TOOL_STAT:Q}
193 postinstall-check: .PHONY
194 @echo " === Post installation checks ==="
195 ${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ check; if [ $$? -gt 1 ]; then exit 1; fi
196 @echo " ================================"
198 postinstall-fix: .NOTMAIN .PHONY
199 @echo " === Post installation fixes ==="
200 ${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix
201 @echo " ==============================="
203 postinstall-fix-obsolete: .NOTMAIN .PHONY
204 @echo " === Removing obsolete files ==="
205 ${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix obsolete
206 @echo " ==============================="
210 # Targets (in order!) called by "make build".
212 .if defined(HAVE_GCC)
213 .if ${HAVE_GCC} == "4"
214 LIBGCC_EXT=4
215 BUILD_CC_LIB_BASEDIR= gnu/lib
216 BUILD_CC_LIB_BASETARGET= gnu-lib
217 .else
218 LIBGCC_EXT=
219 BUILD_CC_LIB_BASEDIR= external/gpl3/gcc/lib
220 BUILD_CC_LIB_BASETARGET= external-gpl3-gcc-lib
221 .endif
222 .endif
224 BUILDTARGETS+= check-tools
225 .if ${MKUPDATE} == "no" && !defined(NOCLEANDIR)
226 BUILDTARGETS+= cleandir
227 .endif
228 .if ${MKOBJDIRS} != "no"
229 BUILDTARGETS+= do-top-obj
230 .endif
231 .if ${USETOOLS} == "yes" # {
232 .if ${MKOBJDIRS} != "no"
233 BUILDTARGETS+= do-tools-obj
234 .endif
235 BUILDTARGETS+= do-tools
236 .endif # USETOOLS # }
237 .if ${MKOBJDIRS} != "no"
238 BUILDTARGETS+= obj
239 .endif
240 BUILDTARGETS+= clean_METALOG
241 .if !defined(NODISTRIBDIRS)
242 BUILDTARGETS+= do-distrib-dirs
243 .endif
244 .if !defined(NOINCLUDES)
245 BUILDTARGETS+= includes
246 .endif
247 BUILDTARGETS+= do-lib
248 .if !defined(__MINIX)
249 # LSC Not used in MINIX3
250 BUILDTARGETS+= do-compat-lib
251 .endif # !defined(__MINIX)
252 BUILDTARGETS+= do-build
253 .if ${MKX11} != "no"
254 BUILDTARGETS+= do-x11
255 .endif
256 .if ${MKEXTSRC} != "no"
257 BUILDTARGETS+= do-extsrc
258 .endif
259 BUILDTARGETS+= do-obsolete
262 # Enforce proper ordering of some rules.
265 .ORDER: ${BUILDTARGETS}
266 includes-lib: .PHONY includes-include includes-sys
267 includes-gnu: .PHONY includes-lib
270 # Build the system and install into DESTDIR.
273 START_TIME!= date
275 .if defined(__MINIX)
276 world: build .PHONY .MAKE
277 ${MAKEDIRTARGET} . etcfiles
278 @echo "WARNING: "
279 @echo "WARNING: The 'world' target is obsolete, please use 'build' instead."
280 @echo "WARNING: "
282 etcfiles: .PHONY .MAKE
283 ${MAKEDIRTARGET} etc install-etc-files-safe DESTDIR=${DESTDIR:U/}
285 etcforce: .PHONY .MAKE
286 ${MAKEDIRTARGET} etc install-etc-files DESTDIR=${DESTDIR:U/}
288 .endif # defined(__MINIX)
290 build: .PHONY .MAKE
291 .if defined(BUILD_DONE)
292 @echo "Build already installed into ${DESTDIR}"
293 .else
294 @echo "Build started at: ${START_TIME}"
295 .for tgt in ${BUILDTARGETS}
296 ${MAKEDIRTARGET} . ${tgt}
297 .endfor
298 ${MAKEDIRTARGET} etc install-etc-release
299 .if defined(__MINIX)
300 ${MAKEDIRTARGET} releasetools do-hdboot
301 .endif # defined(__MINIX)
302 @echo "Build started at: ${START_TIME}"
303 @printf "Build finished at: " && date
304 .endif
307 # Build a full distribution, but not a release (i.e. no sets into
308 # ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != /
311 distribution buildworld: .PHONY .MAKE
312 .if make(buildworld) && \
313 (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
314 @echo "Won't make ${.TARGET} with DESTDIR=/"
315 @false
316 .endif
317 ${MAKEDIRTARGET} . build NOPOSTINSTALL=1
318 ${MAKEDIRTARGET} etc distribution INSTALL_DONE=1
319 .if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" && ${CHECKFLIST:Uyes} == "yes"
320 ${MAKEDIRTARGET} . postinstall-fix-obsolete
321 ${MAKEDIRTARGET} distrib/sets checkflist
322 .endif
323 @echo "make ${.TARGET} started at: ${START_TIME}"
324 @printf "make ${.TARGET} finished at: " && date
327 # Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/')
328 # If installing to /, ensures that the host's operating system is NetBSD and
329 # the host's `uname -m` == ${MACHINE}.
332 HOST_UNAME_S!= uname -s
333 .if ${HOST_OSTYPE:C/\-.*//} != "Minix"
334 HOST_UNAME_M!= uname -m
335 .else
336 HOST_UNAME_M:= ${MACHINE}
337 .endif
339 installworld: .PHONY .MAKE
340 .if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
341 @echo "Can't make ${.TARGET} to DESTDIR=/"
342 @false
343 .endif
344 .if !defined(INSTALLWORLDDIR) || \
345 ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/"
346 .if (${HOST_UNAME_S} != "Minix")
347 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to Minix with INSTALLWORLDDIR=/"
348 @false
349 .endif
350 .if (${HOST_UNAME_M} != ${MACHINE})
351 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/"
352 @false
353 .endif
354 .endif
355 ${MAKEDIRTARGET} distrib/sets installsets \
356 INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS=${INSTALLSETS:Q}
357 ${MAKEDIRTARGET} . postinstall-check DESTDIR=${INSTALLWORLDDIR}
358 @echo "make ${.TARGET} started at: ${START_TIME}"
359 @printf "make ${.TARGET} finished at: " && date
362 # Install modules from $DESTDIR to $INSTALLMODULESDIR
364 installmodules: .PHONY .MAKE
365 .if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
366 @echo "Can't make ${.TARGET} to DESTDIR=/"
367 @false
368 .endif
369 .if !defined(INSTALLMODULESDIR) || \
370 ${INSTALLMODULESDIR} == "" || ${INSTALLMODULESDIR} == "/"
371 .if (${HOST_UNAME_S} != "NetBSD")
372 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLMODULESDIR=/"
373 @false
374 .endif
375 .if (${HOST_UNAME_M} != ${MACHINE})
376 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLMODULESDIR=/"
377 @false
378 .endif
379 .endif
380 ${MAKEDIRTARGET} sys/modules install DESTDIR=${INSTALLMODULESDIR:U/}
381 @echo "make ${.TARGET} started at: ${START_TIME}"
382 @printf "make ${.TARGET} finished at: " && date
385 # Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR
388 .for tgt in sets sourcesets syspkgs
389 ${tgt}: .PHONY .MAKE
390 ${MAKEDIRTARGET} distrib/sets ${tgt}
391 .endfor
394 # Build a release or snapshot (implies "make distribution"). Note that
395 # in this case, the set lists will be checked before the tar files
396 # are made.
399 release snapshot: .PHONY .MAKE
400 ${MAKEDIRTARGET} . distribution
401 ${MAKEDIRTARGET} etc release DISTRIBUTION_DONE=1
402 @echo "make ${.TARGET} started at: ${START_TIME}"
403 @printf "make ${.TARGET} finished at: " && date
406 # Create a CD-ROM image.
409 iso-image: .PHONY
410 ${MAKEDIRTARGET} distrib iso_image
411 ${MAKEDIRTARGET} etc iso-image
412 @echo "make ${.TARGET} started at: ${START_TIME}"
413 @printf "make ${.TARGET} finished at: " && date
415 iso-image-source: .PHONY
416 ${MAKEDIRTARGET} distrib iso_image CDSOURCE=true
417 ${MAKEDIRTARGET} etc iso-image
418 @echo "make ${.TARGET} started at: ${START_TIME}"
419 @printf "make ${.TARGET} finished at: " && date
422 # Create bootable live images.
425 live-image: .PHONY
426 ${MAKEDIRTARGET} etc live-image
427 @echo "make ${.TARGET} started at: ${START_TIME}"
428 @printf "make ${.TARGET} finished at: " && date
431 # Create bootable installation images.
434 install-image: .PHONY
435 ${MAKEDIRTARGET} etc install-image
436 @echo "make ${.TARGET} started at: ${START_TIME}"
437 @printf "make ${.TARGET} finished at: " && date
440 # Special components of the "make build" process.
443 check-tools: .PHONY
444 .if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN)
445 @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.'
446 @echo '*** May result in a failed build or corrupt binaries!'
447 .elif defined(EXTERNAL_TOOLCHAIN)
448 @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.'
449 .endif
450 .if defined(NBUILDJOBS)
451 @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!'
452 .endif
454 # Delete or sanitise a leftover METALOG from a previous build.
455 clean_METALOG: .PHONY .MAKE
456 .if ${MKUPDATE} != "no"
457 ${MAKEDIRTARGET} distrib/sets clean_METALOG
458 .endif
460 do-distrib-dirs: .PHONY .MAKE
461 .if !defined(DESTDIR) || ${DESTDIR} == ""
462 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=/
463 .else
464 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=${DESTDIR}
465 .endif
467 .for targ in cleandir obj includes
468 do-${targ}: .PHONY ${targ}
469 @true
470 .endfor
472 .for dir in tools tools/compat
473 do-${dir:S/\//-/g}: .PHONY .MAKE
474 .for targ in dependall install
475 ${MAKEDIRTARGET} ${dir} ${targ}
476 .endfor
477 .endfor
479 do-lib: .PHONY .MAKE
480 ${MAKEDIRTARGET} lib build_install
482 do-compat-lib: .PHONY .MAKE
483 ${MAKEDIRTARGET} compat build_install BOOTSTRAP_SUBDIRS="../../../lib"
485 do-top-obj: .PHONY .MAKE
486 ${MAKEDIRTARGET} . obj NOSUBDIR=
488 do-tools-obj: .PHONY .MAKE
489 ${MAKEDIRTARGET} tools obj
491 do-build: .PHONY .MAKE
492 .for targ in dependall install
493 ${MAKEDIRTARGET} . ${targ} BUILD_tools=no BUILD_lib=no
494 .endfor
496 do-x11: .PHONY .MAKE
497 .if ${MKX11} != "no"
498 .if ${X11FLAVOUR} == "Xorg"
499 ${MAKEDIRTARGET} external/mit/xorg build
500 .else
501 ${MAKEDIRTARGET} x11 build
502 .endif
503 .else
504 @echo "MKX11 is not enabled"
505 @false
506 .endif
508 do-extsrc: .PHONY .MAKE
509 .if ${MKEXTSRC} != "no"
510 ${MAKEDIRTARGET} extsrc build
511 .else
512 @echo "MKEXTSRC is not enabled"
513 @false
514 .endif
516 do-obsolete: .PHONY .MAKE
517 ${MAKEDIRTARGET} etc install-obsolete-lists
520 # Speedup stubs for some subtrees that don't need to run these rules.
521 # (Tells <bsd.subdir.mk> not to recurse for them.)
524 .for dir in bin etc distrib games libexec regress sbin usr.bin usr.sbin tools
525 includes-${dir}: .PHONY
526 @true
527 .endfor
528 .for dir in etc distrib regress
529 install-${dir}: .PHONY
530 @true
531 .endfor
534 # XXX this needs to change when distrib Makefiles are recursion compliant
535 # XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first...
537 dependall-distrib depend-distrib all-distrib: .PHONY
538 @true
540 .include <bsd.sys.mk>
541 .include <bsd.obj.mk>
542 .include <bsd.kernobj.mk>
543 .include <bsd.subdir.mk>
546 # Display current make(1) parameters
548 params: .PHONY .MAKE
549 ${MAKEDIRTARGET} etc params