go back to using gd_cpuid instead of gd_cpu.
[dragonfly.git] / Makefile.upgrade
CommitLineData
984263bc
MD
1#
2# $FreeBSD: src/Makefile.upgrade,v 1.17 1999/08/28 01:35:58 peter Exp $
1de703da 3# $DragonFly: src/Attic/Makefile.upgrade,v 1.2 2003/06/17 04:21:10 dillon Exp $
984263bc
MD
4#
5# This makefile contains rules for preforming upgrades that are outside
6# the scope of the normal build world process.
7#
8
9#
10# Make sure the PATH is set correctly
11#
12PATH=/sbin:/bin:/usr/sbin:/usr/bin
13
14#
15# Build things relative to the user's preferred object directory,
16# defaulting to /usr/obj if not defined.
17#
18MAKEOBJDIRPREFIX?=/usr/obj
19
20#
21# The installed operating system release gives us the hint as to whether
22# we need to build a kernel too.
23#
24INSTALLEDVERSION!=sh ${.CURDIR}/tools/tools/upgrade/getosreldate.sh
25INSTALLEDNAME!=uname -r
26
27#
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.
31#
32make :
33 @echo
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
39
40#
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.
47#
48aout-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
57
58# front-load all the information we're going to need.
59/var/db/update.cfg:
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; \
62 else \
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; \
64 fi
65
66#
67# Just do the build parts of the transition build.
68#
69aout-to-elf-build : \
70 ${MAKEOBJDIRPREFIX}/do_aout_buildworld \
71 ${MAKEOBJDIRPREFIX}/do_elf_buildworld
72
73#
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
76# set of tools.
77#
78${MAKEOBJDIRPREFIX}/do_aout_buildworld :
79 @echo
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
87
88#
89# Temporary path for initial elf build.
90#
91AOUTTMPPATH= ${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
92
93#
94# Use the aout tools from the aout buildworld to do an elf buildworld.
95#
96${MAKEOBJDIRPREFIX}/do_elf_buildworld :
97 @echo
98 @echo "--------------------------------------------------------------"
99 @echo " Doing an elf buildworld using the aout tools in the aout"
100 @echo " obj tree."
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
108
109#
110# ldconfig should list the directories that the system is currently using.
111#
112CUSTOM_LIBDIRS!=ldconfig -r | grep search | sed "s/search directories: //" | sed "s/:/ /g"
113
114#
115# These are the standard library directories that should end up containing
116# just elf libraries.
117#
118LIBDIRS=/usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib
119
120#
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.
124#
125.for _lib in ${CUSTOM_LIBDIRS}
126_lib1=${_lib:S/\/aout//}
127.if ${_lib1} == ${_lib}
128.if ${LIBDIRS:R:M${_lib:R}} == ""
129LIBDIRS+=${_lib}
130.endif
131.endif
132.endfor
133
134#
135# Go through the list of library directories and prepare a list of
136# aout directories.
137#
138AOUTLIBDIRS=
139.for _lib in ${LIBDIRS}
140AOUTLIBDIRS+=${_lib}/aout
141.endfor
142
143#
144# Move the aout libraries into an aout sub-directory of each elf library
145# directory.
146#
147${MAKEOBJDIRPREFIX}/do_move_aout_libs move-aout-libs :
148.if !defined(NOCONFIRM)
149 @echo
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}
159.else
160 @NOCONFIRM=1 sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
161.endif
162 @ldconfig ${AOUTLIBDIRS}
163 @touch ${MAKEOBJDIRPREFIX}/do_move_aout_libs
164
165#
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.
170#
171# Install the aout world so that anything that isn't replaced by the
172# elf world will be updated.
173#
174${MAKEOBJDIRPREFIX}/do_aout_installworld :
175.if ${INSTALLEDVERSION} < 300003
176 @echo
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}
182.endif
183 @touch ${MAKEOBJDIRPREFIX}/do_aout_installworld
184
185#
186# Build and install a new kernel, as well as the boot blocks necessary to
187# boot it.
188#
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; \
192 fi
193 @touch ${MAKEOBJDIRPREFIX}/do_elf_kernel
194 @rm -f /var/db/update.cfg
195
196#
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).
200#
201${MAKEOBJDIRPREFIX}/do_elf_installworld :
202.if !defined(NOCONFIRM)
203 @echo
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"
212.endif
213 @echo
214 @echo "--------------------------------------------------------------"
215 @echo " Doing an elf installworld using the aout tools in the aout"
216 @echo " obj tree."
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
226
227#
228# Now that the elf world has been installed, we can set the default
229# object format to elf.
230#
231${MAKEOBJDIRPREFIX}/do_set_objformat :
232 @echo
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
238
239#
240# Time to reboot!
241${MAKEOBJDIRPREFIX}/do_reboot :
242.if !defined(NOCONFIRM)
243 @echo
244 @echo "--------------------------------------------------------------"
245 @echo " Your system has now been fully updated to elf!"
246 @echo
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"
252.endif
253 @echo " Rebooting......."
254 @echo "--------------------------------------------------------------"
255 @touch ${MAKEOBJDIRPREFIX}/do_reboot
256 @-${MAKEOBJDIRPREFIX}/reboot