Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 1132 lines (1008 sloc) 37.184 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131
#
# $FreeBSD: src/Makefile.inc1,v 1.141.2.62 2003/04/06 19:54:00 dwmalone Exp $
#
# Build-time options are documented in make.conf(5).
#
# The intended user-driven targets are:
#
# buildworld - rebuild *everything*, including glue to help do upgrades
# quickworld - skip the glue and do a depend+build on the meat
# realquickworld - skip the glue and depend stages and just build the meat
# crossworld - only build the glue (particularly the cross-build environment)
# installworld- install everything built by "buildworld"
# backupworld - copies /bin /sbin /usr/bin /usr/sbin /usr/lib /usr/libexec
# to manual backup dir
# restoreworld- installs binaries from manual backup dir to world
# restoreworld-auto - installs binaries from auto-backup dir to world
# most - build user commands, no libraries or include files
# installmost - install user commands, no libraries or include files
# backup-clean - delete backup from manual backup dir
# backup-auto-clean - delete backup from auto-backup dir
#
# Standard targets (not defined here) are documented in the makefiles in
# /usr/share/mk. These include:
# obj depend all install clean cleandepend cleanobj

# Put initial settings here.
SUBDIR=

# /libexec/ld-elf.so.2 needs to be installed first
# Otherwise, install(1) beeing a dynamically linked binary will fail
# during the first upgrade from a static to a dynamic world
.if exists(${.CURDIR}/libexec)
SUBDIR+= libexec
.endif

# We must do share/info early so that installation of info `dir'
# entries works correctly. Do it first since it is less likely to
# grow dependencies on include and lib than vice versa.
.if exists(${.CURDIR}/share/info)
SUBDIR+= share/info
.endif

# We must do include and lib early so that the perl *.ph generation
# works correctly as it uses the header files installed by this.
.if exists(${.CURDIR}/include)
SUBDIR+= include
.endif
.if exists(${.CURDIR}/lib)
SUBDIR+= lib
.endif
# This exists simply to ensure that the obj dir hierarchy is
# intact for nrelease, allowing the nrelease Makefile's to
# reference ${.OBJDIR}.
#
.if exists(${.CURDIR}/nrelease)
SUBDIR+= nrelease
.endif

.if exists(${.CURDIR}/bin)
SUBDIR+= bin
.endif
.if exists(${.CURDIR}/games) && !defined(NO_GAMES)
SUBDIR+= games
.endif
.if exists(${.CURDIR}/gnu)
SUBDIR+= gnu
.endif
.if exists(${.CURDIR}/sbin)
SUBDIR+= sbin
.endif
.if exists(${.CURDIR}/secure) && !defined(NO_CRYPT)
SUBDIR+= secure
.endif
.if exists(${.CURDIR}/share) && !defined(NO_SHARE)
SUBDIR+= share
.endif
.if exists(${.CURDIR}/sys)
SUBDIR+= sys
.endif
.if exists(${.CURDIR}/usr.bin)
SUBDIR+= usr.bin
.endif
.if exists(${.CURDIR}/usr.sbin)
SUBDIR+= usr.sbin
.endif

.if exists(${.CURDIR}/etc)
SUBDIR+= etc
.endif

# These are last, since it is nice to at least get the base system
# rebuilt before you do them.
.if defined(LOCAL_DIRS)
.for _DIR in ${LOCAL_DIRS}
.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
SUBDIR+= ${_DIR}
.endif
.endfor
.endif

.if defined(SUBDIR_OVERRIDE)
SUBDIR= ${SUBDIR_OVERRIDE}
.endif

.if defined(NOCLEANDIR)
CLEANDIR= clean cleandepend
.else
CLEANDIR= cleandir
.endif

.if defined(NO_CLEAN)
NOCLEAN= # defined
.endif

# Object directory base in primary make. Note that when we rerun make
# from inside this file we change MAKEOBJDIRPREFIX to the appropriate
# subdirectory because the rest of the build system needs it that way.
# The original object directory base is saved in OBJTREE.
#
MAKEOBJDIRPREFIX?= /usr/obj
OBJTREE?= ${MAKEOBJDIRPREFIX}

# Used for stage installs and pathing
#
DESTDIRBASE:= ${OBJTREE}${.CURDIR}

# Remove DESTDIR from MAKEFLAGS. It is present in the environment
# anyhow, and we need to be able to override it for stage installs
.MAKEFLAGS:= ${.MAKEFLAGS:NDESTDIR=*}

# This section sets the tools used to build the world/kernel
WORLD_CCVER?= gcc47
WORLD_LDVER?= ld.bfd
WORLD_BINUTILSVER?= binutils224

# Set the backup parameters if they are not already defined
#
WORLD_BACKUP?= /var/backups/world_backup
AUTO_BACKUP?= ${OBJTREE}/world_backup/${DESTDIR}

TARGET_ARCH?= ${MACHINE_ARCH}
.if ${TARGET_ARCH} == ${MACHINE_ARCH}
TARGET?= ${MACHINE}
.else
TARGET?= ${TARGET_ARCH}
.endif
.if make(buildworld)
BUILD_ARCH!= sysctl -n hw.machine_arch

# temporary until everybody has converted to x86_64
.if ${BUILD_ARCH} == "amd64"
BUILD_ARCH= x86_64
.endif

.if ${MACHINE_ARCH} != ${BUILD_ARCH}
.error To cross-build, set TARGET_ARCH.
.endif
.endif

# Backwards compatibility with older make's or older sys.mk's. make
# is expected to define MACHINE_PLATFORM.
#
.if !defined(MACHINE_PLATFORM)
MACHINE_PLATFORM= pc32
.endif

# XXX this is ugly and we need to come up with a nicer solution
.if !defined(TARGET_PLATFORM)
.if ${TARGET_ARCH} == "i386"
TARGET_PLATFORM= pc32
.elif ${TARGET_ARCH} == "x86_64"
TARGET_PLATFORM= pc64
.else
.error Unknown target architecture.
.endif
.endif

THREAD_LIB?= thread_xu
.if ${THREAD_LIB} == "c_r"
.if defined(NO_LIBC_R)
.error libc_r is chosen as the default thread library, but NO_LIBC_R is defined
.endif
.endif

# BTOOLS (Natively built) All non-cross-development tools that the
# main build needs. This includes things like 'mkdir' and 'rm'.
# We will not use the native system's exec path once we start
# on WORLD. (bootstrap-tools and build-tools or BTOOLS)
#
# CTOOLS (Natively built) Cross development tools which are specific
# to the target architecture.
#
# WORLD (Cross built) Our ultimate buildworld, using only BTOOLS and
# CTOOLS.
#
# MACHINE_PLATFORM Platform Architecture we are building on
# MACHINE Machine Architecture (usually the same as MACHINE_ARCH)
# MACHINE_ARCH Cpu Architecture we are building on
#
# TARGET_PLATFORM Platform Architecture we are building for
# TARGET Machine Architecture we are building for
# TARGET_ARCH Cpu Architecture we are building for
#
BTOOLSDEST= ${DESTDIRBASE}/btools_${MACHINE_ARCH}
CTOOLSDEST= ${DESTDIRBASE}/ctools_${MACHINE_ARCH}_${TARGET_ARCH}
WORLDDEST= ${DESTDIRBASE}/world_${TARGET_ARCH}

# The bootstrap-tools path is used by the bootstrap-tools, build-tools, and
# cross-tools stages to augment the existing command path to access newer
# versions of certain utilities such as 'patch' that the cross-tools stage
# might expect.
#
BTOOLSPATH= ${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games

# The strict temporary command path contains all binaries required
# by the buildworld system after the cross-tools stage.
#
STRICTTMPPATH= ${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games:/usr/local/bin:/usr/pkg/bin

TMPDIR?= /tmp
TMPPID!= echo $$$$

#
# Building a world goes through the following stages
#
# 1. bootstrap-tool stage [BMAKE]
# This stage is responsible for creating programs that
# are needed for backward compatibility reasons. They
# are not built as cross-tools.
# 2. build-tool stage [TMAKE]
# This stage is responsible for creating the object
# tree and building any tools that are needed during
# the build process.
# 3. cross-tool stage [XMAKE]
# This stage is responsible for creating any tools that
# are needed for cross-builds. A cross-compiler is one
# of them.
# 4. world stage [WMAKE]
# This stage actually builds the world.
# 5. install stage (optional) [IMAKE]
# This stage installs a previously built world.
#
# In all cases we must carefully adjust the environment so the proper
# tools and header files are used.
#
# NOTE: The M4 environment variable is used by the [f]lex binary to
# override the location of the 'm4' binary. The override is
# needed for certain buildworld version transitions, specifically
# past a certain point in 3.3 because the older /usr/bin/m4 will
# generate output that will blow up the newer [f]lex/yacc/bison
# utilities.
#

# bootstrap-tool stage
#
BMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
OBJTREE=${OBJTREE} \
DESTDIR=${BTOOLSDEST} \
PATH=${BTOOLSPATH}:${PATH} \
M4=${BTOOLSDEST}/usr/bin/m4 \
INSTALL="sh ${.CURDIR}/tools/install.sh"

BMAKE= ${BMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \
-DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
-DNO_WERROR -DNO_NLS

# build-tool stage
#
TMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
OBJTREE=${OBJTREE} \
DESTDIR= \
PATH=${BTOOLSPATH}:${PATH} \
M4=${BTOOLSDEST}/usr/bin/m4 \
INSTALL="sh ${.CURDIR}/tools/install.sh"

TMAKE= ${TMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \
-DNO_FORTRAN -DNOSHARED

# cross-tool stage
#
# note: TOOLS_PREFIX points to the obj root holding the cross
# compiler binaries, while USRDATA_PREFIX points to the obj root
# holding the target environment (and also determines where cross-built
# libraries, crt*.o, and include files are installed).
#
XMAKEENV= MAKEOBJDIRPREFIX=${CTOOLSDEST} \
OBJTREE=${OBJTREE} \
DESTDIR=${CTOOLSDEST} \
_SHLIBDIRPREFIX=${CTOOLSDEST} \
INSTALL="sh ${.CURDIR}/tools/install.sh" \
TOOLS_PREFIX=${CTOOLSDEST} \
USRDATA_PREFIX=${WORLDDEST} \
M4=${BTOOLSDEST}/usr/bin/m4 \
PATH=${BTOOLSPATH}:${PATH}

XMAKE= ${XMAKEENV} make -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
-DBOOTSTRAPPING -DNOSHARED

# world stage, note the strict path and note that TOOLS_PREFIX is left
# unset and USRDATA_PREFIX (which defaults to TOOLS_PREFIX) is set to empty,
# which is primarily for the compiler so it targets / (e.g. /usr/<blah>)
# for both binary and library paths, even though it is being compiled to
# WORLDDEST. None of the programs in the world stage are ever actually
# executed during the buildworld/installworld.
#
CROSSENV= MAKEOBJDIRPREFIX=${WORLDDEST} \
OBJTREE=${OBJTREE} \
MACHINE_ARCH=${TARGET_ARCH} \
MACHINE=${TARGET} \
MACHINE_PLATFORM=${TARGET_PLATFORM} \
OBJFORMAT_PATH=${CTOOLSDEST} \
HOST_CCVER=${HOST_CCVER} \
CCVER=${WORLD_CCVER} \
LDVER=${WORLD_LDVER} \
BINUTILSVER=${WORLD_BINUTILSVER}

WMAKEENV= ${CROSSENV} \
DESTDIR=${WORLDDEST} \
_SHLIBDIRPREFIX=${WORLDDEST} \
INSTALL="sh ${.CURDIR}/tools/install.sh" \
M4=${BTOOLSDEST}/usr/bin/m4 \
PATH=${STRICTTMPPATH}

WMAKE= ${WMAKEENV} make -f Makefile.inc1

# install stage
#
IMAKEENV= ${CROSSENV} \
PATH=${STRICTTMPPATH}
IMAKE= ${IMAKEENV} make -f Makefile.inc1

# kernel stage
#
KMAKEENV= ${WMAKEENV}

# buildworld
#
# Attempt to rebuild the entire system, with reasonable chance of
# success, regardless of how old your existing system is.
#
_worldtmp: _cleantmp _mtreetmp
.ORDER: _cleantmp _mtreetmp

_cleantmp:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> Rebuilding the temporary build tree"
@echo "--------------------------------------------------------------"
.if !defined(NOCLEAN)
rm -rf ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
.else
# XXX - These two can depend on any header file.
rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
.endif

_mtreetmp:
mkdir -p ${DESTDIRBASE} ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
.for _dir in ${WORLDDEST} ${BTOOLSDEST} ${CTOOLSDEST}
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
-p ${_dir}/ > /dev/null
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
-p ${_dir}/usr > /dev/null
.endfor
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
-p ${WORLDDEST}/usr/include > /dev/null
${LN} -sf ${.CURDIR}/sys ${WORLDDEST}

_bootstrap-tools:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 1: bootstrap tools"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${BMAKE} bootstrap-tools
_cleanobj:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 2a: cleaning up the object tree"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
_obj:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 2b: rebuilding the object tree"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} par-obj
_build-tools:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 2c: build tools"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${TMAKE} build-tools
_cross-tools:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 3: cross tools"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${XMAKE} cross-tools
_includes:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 4a: populating ${WORLDDEST}/usr/include"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
_libraries:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 4b: building libraries"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
_depend:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 4c: make dependencies"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} par-depend
everything:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 4d: building everything.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} all

# note: buildworld no longer depends on _cleanobj because we rm -rf the
# entire object tree and built the bootstrap tools in a different location.
#
# buildworld - build everything from scratch
# quickworld - skip the bootstrap, build, and cross-build steps
# realquickworld - skip the bootstrap, build, crossbuild, and depend step.
#
# note: we include _obj in realquickworld to prevent accidental creation
# of files in /usr/src.

WMAKE_TGTS=
.if !defined(SUBDIR_OVERRIDE)
WMAKE_TGTS+= _worldtmp _bootstrap-tools
.endif
WMAKE_TGTS+= _obj _build-tools
.if !defined(SUBDIR_OVERRIDE)
WMAKE_TGTS+= _cross-tools
.endif
WMAKE_TGTS+= _includes _libraries _depend everything

buildworld: ${WMAKE_TGTS}

quickworld: _mtreetmp _obj _includes _libraries _depend everything

realquickworld: _mtreetmp _obj _includes _libraries everything

crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools

.ORDER: ${WMAKE_TGTS}
.ORDER: _obj _includes
.ORDER: _mtreetmp _obj
.ORDER: installcheck backupworld-auto

#
# installcheck
#
# Checks to be sure system is ready for installworld
#
installcheck:
.if !defined(NO_SENDMAIL)
@pw usershow smmsp || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
@pw groupshow smmsp || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
.endif
@pw usershow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
@pw groupshow authpf || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
@pw groupshow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
.if !defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/"
@case `uname -r` in 1.2*|1.3-*|1.3.*|1.4.*|1.5.0-*|1.5.1-*|1.5.2-*|1.5.3-*) echo "You must upgrade your kernel to at least 1.5.4 and reboot before you can safely installworld, due to libc/system call ABI changes" ; /usr/bin/false ; esac
.endif

#
# installworld
#
# Backs up the current world if ${AUTO_BACKUP} is writable.
# Installs everything compiled by a 'buildworld'.

installworld: installcheck
-@mkdir -p ${AUTO_BACKUP} > /dev/null 2>&1
@cd ${.CURDIR}; \
(touch ${AUTO_BACKUP}/.updating > /dev/null 2>&1 && \
${IMAKE} backupworld-auto) || \
echo "Cannot write to ${AUTO_BACKUP} - world not backed up"

cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
${INSTALL} -o root -g wheel -m 644 ${.CURDIR}/Makefile_upgrade.inc ${DESTDIR}/etc/upgrade/
mkinitrd -b ${DESTDIR}/boot

#
# reinstall
#
# If you have a build server, you can NFS mount the source and obj directories
# and do a 'make reinstall' on the *client* to install new binaries from the
# most recent server build.
#
reinstall:
@echo "--------------------------------------------------------------"
@echo ">>> Making hierarchy"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; make -f Makefile.inc1 hierarchy
@echo
@echo "--------------------------------------------------------------"
@echo ">>> Installing everything.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; make -f Makefile.inc1 install

#
# buildkernel, nativekernel, quickkernel, and installkernel
#
# Which kernels to build and/or install is specified by setting
# KERNCONF. If not defined a GENERIC kernel is built/installed.
# Only the existing (depending TARGET) config files are used
# for building kernels and only the first of these is designated
# as the one being installed.
#
# You can specify INSTALLSTRIPPED=1 if you wish the installed
# kernel and modules to be stripped of its debug info (required
# symbols are left intact). You can specify INSTALLSTRIPPEDMODULES
# if you only want to strip the modules of their debug info. These
# only apply if you have DEBUG=-g in your kernel config or make line.
#
# Note that we have to use TARGET instead of TARGET_ARCH when
# we're in kernel-land. Since only TARGET_ARCH is (expected) to
# be set to cross-build, we have to make sure TARGET is set
# properly.

.if !defined(KERNCONF) && defined(KERNEL)
KERNCONF= ${KERNEL}
KERNWARN= yes
.else
# XXX makeshift fix to build the right kernel for the (target) architecture
# We should configure this in the platform files somehow
.if ${TARGET_ARCH} == "i386"
KERNCONF?= GENERIC
.else
KERNCONF?= X86_64_GENERIC
.endif
.endif
INSTKERNNAME?= kernel

KRNLSRCDIR= ${.CURDIR}/sys
KRNLCONFDIR= ${KRNLSRCDIR}/config
KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR}
KERNCONFDIR?= ${KRNLCONFDIR}

BUILDKERNELS=
INSTALLKERNEL=
.for _kernel in ${KERNCONF}
.if exists(${KERNCONFDIR}/${_kernel})
BUILDKERNELS+= ${_kernel}
.if empty(INSTALLKERNEL)
INSTALLKERNEL= ${_kernel}
.endif
.endif
.endfor

# kernel version numbers survive rm -rf
#
.for _kernel in ${BUILDKERNELS}
.if exists(${KRNLOBJDIR}/${_kernel}/version)
KERNEL_VERSION_${_kernel} != cat ${KRNLOBJDIR}/${_kernel}/version
.endif
.endfor

#
# buildkernel
#
# Builds all kernels defined by BUILDKERNELS.
#
bk_tools:
@if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
echo "You must buildworld before buildkernel. If you wish"; \
echo "to build a kernel using native tools, config it manually"; \
echo "or use the nativekernel target if you are in a rush"; \
/usr/bin/false; \
fi

maybe_bk_tools:
.for _kernel in ${BUILDKERNELS}
@if [ ! -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
echo "The kernel was build using buildworld tools which no" ; \
echo "longer appear to exist, quickkernel failed!" ; \
/usr/bin/false; \
fi; \
fi
.endfor

bk_build_list:
.if empty(BUILDKERNELS)
@echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
@echo ">>> Did you move your kernel configs from i386/conf to config/?"
@false
.endif

bk_kernwarn:
.if defined(KERNWARN)
@echo "--------------------------------------------------------------"
@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
@echo "--------------------------------------------------------------"
@sleep 3
.endif
@echo

# The buildkernel target rebuilds the specified kernels from scratch
# using the crossbuild tools generated by the last buildworld. It is
# the safest (but also the most time consuming) way to build a new kernel.
#
buildkernel: bk_tools bk_build_list bk_kernwarn
.for _kernel in ${BUILDKERNELS}
@echo "--------------------------------------------------------------"
@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
@echo "===> ${_kernel}"
.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
rm -rf ${KRNLOBJDIR}/${_kernel}
.else
@if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
echo "YOU ARE REBUILDING WITH BUILDKERNEL, REMOVING OLD NATIVEKERNEL BUILD"; \
rm -rf ${KRNLOBJDIR}/${_kernel}; fi
.endif
mkdir -p ${KRNLOBJDIR}
.if !defined(NO_KERNELCONFIG)
cd ${KRNLCONFDIR}; \
PATH=${STRICTTMPPATH} \
config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
${KERNCONFDIR}/${_kernel}
.endif
.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
.endif
touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
.if !defined(NO_KERNELDEPEND)
cd ${KRNLOBJDIR}/${_kernel}; \
${KMAKEENV} make KERNEL=${INSTKERNNAME} depend
.endif
cd ${KRNLOBJDIR}/${_kernel}; \
${KMAKEENV} make KERNEL=${INSTKERNNAME} all
@echo "--------------------------------------------------------------"
@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
.endfor

# The nativekernel target rebuilds the specified kernels from scratch
# using the system's standard compiler rather than using the crossbuild
# tools generated by the last buildworld. This is fairly safe if your
# system is reasonable up-to-date.
#
nativekernel: bk_build_list bk_kernwarn
.for _kernel in ${BUILDKERNELS}
@echo "--------------------------------------------------------------"
@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
@echo "===> ${_kernel}"
.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
rm -rf ${KRNLOBJDIR}/${_kernel}
.else
@if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
echo "YOU ARE REBUILDING WITH NATIVEKERNEL, REMOVING OLD BUILDKERNEL BUILD"; \
rm -rf ${KRNLOBJDIR}/${_kernel}; fi
.endif
mkdir -p ${KRNLOBJDIR}
.if !defined(NO_KERNELCONFIG)
cd ${KRNLCONFDIR}; \
config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
${KERNCONFDIR}/${_kernel}
.endif
.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
.endif
touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
cd ${KRNLOBJDIR}/${_kernel}; \
MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
make -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
.if !defined(NO_KERNELDEPEND)
cd ${KRNLOBJDIR}/${_kernel}; \
make KERNEL=${INSTKERNNAME} depend
.endif
cd ${KRNLOBJDIR}/${_kernel}; \
make KERNEL=${INSTKERNNAME} all
@echo "--------------------------------------------------------------"
@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
.endfor

# The quickkernel target rebuilds the specified kernels as quickly
# as possible. It will use the native tools or the buildworld cross tools
# based on whether the kernel was originally generated via buildkernel or
# nativekernel. Config is rerun but the object hierarchy is not rebuilt,
# nor is the make depend step run.
#
quickkernel: maybe_bk_tools bk_build_list bk_kernwarn
.for _kernel in ${BUILDKERNELS}
@echo "--------------------------------------------------------------"
@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
@echo "===> ${_kernel}"
.if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
.if !defined(NO_KERNELCONFIG)
cd ${KRNLCONFDIR}; \
PATH=${STRICTTMPPATH} \
config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
${KERNCONFDIR}/${_kernel}
.endif
cd ${KRNLOBJDIR}/${_kernel}; \
${KMAKEENV} make KERNEL=${INSTKERNNAME} all
.else
.if !defined(NO_KERNELCONFIG)
cd ${KRNLCONFDIR}; \
config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
${KERNCONFDIR}/${_kernel}
.endif
cd ${KRNLOBJDIR}/${_kernel}; \
make KERNEL=${INSTKERNNAME} all
.endif
@echo "--------------------------------------------------------------"
@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
.endfor


# installkernel
#
# Install the kernel defined by INSTALLKERNEL
#
installkernel reinstallkernel:
@echo "--------------------------------------------------------------"
@echo ">>> Kernel install for ${INSTALLKERNEL} started on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
.if exists(${KRNLOBJDIR}/${INSTALLKERNEL}/.buildkernel_run)
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${IMAKEENV} make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
.else
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
.endif

#
# most
#
# Build most of the user binaries on the existing system libs and includes.
#
most:
@echo "--------------------------------------------------------------"
@echo ">>> Building programs only"
@echo "--------------------------------------------------------------"
.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
cd ${.CURDIR}/${_dir}; make DIRPRFX=${_dir}/ all
.endfor

#
# installmost
#
# Install the binaries built by the 'most' target. This does not include
# libraries or include files.
#
installmost:
@echo "--------------------------------------------------------------"
@echo ">>> Installing programs only"
@echo "--------------------------------------------------------------"
.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
cd ${.CURDIR}/${_dir}; make DIRPRFX=${_dir}/ install
.endfor

#
# ------------------------------------------------------------------------
#
# From here onwards are utility targets used by the 'make world' and
# related targets. If your 'world' breaks, you may like to try to fix
# the problem and manually run the following targets to attempt to
# complete the build. Beware, this is *not* guaranteed to work, you
# need to have a pretty good grip on the current state of the system
# to attempt to manually finish it. If in doubt, 'make world' again.
#

# bootstrap-tools: Build all tools required to build all tools. Note that
# order is important in a number of cases and also note that the bootstrap
# and build tools stages have access to earlier binaries they themselves
# had generated.
#
# patch: older patch's do not have -i. This program must be built
# first so other bootstrap tools that need to apply patches
# can use it.
# [x]install: dependancies on various new install features
# rpcgen: old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
# envs are not compatible with older objformat binaries.
#
.if exists(${.CURDIR}/games) && !defined(NO_GAMES)
_strfile= games/fortune/strfile
.endif

# BSTRAPDIRS1 - must be built in strict order, no parallelism
#
# order is very important. yacc before m4 before flex. flex exec's m4,
# m4's parser file needs the latest byacc (insanity!).
#
BSTRAPDIRS1= ${_strfile} \
usr.bin/patch \
bin/chmod bin/cp bin/cpdup bin/dd bin/mkdir bin/rm bin/echo \
bin/test bin/cat bin/ln bin/mv bin/csh bin/expr bin/sh \
bin/hostname bin/kill \
usr.bin/yacc usr.bin/m4 usr.bin/colldef \
usr.bin/uudecode usr.bin/xinstall \
usr.bin/rpcgen usr.bin/bmake usr.bin/awk usr.bin/stat \
usr.bin/find usr.bin/flex

# BSTRAPDIRS2 - may built in parallel
#
BSTRAPDIRS2= \
usr.bin/sed usr.bin/uname usr.bin/touch \
usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
usr.bin/mklocale usr.bin/uuencode usr.bin/compile_et usr.bin/hexdump \
usr.bin/cap_mkdb usr.bin/true usr.bin/false \
usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
usr.bin/tail usr.bin/unifdef usr.bin/tic \
usr.sbin/chown usr.sbin/mtree usr.sbin/config \
usr.sbin/btxld usr.sbin/zic usr.sbin/makewhatis \
gnu/usr.bin/texinfo gnu/usr.bin/grep usr.bin/sort \
usr.bin/gzip usr.bin/bzip2 usr.bin/mkcsmapper usr.bin/mkesdb \
usr.bin/crunch

bootstrap-tools: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2
touch ${BTOOLSDEST}/.bootstrap_done

bootstrap-tools-before:
${LN} -fs /bin/date ${BTOOLSDEST}/bin/date

bootstrap-tools-targets1: ${BSTRAPDIRS1:S/^/bstrap-/}

bootstrap-tools-targets2: ${BSTRAPDIRS2:S/^/bstrap-/}

.ORDER: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2

.ORDER: ${BSTRAPDIRS1:S/^/bstrap-/}

.for _tool in ${BSTRAPDIRS1} ${BSTRAPDIRS2}
bstrap-${_tool}!
${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
cd ${.CURDIR}/${_tool}; \
make DIRPRFX=${_tool}/ obj; \
make DIRPRFX=${_tool}/ depend; \
make DIRPRFX=${_tool}/ all; \
make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
.endfor

# build-tools: Build special purpose build tools.
#
# XXX we may be able to remove or consolidate this into bootstrap-tools
# now that we have the native helper (.nx/.no) infrastructure.
#
.if exists(${.CURDIR}/share) && !defined(NO_SHARE)
_share= share/syscons/scrnmaps
.endif

_gcc_common_cross= gnu/usr.bin/gmp gnu/usr.bin/mpfr
.if !defined(NO_GCC44)
_gcc44_cross= gnu/usr.bin/cc44
_gcc44_tools= gnu/usr.bin/cc44/cc_prep gnu/usr.bin/cc44/cc_tools
.endif
_gcc47_cross= lib/libz gnu/usr.bin/mpc gnu/usr.bin/cc47
_gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools
_custom_cross= libexec/customcc
_binutils= gnu/usr.bin/${WORLD_BINUTILSVER}

BTOOLSDIRS= ${_gcc44_tools} ${_gcc47_tools} ${_share}

build-tools: build-tools-targets
touch ${BTOOLSDEST}/.build_done

build-tools-targets: ${BTOOLSDIRS:S/^/btools-/}

.ORDER: ${_gcc44_tools:S/^/btools-/}
.ORDER: ${_gcc47_tools:S/^/btools-/}

.for _tool in ${BTOOLSDIRS}
btools-${_tool}!
${ECHODIR} "===> ${_tool} (build-tools)"; \
cd ${.CURDIR}/${_tool}; \
make DIRPRFX=${_tool}/ obj; \
make DIRPRFX=${_tool}/ depend; \
make DIRPRFX=${_tool}/ all; \
make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
.endfor

#
# cross-tools: Build cross-building tools
#
.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
_btxld= usr.sbin/btxld
.endif

CTOOLSDIRS= ${_btxld} ${_binutils} \
usr.bin/objformat usr.bin/crunch/crunchide \
${_gcc_common_cross} \
${_gcc44_cross} ${_gcc47_cross} ${_custom_cross}

cross-tools: cross-tools-targets
touch ${CTOOLSDEST}/.cross_done

cross-tools-targets: ${CTOOLSDIRS:S/^/ctools-/}

.for _tool in ${CTOOLSDIRS}
ctools-${_tool}!
${ECHODIR} "===> ${_tool} (cross-tools)"; \
cd ${.CURDIR}/${_tool}; \
make DIRPRFX=${_tool}/ obj; \
make DIRPRFX=${_tool}/ depend; \
make DIRPRFX=${_tool}/ all; \
make DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
.endfor

#
# hierarchy - ensure that all the needed directories are present
#
hierarchy:
cd ${.CURDIR}/etc; make distrib-dirs

#
# libraries - build all libraries, and install them under ${DESTDIR}.
#
# The list of libraries with dependents (${_prebuild_libs}) and their
# interdependencies (__L) are built automatically by the
# ${.CURDIR}/tools/make_libdeps.sh script.
#
# .makeenv does not work when bootstrapping from 4.x, so we must be sure
# to specify the correct CCVER or 'cc' will not exec the correct compiler.
#
libraries:
cd ${.CURDIR}; \
HOST_CCVER=${HOST_CCVER} CCVER=gcc47 \
make -f Makefile.inc1 _startup_libs47;
.if !defined(NO_GCC44)
cd ${.CURDIR}; \
HOST_CCVER=${HOST_CCVER} CCVER=gcc44 \
make -f Makefile.inc1 _startup_libs44;
.endif
cd ${.CURDIR}; \
make -f Makefile.inc1 _startup_libs; \
make -f Makefile.inc1 _prebuild_libs; \
make -f Makefile.inc1 _generic_libs;
touch ${WORLDDEST}/.libraries_done

# These dependencies are not automatically generated:
#
# gnu/lib/${CCVER}/libgcc and gnu/lib/${CCVER}/csu must be built before all
# shared libraries for ELF. The target for _startup_libsXX is
# specifically built using gccXX.
#
_startup_libs47= gnu/usr.bin/cc47/cc_prep \
gnu/usr.bin/cc47/cc_tools \
gnu/lib/gcc47/csu \
gnu/lib/gcc47/libgcc \
gnu/lib/gcc47/libgcc_eh \
gnu/lib/gcc47/libgcc_pic
_startup_libs44= gnu/usr.bin/cc44/cc_prep \
gnu/usr.bin/cc44/cc_tools \
gnu/lib/gcc44/csu \
gnu/lib/gcc44/libgcc
_startup_libs= lib/csu lib/libc lib/libc_rtld

_prebuild_libs= lib/libbz2 lib/liblzma lib/libz
_prebuild_libs+= lib/libutil

_generic_libs= gnu/lib

_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
lib/libncurses/libncurses lib/libopie

lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L

_generic_libs+= lib

.if !defined(NO_CRYPT)
.if !defined(NO_OPENSSL)
_prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
.if !defined(NO_OPENSSH)
_prebuild_libs+= secure/lib/libssh
secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
.endif
.endif
_generic_libs+= secure/lib
.endif

_prebuild_libs+= lib/libradius lib/libsbuf lib/libtacplus lib/libm \
lib/libpam lib/libypclnt lib/lib${THREAD_LIB} \
lib/libpthread lib/libprop lib/libdevattr

_generic_libs+= usr.bin/flex/lib

.for _lib in ${_startup_libs44} ${_startup_libs47} \
${_startup_libs} ${_prebuild_libs} ${_generic_libs}
${_lib}__L: .PHONY
.if exists(${.CURDIR}/${_lib})
${ECHODIR} "===> ${_lib}"; \
cd ${.CURDIR}/${_lib}; \
make DIRPRFX=${_lib}/ depend; \
make DIRPRFX=${_lib}/ all; \
make DIRPRFX=${_lib}/ install
.endif
.endfor

_startup_libs: ${_startup_libs:S/$/__L/}
_startup_libs47: ${_startup_libs47:S/$/__L/}
_startup_libs44: ${_startup_libs44:S/$/__L/}
_prebuild_libs: ${_prebuild_libs:S/$/__L/}
_generic_libs: ${_generic_libs:S/$/__L/}

# library targets must be ordered because there are inter-library
# races (e.g. generation of tconfig.h)
#
.ORDER: ${_startup_libs47:S/$/__L/}
.ORDER: ${_startup_libs44:S/$/__L/}
.ORDER: ${_startup_libs:S/$/__L/}
.ORDER: ${_prebuild_libs:S/$/__L/}
.ORDER: ${_generic_libs:S/$/__L/}

.for __target in clean cleandepend cleandir obj depend includes
.for entry in ${SUBDIR}
${entry}.${__target}__D: .PHONY
@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
edir=${entry}.${MACHINE_ARCH}; \
cd ${.CURDIR}/$${edir}; \
else \
${ECHODIR} "===> ${DIRPRFX}${entry}"; \
edir=${entry}; \
cd ${.CURDIR}/$${edir}; \
fi; \
make ${__target} DIRPRFX=${DIRPRFX}$${edir}/
.endfor
par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
.ORDER: ${SUBDIR:S/$/.${__target}__D/}
.endfor
.ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes

# The wmake target is used by /usr/bin/wmake to run make in a
# world build environment.
#
wmake:
@echo '${WMAKEENV} make ${WMAKE_ARGS}'

wmakeenv:
@echo '${WMAKEENV} /bin/sh'

bmake:
@echo '${BMAKEENV} make ${BMAKE_ARGS}'

bmakeenv:
@echo '${BMAKEENV} /bin/sh'

tmake:
@echo '${TMAKEENV} make ${TMAKE_ARGS}'

tmakeenv:
@echo '${TMAKEENV} /bin/sh'

xmake:
@echo '${XMAKEENV} make ${XMAKE_ARGS}'

xmakeenv:
@echo '${XMAKEENV} /bin/sh'

backupworld: backup-clean
@mkdir -p ${WORLD_BACKUP}
.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
     exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
     exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
tar -czf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
--options gzip:compression-level=1 \
sbin bin usr/sbin usr/bin usr/lib usr/libexec
.endif

backupworld-auto:
.if !defined(NO_BACKUP)
rm -f ${AUTO_BACKUP}/binaries.tar.gz
@mkdir -p ${AUTO_BACKUP}
.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
     exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
     exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
tar -czf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
--options gzip:compression-level=1 \
sbin bin usr/sbin usr/bin usr/lib usr/libexec
.endif
.endif

backup-auto-clean:
rm -f ${AUTO_BACKUP}/binaries.tar.gz

backup-clean:
rm -f ${WORLD_BACKUP}/binaries.tar.gz

restoreworld:
.if !exists(${WORLD_BACKUP}/binaries.tar.gz)
@echo "There does not seem to be a valid archive present."
.else
@echo "Restoring system binaries from manual backup archive..."
@chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
tar -xzf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
.endif

restoreworld-auto:
.if !exists(${AUTO_BACKUP}/binaries.tar.gz)
@echo "There does not seem to be a valid archive present."
.else
@echo "Restoring system binaries from auto-backup archive..."
@chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
tar -xzf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
.endif

# Take advantage of bmake error response
#
MAKE_PRINT_VAR_ON_ERROR= \
.CURDIR \
.OBJDIR \
LD_LIBRARY_PATH \
MACHINE_ARCH \
MACHINE \
MAKEFILE \
.TARGETS \
.ERROR_TARGET \
.MAKE.LEVEL

.include <bsd.subdir.mk>
Something went wrong with that request. Please try again.