2 # $Id: Makefile.upgrade,v 1.7 1998/10/17 05:40:45 peter 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 : \
43 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
44 ${MAKEOBJDIRPREFIX}/do_elf_buildworld \
45 ${MAKEOBJDIRPREFIX}/do_move_aout_libs \
46 ${MAKEOBJDIRPREFIX}/do_aout_installworld \
47 ${MAKEOBJDIRPREFIX}/do_aout_kernel \
48 ${MAKEOBJDIRPREFIX}/do_elf_installworld \
49 ${MAKEOBJDIRPREFIX}/do_set_objformat \
50 ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
53 # Just do the build parts of the transition build.
56 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
57 ${MAKEOBJDIRPREFIX}/do_elf_buildworld
60 # The installed system may not have tools capable of building an elf
61 # aware world, so a complete aout buildworld is required to get a known
64 ${MAKEOBJDIRPREFIX}/do_aout_buildworld :
66 @echo "--------------------------------------------------------------"
67 @echo " Doing an aout buildworld to get an up-to-date set of tools"
68 @echo "--------------------------------------------------------------"
69 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/aout \
70 OBJFORMAT=aout REALLY_WANT_DEPRECIATED_AOUT=yes \
71 make -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
72 @touch ${MAKEOBJDIRPREFIX}/do_aout_buildworld
75 # Temporary path for initial elf build.
77 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
80 # Use the aout tools from the aout buildworld to do an elf buildworld.
82 ${MAKEOBJDIRPREFIX}/do_elf_buildworld :
84 @echo "--------------------------------------------------------------"
85 @echo " Doing an elf buildworld using the aout tools in the aout"
87 @echo "--------------------------------------------------------------"
88 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
89 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
90 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
91 make -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
92 @touch ${MAKEOBJDIRPREFIX}/do_elf_buildworld
95 # ldconfig should list the directories that the system is currently using.
97 CUSTOM_LIBDIRS!=ldconfig -r | grep search | sed "s/search directories: //" | sed "s/:/ /g"
100 # These are the standard library directories that should end up containing
101 # just elf libraries.
103 LIBDIRS=/usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib
106 # Go through the list of library directories from ldconfig and add any
107 # directory that doesn't contain an aout path component to the list of
108 # library directories to search.
110 .for _lib in ${CUSTOM_LIBDIRS}
111 _lib1=${_lib:S/\/aout//}
112 .if ${_lib1} == ${_lib}
113 .if ${LIBDIRS:R:M${_lib:R}} == ""
120 # Go through the list of library directories and prepare a list of
124 .for _lib in ${LIBDIRS}
125 AOUTLIBDIRS+=${_lib}/aout
129 # Move the aout libraries into an aout sub-directory of each elf library
132 ${MAKEOBJDIRPREFIX}/do_move_aout_libs move-aout-libs :
133 .if !defined(NOCONFIRM)
135 @echo "--------------------------------------------------------------"
136 @echo " You are about to move all the installed a.out libraries into"
137 @echo " an aout sub-directory of each elf library directory. You can"
138 @echo " type Ctrl-C to abort now or press return to start the moving"
139 @echo " the libraries."
140 @echo "--------------------------------------------------------------"
141 @echo Directories to search: ${LIBDIRS}
142 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
143 @sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
145 @NOCONFIRM=1 sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
147 @ldconfig ${AOUTLIBDIRS}
148 @touch ${MAKEOBJDIRPREFIX}/do_move_aout_libs
151 # Before installing the aout world, allow for the possibility that the
152 # world about to be installed has some different syscalls to the installed
153 # kernel which will make shutting the system down problematic. We set aside
154 # copies of certain programs which match the running kernel.
156 # Install the aout world so that anything that isn't replaced by the
157 # elf world will be updated.
159 ${MAKEOBJDIRPREFIX}/do_aout_installworld :
160 .if !defined(NOCONFIRM)
162 @echo "--------------------------------------------------------------"
163 @echo " You are about to update the installed system (or the system"
164 @echo " that your DESTDIR points to). You can type Ctrl-C to abort"
165 @echo " now or press return to start the first phase of the update."
166 @echo "--------------------------------------------------------------"
167 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
169 .if ${INSTALLEDVERSION} < 300003
171 @echo "--------------------------------------------------------------"
172 @echo " Saving a copy of programs required to shut the system down"
173 @echo "--------------------------------------------------------------"
174 @cp /bin/sh ${MAKEOBJDIRPREFIX}
175 @cp /sbin/reboot ${MAKEOBJDIRPREFIX}
178 @echo "--------------------------------------------------------------"
179 @echo " Doing an aout installworld using the aout tools in the aout"
181 @echo "--------------------------------------------------------------"
182 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/aout \
183 PATH=${AOUTTMPPATH} OBJFORMAT=aout NOTOOLS=1 \
184 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
185 make -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
186 @touch ${MAKEOBJDIRPREFIX}/do_aout_installworld
189 # The installed kernel may not match the world that is installed, so build
190 # a generic kernel, but don't install it. The user can decide if the kernel
191 # needs to be installed. Perhaps we should install it in the root
192 # directory as an obscure name just in case a reboot is required?
194 ${MAKEOBJDIRPREFIX}/do_aout_kernel :
195 .if ${INSTALLEDVERSION} >= 300003
197 @echo "--------------------------------------------------------------"
198 @echo " You are already running 3.0, so a kernel build"
199 @echo " is probably not required."
200 @echo "--------------------------------------------------------------"
203 @echo "--------------------------------------------------------------"
204 @echo " Building a generic kernel using the new aout tools"
205 @echo "--------------------------------------------------------------"
206 .if exists(${.CURDIR}/sys/compile/GENERICupgrade)
207 @rm -rf ${.CURDIR}/sys/compile/GENERICupgrade
209 @cd ${.CURDIR}/sys/${MACHINE}/conf; config GENERICupgrade
210 @-cd ${.CURDIR}/sys/compile/GENERICupgrade; \
211 OBJFORMAT=aout make depend && make all
212 @cd ${.CURDIR}/sys/compile/GENERICupgrade; \
213 OBJFORMAT=aout make depend && make all
215 @touch ${MAKEOBJDIRPREFIX}/do_aout_kernel
218 # Install the elf world overwriting just about all the previously installed
219 # aout world. Any aout things that need to be kept have already been
220 # installed in different places (typically in aout subdirectories).
222 ${MAKEOBJDIRPREFIX}/do_elf_installworld :
223 .if !defined(NOCONFIRM)
225 @echo "--------------------------------------------------------------"
226 @echo " You are about to update the installed system (or the system"
227 @echo " that your DESTDIR points to) with the elf versions of"
228 @echo " everything, replacing the aout versions. You can type Ctrl-C"
229 @echo " to abort now, leaving just the aout world installed, or"
230 @echo " press return to start the second phase of the update."
231 @echo "--------------------------------------------------------------"
232 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
235 @echo "--------------------------------------------------------------"
236 @echo " Doing an elf installworld using the aout tools in the aout"
238 @echo "--------------------------------------------------------------"
239 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
240 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
241 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
242 make -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
243 @touch ${MAKEOBJDIRPREFIX}/do_elf_installworld
246 # Now that the elf world has been installed, we can set the default
247 # object format to elf.
249 ${MAKEOBJDIRPREFIX}/do_set_objformat :
251 @echo "--------------------------------------------------------------"
252 @echo " Setting the default object format to elf"
253 @echo "--------------------------------------------------------------"
254 @echo "OBJFORMAT=elf" > ${DESTDIR}/etc/objformat
255 @touch ${MAKEOBJDIRPREFIX}/do_set_objformat
258 # If not already running a current kernel, install the GENERICupgrade kernel
261 ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot :
262 .if ${INSTALLEDVERSION} >= 300003
264 @echo "--------------------------------------------------------------"
265 @echo " Your system has been updated to run elf by default!"
267 @echo " You should reboot your system now."
268 @echo "--------------------------------------------------------------"
269 @touch ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
271 .if !defined(NOCONFIRM)
273 @echo "--------------------------------------------------------------"
274 @echo " Your system has been updated to run elf by default!"
276 @echo " Since you are running ${INSTALLEDNAME}, the kernel must"
277 @echo " be installed before the system is rebooted. You can type"
278 @echo " Ctrl-C to abort the kernel installation (at your own risk),"
279 @echo " or press return for the kernel to be installed and the"
280 @echo " system rebooted."
281 @echo "--------------------------------------------------------------"
282 @${MAKEOBJDIRPREFIX}/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
285 @echo "--------------------------------------------------------------"
286 @echo " Installing a new GENERICupgrade kernel"
287 @echo "--------------------------------------------------------------"
288 @cd ${.CURDIR}/sys/compile/GENERICupgrade; make install
290 @echo "--------------------------------------------------------------"
291 @echo " Rebooting......."
292 @echo "--------------------------------------------------------------"
293 @touch ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
294 @-${MAKEOBJDIRPREFIX}/reboot