2 # $Id: Makefile.upgrade,v 1.14 1999/02/13 18:49:02 jkh Exp $
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 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
105 @touch ${MAKEOBJDIRPREFIX}/do_elf_buildworld
108 # ldconfig should list the directories that the system is currently using.
110 CUSTOM_LIBDIRS!=ldconfig -r | grep search | sed "s/search directories: //" | sed "s/:/ /g"
113 # These are the standard library directories that should end up containing
114 # just elf libraries.
116 LIBDIRS=/usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib
119 # Go through the list of library directories from ldconfig and add any
120 # directory that doesn't contain an aout path component to the list of
121 # library directories to search.
123 .for _lib in ${CUSTOM_LIBDIRS}
124 _lib1=${_lib:S/\/aout//}
125 .if ${_lib1} == ${_lib}
126 .if ${LIBDIRS:R:M${_lib:R}} == ""
133 # Go through the list of library directories and prepare a list of
137 .for _lib in ${LIBDIRS}
138 AOUTLIBDIRS+=${_lib}/aout
142 # Move the aout libraries into an aout sub-directory of each elf library
145 ${MAKEOBJDIRPREFIX}/do_move_aout_libs move-aout-libs :
146 .if !defined(NOCONFIRM)
148 @echo "--------------------------------------------------------------"
149 @echo " You are about to move all the installed a.out libraries into"
150 @echo " an aout sub-directory of each elf library directory. You can"
151 @echo " type Ctrl-C to abort now or press return to start the moving"
152 @echo " the libraries."
153 @echo "--------------------------------------------------------------"
154 @echo Directories to search: ${LIBDIRS}
155 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
156 @sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
158 @NOCONFIRM=1 sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
160 @ldconfig ${AOUTLIBDIRS}
161 @touch ${MAKEOBJDIRPREFIX}/do_move_aout_libs
164 # Before installing the aout world, allow for the possibility that the
165 # world about to be installed has some different syscalls to the installed
166 # kernel which will make shutting the system down problematic. We set aside
167 # copies of certain programs which match the running kernel.
169 # Install the aout world so that anything that isn't replaced by the
170 # elf world will be updated.
172 ${MAKEOBJDIRPREFIX}/do_aout_installworld :
173 .if ${INSTALLEDVERSION} < 300003
175 @echo "--------------------------------------------------------------"
176 @echo " Saving a copy of programs required to shut the system down"
177 @echo "--------------------------------------------------------------"
178 @cp /bin/sh ${MAKEOBJDIRPREFIX}
179 @cp /sbin/reboot ${MAKEOBJDIRPREFIX}
181 @touch ${MAKEOBJDIRPREFIX}/do_aout_installworld
184 # Build and install a new kernel, as well as the boot blocks necessary to
187 ${MAKEOBJDIRPREFIX}/do_elf_kernel :
188 @if [ -f /var/db/update.cfg -a -f ${.CURDIR}/tools/tools/upgrade/doupgrade.sh ]; then \
189 env MACHINE=${MACHINE} CURDIR=${.CURDIR} sh ${.CURDIR}/tools/tools/upgrade/doupgrade.sh 2 /var/db/update.cfg; \
191 @touch ${MAKEOBJDIRPREFIX}/do_elf_kernel
192 @rm -f /var/db/update.cfg
195 # Install the elf world overwriting just about all the previously installed
196 # aout world. Any aout things that need to be kept have already been
197 # installed in different places (typically in aout subdirectories).
199 ${MAKEOBJDIRPREFIX}/do_elf_installworld :
200 .if !defined(NOCONFIRM)
202 @echo "--------------------------------------------------------------"
203 @echo " You are about to update the installed system (or the system"
204 @echo " that your DESTDIR points to) with the elf versions of"
205 @echo " everything, replacing the aout versions. You can type Ctrl-C"
206 @echo " to abort now, leaving just the aout world installed, or"
207 @echo " press return to start the second phase of the update."
208 @echo "--------------------------------------------------------------"
209 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
212 @echo "--------------------------------------------------------------"
213 @echo " Doing an elf installworld using the aout tools in the aout"
215 @echo "--------------------------------------------------------------"
216 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
217 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
218 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
219 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
220 @if [ ! -f /etc/pam.conf ]; then cp ${.CURDIR}/etc/pam.conf /etc; fi
221 @if [ ! -f /etc/auth.conf ]; then cp ${.CURDIR}/etc/auth.conf /etc; fi
222 @if [ ! -f /etc/login.conf ]; then cp ${.CURDIR}/etc/login.conf /etc; fi
223 @touch ${MAKEOBJDIRPREFIX}/do_elf_installworld
226 # Now that the elf world has been installed, we can set the default
227 # object format to elf.
229 ${MAKEOBJDIRPREFIX}/do_set_objformat :
231 @echo "--------------------------------------------------------------"
232 @echo " Setting the default object format to elf"
233 @echo "--------------------------------------------------------------"
234 @echo "OBJFORMAT=elf" > ${DESTDIR}/etc/objformat
235 @touch ${MAKEOBJDIRPREFIX}/do_set_objformat
239 ${MAKEOBJDIRPREFIX}/do_reboot :
240 .if !defined(NOCONFIRM)
242 @echo "--------------------------------------------------------------"
243 @echo " Your system has now been fully updated to elf!"
245 @echo " It's now time to reboot from your new ELF kernel."
246 @echo " You can type Ctrl-C to abort this (at your own risk)"
247 @echo " or press return to reboot the system."
248 @echo "--------------------------------------------------------------"
249 @${MAKEOBJDIRPREFIX}/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
251 @echo " Rebooting......."
252 @echo "--------------------------------------------------------------"
253 @touch ${MAKEOBJDIRPREFIX}/do_reboot
254 @-${MAKEOBJDIRPREFIX}/reboot