2 # $Id: Makefile.upgrade,v 1.8 1999/01/07 06:30:14 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 .if !exists(${.CURDIR}/sys/${MACHINE}/conf/GENERICupgrade)
210 -cp ${.CURDIR}/sys/${MACHINE}/conf/GENERIC \
211 ${.CURDIR}/sys/${MACHINE}/conf/GENERICupgrade
213 @cd ${.CURDIR}/sys/${MACHINE}/conf; config GENERICupgrade
214 @-cd ${.CURDIR}/sys/compile/GENERICupgrade; \
215 OBJFORMAT=aout make KERNFORMAT=aout depend && \
216 OBJFORMAT=aout make KERNFORMAT=aout all
217 @cd ${.CURDIR}/sys/compile/GENERICupgrade; \
218 OBJFORMAT=aout make KERNFORMAT=aout depend && \
219 OBJFORMAT=aout make KERNFORMAT=aout all
221 @touch ${MAKEOBJDIRPREFIX}/do_aout_kernel
224 # Install the elf world overwriting just about all the previously installed
225 # aout world. Any aout things that need to be kept have already been
226 # installed in different places (typically in aout subdirectories).
228 ${MAKEOBJDIRPREFIX}/do_elf_installworld :
229 .if !defined(NOCONFIRM)
231 @echo "--------------------------------------------------------------"
232 @echo " You are about to update the installed system (or the system"
233 @echo " that your DESTDIR points to) with the elf versions of"
234 @echo " everything, replacing the aout versions. You can type Ctrl-C"
235 @echo " to abort now, leaving just the aout world installed, or"
236 @echo " press return to start the second phase of the update."
237 @echo "--------------------------------------------------------------"
238 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
241 @echo "--------------------------------------------------------------"
242 @echo " Doing an elf installworld using the aout tools in the aout"
244 @echo "--------------------------------------------------------------"
245 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
246 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
247 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
248 make -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
249 @touch ${MAKEOBJDIRPREFIX}/do_elf_installworld
252 # Now that the elf world has been installed, we can set the default
253 # object format to elf.
255 ${MAKEOBJDIRPREFIX}/do_set_objformat :
257 @echo "--------------------------------------------------------------"
258 @echo " Setting the default object format to elf"
259 @echo "--------------------------------------------------------------"
260 @echo "OBJFORMAT=elf" > ${DESTDIR}/etc/objformat
261 @touch ${MAKEOBJDIRPREFIX}/do_set_objformat
264 # If not already running a current kernel, install the GENERICupgrade kernel
267 ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot :
268 .if ${INSTALLEDVERSION} >= 300003
270 @echo "--------------------------------------------------------------"
271 @echo " Your system has been updated to run elf by default!"
273 @echo " You should reboot your system now."
274 @echo "--------------------------------------------------------------"
275 @touch ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
277 .if !defined(NOCONFIRM)
279 @echo "--------------------------------------------------------------"
280 @echo " Your system has been updated to run elf by default!"
282 @echo " Since you are running ${INSTALLEDNAME}, the kernel must"
283 @echo " be installed before the system is rebooted. You can type"
284 @echo " Ctrl-C to abort the kernel installation (at your own risk),"
285 @echo " or press return for the kernel to be installed and the"
286 @echo " system rebooted."
287 @echo "--------------------------------------------------------------"
288 @${MAKEOBJDIRPREFIX}/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
291 @echo "--------------------------------------------------------------"
292 @echo " Installing a new GENERICupgrade kernel"
293 @echo "--------------------------------------------------------------"
294 @cd ${.CURDIR}/sys/compile/GENERICupgrade; make install
296 @echo "--------------------------------------------------------------"
297 @echo " Rebooting......."
298 @echo "--------------------------------------------------------------"
299 @touch ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
300 @-${MAKEOBJDIRPREFIX}/reboot