]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.upgrade
On the i386, load the ELF dynamic linker where an mmap(0, ...) would
[FreeBSD/FreeBSD.git] / Makefile.upgrade
1 #
2 #       $Id: Makefile.upgrade,v 1.14 1999/02/13 18:49:02 jkh 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                 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk buildworld
105         @touch ${MAKEOBJDIRPREFIX}/do_elf_buildworld
106
107 #
108 # ldconfig should list the directories that the system is currently using.
109 #
110 CUSTOM_LIBDIRS!=ldconfig -r | grep search | sed "s/search directories: //" | sed "s/:/ /g"
111
112 #
113 # These are the standard library directories that should end up containing
114 # just elf libraries.
115 #
116 LIBDIRS=/usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib
117
118 #
119 # Go through the list of library directories from ldconfig and add any
120 # directory that doesn't contain an aout path component to the list of
121 # library directories to search.
122 #
123 .for _lib in ${CUSTOM_LIBDIRS}
124 _lib1=${_lib:S/\/aout//}
125 .if ${_lib1} == ${_lib}
126 .if ${LIBDIRS:R:M${_lib:R}} == ""
127 LIBDIRS+=${_lib}
128 .endif
129 .endif
130 .endfor
131
132 #
133 # Go through the list of library directories and prepare a list of
134 # aout directories.
135 #
136 AOUTLIBDIRS=
137 .for _lib in ${LIBDIRS}
138 AOUTLIBDIRS+=${_lib}/aout
139 .endfor
140
141 #
142 # Move the aout libraries into an aout sub-directory of each elf library
143 # directory.
144 #
145 ${MAKEOBJDIRPREFIX}/do_move_aout_libs move-aout-libs :
146 .if !defined(NOCONFIRM)
147         @echo
148         @echo "--------------------------------------------------------------"
149         @echo " You are about to move all the installed a.out libraries into"
150         @echo " an aout sub-directory of each elf library directory. You can"
151         @echo " type Ctrl-C to abort now or press return to start the moving"
152         @echo " the libraries."
153         @echo "--------------------------------------------------------------"
154         @echo Directories to search: ${LIBDIRS}
155         @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
156         @sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
157 .else
158         @NOCONFIRM=1 sh ${.CURDIR}/tools/tools/upgrade/move_aout_libs.sh ${LIBDIRS}
159 .endif
160         @ldconfig ${AOUTLIBDIRS}
161         @touch ${MAKEOBJDIRPREFIX}/do_move_aout_libs
162
163 #
164 # Before installing the aout world, allow for the possibility that the
165 # world about to be installed has some different syscalls to the installed
166 # kernel which will make shutting the system down problematic. We set aside
167 # copies of certain programs which match the running kernel.
168 #
169 # Install the aout world so that anything that isn't replaced by the
170 # elf world will be updated.
171 #
172 ${MAKEOBJDIRPREFIX}/do_aout_installworld :
173 .if     ${INSTALLEDVERSION} < 300003
174         @echo
175         @echo "--------------------------------------------------------------"
176         @echo " Saving a copy of programs required to shut the system down"
177         @echo "--------------------------------------------------------------"
178         @cp /bin/sh ${MAKEOBJDIRPREFIX}
179         @cp /sbin/reboot ${MAKEOBJDIRPREFIX}
180 .endif
181         @touch ${MAKEOBJDIRPREFIX}/do_aout_installworld
182
183 #
184 # Build and install a new kernel, as well as the boot blocks necessary to
185 # boot it.
186 #
187 ${MAKEOBJDIRPREFIX}/do_elf_kernel :
188         @if [ -f /var/db/update.cfg -a -f ${.CURDIR}/tools/tools/upgrade/doupgrade.sh ]; then \
189              env MACHINE=${MACHINE} CURDIR=${.CURDIR} sh ${.CURDIR}/tools/tools/upgrade/doupgrade.sh 2 /var/db/update.cfg; \
190         fi
191         @touch ${MAKEOBJDIRPREFIX}/do_elf_kernel
192         @rm -f /var/db/update.cfg
193
194 #
195 # Install the elf world overwriting just about all the previously installed
196 # aout world. Any aout things that need to be kept have already been
197 # installed in different places (typically in aout subdirectories).
198 #
199 ${MAKEOBJDIRPREFIX}/do_elf_installworld :
200 .if !defined(NOCONFIRM)
201         @echo
202         @echo "--------------------------------------------------------------"
203         @echo " You are about to update the installed system (or the system"
204         @echo " that your DESTDIR points to) with the elf versions of"
205         @echo " everything, replacing the aout versions. You can type Ctrl-C"
206         @echo " to abort now, leaving just the aout world installed, or"
207         @echo " press return to start the second phase of the update."
208         @echo "--------------------------------------------------------------"
209         @/bin/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
210 .endif
211         @echo
212         @echo "--------------------------------------------------------------"
213         @echo " Doing an elf installworld using the aout tools in the aout"
214         @echo " obj tree."
215         @echo "--------------------------------------------------------------"
216         @cd ${.CURDIR}; MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/elf \
217                 PATH=${AOUTTMPPATH} OBJFORMAT=elf NOTOOLS=1 \
218                 TOOLROOT=${MAKEOBJDIRPREFIX}/aout${.CURDIR}/tmp \
219                 ${MAKE} -f Makefile.inc1 -m ${.CURDIR}/share/mk installworld
220         @if [ ! -f /etc/pam.conf ]; then cp ${.CURDIR}/etc/pam.conf /etc; fi
221         @if [ ! -f /etc/auth.conf ]; then cp ${.CURDIR}/etc/auth.conf /etc; fi
222         @if [ ! -f /etc/login.conf ]; then cp ${.CURDIR}/etc/login.conf /etc; fi
223         @touch ${MAKEOBJDIRPREFIX}/do_elf_installworld
224
225 #
226 # Now that the elf world has been installed, we can set the default
227 # object format to elf.
228 #
229 ${MAKEOBJDIRPREFIX}/do_set_objformat    :
230         @echo
231         @echo "--------------------------------------------------------------"
232         @echo " Setting the default object format to elf"
233         @echo "--------------------------------------------------------------"
234         @echo "OBJFORMAT=elf" > ${DESTDIR}/etc/objformat
235         @touch ${MAKEOBJDIRPREFIX}/do_set_objformat
236
237 #
238 # Time to reboot!
239 ${MAKEOBJDIRPREFIX}/do_reboot   :
240 .if !defined(NOCONFIRM)
241         @echo
242         @echo "--------------------------------------------------------------"
243         @echo " Your system has now been fully updated to elf!"
244         @echo
245         @echo " It's now time to reboot from your new ELF kernel."
246         @echo " You can type Ctrl-C to abort this (at your own risk)"
247         @echo " or press return to reboot the system."
248         @echo "--------------------------------------------------------------"
249         @${MAKEOBJDIRPREFIX}/sh -c "read -p \"Return to continue or Ctrl-C to abort: \" _e"
250 .endif
251         @echo " Rebooting......."
252         @echo "--------------------------------------------------------------"
253         @touch ${MAKEOBJDIRPREFIX}/do_reboot
254         @-${MAKEOBJDIRPREFIX}/reboot