4 # This makefile contains rules for preforming upgrades that are outside
5 # the scope of the normal build world process.
9 # Make sure the PATH is set correctly
11 PATH=/sbin:/bin:/usr/sbin:/usr/bin
14 # Build things relative to the user's preferred object directory,
15 # defaulting to /usr/obj if not defined.
17 MAKEOBJDIRPREFIX?=/usr/obj
20 # The installed operating system release gives us the hint as to whether
21 # we need to build a kernel too.
23 INSTALLEDVERSION!=sh ${.CURDIR}/tools/tools/upgrade/getosreldate.sh
24 INSTALLEDNAME!=uname -r
27 # Upgrade the installed make to the current version using the installed
28 # headers, libraries and build tools. This is required on installed versions
29 # prior to 2.2.5 in which the installed make doesn't support the -m argument.
33 @echo "--------------------------------------------------------------"
34 @echo " Upgrading the installed make"
35 @echo "--------------------------------------------------------------"
36 @cd ${.CURDIR}/usr.bin/make; \
37 make obj && make depend && make all && make install
40 # Upgrade from aout to elf, doing an aout build first to ensure that there
41 # are up-to-date tools before building the initial elf world. The aout
42 # tools just built into the object directory tree and executed from there
43 # during the elf build. Then install the aout tools, build an aout kernel
44 # with them (in case the installed kernel is an older version), then
45 # install the elf world.
47 aout-to-elf aout-to-elf-install : /var/db/update.cfg \
48 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
49 ${MAKEOBJDIRPREFIX}/do_elf_buildworld \
50 ${MAKEOBJDIRPREFIX}/do_move_aout_libs \
51 ${MAKEOBJDIRPREFIX}/do_aout_installworld \
52 ${MAKEOBJDIRPREFIX}/do_elf_installworld \
53 ${MAKEOBJDIRPREFIX}/do_elf_kernel \
54 ${MAKEOBJDIRPREFIX}/do_set_objformat \
55 ${MAKEOBJDIRPREFIX}/do_reboot
57 # front-load all the information we're going to need.
59 @if [ -f ${.CURDIR}/tools/tools/upgrade/doupgrade.sh ]; then \
60 env MACHINE=${MACHINE} CURDIR=${.CURDIR} sh ${.CURDIR}/tools/tools/upgrade/doupgrade.sh 1 /var/db/update.cfg; \
62 echo "Your source tree must not be fully populated; unable to find upgrade script"; echo "in ${.CURDIR}/tools/tools/upgrade/doupgrade.sh."; exit 1; \
66 # Just do the build parts of the transition build.
69 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
70 ${MAKEOBJDIRPREFIX}/do_elf_buildworld
73 # The installed system may not have tools capable of building an elf
74 # aware world, so a complete aout buildworld is required to get a known
77 ${MAKEOBJDIRPREFIX}/do_aout_buildworld :
79 @echo "--------------------------------------------------------------"
80 @echo " Doing an aout buildworld to get an up-to-date set of tools"
81 @echo "--------------------------------------------------------------"
82 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/aout \
83 OBJFORMAT=aout REALLY_WANT_DEPRECIATED_AOUT=yes \
84 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
85 @touch ${MAKEOBJDIRPREFIX}/do_aout_buildworld
88 # Temporary path for initial elf build.
90 AOUTTMPPATH= ${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp/sbin:${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp/bin:${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp/usr/sbin:${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp/usr/bin:${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp/usr/games
93 # Use the aout tools from the aout buildworld to do an elf buildworld.
95 ${MAKEOBJDIRPREFIX}/do_elf_buildworld :
97 @echo "--------------------------------------------------------------"
98 @echo " Doing an elf buildworld using the aout tools in the aout"
100 @echo "--------------------------------------------------------------"
101 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
102 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
103 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
104 X11BASE=/nonexistent \
105 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
106 @touch ${MAKEOBJDIRPREFIX}/do_elf_buildworld
109 # ldconfig should list the directories that the system is currently using.
111 CUSTOM_LIBDIRS!=ldconfig -r | grep search | sed "s/search directories: //" | sed "s/:/ /g"
114 # These are the standard library directories that should end up containing
115 # just elf libraries.
117 LIBDIRS=/usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib
120 # Go through the list of library directories from ldconfig and add any
121 # directory that doesn't contain an aout path component to the list of
122 # library directories to search.
124 .for _lib in ${CUSTOM_LIBDIRS}
125 _lib1=${_lib:S/\/aout//}
126 .if ${_lib1} == ${_lib}
127 .if ${LIBDIRS:R:M${_lib:R}} == ""
134 # Go through the list of library directories and prepare a list of
138 .for _lib in ${LIBDIRS}
139 AOUTLIBDIRS+=${_lib}/aout
143 # Move the aout libraries into an aout sub-directory of each elf library
146 ${MAKEOBJDIRPREFIX}/do_move_aout_libs move-aout-libs :
147 .if !defined(NOCONFIRM)
149 @echo "--------------------------------------------------------------"
150 @echo " You are about to move all the installed a.out libraries into"
151 @echo " an aout sub-directory of each elf library directory. You can"
152 @echo " type Ctrl-C to abort now or press return to start the moving"
153 @echo " the libraries."
154 @echo "--------------------------------------------------------------"
155 @echo Directories to search: ${LIBDIRS}
156 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
157 @sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
159 @NOCONFIRM=1 sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
161 @ldconfig ${AOUTLIBDIRS}
162 @touch ${MAKEOBJDIRPREFIX}/do_move_aout_libs
165 # Before installing the aout world, allow for the possibility that the
166 # world about to be installed has some different syscalls to the installed
167 # kernel which will make shutting the system down problematic. We set aside
168 # copies of certain programs which match the running kernel.
170 # Install the aout world so that anything that isn't replaced by the
171 # elf world will be updated.
173 ${MAKEOBJDIRPREFIX}/do_aout_installworld :
174 .if ${INSTALLEDVERSION} < 300003
176 @echo "--------------------------------------------------------------"
177 @echo " Saving a copy of programs required to shut the system down"
178 @echo "--------------------------------------------------------------"
179 @cp /bin/sh ${MAKEOBJDIRPREFIX}
180 @cp /sbin/reboot ${MAKEOBJDIRPREFIX}
182 @touch ${MAKEOBJDIRPREFIX}/do_aout_installworld
185 # Build and install a new kernel, as well as the boot blocks necessary to
188 ${MAKEOBJDIRPREFIX}/do_elf_kernel :
189 @if [ -f /var/db/update.cfg -a -f ${.CURDIR}/tools/tools/upgrade/doupgrade.sh ]; then \
190 env MACHINE=${MACHINE} CURDIR=${.CURDIR} sh ${.CURDIR}/tools/tools/upgrade/doupgrade.sh 2 /var/db/update.cfg; \
192 @touch ${MAKEOBJDIRPREFIX}/do_elf_kernel
193 @rm -f /var/db/update.cfg
196 # Install the elf world overwriting just about all the previously installed
197 # aout world. Any aout things that need to be kept have already been
198 # installed in different places (typically in aout subdirectories).
200 ${MAKEOBJDIRPREFIX}/do_elf_installworld :
201 .if !defined(NOCONFIRM)
203 @echo "--------------------------------------------------------------"
204 @echo " You are about to update the installed system (or the system"
205 @echo " that your DESTDIR points to) with the elf versions of"
206 @echo " everything, replacing the aout versions. You can type Ctrl-C"
207 @echo " to abort now, leaving just the aout world installed, or"
208 @echo " press return to start the second phase of the update."
209 @echo "--------------------------------------------------------------"
210 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
213 @echo "--------------------------------------------------------------"
214 @echo " Doing an elf installworld using the aout tools in the aout"
216 @echo "--------------------------------------------------------------"
217 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
218 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
219 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
220 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
221 @if [ ! -f /etc/pam.conf ]; then cp ${.CURDIR}/etc/pam.conf /etc; fi
222 @if [ ! -f /etc/auth.conf ]; then cp ${.CURDIR}/etc/auth.conf /etc; fi
223 @if [ ! -f /etc/login.conf ]; then cp ${.CURDIR}/etc/login.conf /etc; fi
224 @touch ${MAKEOBJDIRPREFIX}/do_elf_installworld
227 # Now that the elf world has been installed, we can set the default
228 # object format to elf.
230 ${MAKEOBJDIRPREFIX}/do_set_objformat :
232 @echo "--------------------------------------------------------------"
233 @echo " Setting the default object format to elf"
234 @echo "--------------------------------------------------------------"
235 @echo "OBJFORMAT=elf" > ${DESTDIR}/etc/objformat
236 @touch ${MAKEOBJDIRPREFIX}/do_set_objformat
240 ${MAKEOBJDIRPREFIX}/do_reboot :
241 .if !defined(NOCONFIRM)
243 @echo "--------------------------------------------------------------"
244 @echo " Your system has now been fully updated to elf!"
246 @echo " It's now time to reboot from your new ELF kernel."
247 @echo " You can type Ctrl-C to abort this (at your own risk)"
248 @echo " or press return to reboot the system."
249 @echo "--------------------------------------------------------------"
250 @${MAKEOBJDIRPREFIX}/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
252 @echo " Rebooting......."
253 @echo "--------------------------------------------------------------"
254 @touch ${MAKEOBJDIRPREFIX}/do_reboot
255 @-${MAKEOBJDIRPREFIX}/reboot