2 # $Id: Makefile.upgrade,v 1.4 1998/09/05 08:10:44 jb 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!=uname -r
21 # Upgrade the installed make to the current version using the installed
22 # headers, libraries and build tools. This is required on installed versions
23 # prior to 2.2.5 in which the installed make doesn't support the -m argument.
27 @echo "--------------------------------------------------------------"
28 @echo " Upgrading the installed make"
29 @echo "--------------------------------------------------------------"
30 @cd ${.CURDIR}/usr.bin/make; \
31 make obj && make depend && make all && make install
34 # Upgrade from aout to elf, doing an aout build first to ensure that there
35 # are up-to-date tools before building the initial elf world. The aout
36 # tools just built into the object directory tree and executed from there
37 # during the elf build. Then install the aout tools, build an aout kernel
38 # with them (in case the installed kernel is an older version), then
39 # install the elf world.
41 aout-to-elf aout-to-elf-install : \
42 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
43 ${MAKEOBJDIRPREFIX}/do_elf_buildworld \
44 ${MAKEOBJDIRPREFIX}/do_move_aout_libs \
45 ${MAKEOBJDIRPREFIX}/do_aout_installworld \
46 ${MAKEOBJDIRPREFIX}/do_aout_kernel \
47 ${MAKEOBJDIRPREFIX}/do_elf_installworld \
48 ${MAKEOBJDIRPREFIX}/do_set_objformat \
49 ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
52 # Just do the build parts of the transition build.
55 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
56 ${MAKEOBJDIRPREFIX}/do_elf_buildworld
59 # The installed system may not have tools capable of building an elf
60 # aware world, so a complete aout buildworld is required to get a known
63 ${MAKEOBJDIRPREFIX}/do_aout_buildworld :
65 @echo "--------------------------------------------------------------"
66 @echo " Doing an aout buildworld to get an up-to-date set of tools"
67 @echo "--------------------------------------------------------------"
68 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/aout \
70 make -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
71 @touch ${MAKEOBJDIRPREFIX}/do_aout_buildworld
74 # Temporary path for initial elf build.
76 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
79 # Use the aout tools from the aout buildworld to do an elf buildworld.
81 ${MAKEOBJDIRPREFIX}/do_elf_buildworld :
83 @echo "--------------------------------------------------------------"
84 @echo " Doing an elf buildworld using the aout tools in the aout"
86 @echo "--------------------------------------------------------------"
87 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
88 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
89 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
90 make -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
91 @touch ${MAKEOBJDIRPREFIX}/do_elf_buildworld
94 # ldconfig should list the directories that the system is currently using.
96 CUSTOM_LIBDIRS!=ldconfig -r | grep search | sed "s/search directories: //" | sed "s/:/ /g"
99 # These are the standard library directories that should end up containing
100 # just elf libraries.
102 LIBDIRS=/usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib
105 # Go through the list of library directories from ldconfig and add any
106 # directory that doesn't contain an aout path component to the list of
107 # library directories to search.
109 .for _lib in ${CUSTOM_LIBDIRS}
110 _lib1=${_lib:S/\/aout//}
111 .if ${_lib1} == ${_lib}
112 .if ${LIBDIRS:R:M${_lib:R}} == ""
119 # Go through the list of library directories and prepare a list of
123 .for _lib in ${LIBDIRS}
124 AOUTLIBDIRS+=${_lib}/aout
128 # Move the aout libraries into an aout sub-directory of each elf library
131 ${MAKEOBJDIRPREFIX}/do_move_aout_libs move-aout-libs :
133 @echo "--------------------------------------------------------------"
134 @echo " You are about to move all the installed a.out libraries into"
135 @echo " an aout sub-directory of each elf library directory. You can"
136 @echo " type Ctrl-C to abort now or press return to start the moving"
137 @echo " the libraries."
138 @echo "--------------------------------------------------------------"
139 @echo Directories to search: ${LIBDIRS}
140 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
141 @sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
142 @ldconfig ${AOUTLIBDIRS}
143 @touch ${MAKEOBJDIRPREFIX}/do_move_aout_libs
146 # Before installing the aout world, allow for the possibility that the
147 # world about to be installed has some different syscalls to the installed
148 # kernel which will make shutting the system down problematic. We set aside
149 # copies of certain programs which match the running kernel.
151 # Install the aout world so that anything that isn't replaced by the
152 # elf world will be updated.
154 ${MAKEOBJDIRPREFIX}/do_aout_installworld :
156 @echo "--------------------------------------------------------------"
157 @echo " You are about to update the installed system (or the system"
158 @echo " that your DESTDIR points to). You can type Ctrl-C to abort"
159 @echo " now or press return to start the first phase of the update."
160 @echo "--------------------------------------------------------------"
161 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
162 .if ${INSTALLEDVERSION} != "3.0-CURRENT"
164 @echo "--------------------------------------------------------------"
165 @echo " Saving a copy of programs required to shut the system down"
166 @echo "--------------------------------------------------------------"
167 @cp /bin/sh ${MAKEOBJDIRPREFIX}
168 @cp /sbin/reboot ${MAKEOBJDIRPREFIX}
171 @echo "--------------------------------------------------------------"
172 @echo " Doing an aout installworld using the aout tools in the aout"
174 @echo "--------------------------------------------------------------"
175 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/aout \
176 PATH=${AOUTTMPPATH} OBJFORMAT=aout NOTOOLS=1 \
177 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
178 make -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
179 @touch ${MAKEOBJDIRPREFIX}/do_aout_installworld
182 # The installed kernel may not match the world that is installed, so build
183 # a generic kernel, but don't install it. The user can decide if the kernel
184 # needs to be installed. Perhaps we should install it in the root
185 # directory as an obscure name just in case a reboot is required?
187 ${MAKEOBJDIRPREFIX}/do_aout_kernel :
188 .if ${INSTALLEDVERSION} == "3.0-CURRENT"
190 @echo "--------------------------------------------------------------"
191 @echo " You are already running 3.0-CURRENT, so a kernel build"
192 @echo " is probably not required."
193 @echo "--------------------------------------------------------------"
196 @echo "--------------------------------------------------------------"
197 @echo " Building a generic kernel using the new aout tools"
198 @echo "--------------------------------------------------------------"
199 .if exists(${.CURDIR}/sys/compile/GENERICupgrade)
200 @rm -rf ${.CURDIR}/sys/compile/GENERICupgrade
202 @cd ${.CURDIR}/sys/${MACHINE}/conf; config GENERICupgrade
203 @-cd ${.CURDIR}/sys/compile/GENERICupgrade; \
204 OBJFORMAT=aout make depend && make all
205 @cd ${.CURDIR}/sys/compile/GENERICupgrade; \
206 OBJFORMAT=aout make depend && make all
208 @touch ${MAKEOBJDIRPREFIX}/do_aout_kernel
211 # Install the elf world overwriting just about all the previously installed
212 # aout world. Any aout things that need to be kept have already been
213 # installed in different places (typically in aout subdirectories).
215 ${MAKEOBJDIRPREFIX}/do_elf_installworld :
217 @echo "--------------------------------------------------------------"
218 @echo " You are about to update the installed system (or the system"
219 @echo " that your DESTDIR points to) with the elf versions of"
220 @echo " everything, replacing the aout versions. You can type Ctrl-C"
221 @echo " to abort now, leaving just the aout world installed, or"
222 @echo " press return to start the second phase of the update."
223 @echo "--------------------------------------------------------------"
224 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
226 @echo "--------------------------------------------------------------"
227 @echo " Doing an elf installworld using the aout tools in the aout"
229 @echo "--------------------------------------------------------------"
230 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
231 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
232 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
233 make -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
234 @touch ${MAKEOBJDIRPREFIX}/do_elf_installworld
237 # Now that the elf world has been installed, we can set the default
238 # object format to elf.
240 ${MAKEOBJDIRPREFIX}/do_set_objformat :
242 @echo "--------------------------------------------------------------"
243 @echo " Setting the default object format to elf"
244 @echo "--------------------------------------------------------------"
245 @echo "OBJFORMAT=elf" > ${DESTDIR}/etc/objformat
246 @touch ${MAKEOBJDIRPREFIX}/do_set_objformat
249 # If not already running a current kernel, install the GENERICupgrade kernel
252 ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot :
253 .if ${INSTALLEDVERSION} == "3.0-CURRENT"
255 @echo "--------------------------------------------------------------"
256 @echo " Your system has been updated to run elf by default!"
258 @echo " You should reboot your system now."
259 @echo "--------------------------------------------------------------"
260 @touch ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
263 @echo "--------------------------------------------------------------"
264 @echo " Your system has been updated to run elf by default!"
266 @echo " Since you are running ${INSTALLEDVERSION}, the kernel must"
267 @echo " be installed before the system is rebooted. You can type"
268 @echo " Ctrl-C to abort the kernel installation (at your own risk),"
269 @echo " or press return for the kernel to be installed and the"
270 @echo " system rebooted."
271 @echo "--------------------------------------------------------------"
272 @${MAKEOBJDIRPREFIX}/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
274 @echo "--------------------------------------------------------------"
275 @echo " Installing a new GENERICupgrade kernel"
276 @echo "--------------------------------------------------------------"
277 @cd ${.CURDIR}/sys/compile/GENERICupgrade; make install
279 @echo "--------------------------------------------------------------"
280 @echo " Rebooting......."
281 @echo "--------------------------------------------------------------"
282 @touch ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
283 @-${MAKEOBJDIRPREFIX}/reboot