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