2 # $Id: Makefile.upgrade,v 1.12 1999/01/27 08:49:53 jkh Exp $
4 # This makefile contains rules for preforming upgrades that are outside
5 # the scope of the normal build world process.
9 # Build things relative to the user's preferred object directory,
10 # defaulting to /usr/obj if not defined.
12 MAKEOBJDIRPREFIX?=/usr/obj
15 # The installed operating system release gives us the hint as to whether
16 # we need to build a kernel too.
18 INSTALLEDVERSION!=sh ${.CURDIR}/tools/tools/upgrade/getosreldate.sh
19 INSTALLEDNAME!=uname -r
22 # Upgrade the installed make to the current version using the installed
23 # headers, libraries and build tools. This is required on installed versions
24 # prior to 2.2.5 in which the installed make doesn't support the -m argument.
28 @echo "--------------------------------------------------------------"
29 @echo " Upgrading the installed make"
30 @echo "--------------------------------------------------------------"
31 @cd ${.CURDIR}/usr.bin/make; \
32 make obj && make depend && make all && make install
35 # Upgrade from aout to elf, doing an aout build first to ensure that there
36 # are up-to-date tools before building the initial elf world. The aout
37 # tools just built into the object directory tree and executed from there
38 # during the elf build. Then install the aout tools, build an aout kernel
39 # with them (in case the installed kernel is an older version), then
40 # install the elf world.
42 aout-to-elf aout-to-elf-install : /var/db/update.cfg \
43 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
44 ${MAKEOBJDIRPREFIX}/do_elf_buildworld \
45 ${MAKEOBJDIRPREFIX}/do_move_aout_libs \
46 ${MAKEOBJDIRPREFIX}/do_aout_installworld \
47 ${MAKEOBJDIRPREFIX}/do_elf_installworld \
48 ${MAKEOBJDIRPREFIX}/do_elf_kernel \
49 ${MAKEOBJDIRPREFIX}/do_set_objformat \
50 ${MAKEOBJDIRPREFIX}/do_reboot
52 # front-load all the information we're going to need.
54 @if [ -f ${.CURDIR}/tools/tools/upgrade/doupgrade.sh ]; then \
55 env MACHINE=${MACHINE} CURDIR=${.CURDIR} sh ${.CURDIR}/tools/tools/upgrade/doupgrade.sh 1 /var/db/update.cfg; \
57 echo "Your source tree must not be fully populated; unable to find upgrade script"; echo "in ${.CURDIR}/tools/tools/upgrade/doupgrade.sh."; exit 1; \
61 # Just do the build parts of the transition build.
64 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
65 ${MAKEOBJDIRPREFIX}/do_elf_buildworld
68 # The installed system may not have tools capable of building an elf
69 # aware world, so a complete aout buildworld is required to get a known
72 ${MAKEOBJDIRPREFIX}/do_aout_buildworld :
74 @echo "--------------------------------------------------------------"
75 @echo " Doing an aout buildworld to get an up-to-date set of tools"
76 @echo "--------------------------------------------------------------"
77 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/aout \
78 OBJFORMAT=aout REALLY_WANT_DEPRECIATED_AOUT=yes \
79 make -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
80 @touch ${MAKEOBJDIRPREFIX}/do_aout_buildworld
83 # Temporary path for initial elf build.
85 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
88 # Use the aout tools from the aout buildworld to do an elf buildworld.
90 ${MAKEOBJDIRPREFIX}/do_elf_buildworld :
92 @echo "--------------------------------------------------------------"
93 @echo " Doing an elf buildworld using the aout tools in the aout"
95 @echo "--------------------------------------------------------------"
96 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
97 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
98 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
99 make -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
100 @touch ${MAKEOBJDIRPREFIX}/do_elf_buildworld
103 # ldconfig should list the directories that the system is currently using.
105 CUSTOM_LIBDIRS!=ldconfig -r | grep search | sed "s/search directories: //" | sed "s/:/ /g"
108 # These are the standard library directories that should end up containing
109 # just elf libraries.
111 LIBDIRS=/usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib
114 # Go through the list of library directories from ldconfig and add any
115 # directory that doesn't contain an aout path component to the list of
116 # library directories to search.
118 .for _lib in ${CUSTOM_LIBDIRS}
119 _lib1=${_lib:S/\/aout//}
120 .if ${_lib1} == ${_lib}
121 .if ${LIBDIRS:R:M${_lib:R}} == ""
128 # Go through the list of library directories and prepare a list of
132 .for _lib in ${LIBDIRS}
133 AOUTLIBDIRS+=${_lib}/aout
137 # Move the aout libraries into an aout sub-directory of each elf library
140 ${MAKEOBJDIRPREFIX}/do_move_aout_libs move-aout-libs :
141 .if !defined(NOCONFIRM)
143 @echo "--------------------------------------------------------------"
144 @echo " You are about to move all the installed a.out libraries into"
145 @echo " an aout sub-directory of each elf library directory. You can"
146 @echo " type Ctrl-C to abort now or press return to start the moving"
147 @echo " the libraries."
148 @echo "--------------------------------------------------------------"
149 @echo Directories to search: ${LIBDIRS}
150 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
151 @sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
153 @NOCONFIRM=1 sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
155 @ldconfig ${AOUTLIBDIRS}
156 @touch ${MAKEOBJDIRPREFIX}/do_move_aout_libs
159 # Before installing the aout world, allow for the possibility that the
160 # world about to be installed has some different syscalls to the installed
161 # kernel which will make shutting the system down problematic. We set aside
162 # copies of certain programs which match the running kernel.
164 # Install the aout world so that anything that isn't replaced by the
165 # elf world will be updated.
167 ${MAKEOBJDIRPREFIX}/do_aout_installworld :
168 .if ${INSTALLEDVERSION} < 300003
170 @echo "--------------------------------------------------------------"
171 @echo " Saving a copy of programs required to shut the system down"
172 @echo "--------------------------------------------------------------"
173 @cp /bin/sh ${MAKEOBJDIRPREFIX}
174 @cp /sbin/reboot ${MAKEOBJDIRPREFIX}
176 @touch ${MAKEOBJDIRPREFIX}/do_aout_installworld
179 # Build and install a new kernel, as well as the boot blocks necessary to
182 ${MAKEOBJDIRPREFIX}/do_elf_kernel :
183 @if [ -f /var/db/update.cfg -a -f ${.CURDIR}/tools/tools/upgrade/doupgrade.sh ]; then \
184 env MACHINE=${MACHINE} CURDIR=${.CURDIR} sh ${.CURDIR}/tools/tools/upgrade/doupgrade.sh 2 /var/db/update.cfg; \
186 @touch ${MAKEOBJDIRPREFIX}/do_elf_kernel
187 @rm -f /var/db/update.cfg
190 # Install the elf world overwriting just about all the previously installed
191 # aout world. Any aout things that need to be kept have already been
192 # installed in different places (typically in aout subdirectories).
194 ${MAKEOBJDIRPREFIX}/do_elf_installworld :
195 .if !defined(NOCONFIRM)
197 @echo "--------------------------------------------------------------"
198 @echo " You are about to update the installed system (or the system"
199 @echo " that your DESTDIR points to) with the elf versions of"
200 @echo " everything, replacing the aout versions. You can type Ctrl-C"
201 @echo " to abort now, leaving just the aout world installed, or"
202 @echo " press return to start the second phase of the update."
203 @echo "--------------------------------------------------------------"
204 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
207 @echo "--------------------------------------------------------------"
208 @echo " Doing an elf installworld using the aout tools in the aout"
210 @echo "--------------------------------------------------------------"
211 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
212 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
213 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
214 make -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
215 @if [ ! -f /etc/pam.conf ]; then cp ${.CURDIR}/etc/pam.conf /etc; fi
216 @if [ ! -f /etc/auth.conf ]; then cp ${.CURDIR}/etc/auth.conf /etc; fi
217 @if [ ! -f /etc/login.conf ]; then cp ${.CURDIR}/etc/login.conf /etc; fi
218 @touch ${MAKEOBJDIRPREFIX}/do_elf_installworld
221 # Now that the elf world has been installed, we can set the default
222 # object format to elf.
224 ${MAKEOBJDIRPREFIX}/do_set_objformat :
226 @echo "--------------------------------------------------------------"
227 @echo " Setting the default object format to elf"
228 @echo "--------------------------------------------------------------"
229 @echo "OBJFORMAT=elf" > ${DESTDIR}/etc/objformat
230 @touch ${MAKEOBJDIRPREFIX}/do_set_objformat
234 ${MAKEOBJDIRPREFIX}/do_reboot :
235 .if !defined(NOCONFIRM)
237 @echo "--------------------------------------------------------------"
238 @echo " Your system has now been fully updated to elf!"
240 @echo " It's now time to reboot from your new ELF kernel."
241 @echo " You can type Ctrl-C to abort this (at your own risk)"
242 @echo " or press return to reboot the system."
243 @echo "--------------------------------------------------------------"
244 @${MAKEOBJDIRPREFIX}/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
246 @echo " Rebooting......."
247 @echo "--------------------------------------------------------------"
248 @touch ${MAKEOBJDIRPREFIX}/do_reboot
249 @-${MAKEOBJDIRPREFIX}/reboot