2 # $FreeBSD: src/Makefile.upgrade,v 1.17 1999/08/28 01:35:58 peter Exp $
3 # $DragonFly: src/Attic/Makefile.upgrade,v 1.2 2003/06/17 04:21:10 dillon Exp $
5 # This makefile contains rules for preforming upgrades that are outside
6 # the scope of the normal build world process.
10 # Make sure the PATH is set correctly
12 PATH=/sbin:/bin:/usr/sbin:/usr/bin
15 # Build things relative to the user's preferred object directory,
16 # defaulting to /usr/obj if not defined.
18 MAKEOBJDIRPREFIX?=/usr/obj
21 # The installed operating system release gives us the hint as to whether
22 # we need to build a kernel too.
24 INSTALLEDVERSION!=sh ${.CURDIR}/tools/tools/upgrade/getosreldate.sh
25 INSTALLEDNAME!=uname -r
28 # Upgrade the installed make to the current version using the installed
29 # headers, libraries and build tools. This is required on installed versions
30 # prior to 2.2.5 in which the installed make doesn't support the -m argument.
34 @echo "--------------------------------------------------------------"
35 @echo " Upgrading the installed make"
36 @echo "--------------------------------------------------------------"
37 @cd ${.CURDIR}/usr.bin/make; \
38 make obj && make depend && make all && make install
41 # Upgrade from aout to elf, doing an aout build first to ensure that there
42 # are up-to-date tools before building the initial elf world. The aout
43 # tools just built into the object directory tree and executed from there
44 # during the elf build. Then install the aout tools, build an aout kernel
45 # with them (in case the installed kernel is an older version), then
46 # install the elf world.
48 aout-to-elf aout-to-elf-install : /var/db/update.cfg \
49 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
50 ${MAKEOBJDIRPREFIX}/do_elf_buildworld \
51 ${MAKEOBJDIRPREFIX}/do_move_aout_libs \
52 ${MAKEOBJDIRPREFIX}/do_aout_installworld \
53 ${MAKEOBJDIRPREFIX}/do_elf_installworld \
54 ${MAKEOBJDIRPREFIX}/do_elf_kernel \
55 ${MAKEOBJDIRPREFIX}/do_set_objformat \
56 ${MAKEOBJDIRPREFIX}/do_reboot
58 # front-load all the information we're going to need.
60 @if [ -f ${.CURDIR}/tools/tools/upgrade/doupgrade.sh ]; then \
61 env MACHINE=${MACHINE} CURDIR=${.CURDIR} sh ${.CURDIR}/tools/tools/upgrade/doupgrade.sh 1 /var/db/update.cfg; \
63 echo "Your source tree must not be fully populated; unable to find upgrade script"; echo "in ${.CURDIR}/tools/tools/upgrade/doupgrade.sh."; exit 1; \
67 # Just do the build parts of the transition build.
70 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
71 ${MAKEOBJDIRPREFIX}/do_elf_buildworld
74 # The installed system may not have tools capable of building an elf
75 # aware world, so a complete aout buildworld is required to get a known
78 ${MAKEOBJDIRPREFIX}/do_aout_buildworld :
80 @echo "--------------------------------------------------------------"
81 @echo " Doing an aout buildworld to get an up-to-date set of tools"
82 @echo "--------------------------------------------------------------"
83 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/aout \
84 OBJFORMAT=aout REALLY_WANT_DEPRECIATED_AOUT=yes \
85 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
86 @touch ${MAKEOBJDIRPREFIX}/do_aout_buildworld
89 # Temporary path for initial elf build.
91 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
94 # Use the aout tools from the aout buildworld to do an elf buildworld.
96 ${MAKEOBJDIRPREFIX}/do_elf_buildworld :
98 @echo "--------------------------------------------------------------"
99 @echo " Doing an elf buildworld using the aout tools in the aout"
101 @echo "--------------------------------------------------------------"
102 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
103 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
104 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
105 X11BASE=/nonexistent \
106 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
107 @touch ${MAKEOBJDIRPREFIX}/do_elf_buildworld
110 # ldconfig should list the directories that the system is currently using.
112 CUSTOM_LIBDIRS!=ldconfig -r | grep search | sed "s/search directories: //" | sed "s/:/ /g"
115 # These are the standard library directories that should end up containing
116 # just elf libraries.
118 LIBDIRS=/usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib
121 # Go through the list of library directories from ldconfig and add any
122 # directory that doesn't contain an aout path component to the list of
123 # library directories to search.
125 .for _lib in ${CUSTOM_LIBDIRS}
126 _lib1=${_lib:S/\/aout//}
127 .if ${_lib1} == ${_lib}
128 .if ${LIBDIRS:R:M${_lib:R}} == ""
135 # Go through the list of library directories and prepare a list of
139 .for _lib in ${LIBDIRS}
140 AOUTLIBDIRS+=${_lib}/aout
144 # Move the aout libraries into an aout sub-directory of each elf library
147 ${MAKEOBJDIRPREFIX}/do_move_aout_libs move-aout-libs :
148 .if !defined(NOCONFIRM)
150 @echo "--------------------------------------------------------------"
151 @echo " You are about to move all the installed a.out libraries into"
152 @echo " an aout sub-directory of each elf library directory. You can"
153 @echo " type Ctrl-C to abort now or press return to start the moving"
154 @echo " the libraries."
155 @echo "--------------------------------------------------------------"
156 @echo Directories to search: ${LIBDIRS}
157 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
158 @sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
160 @NOCONFIRM=1 sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
162 @ldconfig ${AOUTLIBDIRS}
163 @touch ${MAKEOBJDIRPREFIX}/do_move_aout_libs
166 # Before installing the aout world, allow for the possibility that the
167 # world about to be installed has some different syscalls to the installed
168 # kernel which will make shutting the system down problematic. We set aside
169 # copies of certain programs which match the running kernel.
171 # Install the aout world so that anything that isn't replaced by the
172 # elf world will be updated.
174 ${MAKEOBJDIRPREFIX}/do_aout_installworld :
175 .if ${INSTALLEDVERSION} < 300003
177 @echo "--------------------------------------------------------------"
178 @echo " Saving a copy of programs required to shut the system down"
179 @echo "--------------------------------------------------------------"
180 @cp /bin/sh ${MAKEOBJDIRPREFIX}
181 @cp /sbin/reboot ${MAKEOBJDIRPREFIX}
183 @touch ${MAKEOBJDIRPREFIX}/do_aout_installworld
186 # Build and install a new kernel, as well as the boot blocks necessary to
189 ${MAKEOBJDIRPREFIX}/do_elf_kernel :
190 @if [ -f /var/db/update.cfg -a -f ${.CURDIR}/tools/tools/upgrade/doupgrade.sh ]; then \
191 env MACHINE=${MACHINE} CURDIR=${.CURDIR} sh ${.CURDIR}/tools/tools/upgrade/doupgrade.sh 2 /var/db/update.cfg; \
193 @touch ${MAKEOBJDIRPREFIX}/do_elf_kernel
194 @rm -f /var/db/update.cfg
197 # Install the elf world overwriting just about all the previously installed
198 # aout world. Any aout things that need to be kept have already been
199 # installed in different places (typically in aout subdirectories).
201 ${MAKEOBJDIRPREFIX}/do_elf_installworld :
202 .if !defined(NOCONFIRM)
204 @echo "--------------------------------------------------------------"
205 @echo " You are about to update the installed system (or the system"
206 @echo " that your DESTDIR points to) with the elf versions of"
207 @echo " everything, replacing the aout versions. You can type Ctrl-C"
208 @echo " to abort now, leaving just the aout world installed, or"
209 @echo " press return to start the second phase of the update."
210 @echo "--------------------------------------------------------------"
211 @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
214 @echo "--------------------------------------------------------------"
215 @echo " Doing an elf installworld using the aout tools in the aout"
217 @echo "--------------------------------------------------------------"
218 @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
219 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
220 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
221 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
222 @if [ ! -f /etc/pam.conf ]; then cp ${.CURDIR}/etc/pam.conf /etc; fi
223 @if [ ! -f /etc/auth.conf ]; then cp ${.CURDIR}/etc/auth.conf /etc; fi
224 @if [ ! -f /etc/login.conf ]; then cp ${.CURDIR}/etc/login.conf /etc; fi
225 @touch ${MAKEOBJDIRPREFIX}/do_elf_installworld
228 # Now that the elf world has been installed, we can set the default
229 # object format to elf.
231 ${MAKEOBJDIRPREFIX}/do_set_objformat :
233 @echo "--------------------------------------------------------------"
234 @echo " Setting the default object format to elf"
235 @echo "--------------------------------------------------------------"
236 @echo "OBJFORMAT=elf" > ${DESTDIR}/etc/objformat
237 @touch ${MAKEOBJDIRPREFIX}/do_set_objformat
241 ${MAKEOBJDIRPREFIX}/do_reboot :
242 .if !defined(NOCONFIRM)
244 @echo "--------------------------------------------------------------"
245 @echo " Your system has now been fully updated to elf!"
247 @echo " It's now time to reboot from your new ELF kernel."
248 @echo " You can type Ctrl-C to abort this (at your own risk)"
249 @echo " or press return to reboot the system."
250 @echo "--------------------------------------------------------------"
251 @${MAKEOBJDIRPREFIX}/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
253 @echo " Rebooting......."
254 @echo "--------------------------------------------------------------"
255 @touch ${MAKEOBJDIRPREFIX}/do_reboot
256 @-${MAKEOBJDIRPREFIX}/reboot