]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.upgrade
make aout-to-elf first does an a.out makeworld to bring the current
[FreeBSD/FreeBSD.git] / Makefile.upgrade
1 #
2 #       $Id: Makefile.upgrade,v 1.7 1998/10/17 05:40:45 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 # Build things relative to the user's preferred object directory,
10 # defaulting to /usr/obj if not defined.
11 #
12 MAKEOBJDIRPREFIX?=/usr/obj
13
14 #
15 # The installed operating system release gives us the hint as to whether
16 # we need to build a kernel too.
17 #
18 INSTALLEDVERSION!=sh ${.CURDIR}/tools/tools/upgrade/getosreldate.sh
19 INSTALLEDNAME!=uname -r
20
21 #
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.
25 #
26 make    :
27         @echo
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
33
34 #
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.
41 #
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
51
52 #
53 # Just do the build parts of the transition build.
54 #
55 aout-to-elf-build :                                             \
56                 ${MAKEOBJDIRPREFIX}/do_aout_buildworld          \
57                 ${MAKEOBJDIRPREFIX}/do_elf_buildworld           
58
59 #
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
62 # set of tools.
63 #
64 ${MAKEOBJDIRPREFIX}/do_aout_buildworld :
65         @echo
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
73
74 #
75 # Temporary path for initial elf build.
76 #
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
78
79 #
80 # Use the aout tools from the aout buildworld to do an elf buildworld.
81 #
82 ${MAKEOBJDIRPREFIX}/do_elf_buildworld :
83         @echo
84         @echo "--------------------------------------------------------------"
85         @echo " Doing an elf buildworld using the aout tools in the aout"
86         @echo " obj tree."
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
93
94 #
95 # ldconfig should list the directories that the system is currently using.
96 #
97 CUSTOM_LIBDIRS!=ldconfig -r | grep search | sed "s/search directories: //" | sed "s/:/ /g"
98
99 #
100 # These are the standard library directories that should end up containing
101 # just elf libraries.
102 #
103 LIBDIRS=/usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib
104
105 #
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.
109 #
110 .for _lib in ${CUSTOM_LIBDIRS}
111 _lib1=${_lib:S/\/aout//}
112 .if ${_lib1} == ${_lib}
113 .if ${LIBDIRS:R:M${_lib:R}} == ""
114 LIBDIRS+=${_lib}
115 .endif
116 .endif
117 .endfor
118
119 #
120 # Go through the list of library directories and prepare a list of
121 # aout directories.
122 #
123 AOUTLIBDIRS=
124 .for _lib in ${LIBDIRS}
125 AOUTLIBDIRS+=${_lib}/aout
126 .endfor
127
128 #
129 # Move the aout libraries into an aout sub-directory of each elf library
130 # directory.
131 #
132 ${MAKEOBJDIRPREFIX}/do_move_aout_libs move-aout-libs :
133 .if !defined(NOCONFIRM)
134         @echo
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}
144 .else
145         @NOCONFIRM=1 sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
146 .endif
147         @ldconfig ${AOUTLIBDIRS}
148         @touch ${MAKEOBJDIRPREFIX}/do_move_aout_libs
149
150 #
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.
155 #
156 # Install the aout world so that anything that isn't replaced by the
157 # elf world will be updated.
158 #
159 ${MAKEOBJDIRPREFIX}/do_aout_installworld :
160 .if !defined(NOCONFIRM)
161         @echo
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"
168 .endif
169 .if     ${INSTALLEDVERSION} < 300003
170         @echo
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}
176 .endif
177         @echo
178         @echo "--------------------------------------------------------------"
179         @echo " Doing an aout installworld using the aout tools in the aout"
180         @echo " obj tree."
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
187
188 #
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?
193 #
194 ${MAKEOBJDIRPREFIX}/do_aout_kernel :
195 .if     ${INSTALLEDVERSION} >= 300003
196         @echo
197         @echo "--------------------------------------------------------------"
198         @echo " You are already running 3.0, so a kernel build"
199         @echo " is probably not required."
200         @echo "--------------------------------------------------------------"
201 .else
202         @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
208 .endif
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
214 .endif
215         @touch ${MAKEOBJDIRPREFIX}/do_aout_kernel
216
217 #
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).
221 #
222 ${MAKEOBJDIRPREFIX}/do_elf_installworld :
223 .if !defined(NOCONFIRM)
224         @echo
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"
233 .endif
234         @echo
235         @echo "--------------------------------------------------------------"
236         @echo " Doing an elf installworld using the aout tools in the aout"
237         @echo " obj tree."
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
244
245 #
246 # Now that the elf world has been installed, we can set the default
247 # object format to elf.
248 #
249 ${MAKEOBJDIRPREFIX}/do_set_objformat    :
250         @echo
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
256
257 #
258 # If not already running a current kernel, install the GENERICupgrade kernel
259 # and reboot.
260 #
261 ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot    :
262 .if     ${INSTALLEDVERSION} >= 300003
263         @echo
264         @echo "--------------------------------------------------------------"
265         @echo " Your system has been updated to run elf by default!"
266         @echo
267         @echo " You should reboot your system now."
268         @echo "--------------------------------------------------------------"
269         @touch ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
270 .else
271 .if !defined(NOCONFIRM)
272         @echo
273         @echo "--------------------------------------------------------------"
274         @echo " Your system has been updated to run elf by default!"
275         @echo
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"
283 .endif
284         @echo
285         @echo "--------------------------------------------------------------"
286         @echo " Installing a new GENERICupgrade kernel"
287         @echo "--------------------------------------------------------------"
288         @cd ${.CURDIR}/sys/compile/GENERICupgrade; make install
289         @echo
290         @echo "--------------------------------------------------------------"
291         @echo " Rebooting......."
292         @echo "--------------------------------------------------------------"
293         @touch ${MAKEOBJDIRPREFIX}/do_install_kernel_reboot
294         @-${MAKEOBJDIRPREFIX}/reboot
295 .endif
296