1# 2# $FreeBSD$ 3# 4# Make command line options: 5# -DNO_DYNAMICROOT do not link /bin and /sbin dynamically 6# -DNO_KERBEROS Do not build Heimdal (Kerberos 5) 7# -DNO_RESCUE do not build rescue binaries 8# -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir 9# -DNO_CLEAN do not clean at all 10# -DNO_CRYPT will prevent building of crypt versions 11# -DNO_MAN do not build the manual pages 12# -DNO_NLS do not build Native Language Support files 13# -DNO_PROFILE do not build profiled libraries 14# -DNO_GAMES do not go into games subdir 15# -DNO_SHARE do not go into share subdir 16# -DNO_INFO do not make or install info files 17# -DNO_LIBC_R do not build libc_r. 18# -DNO_FORTRAN do not build g77 and related libraries. 19# -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel 20# -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel 21# -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel 22# -DNO_PORTSUPDATE do not update ports in ${MAKE} update 23# -DNO_DOCUPDATE do not update doc in ${MAKE} update 24# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list 25# TARGET_ARCH="arch" to crossbuild world to a different arch 26 27# 28# The intended user-driven targets are: 29# buildworld - rebuild *everything*, including glue to help do upgrades 30# installworld- install everything built by "buildworld" 31# update - convenient way to update your source tree (eg: cvsup/cvs) 32# 33# Standard targets (not defined here) are documented in the makefiles in 34# /usr/share/mk. These include: 35# obj depend all install clean cleandepend cleanobj 36 37# We must do share/info early so that installation of info `dir' 38# entries works correctly. Do it first since it is less likely to 39# grow dependencies on include and lib than vice versa. 40# 41# We must do lib and libexec before bin, because if installworld 42# installs a new /bin/sh, the 'make' command will *immediately* 43# use that new version. And the new (dynamically-linked) /bin/sh 44# will expect to find appropriate libraries in /lib and /libexec. 45# 46# We must do etc last for install/distribute to work. 47# 48SUBDIR= share/info include lib libexec bin 49.if !defined(NO_GAMES) 50SUBDIR+=games 51.endif 52SUBDIR+=gnu 53.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL) 54SUBDIR+=kerberos5 55.endif 56.if !defined(NO_RESCUE) 57SUBDIR+=rescue 58.endif 59SUBDIR+=sbin 60.if !defined(NO_CRYPT) 61SUBDIR+=secure 62.endif 63.if !defined(NO_SHARE) 64SUBDIR+=share 65.endif 66SUBDIR+=sys usr.bin usr.sbin etc 67 68# These are last, since it is nice to at least get the base system 69# rebuilt before you do them. 70.for _DIR in ${LOCAL_DIRS} 71.if exists(${.CURDIR}/${_DIR}/Makefile) 72SUBDIR+= ${_DIR} 73.endif 74.endfor 75 76.if defined(SUBDIR_OVERRIDE) 77SUBDIR= ${SUBDIR_OVERRIDE} 78.endif 79 80.if defined(NOCLEAN) 81NO_CLEAN= ${NOCLEAN} 82.endif 83.if defined(NO_CLEANDIR) 84CLEANDIR= clean cleandepend 85.else 86CLEANDIR= cleandir 87.endif 88 89CVS?= cvs 90CVSFLAGS?= -A -P -d -I! 91SUP?= /usr/local/bin/cvsup 92SUPFLAGS?= -g -L 2 -P - 93.if defined(SUPHOST) 94SUPFLAGS+= -h ${SUPHOST} 95.endif 96 97MAKEOBJDIRPREFIX?= /usr/obj 98.if !defined(OSRELDATE) 99.if exists(/usr/include/osreldate.h) 100OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \ 101 /usr/include/osreldate.h 102.else 103OSRELDATE= 0 104.endif 105.endif 106TARGET_ARCH?= ${MACHINE_ARCH} 107.if ${TARGET_ARCH} == ${MACHINE_ARCH} 108TARGET?= ${MACHINE} 109TARGET_CPUTYPE?=${CPUTYPE} 110.else 111TARGET?= ${TARGET_ARCH} 112TARGET_CPUTYPE?= 113.endif 114.if !empty(TARGET_CPUTYPE) 115_TARGET_CPUTYPE=${TARGET_CPUTYPE} 116.else 117_TARGET_CPUTYPE=dummy 118.endif 119_CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \ 120 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE 121.if ${_CPUTYPE} != ${_TARGET_CPUTYPE} 122.error CPUTYPE global should be set with ?=. 123.endif 124.if make(buildworld) 125BUILD_ARCH!= sysctl -n hw.machine_arch 126.if ${MACHINE_ARCH} != ${BUILD_ARCH} 127.error To cross-build, set TARGET_ARCH. 128.endif 129.endif 130.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING) 131OBJTREE= ${MAKEOBJDIRPREFIX} 132.else 133OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET} 134.endif 135WORLDTMP= ${OBJTREE}${.CURDIR}/tmp 136# /usr/games added for fortune which depend on strfile 137BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games 138XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games 139STRICTTMPPATH= ${BPATH}:${XPATH} 140TMPPATH= ${STRICTTMPPATH}:${PATH} 141 142INSTALLTMP!= /usr/bin/mktemp -d -u -t install 143 144# 145# Building a world goes through the following stages 146# 147# 1. legacy stage [BMAKE] 148# This stage is responsible for creating compatibility 149# shims that are needed by the bootstrap-tools, 150# build-tools and cross-tools stages. 151# 1. bootstrap-tools stage [BMAKE] 152# This stage is responsible for creating programs that 153# are needed for backward compatibility reasons. They 154# are not built as cross-tools. 155# 2. build-tools stage [TMAKE] 156# This stage is responsible for creating the object 157# tree and building any tools that are needed during 158# the build process. 159# 3. cross-tools stage [XMAKE] 160# This stage is responsible for creating any tools that 161# are needed for cross-builds. A cross-compiler is one 162# of them. 163# 4. world stage [WMAKE] 164# This stage actually builds the world. 165# 5. install stage (optional) [IMAKE] 166# This stage installs a previously built world. 167# 168 169BOOTSTRAPPING?= 0 170 171# Common environment for world related stages 172CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \ 173 MACHINE_ARCH=${TARGET_ARCH} \ 174 MACHINE=${TARGET} \ 175 CPUTYPE=${TARGET_CPUTYPE} \ 176 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \ 177 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \ 178 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac 179 180# bootstrap-tools stage 181BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \ 182 PATH=${BPATH}:${PATH} \ 183 WORLDTMP=${WORLDTMP} \ 184 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" 185BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \ 186 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \ 187 DESTDIR= \ 188 BOOTSTRAPPING=${OSRELDATE} \ 189 -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \ 190 -DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS 191 192# build-tools stage 193TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \ 194 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \ 195 DESTDIR= \ 196 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS 197 198# cross-tools stage 199XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB 200 201# world stage 202WMAKEENV= ${CROSSENV} \ 203 _SHLIBDIRPREFIX=${WORLDTMP} \ 204 INSTALL="sh ${.CURDIR}/tools/install.sh" \ 205 PATH=${TMPPATH} 206WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP} 207 208.if ${TARGET_ARCH} == "amd64" 209# 32 bit world 210LIB32TMP= ${OBJTREE}${.CURDIR}/lib32 211 212LIB32PREFLAGS= -m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT 213LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \ 214 -L${LIB32TMP}/usr/lib32 \ 215 -B${LIB32TMP}/usr/lib32 216LIB32CC= ${LIB32PREFLAGS} \ 217 ${LIB32POSTFLAGS} 218LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \ 219 ${LIB32POSTFLAGS} 220LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \ 221 ${LIB32POSTFLAGS} 222 223# Yes, the flags are redundant. 224LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \ 225 _SHLIBDIRPREFIX=${LIB32TMP} \ 226 MACHINE=i386 \ 227 MACHINE_ARCH=i386 \ 228 INSTALL="sh ${.CURDIR}/tools/install.sh" \ 229 PATH=${TMPPATH} \ 230 CC="${CC} ${LIB32CC}" \ 231 CXX="${CXX} ${LIB32CXX}" \ 232 OBJC="${OBJC} ${LIB32OBJC}" \ 233 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \ 234 AS="${AS} --32" \ 235 LIBDIR=/usr/lib32 \ 236 SHLIBDIR=/usr/lib32 237 238LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \ 239 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML \ 240 CC="${CC} ${LIB32CC}" \ 241 CXX="${CXX} ${LIB32CXX}" \ 242 OBJC="${OBJC} ${LIB32OBJC}" \ 243 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \ 244 AS="${AS} --32" \ 245 LIBDIR=/usr/lib32 \ 246 SHLIBDIR=/usr/lib32 247.endif 248 249# install stage 250.if empty(.MAKEFLAGS:M-n) 251IMAKEENV= ${CROSSENV} \ 252 PATH=${STRICTTMPPATH}:${INSTALLTMP} 253.else 254IMAKEENV= ${CROSSENV} \ 255 PATH=${TMPPATH}:${INSTALLTMP} 256.endif 257IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 258 259# kernel stage 260KMAKEENV= ${WMAKEENV} 261 262# 263# buildworld 264# 265# Attempt to rebuild the entire system, with reasonable chance of 266# success, regardless of how old your existing system is. 267# 268_worldtmp: 269.if ${.CURDIR:C/[^,]//g} != "" 270# The m4 build of sendmail files doesn't like it if ',' is used 271# anywhere in the path of it's files. 272 @echo 273 @echo "*** Error: path to source tree contains a comma ','" 274 @echo 275 false 276.endif 277 @echo 278 @echo "--------------------------------------------------------------" 279 @echo ">>> Rebuilding the temporary build tree" 280 @echo "--------------------------------------------------------------" 281.if !defined(NO_CLEAN) 282 rm -rf ${WORLDTMP} 283.else 284 rm -rf ${WORLDTMP}/legacy/usr/include 285 # XXX - These two can depend on any header file. 286 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c 287 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c 288.endif 289.for _dir in \ 290 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \ 291 usr/libexec usr/sbin usr/share/dict \ 292 usr/share/groff_font/devX100 \ 293 usr/share/groff_font/devX100-12 \ 294 usr/share/groff_font/devX75 \ 295 usr/share/groff_font/devX75-12 \ 296 usr/share/groff_font/devascii \ 297 usr/share/groff_font/devcp1047 \ 298 usr/share/groff_font/devdvi \ 299 usr/share/groff_font/devhtml \ 300 usr/share/groff_font/devkoi8-r \ 301 usr/share/groff_font/devlatin1 \ 302 usr/share/groff_font/devlbp \ 303 usr/share/groff_font/devlj4 \ 304 usr/share/groff_font/devps \ 305 usr/share/groff_font/devutf8 \ 306 usr/share/tmac/mdoc usr/share/tmac/mm 307 mkdir -p ${WORLDTMP}/legacy/${_dir} 308.endfor 309.for _dir in \ 310 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \ 311 usr/libexec usr/sbin usr/share/misc \ 312 usr/share/snmp/defs usr/share/snmp/mibs 313 mkdir -p ${WORLDTMP}/${_dir} 314.endfor 315 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 316 -p ${WORLDTMP}/usr/include >/dev/null 317 ln -sf ${.CURDIR}/sys ${WORLDTMP} 318.if defined(WITH_BIND_LIBS) && !defined(NO_BIND) 319 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \ 320 -p ${WORLDTMP}/usr/include >/dev/null 321.endif 322_legacy: 323 @echo 324 @echo "--------------------------------------------------------------" 325 @echo ">>> stage 1.1: legacy release compatibility shims" 326 @echo "--------------------------------------------------------------" 327 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy 328_bootstrap-tools: 329 @echo 330 @echo "--------------------------------------------------------------" 331 @echo ">>> stage 1.2: bootstrap tools" 332 @echo "--------------------------------------------------------------" 333 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools 334_cleanobj: 335.if !defined(NO_CLEAN) 336 @echo 337 @echo "--------------------------------------------------------------" 338 @echo ">>> stage 2.1: cleaning up the object tree" 339 @echo "--------------------------------------------------------------" 340 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/} 341.endif 342_obj: 343 @echo 344 @echo "--------------------------------------------------------------" 345 @echo ">>> stage 2.2: rebuilding the object tree" 346 @echo "--------------------------------------------------------------" 347 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj 348_build-tools: 349 @echo 350 @echo "--------------------------------------------------------------" 351 @echo ">>> stage 2.3: build tools" 352 @echo "--------------------------------------------------------------" 353 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools 354_cross-tools: 355 @echo 356 @echo "--------------------------------------------------------------" 357 @echo ">>> stage 3: cross tools" 358 @echo "--------------------------------------------------------------" 359 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools 360_includes: 361 @echo 362 @echo "--------------------------------------------------------------" 363 @echo ">>> stage 4.1: building includes" 364 @echo "--------------------------------------------------------------" 365 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes 366_libraries: 367 @echo 368 @echo "--------------------------------------------------------------" 369 @echo ">>> stage 4.2: building libraries" 370 @echo "--------------------------------------------------------------" 371 ${_+_}cd ${.CURDIR}; \ 372 ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \ 373 -DNO_NLS -DNO_PROFILE libraries 374_depend: 375 @echo 376 @echo "--------------------------------------------------------------" 377 @echo ">>> stage 4.3: make dependencies" 378 @echo "--------------------------------------------------------------" 379 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend 380everything: 381 @echo 382 @echo "--------------------------------------------------------------" 383 @echo ">>> stage 4.4: building everything" 384 @echo "--------------------------------------------------------------" 385 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all 386.if ${TARGET_ARCH} == "amd64" 387build32: 388 @echo 389 @echo "--------------------------------------------------------------" 390 @echo ">>> stage 5.1: building 32 bit shim libraries" 391 @echo "--------------------------------------------------------------" 392.for _dir in \ 393 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \ 394 usr/libexec usr/sbin usr/share/misc \ 395 usr/share/snmp/defs usr/share/snmp/mibs 396 mkdir -p ${LIB32TMP}/${_dir} 397.endfor 398 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 399 -p ${LIB32TMP}/usr/include >/dev/null 400 ln -sf ${.CURDIR}/sys ${WORLDTMP} 401.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL) 402.for _t in obj depend all 403 cd ${.CURDIR}/kerberos5/tools; \ 404 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t} 405.endfor 406.endif 407.for _t in obj includes 408 cd ${.CURDIR}/include; \ 409 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t} 410 cd ${.CURDIR}/lib; \ 411 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t} 412 cd ${.CURDIR}/gnu/lib; \ 413 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t} 414.if !defined(NO_CRYPT) 415 cd ${.CURDIR}/secure/lib; \ 416 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t} 417.endif 418.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL) 419 cd ${.CURDIR}/kerberos5/lib; \ 420 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t} 421.endif 422.endfor 423.for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib 424 cd ${.CURDIR}/${_dir}; \ 425 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj 426.endfor 427.for _dir in lib/libncurses lib/libmagic 428 cd ${.CURDIR}/${_dir}; \ 429 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools 430.endfor 431 cd ${.CURDIR}; \ 432 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries 433.for _t in obj depend all 434 cd ${.CURDIR}/libexec/rtld-elf; \ 435 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t} 436.endfor 437 438distribute32 install32: 439.if make(distribute32) 440 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree 441.else 442 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree 443.endif 444 cd ${.CURDIR}/lib; ${LIB32MAKE} ${.TARGET:S/32$//} 445 cd ${.CURDIR}/gnu/lib; ${LIB32MAKE} ${.TARGET:S/32$//} 446.if !defined(NO_CRYPT) 447 cd ${.CURDIR}/secure/lib; ${LIB32MAKE} ${.TARGET:S/32$//} 448.endif 449 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32MAKE} ${.TARGET:S/32$//} 450.endif 451 452 453WMAKE_TGTS= 454.if !defined(SUBDIR_OVERRIDE) 455WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools 456.endif 457WMAKE_TGTS+= _cleanobj _obj _build-tools 458.if !defined(SUBDIR_OVERRIDE) 459WMAKE_TGTS+= _cross-tools 460.endif 461WMAKE_TGTS+= _includes _libraries _depend everything 462.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32) 463WMAKE_TGTS+= build32 464.endif 465 466buildworld: ${WMAKE_TGTS} 467.ORDER: ${WMAKE_TGTS} 468 469buildenv: 470 @echo Entering world for ${TARGET_ARCH}:${TARGET} 471 @cd ${.CURDIR} && env ${WMAKEENV} sh || true 472 473TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything} 474toolchain: ${TOOLCHAIN_TGTS} 475kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} 476 477# 478# Use this to add checks to installworld/installkernel targets. 479# 480SPECIAL_INSTALLCHECKS= 481 482# 483# installcheck 484# 485# Checks to be sure system is ready for installworld 486# 487CHECK_UIDS= 488CHECK_GIDS= 489.if !defined(NO_SENDMAIL) 490CHECK_UIDS+= smmsp 491CHECK_GIDS+= smmsp 492.endif 493.if !defined(NO_PF) 494CHECK_UIDS+= proxy 495CHECK_GIDS+= proxy authpf 496.endif 497installcheck: ${SPECIAL_INSTALLCHECKS} 498.for uid in ${CHECK_UIDS} 499 @if ! `id -u ${uid} >/dev/null 2>&1`; then \ 500 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \ 501 false; \ 502 fi 503.endfor 504.for gid in ${CHECK_GIDS} 505 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \ 506 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \ 507 false; \ 508 fi 509.endfor 510 511# 512# distributeworld 513# 514# Distributes everything compiled by a `buildworld'. 515# 516# installworld 517# 518# Installs everything compiled by a 'buildworld'. 519# 520distributeworld installworld: installcheck 521 mkdir -p ${INSTALLTMP} 522 for prog in [ awk cap_mkdb cat chflags chmod chown \ 523 date echo egrep find grep install-info \ 524 ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \ 525 test true uname wc zic; do \ 526 cp `which $$prog` ${INSTALLTMP}; \ 527 done 528 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//} 529 rm -rf ${INSTALLTMP} 530 531# 532# reinstall 533# 534# If you have a build server, you can NFS mount the source and obj directories 535# and do a 'make reinstall' on the *client* to install new binaries from the 536# most recent server build. 537# 538reinstall: ${SPECIAL_INSTALLCHECKS} 539 @echo "--------------------------------------------------------------" 540 @echo ">>> Making hierarchy" 541 @echo "--------------------------------------------------------------" 542 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy 543 @echo 544 @echo "--------------------------------------------------------------" 545 @echo ">>> Installing everything" 546 @echo "--------------------------------------------------------------" 547 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install 548.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32) 549 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32 550.endif 551 552redistribute: 553 @echo "--------------------------------------------------------------" 554 @echo ">>> Distributing everything" 555 @echo "--------------------------------------------------------------" 556 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute 557.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32) 558 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32 559.endif 560 561distribution: 562 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} distribution 563 564# 565# buildkernel and installkernel 566# 567# Which kernels to build and/or install is specified by setting 568# KERNCONF. If not defined a GENERIC kernel is built/installed. 569# Only the existing (depending TARGET) config files are used 570# for building kernels and only the first of these is designated 571# as the one being installed. 572# 573# Note that we have to use TARGET instead of TARGET_ARCH when 574# we're in kernel-land. Since only TARGET_ARCH is (expected) to 575# be set to cross-build, we have to make sure TARGET is set 576# properly. 577 578.if !defined(KERNCONF) && defined(KERNEL) 579KERNCONF= ${KERNEL} 580KERNWARN= 581.else 582KERNCONF?= GENERIC 583.endif 584INSTKERNNAME?= kernel 585 586KERNSRCDIR?= ${.CURDIR}/sys 587KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf 588KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR} 589KERNCONFDIR?= ${KRNLCONFDIR} 590 591BUILDKERNELS= 592INSTALLKERNEL= 593.for _kernel in ${KERNCONF} 594.if exists(${KERNCONFDIR}/${_kernel}) 595BUILDKERNELS+= ${_kernel} 596.if empty(INSTALLKERNEL) 597INSTALLKERNEL= ${_kernel} 598.endif 599.endif 600.endfor 601 602# 603# buildkernel 604# 605# Builds all kernels defined by BUILDKERNELS. 606# 607buildkernel: 608.if empty(BUILDKERNELS) 609 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \ 610 false 611.endif 612.if defined(KERNWARN) 613 @echo "--------------------------------------------------------------" 614 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF=" 615 @echo "--------------------------------------------------------------" 616 @sleep 3 617.endif 618 @echo 619.for _kernel in ${BUILDKERNELS} 620 @echo "--------------------------------------------------------------" 621 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`" 622 @echo "--------------------------------------------------------------" 623 @echo "===> ${_kernel}" 624 mkdir -p ${KRNLOBJDIR} 625.if !defined(NO_KERNELCONFIG) 626 @echo 627 @echo "--------------------------------------------------------------" 628 @echo ">>> stage 1: configuring the kernel" 629 @echo "--------------------------------------------------------------" 630 cd ${KRNLCONFDIR}; \ 631 PATH=${TMPPATH} \ 632 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ 633 ${KERNCONFDIR}/${_kernel} 634.endif 635.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN) 636 @echo 637 @echo "--------------------------------------------------------------" 638 @echo ">>> stage 2.1: cleaning up the object tree" 639 @echo "--------------------------------------------------------------" 640 cd ${KRNLOBJDIR}/${_kernel}; \ 641 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR} 642.endif 643 @echo 644 @echo "--------------------------------------------------------------" 645 @echo ">>> stage 2.2: rebuilding the object tree" 646 @echo "--------------------------------------------------------------" 647 cd ${KRNLOBJDIR}/${_kernel}; \ 648 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj 649 @echo 650 @echo "--------------------------------------------------------------" 651 @echo ">>> stage 2.3: build tools" 652 @echo "--------------------------------------------------------------" 653 cd ${KRNLOBJDIR}/${_kernel}; \ 654 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \ 655 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile 656# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case. 657.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules) 658.for target in obj depend all 659 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \ 660 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \ 661 ${MAKE} -DNO_CPU_CFLAGS ${target} 662.endfor 663.endif 664.if !defined(NO_KERNELDEPEND) 665 @echo 666 @echo "--------------------------------------------------------------" 667 @echo ">>> stage 3.1: making dependencies" 668 @echo "--------------------------------------------------------------" 669 cd ${KRNLOBJDIR}/${_kernel}; \ 670 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ 671.endif 672 @echo 673 @echo "--------------------------------------------------------------" 674 @echo ">>> stage 3.2: building everything" 675 @echo "--------------------------------------------------------------" 676 cd ${KRNLOBJDIR}/${_kernel}; \ 677 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ 678 @echo "--------------------------------------------------------------" 679 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`" 680 @echo "--------------------------------------------------------------" 681.endfor 682 683# 684# installkernel, etc. 685# 686# Install the kernel defined by INSTALLKERNEL 687# 688installkernel installkernel.debug \ 689reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS} 690.if empty(INSTALLKERNEL) 691 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \ 692 false 693.endif 694 @echo "--------------------------------------------------------------" 695 @echo ">>> Making hierarchy" 696 @echo "--------------------------------------------------------------" 697 cd ${.CURDIR}; \ 698 ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy 699 @echo 700 @echo "--------------------------------------------------------------" 701 @echo ">>> Installing kernel" 702 @echo "--------------------------------------------------------------" 703 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ 704 ${CROSSENV} PATH=${TMPPATH} \ 705 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//} 706 707# 708# update 709# 710# Update the source tree, by running cvsup and/or running cvs to update to the 711# latest copy. 712# 713update: 714.if defined(SUP_UPDATE) 715 @echo "--------------------------------------------------------------" 716 @echo ">>> Running ${SUP}" 717 @echo "--------------------------------------------------------------" 718.if defined(SUPFILE) 719 @${SUP} ${SUPFLAGS} ${SUPFILE} 720.endif 721.if defined(SUPFILE1) 722 @${SUP} ${SUPFLAGS} ${SUPFILE1} 723.endif 724.if defined(SUPFILE2) 725 @${SUP} ${SUPFLAGS} ${SUPFILE2} 726.endif 727.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE) 728 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE} 729.endif 730.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE) 731 @${SUP} ${SUPFLAGS} ${DOCSUPFILE} 732.endif 733.endif 734.if defined(CVS_UPDATE) 735 @echo "--------------------------------------------------------------" 736 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} 737 @echo "--------------------------------------------------------------" 738 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS} 739.endif 740 741# 742# ------------------------------------------------------------------------ 743# 744# From here onwards are utility targets used by the 'make world' and 745# related targets. If your 'world' breaks, you may like to try to fix 746# the problem and manually run the following targets to attempt to 747# complete the build. Beware, this is *not* guaranteed to work, you 748# need to have a pretty good grip on the current state of the system 749# to attempt to manually finish it. If in doubt, 'make world' again. 750# 751 752# 753# legacy: Build compatibility shims for the next three targets 754# 755legacy: 756.if ${BOOTSTRAPPING} < 503000 757 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \ 758 false 759.endif 760.for _tool in tools/build 761 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \ 762 cd ${.CURDIR}/${_tool}; \ 763 ${MAKE} DIRPRFX=${_tool}/ obj; \ 764 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \ 765 ${MAKE} DIRPRFX=${_tool}/ depend; \ 766 ${MAKE} DIRPRFX=${_tool}/ all; \ 767 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install 768.endfor 769 770# 771# bootstrap-tools: Build tools needed for compatibility 772# 773.if !defined(NO_GAMES) 774_strfile= games/fortune/strfile 775.endif 776 777.if !defined(NO_CXX) 778_gperf= gnu/usr.bin/gperf 779.if ${BOOTSTRAPPING} < 500113 780_groff= gnu/usr.bin/groff 781.else 782_groff= gnu/usr.bin/groff/tmac 783.endif 784.endif 785 786.if ${BOOTSTRAPPING} < 600029 787_texinfo= gnu/usr.bin/texinfo 788.endif 789 790.if ${BOOTSTRAPPING} < 600015 791_cap_mkdb= usr.bin/cap_mkdb 792.endif 793 794.if ${BOOTSTRAPPING} < 600018 795_colldef= usr.bin/colldef 796.endif 797 798.if ${BOOTSTRAPPING} < 600017 799_gencat= usr.bin/gencat 800.endif 801 802.if ${BOOTSTRAPPING} < 600016 803_mklocale= usr.bin/mklocale 804.endif 805 806.if !defined(NO_RESCUE) && \ 807 ${BOOTSTRAPPING} < 600008 808_crunchgen= usr.sbin/crunch/crunchgen 809.endif 810 811.if ${BOOTSTRAPPING} < 600020 812_pwd_mkdb= usr.sbin/pwd_mkdb 813.endif 814 815bootstrap-tools: 816.for _tool in \ 817 ${_strfile} \ 818 ${_gperf} \ 819 ${_groff} \ 820 ${_texinfo} \ 821 ${_cap_mkdb} \ 822 ${_colldef} \ 823 ${_gencat} \ 824 usr.bin/lorder \ 825 usr.bin/makewhatis \ 826 ${_mklocale} \ 827 usr.bin/rpcgen \ 828 usr.bin/xinstall \ 829 usr.sbin/config \ 830 ${_crunchgen} \ 831 ${_pwd_mkdb} 832 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ 833 cd ${.CURDIR}/${_tool}; \ 834 ${MAKE} DIRPRFX=${_tool}/ obj; \ 835 ${MAKE} DIRPRFX=${_tool}/ depend; \ 836 ${MAKE} DIRPRFX=${_tool}/ all; \ 837 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install 838.endfor 839 840# 841# build-tools: Build special purpose build tools 842# 843.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules) 844_aicasm= sys/modules/aic7xxx/aicasm 845.endif 846 847.if !defined(NO_SHARE) 848_share= share/syscons/scrnmaps 849.endif 850 851.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL) 852_kerberos5_tools= kerberos5/tools 853.endif 854 855.if !defined(NO_RESCUE) 856_rescue= rescue/rescue 857.endif 858 859build-tools: 860.for _tool in \ 861 bin/csh \ 862 bin/sh \ 863 ${_rescue} \ 864 lib/libncurses \ 865 ${_share} \ 866 ${_aicasm} \ 867 usr.bin/awk \ 868 lib/libmagic \ 869 usr.sbin/sysinstall 870 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \ 871 cd ${.CURDIR}/${_tool}; \ 872 ${MAKE} DIRPRFX=${_tool}/ obj; \ 873 ${MAKE} DIRPRFX=${_tool}/ build-tools 874.endfor 875.for _tool in \ 876 gnu/usr.bin/cc/cc_tools \ 877 ${_kerberos5_tools} 878 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \ 879 cd ${.CURDIR}/${_tool}; \ 880 ${MAKE} DIRPRFX=${_tool}/ obj; \ 881 ${MAKE} DIRPRFX=${_tool}/ depend; \ 882 ${MAKE} DIRPRFX=${_tool}/ all 883.endfor 884 885# 886# cross-tools: Build cross-building tools 887# 888.if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \ 889 ${TARGET_ARCH} != ${MACHINE_ARCH} 890_btxld= usr.sbin/btxld 891.endif 892 893.if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \ 894 ${TARGET_ARCH} != ${MACHINE_ARCH} 895_crunchide= usr.sbin/crunch/crunchide 896.endif 897 898.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH} 899_elf2exe= usr.sbin/elf2exe 900.endif 901 902.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \ 903 defined(RELEASEDIR) 904_kgzip= usr.sbin/kgzip 905.endif 906 907cross-tools: 908.for _tool in \ 909 gnu/usr.bin/binutils \ 910 gnu/usr.bin/cc \ 911 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \ 912 ${_btxld} \ 913 ${_crunchide} \ 914 ${_elf2exe} \ 915 ${_kgzip} 916 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ 917 cd ${.CURDIR}/${_tool}; \ 918 ${MAKE} DIRPRFX=${_tool}/ obj; \ 919 ${MAKE} DIRPRFX=${_tool}/ depend; \ 920 ${MAKE} DIRPRFX=${_tool}/ all; \ 921 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install 922.endfor 923 924# 925# hierarchy - ensure that all the needed directories are present 926# 927hierarchy: 928 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs 929 930# 931# libraries - build all libraries, and install them under ${DESTDIR}. 932# 933# The list of libraries with dependents (${_prebuild_libs}) and their 934# interdependencies (__L) are built automatically by the 935# ${.CURDIR}/tools/make_libdeps.sh script. 936# 937libraries: 938 cd ${.CURDIR}; \ 939 ${MAKE} -f Makefile.inc1 _startup_libs; \ 940 ${MAKE} -f Makefile.inc1 _prebuild_libs; \ 941 ${MAKE} -f Makefile.inc1 _generic_libs; 942 943# These dependencies are not automatically generated: 944# 945# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all 946# shared libraries for ELF. 947# 948_startup_libs= gnu/lib/csu gnu/lib/libgcc 949.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf) 950_startup_libs+= lib/csu/${MACHINE_ARCH}-elf 951.else 952_startup_libs+= lib/csu/${MACHINE_ARCH} 953.endif 954 955_prebuild_libs= 956 957_generic_libs= gnu/lib 958 959.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL) 960_prebuild_libs+= kerberos5/lib/libasn1 961_prebuild_libs+= kerberos5/lib/libgssapi 962_prebuild_libs+= kerberos5/lib/libkrb5 963_prebuild_libs+= kerberos5/lib/libroken 964_generic_libs+= kerberos5/lib 965.endif 966 967_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \ 968 lib/libkvm lib/libmd \ 969 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \ 970 lib/libradius \ 971 lib/libsbuf lib/libtacplus lib/libutil \ 972 lib/libz lib/msun 973 974lib/libopie__L lib/libtacplus__L: lib/libmd__L 975 976.if !defined(NO_BIND) 977.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64" 978_prebuild_libs+= lib/libc_r 979.else 980_prebuild_libs+= lib/libpthread 981.endif 982.endif 983 984_generic_libs+= lib 985 986.if !defined(NO_CRYPT) 987.if !defined(NO_OPENSSL) 988_prebuild_libs+= secure/lib/libcrypto secure/lib/libssl 989lib/libradius__L: secure/lib/libssl__L 990secure/lib/libssl__L: secure/lib/libcrypto__L 991.if !defined(NO_OPENSSH) 992_prebuild_libs+= secure/lib/libssh 993secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L 994.if !defined(NO_KERBEROS) 995secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \ 996 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \ 997 kerberos5/lib/libroken__L 998.endif 999.endif 1000.endif 1001_generic_libs+= secure/lib 1002.endif 1003 1004.if defined(NO_CRYPT) || defined(NO_OPENSSL) 1005lib/libradius__L: lib/libmd__L 1006.endif 1007 1008.if !defined(NO_NIS) 1009_prebuild_libs+= lib/libypclnt 1010.endif 1011 1012_generic_libs+= usr.bin/lex/lib 1013 1014.if ${MACHINE_ARCH} == "i386" 1015_generic_libs+= usr.sbin/pcvt/keycap 1016.endif 1017 1018.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs} 1019${_lib}__L: .PHONY 1020.if exists(${.CURDIR}/${_lib}) 1021 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \ 1022 cd ${.CURDIR}/${_lib}; \ 1023 ${MAKE} DIRPRFX=${_lib}/ depend; \ 1024 ${MAKE} DIRPRFX=${_lib}/ all; \ 1025 ${MAKE} DIRPRFX=${_lib}/ install 1026.endif 1027.endfor 1028 1029# libpam is special: we need to build static PAM modules before 1030# static PAM library, and dynamic PAM library before dynamic PAM 1031# modules. 1032lib/libpam__L: .PHONY 1033 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \ 1034 cd ${.CURDIR}/lib/libpam; \ 1035 ${MAKE} DIRPRFX=lib/libpam/ depend; \ 1036 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \ 1037 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install 1038 1039_startup_libs: ${_startup_libs:S/$/__L/} 1040_prebuild_libs: ${_prebuild_libs:S/$/__L/} 1041_generic_libs: ${_generic_libs:S/$/__L/} 1042 1043.for __target in all clean cleandepend cleandir depend includes obj 1044.for entry in ${SUBDIR} 1045${entry}.${__target}__D: .PHONY 1046 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \ 1047 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \ 1048 edir=${entry}.${MACHINE_ARCH}; \ 1049 cd ${.CURDIR}/$${edir}; \ 1050 else \ 1051 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \ 1052 edir=${entry}; \ 1053 cd ${.CURDIR}/$${edir}; \ 1054 fi; \ 1055 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/ 1056.endfor 1057par-${__target}: ${SUBDIR:S/$/.${__target}__D/} 1058.endfor 1059 1060.include <bsd.subdir.mk> 1061