1# 2# $FreeBSD$ 3# 4# Make command line options: 5# -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir 6# -DNO_CLEAN do not clean at all 7# -DNO_SHARE do not go into share subdir 8# -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ} 9# -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel 10# -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel 11# -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel 12# -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel 13# -DNO_PORTSUPDATE do not update ports in ${MAKE} update 14# -DNO_DOCUPDATE do not update doc in ${MAKE} update 15# -DNO_CTF do not run the DTrace CTF conversion tools on built objects 16# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list 17# TARGET="machine" to crossbuild world for a different machine type 18# TARGET_ARCH= may be required when a TARGET supports multiple endians 19 20# 21# The intended user-driven targets are: 22# buildworld - rebuild *everything*, including glue to help do upgrades 23# installworld- install everything built by "buildworld" 24# doxygen - build API documentation of the kernel 25# update - convenient way to update your source tree (eg: cvsup/cvs) 26# 27# Standard targets (not defined here) are documented in the makefiles in 28# /usr/share/mk. These include: 29# obj depend all install clean cleandepend cleanobj 30 31# You are supposed to define both of these when calling Makefile.inc1 32# directly. However, some old scripts don't. Cope for the moment, but 33# issue a new warning for a transition period. 34.if defined(TARGET) && !defined(TARGET_ARCH) 35.warning "You must pass both TARGET and TARGET_ARCH to Makefile.inc1. Setting TARGET_ARCH=${TARGET}." 36TARGET_ARCH=${TARGET} 37.endif 38.if !defined(TARGET) || !defined(TARGET_ARCH) 39.error "Both TARGET and TARGET_ARCH must be defined." 40.endif 41 42.include <bsd.own.mk> 43.include <bsd.arch.inc.mk> 44 45# We must do share/info early so that installation of info `dir' 46# entries works correctly. Do it first since it is less likely to 47# grow dependencies on include and lib than vice versa. 48# 49# We must do lib/ and libexec/ before bin/, because if installworld 50# installs a new /bin/sh, the 'make' command will *immediately* 51# use that new version. And the new (dynamically-linked) /bin/sh 52# will expect to find appropriate libraries in /lib and /libexec. 53# 54SUBDIR= share/info lib libexec 55SUBDIR+=bin 56.if ${MK_GAMES} != "no" 57SUBDIR+=games 58.endif 59.if ${MK_CDDL} != "no" 60SUBDIR+=cddl 61.else 62NO_CTF=1 63.endif 64SUBDIR+=gnu include 65.if ${MK_KERBEROS} != "no" 66SUBDIR+=kerberos5 67.endif 68.if ${MK_RESCUE} != "no" 69SUBDIR+=rescue 70.endif 71SUBDIR+=sbin 72.if ${MK_CRYPT} != "no" 73SUBDIR+=secure 74.endif 75.if !defined(NO_SHARE) 76SUBDIR+=share 77.endif 78SUBDIR+=sys usr.bin usr.sbin 79# 80# We must do etc/ last for install/distribute to work. 81# 82SUBDIR+=etc 83 84# These are last, since it is nice to at least get the base system 85# rebuilt before you do them. 86.for _DIR in ${LOCAL_DIRS} 87.if exists(${.CURDIR}/${_DIR}/Makefile) 88SUBDIR+= ${_DIR} 89.endif 90.endfor 91 92.if defined(SUBDIR_OVERRIDE) 93SUBDIR= ${SUBDIR_OVERRIDE} 94.endif 95 96.if defined(NOCLEAN) 97NO_CLEAN= ${NOCLEAN} 98.endif 99.if defined(NO_CLEANDIR) 100CLEANDIR= clean cleandepend 101.else 102CLEANDIR= cleandir 103.endif 104 105CVS?= cvs 106CVSFLAGS?= -A -P -d -I! 107SVN?= svn 108SVNFLAGS?= -r HEAD 109SUP?= /usr/bin/csup 110SUPFLAGS?= -g -L 2 111.if defined(SUPHOST) 112SUPFLAGS+= -h ${SUPHOST} 113.endif 114 115MAKEOBJDIRPREFIX?= /usr/obj 116.if !defined(OSRELDATE) 117.if exists(/usr/include/osreldate.h) 118OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \ 119 /usr/include/osreldate.h 120.else 121OSRELDATE= 0 122.endif 123.endif 124 125.if !defined(VERSION) 126VERSION!= uname -srp 127VERSION+= ${OSRELDATE} 128.endif 129 130KNOWN_ARCHES?= amd64 arm armeb/arm i386 i386/pc98 ia64 mipsel/mips mipseb/mips mips64el/mips mips64eb/mips mipsn32el/mips mipsn32eb/mips powerpc powerpc64/powerpc sparc64 sparc64/sun4v 131.if ${TARGET} == ${TARGET_ARCH} 132_t= ${TARGET} 133.else 134_t= ${TARGET_ARCH}/${TARGET} 135.endif 136.for _t in ${_t} 137.if empty(KNOWN_ARCHES:M${_t}) 138.error Unknown target ${TARGET_ARCH}:${TARGET}. 139.endif 140.endfor 141 142.if ${TARGET} == ${MACHINE} 143TARGET_CPUTYPE?=${CPUTYPE} 144.else 145TARGET_CPUTYPE?= 146.endif 147 148.if !empty(TARGET_CPUTYPE) 149_TARGET_CPUTYPE=${TARGET_CPUTYPE} 150.else 151_TARGET_CPUTYPE=dummy 152.endif 153_CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \ 154 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE 155.if ${_CPUTYPE} != ${_TARGET_CPUTYPE} 156.error CPUTYPE global should be set with ?=. 157.endif 158.if make(buildworld) 159BUILD_ARCH!= uname -p 160.if ${MACHINE_ARCH} != ${BUILD_ARCH} 161.error To cross-build, set TARGET_ARCH. 162.endif 163.endif 164.if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING) 165OBJTREE= ${MAKEOBJDIRPREFIX} 166.else 167OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH} 168.endif 169WORLDTMP= ${OBJTREE}${.CURDIR}/tmp 170# /usr/games added for fortune which depend on strfile 171BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games 172XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games 173STRICTTMPPATH= ${BPATH}:${XPATH} 174TMPPATH= ${STRICTTMPPATH}:${PATH} 175 176# 177# Avoid running mktemp(1) unless actually needed. 178# It may not be functional, e.g., due to new ABI 179# when in the middle of installing over this system. 180# 181.if make(distributeworld) || make(installworld) 182INSTALLTMP!= /usr/bin/mktemp -d -u -t install 183.endif 184 185# 186# Building a world goes through the following stages 187# 188# 1. legacy stage [BMAKE] 189# This stage is responsible for creating compatibility 190# shims that are needed by the bootstrap-tools, 191# build-tools and cross-tools stages. 192# 1. bootstrap-tools stage [BMAKE] 193# This stage is responsible for creating programs that 194# are needed for backward compatibility reasons. They 195# are not built as cross-tools. 196# 2. build-tools stage [TMAKE] 197# This stage is responsible for creating the object 198# tree and building any tools that are needed during 199# the build process. 200# 3. cross-tools stage [XMAKE] 201# This stage is responsible for creating any tools that 202# are needed for cross-builds. A cross-compiler is one 203# of them. 204# 4. world stage [WMAKE] 205# This stage actually builds the world. 206# 5. install stage (optional) [IMAKE] 207# This stage installs a previously built world. 208# 209 210BOOTSTRAPPING?= 0 211 212# Common environment for world related stages 213CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \ 214 MACHINE_ARCH=${TARGET_ARCH} \ 215 MACHINE=${TARGET} \ 216 CPUTYPE=${TARGET_CPUTYPE} 217.if ${OSRELDATE} < 700044 218CROSSENV+= AR=gnu-ar RANLIB=gnu-ranlib 219.endif 220.if ${MK_GROFF} != "no" 221CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \ 222 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \ 223 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac 224.endif 225 226# bootstrap-tools stage 227BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \ 228 PATH=${BPATH}:${PATH} \ 229 WORLDTMP=${WORLDTMP} \ 230 VERSION="${VERSION}" \ 231 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" 232BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \ 233 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \ 234 DESTDIR= \ 235 BOOTSTRAPPING=${OSRELDATE} \ 236 SSP_CFLAGS= \ 237 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \ 238 -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \ 239 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF 240 241# build-tools stage 242TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \ 243 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \ 244 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ 245 DESTDIR= \ 246 SSP_CFLAGS= \ 247 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS \ 248 -DNO_WARNS -DNO_CTF 249 250# cross-tools stage 251XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \ 252 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ 253 -DWITHOUT_GDB 254 255# world stage 256WMAKEENV= ${CROSSENV} \ 257 _SHLIBDIRPREFIX=${WORLDTMP} \ 258 VERSION="${VERSION}" \ 259 INSTALL="sh ${.CURDIR}/tools/install.sh" \ 260 PATH=${TMPPATH} 261.if ${MK_CDDL} == "no" 262WMAKEENV+= NO_CTF=1 263.endif 264WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP} 265 266.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64" 267# 32 bit world 268LIB32TMP= ${OBJTREE}${.CURDIR}/lib32 269 270.if ${TARGET_ARCH} == "amd64" 271.if empty(TARGET_CPUTYPE) 272LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 273.else 274LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} 275.endif 276LIB32CPUFLAGS+= -mfancy-math-387 277LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \ 278 MACHINE_CPU="i686 mmx sse sse2" \ 279 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \ 280 AS="${AS} --32" 281 282.elif ${TARGET_ARCH} == "powerpc64" 283.if empty(TARGET_CPUTYPE) 284LIB32CPUFLAGS= -mcpu=powerpc 285.else 286LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE} 287.endif 288LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc \ 289 LD="${LD} -m elf32ppc" 290.endif 291 292 293LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \ 294 -isystem ${LIB32TMP}/usr/include/ \ 295 -L${LIB32TMP}/usr/lib32 \ 296 -B${LIB32TMP}/usr/lib32 297 298# Yes, the flags are redundant. 299LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \ 300 _SHLIBDIRPREFIX=${LIB32TMP} \ 301 VERSION="${VERSION}" \ 302 INSTALL="sh ${.CURDIR}/tools/install.sh" \ 303 PATH=${TMPPATH} \ 304 CC="${CC} ${LIB32FLAGS}" \ 305 CXX="${CXX} ${LIB32FLAGS}" \ 306 OBJC="${OBJC} ${LIB32FLAGS}" \ 307 LIBDIR=/usr/lib32 \ 308 SHLIBDIR=/usr/lib32 309 310LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \ 311 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \ 312 -DWITHOUT_HTML -DNO_CTF -DNO_LINT DESTDIR=${LIB32TMP} 313LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS 314.endif 315 316# install stage 317IMAKEENV= ${CROSSENV} 318IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 319.if empty(.MAKEFLAGS:M-n) 320IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \ 321 LD_LIBRARY_PATH=${INSTALLTMP} \ 322 PATH_LOCALE=${INSTALLTMP}/locale 323IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh 324.else 325IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP} 326.endif 327 328# kernel stage 329KMAKEENV= ${WMAKEENV} 330KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} 331 332# 333# buildworld 334# 335# Attempt to rebuild the entire system, with reasonable chance of 336# success, regardless of how old your existing system is. 337# 338_worldtmp: 339.if ${.CURDIR:C/[^,]//g} != "" 340# The m4 build of sendmail files doesn't like it if ',' is used 341# anywhere in the path of it's files. 342 @echo 343 @echo "*** Error: path to source tree contains a comma ','" 344 @echo 345 false 346.endif 347 @echo 348 @echo "--------------------------------------------------------------" 349 @echo ">>> Rebuilding the temporary build tree" 350 @echo "--------------------------------------------------------------" 351.if !defined(NO_CLEAN) 352 rm -rf ${WORLDTMP} 353.if defined(LIB32TMP) 354 rm -rf ${LIB32TMP} 355.endif 356.else 357 rm -rf ${WORLDTMP}/legacy/usr/include 358# XXX - These three can depend on any header file. 359 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c 360 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c 361 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c 362.endif 363.for _dir in \ 364 lib usr legacy/usr 365 mkdir -p ${WORLDTMP}/${_dir} 366.endfor 367 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 368 -p ${WORLDTMP}/legacy/usr >/dev/null 369.if ${MK_GROFF} != "no" 370 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \ 371 -p ${WORLDTMP}/legacy/usr >/dev/null 372.endif 373 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 374 -p ${WORLDTMP}/usr >/dev/null 375 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 376 -p ${WORLDTMP}/usr/include >/dev/null 377 ln -sf ${.CURDIR}/sys ${WORLDTMP} 378.if ${MK_BIND_LIBS} != "no" 379 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \ 380 -p ${WORLDTMP}/usr/include >/dev/null 381.endif 382_legacy: 383 @echo 384 @echo "--------------------------------------------------------------" 385 @echo ">>> stage 1.1: legacy release compatibility shims" 386 @echo "--------------------------------------------------------------" 387 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy 388_bootstrap-tools: 389 @echo 390 @echo "--------------------------------------------------------------" 391 @echo ">>> stage 1.2: bootstrap tools" 392 @echo "--------------------------------------------------------------" 393 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools 394_cleanobj: 395.if !defined(NO_CLEAN) 396 @echo 397 @echo "--------------------------------------------------------------" 398 @echo ">>> stage 2.1: cleaning up the object tree" 399 @echo "--------------------------------------------------------------" 400 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/} 401.if defined(LIB32TMP) 402 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/} 403.endif 404.endif 405_obj: 406 @echo 407 @echo "--------------------------------------------------------------" 408 @echo ">>> stage 2.2: rebuilding the object tree" 409 @echo "--------------------------------------------------------------" 410 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj 411_build-tools: 412 @echo 413 @echo "--------------------------------------------------------------" 414 @echo ">>> stage 2.3: build tools" 415 @echo "--------------------------------------------------------------" 416 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools 417_cross-tools: 418 @echo 419 @echo "--------------------------------------------------------------" 420 @echo ">>> stage 3: cross tools" 421 @echo "--------------------------------------------------------------" 422 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools 423_includes: 424 @echo 425 @echo "--------------------------------------------------------------" 426 @echo ">>> stage 4.1: building includes" 427 @echo "--------------------------------------------------------------" 428 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes 429_libraries: 430 @echo 431 @echo "--------------------------------------------------------------" 432 @echo ">>> stage 4.2: building libraries" 433 @echo "--------------------------------------------------------------" 434 ${_+_}cd ${.CURDIR}; \ 435 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \ 436 -DWITHOUT_MAN -DWITHOUT_PROFILE libraries 437_depend: 438 @echo 439 @echo "--------------------------------------------------------------" 440 @echo ">>> stage 4.3: make dependencies" 441 @echo "--------------------------------------------------------------" 442 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend 443everything: 444 @echo 445 @echo "--------------------------------------------------------------" 446 @echo ">>> stage 4.4: building everything" 447 @echo "--------------------------------------------------------------" 448 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all 449.if defined(LIB32TMP) 450build32: 451 @echo 452 @echo "--------------------------------------------------------------" 453 @echo ">>> stage 5.1: building 32 bit shim libraries" 454 @echo "--------------------------------------------------------------" 455 mkdir -p ${LIB32TMP}/usr/include 456 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 457 -p ${LIB32TMP}/usr >/dev/null 458 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 459 -p ${LIB32TMP}/usr/include >/dev/null 460 mkdir -p ${WORLDTMP} 461 ln -sf ${.CURDIR}/sys ${WORLDTMP} 462.if ${MK_KERBEROS} != "no" 463.for _t in obj depend all 464 cd ${.CURDIR}/kerberos5/tools; \ 465 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \ 466 ${_t} 467.endfor 468.endif 469.for _t in obj includes 470 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t} 471 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t} 472.if ${MK_CDDL} != "no" 473 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t} 474.endif 475 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t} 476.if ${MK_CRYPT} != "no" 477 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t} 478.endif 479.if ${MK_KERBEROS} != "no" 480 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t} 481.endif 482.endfor 483.for _dir in usr.bin/lex/lib 484 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj 485.endfor 486.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic 487 cd ${.CURDIR}/${_dir}; \ 488 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \ 489 build-tools 490.endfor 491 cd ${.CURDIR}; \ 492 ${LIB32WMAKE} -f Makefile.inc1 libraries 493.for _t in obj depend all 494 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t} 495 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} ${_t} 496.endfor 497 498distribute32 install32: 499 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} 500.if ${MK_CDDL} != "no" 501 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} 502.endif 503 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} 504.if ${MK_CRYPT} != "no" 505 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} 506.endif 507.if ${MK_KERBEROS} != "no" 508 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} 509.endif 510 cd ${.CURDIR}/libexec/rtld-elf; \ 511 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//} 512 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//} 513.endif 514 515WMAKE_TGTS= 516.if !defined(SUBDIR_OVERRIDE) 517WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools 518.endif 519WMAKE_TGTS+= _cleanobj _obj _build-tools 520.if !defined(SUBDIR_OVERRIDE) 521WMAKE_TGTS+= _cross-tools 522.endif 523WMAKE_TGTS+= _includes _libraries _depend everything 524.if defined(LIB32TMP) && ${MK_LIB32} != "no" 525WMAKE_TGTS+= build32 526.endif 527 528buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue 529.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue 530 531buildworld_prologue: 532 @echo "--------------------------------------------------------------" 533 @echo ">>> World build started on `LC_ALL=C date`" 534 @echo "--------------------------------------------------------------" 535 536buildworld_epilogue: 537 @echo 538 @echo "--------------------------------------------------------------" 539 @echo ">>> World build completed on `LC_ALL=C date`" 540 @echo "--------------------------------------------------------------" 541 542# 543# We need to have this as a target because the indirection between Makefile 544# and Makefile.inc1 causes the correct PATH to be used, rather than a 545# modification of the current environment's PATH. In addition, we need 546# to quote multiword values. 547# 548buildenvvars: 549 @echo ${WMAKEENV:Q} 550 551buildenv: 552 @echo Entering world for ${TARGET_ARCH}:${TARGET} 553 @cd ${.CURDIR} && env ${WMAKEENV} sh || true 554 555TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32} 556toolchain: ${TOOLCHAIN_TGTS} 557kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} 558 559# 560# installcheck 561# 562# Checks to be sure system is ready for installworld/installkernel. 563# 564installcheck: 565 566# 567# Require DESTDIR to be set if installing for a different architecture. 568# 569.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} 570.if !make(distributeworld) 571installcheck: installcheck_DESTDIR 572installcheck_DESTDIR: 573.if !defined(DESTDIR) || empty(DESTDIR) 574 @echo "ERROR: Please set DESTDIR!"; \ 575 false 576.endif 577.endif 578.endif 579 580# 581# Check for missing UIDs/GIDs. 582# 583CHECK_UIDS= 584CHECK_GIDS= audit 585.if ${MK_SENDMAIL} != "no" 586CHECK_UIDS+= smmsp 587CHECK_GIDS+= smmsp 588.endif 589.if ${MK_PF} != "no" 590CHECK_UIDS+= proxy 591CHECK_GIDS+= proxy authpf 592.endif 593installcheck: installcheck_UGID 594installcheck_UGID: 595.for uid in ${CHECK_UIDS} 596 @if ! `id -u ${uid} >/dev/null 2>&1`; then \ 597 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \ 598 false; \ 599 fi 600.endfor 601.for gid in ${CHECK_GIDS} 602 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \ 603 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \ 604 false; \ 605 fi 606.endfor 607 608# 609# Required install tools to be saved in a scratch dir for safety. 610# 611.if ${MK_INFO} != "no" 612_install-info= install-info 613.endif 614.if ${MK_ZONEINFO} != "no" 615_zoneinfo= zic tzsetup 616.endif 617 618ITOOLS= [ awk cap_mkdb cat chflags chmod chown \ 619 date echo egrep find grep ${_install-info} \ 620 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \ 621 test true uname wc ${_zoneinfo} 622 623# 624# distributeworld 625# 626# Distributes everything compiled by a `buildworld'. 627# 628# installworld 629# 630# Installs everything compiled by a 'buildworld'. 631# 632distributeworld installworld: installcheck 633 mkdir -p ${INSTALLTMP} 634 progs=$$(for prog in ${ITOOLS}; do \ 635 if progpath=`which $$prog`; then \ 636 echo $$progpath; \ 637 else \ 638 echo "Required tool $$prog not found in PATH." >&2; \ 639 exit 1; \ 640 fi; \ 641 done); \ 642 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \ 643 while read line; do \ 644 set -- $$line; \ 645 if [ "$$2 $$3" != "not found" ]; then \ 646 echo $$2; \ 647 else \ 648 echo "Required library $$1 not found." >&2; \ 649 exit 1; \ 650 fi; \ 651 done); \ 652 cp $$libs $$progs ${INSTALLTMP} 653 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale 654 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \ 655 ${IMAKEENV} rm -rf ${INSTALLTMP} 656 657# 658# reinstall 659# 660# If you have a build server, you can NFS mount the source and obj directories 661# and do a 'make reinstall' on the *client* to install new binaries from the 662# most recent server build. 663# 664reinstall: 665 @echo "--------------------------------------------------------------" 666 @echo ">>> Making hierarchy" 667 @echo "--------------------------------------------------------------" 668 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy 669 @echo 670 @echo "--------------------------------------------------------------" 671 @echo ">>> Installing everything" 672 @echo "--------------------------------------------------------------" 673 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install 674.if defined(LIB32TMP) && ${MK_LIB32} != "no" 675 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32 676.endif 677 678redistribute: 679 @echo "--------------------------------------------------------------" 680 @echo ">>> Distributing everything" 681 @echo "--------------------------------------------------------------" 682 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute 683.if defined(LIB32TMP) && ${MK_LIB32} != "no" 684 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \ 685 DISTRIBUTION=lib32 686.endif 687 688distrib-dirs distribution: 689 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET} 690 691# 692# buildkernel and installkernel 693# 694# Which kernels to build and/or install is specified by setting 695# KERNCONF. If not defined a GENERIC kernel is built/installed. 696# Only the existing (depending TARGET) config files are used 697# for building kernels and only the first of these is designated 698# as the one being installed. 699# 700# Note that we have to use TARGET instead of TARGET_ARCH when 701# we're in kernel-land. Since only TARGET_ARCH is (expected) to 702# be set to cross-build, we have to make sure TARGET is set 703# properly. 704 705.if defined(KERNFAST) 706NO_KERNELCLEAN= t 707NO_KERNELCONFIG= t 708NO_KERNELDEPEND= t 709NO_KERNELOBJ= t 710# Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah 711.if !defined(KERNCONF) && ${KERNFAST} != "1" 712KERNCONF=${KERNFAST} 713.endif 714.endif 715.if !defined(KERNCONF) && defined(KERNEL) 716KERNCONF= ${KERNEL} 717KERNWARN= 718.else 719.if ${TARGET_ARCH} == "powerpc64" 720KERNCONF?= GENERIC64 721.else 722KERNCONF?= GENERIC 723.endif 724.endif 725INSTKERNNAME?= kernel 726 727KERNSRCDIR?= ${.CURDIR}/sys 728KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf 729KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR} 730KERNCONFDIR?= ${KRNLCONFDIR} 731 732BUILDKERNELS= 733INSTALLKERNEL= 734.for _kernel in ${KERNCONF} 735.if exists(${KERNCONFDIR}/${_kernel}) 736BUILDKERNELS+= ${_kernel} 737.if empty(INSTALLKERNEL) 738INSTALLKERNEL= ${_kernel} 739.endif 740.endif 741.endfor 742 743# 744# buildkernel 745# 746# Builds all kernels defined by BUILDKERNELS. 747# 748buildkernel: 749.if empty(BUILDKERNELS) 750 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \ 751 false 752.endif 753.if defined(KERNWARN) 754 @echo "--------------------------------------------------------------" 755 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF=" 756 @echo "--------------------------------------------------------------" 757 @sleep 3 758.endif 759 @echo 760.for _kernel in ${BUILDKERNELS} 761 @echo "--------------------------------------------------------------" 762 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`" 763 @echo "--------------------------------------------------------------" 764 @echo "===> ${_kernel}" 765 mkdir -p ${KRNLOBJDIR} 766.if !defined(NO_KERNELCONFIG) 767 @echo 768 @echo "--------------------------------------------------------------" 769 @echo ">>> stage 1: configuring the kernel" 770 @echo "--------------------------------------------------------------" 771 cd ${KRNLCONFDIR}; \ 772 PATH=${TMPPATH} \ 773 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ 774 ${KERNCONFDIR}/${_kernel} 775.endif 776.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN) 777 @echo 778 @echo "--------------------------------------------------------------" 779 @echo ">>> stage 2.1: cleaning up the object tree" 780 @echo "--------------------------------------------------------------" 781 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR} 782.endif 783.if !defined(NO_KERNELOBJ) 784 @echo 785 @echo "--------------------------------------------------------------" 786 @echo ">>> stage 2.2: rebuilding the object tree" 787 @echo "--------------------------------------------------------------" 788 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj 789.endif 790 @echo 791 @echo "--------------------------------------------------------------" 792 @echo ">>> stage 2.3: build tools" 793 @echo "--------------------------------------------------------------" 794 cd ${KRNLOBJDIR}/${_kernel}; \ 795 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \ 796 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS \ 797 -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile 798# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case. 799.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules) 800.for target in obj depend all 801 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \ 802 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \ 803 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target} 804.endfor 805.endif 806.if !defined(NO_KERNELDEPEND) 807 @echo 808 @echo "--------------------------------------------------------------" 809 @echo ">>> stage 3.1: making dependencies" 810 @echo "--------------------------------------------------------------" 811 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ 812.endif 813 @echo 814 @echo "--------------------------------------------------------------" 815 @echo ">>> stage 3.2: building everything" 816 @echo "--------------------------------------------------------------" 817 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ 818 @echo "--------------------------------------------------------------" 819 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`" 820 @echo "--------------------------------------------------------------" 821.endfor 822 823# 824# installkernel, etc. 825# 826# Install the kernel defined by INSTALLKERNEL 827# 828installkernel installkernel.debug \ 829reinstallkernel reinstallkernel.debug: installcheck 830.if empty(INSTALLKERNEL) 831 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \ 832 false 833.endif 834 @echo "--------------------------------------------------------------" 835 @echo ">>> Installing kernel" 836 @echo "--------------------------------------------------------------" 837 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ 838 ${CROSSENV} PATH=${TMPPATH} \ 839 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//} 840 841# 842# doxygen 843# 844# Build the API documentation with doxygen 845# 846doxygen: 847 @if [ ! -x `/usr/bin/which doxygen` ]; then \ 848 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \ 849 exit 1; \ 850 fi 851 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all 852 853# 854# update 855# 856# Update the source tree, by running cvsup and/or running cvs to update to the 857# latest copy. 858# 859update: 860.if defined(SUP_UPDATE) 861 @echo "--------------------------------------------------------------" 862 @echo ">>> Running ${SUP}" 863 @echo "--------------------------------------------------------------" 864.if defined(SUPFILE) 865 @${SUP} ${SUPFLAGS} ${SUPFILE} 866.endif 867.if defined(SUPFILE1) 868 @${SUP} ${SUPFLAGS} ${SUPFILE1} 869.endif 870.if defined(SUPFILE2) 871 @${SUP} ${SUPFLAGS} ${SUPFILE2} 872.endif 873.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE) 874 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE} 875.endif 876.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE) 877 @${SUP} ${SUPFLAGS} ${DOCSUPFILE} 878.endif 879.endif 880.if defined(CVS_UPDATE) 881 @cd ${.CURDIR} ; \ 882 if [ -d CVS ] ; then \ 883 echo "--------------------------------------------------------------" ; \ 884 echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \ 885 echo "--------------------------------------------------------------" ; \ 886 echo ${CVS} -R -q update ${CVSFLAGS} ; \ 887 ${CVS} -R -q update ${CVSFLAGS} ; \ 888 fi 889.endif 890.if defined(SVN_UPDATE) 891 @cd ${.CURDIR} ; \ 892 if [ -d .svn ] ; then \ 893 echo "--------------------------------------------------------------" ; \ 894 echo ">>> Updating ${.CURDIR} using Subversion" ; \ 895 echo "--------------------------------------------------------------" ; \ 896 echo ${SVN} update ${SVNFLAGS} ; \ 897 ${SVN} update ${SVNFLAGS} ; \ 898 fi 899.endif 900 901# 902# ------------------------------------------------------------------------ 903# 904# From here onwards are utility targets used by the 'make world' and 905# related targets. If your 'world' breaks, you may like to try to fix 906# the problem and manually run the following targets to attempt to 907# complete the build. Beware, this is *not* guaranteed to work, you 908# need to have a pretty good grip on the current state of the system 909# to attempt to manually finish it. If in doubt, 'make world' again. 910# 911 912# 913# legacy: Build compatibility shims for the next three targets 914# 915legacy: 916.if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0 917 @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \ 918 false 919.endif 920.for _tool in tools/build 921 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \ 922 cd ${.CURDIR}/${_tool}; \ 923 ${MAKE} DIRPRFX=${_tool}/ obj; \ 924 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \ 925 ${MAKE} DIRPRFX=${_tool}/ depend; \ 926 ${MAKE} DIRPRFX=${_tool}/ all; \ 927 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install 928.endfor 929 930# 931# bootstrap-tools: Build tools needed for compatibility 932# 933.if ${MK_GAMES} != "no" 934_strfile= games/fortune/strfile 935.endif 936 937.if ${MK_CXX} != "no" 938_gperf= gnu/usr.bin/gperf 939.endif 940 941.if ${MK_GROFF} != "no" 942_groff= gnu/usr.bin/groff 943.endif 944 945.if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022 946_ar= usr.bin/ar 947.endif 948 949.if ${BOOTSTRAPPING} < 800013 950_mklocale= usr.bin/mklocale 951.endif 952 953.if ${BOOTSTRAPPING} < 900002 954_sed= usr.bin/sed 955.endif 956 957.if ${BOOTSTRAPPING} < 900006 958_lex= usr.bin/lex 959_yacc= usr.bin/yacc 960.endif 961 962.if ${BOOTSTRAPPING} < 700018 963_gensnmptree= usr.sbin/bsnmpd/gensnmptree 964.endif 965 966.if ${MK_RESCUE} != "no" && \ 967 ${BOOTSTRAPPING} < 700026 968_crunchgen= usr.sbin/crunch/crunchgen 969.endif 970 971# XXX: There is no way to specify bootstrap tools depending on MK-flags 972# with different per-architecture default values. Always build tblgen. 973_clang_tblgen= \ 974 lib/clang/libllvmsupport \ 975 usr.bin/clang/tblgen 976 977.if ${MK_CDDL} != "no" 978_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \ 979 lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge 980.endif 981 982.if ${MK_FDT} != "no" 983_dtc= gnu/usr.bin/dtc 984.endif 985 986bootstrap-tools: 987.for _tool in \ 988 ${_clang_tblgen} \ 989 ${_dtrace_tools} \ 990 ${_strfile} \ 991 ${_gperf} \ 992 ${_groff} \ 993 ${_ar} \ 994 ${_dtc} \ 995 usr.bin/lorder \ 996 usr.bin/makewhatis \ 997 ${_mklocale} \ 998 usr.bin/rpcgen \ 999 ${_sed} \ 1000 ${_lex} \ 1001 ${_yacc} \ 1002 usr.bin/xinstall \ 1003 ${_gensnmptree} \ 1004 usr.sbin/config \ 1005 ${_crunchgen} 1006 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ 1007 cd ${.CURDIR}/${_tool}; \ 1008 ${MAKE} DIRPRFX=${_tool}/ obj; \ 1009 ${MAKE} DIRPRFX=${_tool}/ depend; \ 1010 ${MAKE} DIRPRFX=${_tool}/ all; \ 1011 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install 1012.endfor 1013 1014# 1015# build-tools: Build special purpose build tools 1016# 1017.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules) 1018_aicasm= sys/modules/aic7xxx/aicasm 1019.endif 1020 1021.if !defined(NO_SHARE) 1022_share= share/syscons/scrnmaps 1023.endif 1024 1025.if ${MK_KERBEROS} != "no" 1026_kerberos5_tools= kerberos5/tools 1027.endif 1028 1029.if ${MK_RESCUE} != "no" 1030_rescue= rescue/rescue 1031.endif 1032 1033build-tools: 1034.for _tool in \ 1035 bin/csh \ 1036 bin/sh \ 1037 ${_rescue} \ 1038 lib/ncurses/ncurses \ 1039 lib/ncurses/ncursesw \ 1040 ${_share} \ 1041 ${_aicasm} \ 1042 usr.bin/awk \ 1043 lib/libmagic \ 1044 usr.sbin/sysinstall \ 1045 usr.bin/mkesdb_static \ 1046 usr.bin/mkcsmapper_static 1047 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \ 1048 cd ${.CURDIR}/${_tool}; \ 1049 ${MAKE} DIRPRFX=${_tool}/ obj; \ 1050 ${MAKE} DIRPRFX=${_tool}/ build-tools 1051.endfor 1052.for _tool in \ 1053 gnu/usr.bin/cc/cc_tools \ 1054 ${_kerberos5_tools} 1055 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \ 1056 cd ${.CURDIR}/${_tool}; \ 1057 ${MAKE} DIRPRFX=${_tool}/ obj; \ 1058 ${MAKE} DIRPRFX=${_tool}/ depend; \ 1059 ${MAKE} DIRPRFX=${_tool}/ all 1060.endfor 1061 1062# 1063# cross-tools: Build cross-building tools 1064# 1065.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035 1066.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386" 1067_btxld= usr.sbin/btxld 1068.endif 1069.endif 1070.if ${TARGET_ARCH} != ${MACHINE_ARCH} 1071.if ${MK_RESCUE} != "no" || defined(RELEASEDIR) 1072_crunchide= usr.sbin/crunch/crunchide 1073.endif 1074.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR) 1075_kgzip= usr.sbin/kgzip 1076.endif 1077.endif 1078 1079.if ${CC:T:Mclang} == "clang" 1080_clang= usr.bin/clang 1081_clang_libs= lib/clang 1082.endif 1083 1084cross-tools: 1085.for _tool in \ 1086 ${_clang_libs} \ 1087 ${_clang} \ 1088 gnu/usr.bin/binutils \ 1089 gnu/usr.bin/cc \ 1090 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \ 1091 ${_btxld} \ 1092 ${_crunchide} \ 1093 ${_kgzip} 1094 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ 1095 cd ${.CURDIR}/${_tool}; \ 1096 ${MAKE} DIRPRFX=${_tool}/ obj; \ 1097 ${MAKE} DIRPRFX=${_tool}/ depend; \ 1098 ${MAKE} DIRPRFX=${_tool}/ all; \ 1099 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install 1100.endfor 1101 1102# 1103# hierarchy - ensure that all the needed directories are present 1104# 1105hierarchy: 1106 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs 1107 1108# 1109# libraries - build all libraries, and install them under ${DESTDIR}. 1110# 1111# The list of libraries with dependents (${_prebuild_libs}) and their 1112# interdependencies (__L) are built automatically by the 1113# ${.CURDIR}/tools/make_libdeps.sh script. 1114# 1115libraries: 1116 cd ${.CURDIR}; \ 1117 ${MAKE} -f Makefile.inc1 _prereq_libs; \ 1118 ${MAKE} -f Makefile.inc1 _startup_libs; \ 1119 ${MAKE} -f Makefile.inc1 _prebuild_libs; \ 1120 ${MAKE} -f Makefile.inc1 _generic_libs; 1121 1122# 1123# static libgcc.a prerequisite for shared libc 1124# 1125_prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt 1126 1127# These dependencies are not automatically generated: 1128# 1129# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before 1130# all shared libraries for ELF. 1131# 1132_startup_libs= gnu/lib/csu 1133.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf) 1134_startup_libs+= lib/csu/${MACHINE_ARCH}-elf 1135.elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}) 1136_startup_libs+= lib/csu/${MACHINE_ARCH} 1137.else 1138_startup_libs+= lib/csu/${MACHINE_CPUARCH} 1139.endif 1140_startup_libs+= gnu/lib/libgcc 1141_startup_libs+= lib/libcompiler_rt 1142_startup_libs+= lib/libc 1143 1144gnu/lib/libgcc__L: lib/libc__L 1145 1146_prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \ 1147 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \ 1148 ${_kerberos5_lib_libroken} \ 1149 lib/libbz2 lib/libcom_err lib/libcrypt \ 1150 lib/libexpat lib/libfetch \ 1151 ${_lib_libgssapi} ${_lib_libipx} \ 1152 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \ 1153 lib/ncurses/ncurses lib/ncurses/ncursesw \ 1154 lib/libopie lib/libpam ${_lib_libthr} \ 1155 lib/libradius lib/libsbuf lib/libtacplus \ 1156 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \ 1157 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \ 1158 ${_secure_lib_libssl} 1159 1160.if ${MK_LIBTHR} != "no" 1161_lib_libthr= lib/libthr 1162.endif 1163 1164_generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib 1165 1166lib/libopie__L lib/libtacplus__L: lib/libmd__L 1167 1168.if ${MK_CDDL} != "no" 1169_cddl_lib= cddl/lib 1170.endif 1171 1172.if ${MK_CRYPT} != "no" 1173.if ${MK_OPENSSL} != "no" 1174_secure_lib_libcrypto= secure/lib/libcrypto 1175_secure_lib_libssl= secure/lib/libssl 1176lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L 1177lib/libfetch__L: secure/lib/libcrypto__L secure/lib/libssl__L lib/libmd__L 1178.if ${MK_OPENSSH} != "no" 1179_secure_lib_libssh= secure/lib/libssh 1180secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L 1181.if ${MK_KERBEROS_SUPPORT} != "no" 1182secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \ 1183 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \ 1184 lib/libmd__L kerberos5/lib/libroken__L 1185.endif 1186.endif 1187.endif 1188_secure_lib= secure/lib 1189.endif 1190 1191.if ${MK_GSSAPI} != "no" 1192_lib_libgssapi= lib/libgssapi 1193.endif 1194 1195.if ${MK_IPX} != "no" 1196_lib_libipx= lib/libipx 1197.endif 1198 1199.if ${MK_KERBEROS} != "no" 1200_kerberos5_lib= kerberos5/lib 1201_kerberos5_lib_libasn1= kerberos5/lib/libasn1 1202_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5 1203_kerberos5_lib_libhx509= kerberos5/lib/libhx509 1204_kerberos5_lib_libroken= kerberos5/lib/libroken 1205_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm 1206.endif 1207 1208.if ${MK_NIS} != "no" 1209_lib_libypclnt= lib/libypclnt 1210.endif 1211 1212.if ${MK_OPENSSL} == "no" 1213lib/libfetch__L lib/libradius__L: lib/libmd__L 1214.endif 1215 1216.for _lib in ${_prereq_libs} 1217${_lib}__PL: .PHONY 1218.if exists(${.CURDIR}/${_lib}) 1219 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \ 1220 cd ${.CURDIR}/${_lib}; \ 1221 ${MAKE} DIRPRFX=${_lib}/ obj; \ 1222 ${MAKE} DIRPRFX=${_lib}/ depend; \ 1223 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \ 1224 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install 1225.endif 1226.endfor 1227 1228.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs} 1229${_lib}__L: .PHONY 1230.if exists(${.CURDIR}/${_lib}) 1231 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \ 1232 cd ${.CURDIR}/${_lib}; \ 1233 ${MAKE} DIRPRFX=${_lib}/ obj; \ 1234 ${MAKE} DIRPRFX=${_lib}/ depend; \ 1235 ${MAKE} DIRPRFX=${_lib}/ all; \ 1236 ${MAKE} DIRPRFX=${_lib}/ install 1237.endif 1238.endfor 1239 1240# libpam is special: we need to build static PAM modules before 1241# static PAM library, and dynamic PAM library before dynamic PAM 1242# modules. 1243lib/libpam__L: .PHONY 1244 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \ 1245 cd ${.CURDIR}/lib/libpam; \ 1246 ${MAKE} DIRPRFX=lib/libpam/ obj; \ 1247 ${MAKE} DIRPRFX=lib/libpam/ depend; \ 1248 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \ 1249 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install 1250 1251_prereq_libs: ${_prereq_libs:S/$/__PL/} 1252_startup_libs: ${_startup_libs:S/$/__L/} 1253_prebuild_libs: ${_prebuild_libs:S/$/__L/} 1254_generic_libs: ${_generic_libs:S/$/__L/} 1255 1256.for __target in all clean cleandepend cleandir depend includes obj 1257.for entry in ${SUBDIR} 1258${entry}.${__target}__D: .PHONY 1259 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \ 1260 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \ 1261 edir=${entry}.${MACHINE_ARCH}; \ 1262 cd ${.CURDIR}/$${edir}; \ 1263 else \ 1264 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \ 1265 edir=${entry}; \ 1266 cd ${.CURDIR}/$${edir}; \ 1267 fi; \ 1268 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/ 1269.endfor 1270par-${__target}: ${SUBDIR:S/$/.${__target}__D/} 1271.endfor 1272 1273.include <bsd.subdir.mk> 1274 1275.if make(check-old) || make(check-old-dirs) || \ 1276 make(check-old-files) || make(check-old-libs) || \ 1277 make(delete-old) || make(delete-old-dirs) || \ 1278 make(delete-old-files) || make(delete-old-libs) 1279 1280# 1281# check for / delete old files section 1282# 1283 1284.include "ObsoleteFiles.inc" 1285 1286OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \ 1287else you can not start such an application. Consult UPDATING for more \ 1288information regarding how to cope with the removal/revision bump of a \ 1289specific library." 1290 1291.if !defined(BATCH_DELETE_OLD_FILES) 1292RM_I=-i 1293.else 1294RM_I=-v 1295.endif 1296 1297delete-old-files: 1298 @echo ">>> Removing old files (only deletes safe to delete libs)" 1299# Ask for every old file if the user really wants to remove it. 1300# It's annoying, but better safe than sorry. 1301 @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \ 1302 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 1303 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ 1304 rm ${RM_I} "${DESTDIR}/$${file}"; \ 1305 fi; \ 1306 done 1307# Remove catpages without corresponding manpages. 1308 @exec 3<&0; \ 1309 find ${DESTDIR}/usr/share/man/cat* ! -type d | \ 1310 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ 1311 while read catpage; do \ 1312 read manpage; \ 1313 if [ ! -e "$${manpage}" ]; then \ 1314 rm ${RM_I} $${catpage} <&3 ; \ 1315 fi; \ 1316 done 1317 @echo ">>> Old files removed" 1318 1319check-old-files: 1320 @echo ">>> Checking for old files" 1321 @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \ 1322 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 1323 echo "${DESTDIR}/$${file}"; \ 1324 fi; \ 1325 done 1326# Check for catpages without corresponding manpages. 1327 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \ 1328 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ 1329 while read catpage; do \ 1330 read manpage; \ 1331 if [ ! -e "$${manpage}" ]; then \ 1332 echo $${catpage} ; \ 1333 fi; \ 1334 done 1335 1336delete-old-libs: 1337 @echo ">>> Removing old libraries" 1338 @echo "${OLD_LIBS_MESSAGE}" | fmt 1339 @for file in ${OLD_LIBS}; do \ 1340 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 1341 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ 1342 rm ${RM_I} "${DESTDIR}/$${file}"; \ 1343 fi; \ 1344 done 1345 @echo ">>> Old libraries removed" 1346 1347check-old-libs: 1348 @echo ">>> Checking for old libraries" 1349 @for file in ${OLD_LIBS}; do \ 1350 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ 1351 echo "${DESTDIR}/$${file}"; \ 1352 fi; \ 1353 done 1354 1355delete-old-dirs: 1356 @echo ">>> Removing old directories" 1357 @for dir in ${OLD_DIRS}; do \ 1358 if [ -d "${DESTDIR}/$${dir}" ]; then \ 1359 rmdir -v "${DESTDIR}/$${dir}" || true; \ 1360 elif [ -L "${DESTDIR}/$${dir}" ]; then \ 1361 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \ 1362 fi; \ 1363 done 1364 @echo ">>> Old directories removed" 1365 1366check-old-dirs: 1367 @echo ">>> Checking for old directories" 1368 @for dir in ${OLD_DIRS}; do \ 1369 if [ -d "${DESTDIR}/$${dir}" ]; then \ 1370 echo "${DESTDIR}/$${dir}"; \ 1371 elif [ -L "${DESTDIR}/$${dir}" ]; then \ 1372 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \ 1373 fi; \ 1374 done 1375 1376delete-old: delete-old-files delete-old-dirs 1377 @echo "To remove old libraries run '${MAKE} delete-old-libs'." 1378 1379check-old: check-old-files check-old-libs check-old-dirs 1380 @echo "To remove old files and directories run '${MAKE} delete-old'." 1381 @echo "To remove old libraries run '${MAKE} delete-old-libs'." 1382 1383.endif 1384 1385# 1386# showconfig - show build configuration. 1387# 1388showconfig: 1389 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort 1390 1391.if !empty(KRNLOBJDIR) && !empty(KERNCONF) 1392DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/ 1393 1394.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE) 1395.if exists(${KERNCONFDIR}/${KERNCONF}) 1396FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \ 1397 ${KERNCONFDIR}/${KERNCONF} 1398.endif 1399.endif 1400 1401.endif 1402 1403.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH}) 1404DTBOUTPUTPATH= ${.CURDIR} 1405.endif 1406 1407# 1408# Build 'standalone' Device Tree Blob 1409# 1410builddtb: 1411 @if [ "${FDT_DTS_FILE}" = "" ]; then \ 1412 echo "ERROR: FDT_DTS_FILE must be specified!"; \ 1413 exit 1; \ 1414 fi; \ 1415 if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \ 1416 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \ 1417 exist!"; \ 1418 exit 1; \ 1419 fi; \ 1420 if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then \ 1421 echo "WARNING: DTB will be placed in the current working \ 1422 directory"; \ 1423 fi 1424 @PATH=${TMPPATH} \ 1425 dtc -O dtb -o \ 1426 ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \ 1427 -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} 1428 1429############### 1430 1431.if defined(XDEV) && defined(XDEV_ARCH) 1432 1433.if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH} 1434XDEV_CPUTYPE?=${CPUTYPE} 1435.else 1436XDEV_CPUTYPE?=${TARGET_CPUTYPE} 1437.endif 1438 1439NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \ 1440 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \ 1441 -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \ 1442 TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \ 1443 CPUTYPE=${XDEV_CPUTYPE} 1444 1445XDDIR=${XDEV_ARCH}-freebsd 1446XDTP=/usr/${XDDIR} 1447CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} 1448CDENV= ${CDBENV} \ 1449 _SHLIBDIRPREFIX=${XDTP} \ 1450 TOOLS_PREFIX=${XDTP} 1451CD2ENV=${CDENV} \ 1452 MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH} 1453 1454CDTMP= ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp 1455CDMAKE=${CDENV} ${MAKE} ${NOFUN} 1456CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN} 1457XDDESTDIR=${DESTDIR}${XDTP} 1458.if !defined(OSREL) 1459OSREL!= uname -r | sed -e 's/[-(].*//' 1460.endif 1461 1462.ORDER: xdev-build xdev-install 1463xdev: xdev-build xdev-install 1464 1465.ORDER: _xb-build-tools _xb-cross-tools 1466xdev-build: _xb-build-tools _xb-cross-tools 1467 1468_xb-build-tools: 1469 ${_+_}@cd ${.CURDIR}; \ 1470 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools 1471 1472_xb-cross-tools: 1473.for _tool in \ 1474 gnu/usr.bin/binutils \ 1475 gnu/usr.bin/cc 1476 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \ 1477 cd ${.CURDIR}/${_tool}; \ 1478 ${CDMAKE} DIRPRFX=${_tool}/ obj; \ 1479 ${CDMAKE} DIRPRFX=${_tool}/ depend; \ 1480 ${CDMAKE} DIRPRFX=${_tool}/ all 1481.endfor 1482 1483_xi-mtree: 1484 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}" 1485 mkdir -p ${XDDESTDIR} 1486 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \ 1487 -p ${XDDESTDIR} >/dev/null 1488 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 1489 -p ${XDDESTDIR}/usr >/dev/null 1490 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 1491 -p ${XDDESTDIR}/usr/include >/dev/null 1492 1493.ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links 1494xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links 1495 1496_xi-cross-tools: 1497 @echo "_xi-cross-tools" 1498.for _tool in \ 1499 gnu/usr.bin/binutils \ 1500 gnu/usr.bin/cc 1501 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \ 1502 cd ${.CURDIR}/${_tool}; \ 1503 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR} 1504.endfor 1505 1506_xi-includes: 1507 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \ 1508 DESTDIR=${XDDESTDIR} 1509 1510_xi-libraries: 1511 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \ 1512 DESTDIR=${XDDESTDIR} 1513 1514_xi-links: 1515 ${_+_}cd ${XDDESTDIR}/usr/bin; \ 1516 for i in *; do \ 1517 ln -sf ../../${XDTP}/usr/bin/$$i \ 1518 ../../../../usr/bin/${XDDIR}-$$i; \ 1519 ln -sf ../../${XDTP}/usr/bin/$$i \ 1520 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \ 1521 done 1522.endif 1523