1 | #!/bin/bash
|
---|
2 | # $Id$
|
---|
3 |
|
---|
4 |
|
---|
5 | orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
|
---|
6 |
|
---|
7 |
|
---|
8 | #--------------------------------------#
|
---|
9 | host_prep_Makefiles() { #
|
---|
10 | #--------------------------------------#
|
---|
11 | local CLFS_HOST
|
---|
12 |
|
---|
13 | echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
|
---|
14 |
|
---|
15 | # defined here, only for ease of reading
|
---|
16 | CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
|
---|
17 | (
|
---|
18 | cat << EOF
|
---|
19 | 023-creatingtoolsdir:
|
---|
20 | @\$(call echo_message, Building)
|
---|
21 | @mkdir \$(MOUNT_PT)/tools && \\
|
---|
22 | rm -f /tools && \\
|
---|
23 | ln -s \$(MOUNT_PT)/tools /
|
---|
24 | @\$(call housekeeping)
|
---|
25 |
|
---|
26 | 024-creatingcrossdir: 023-creatingtoolsdir
|
---|
27 | @\$(call echo_message, Building)
|
---|
28 | @mkdir -v \$(MOUNT_PT)/cross-tools && \\
|
---|
29 | rm -f /cross-tools && \\
|
---|
30 | ln -s \$(MOUNT_PT)/cross-tools /
|
---|
31 | @\$(call housekeeping)
|
---|
32 |
|
---|
33 | 025-addinguser: 024-creatingcrossdir
|
---|
34 | @\$(call echo_message, Building)
|
---|
35 | @if [ ! -d /home/\$(LUSER) ]; then \\
|
---|
36 | groupadd \$(LGROUP); \\
|
---|
37 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
38 | else \\
|
---|
39 | touch luser-exist; \\
|
---|
40 | fi;
|
---|
41 | @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
---|
42 | chown \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
|
---|
43 | chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
---|
44 | chmod a+wt \$(SRCSDIR)
|
---|
45 | @\$(call housekeeping)
|
---|
46 |
|
---|
47 | 026-settingenvironment: 025-addinguser
|
---|
48 | @\$(call echo_message, Building)
|
---|
49 | @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
50 | mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
---|
51 | fi;
|
---|
52 | @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
53 | mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
|
---|
54 | fi;
|
---|
55 | @echo "set +h" > /home/\$(LUSER)/.bashrc && \\
|
---|
56 | echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
|
---|
57 | echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
|
---|
58 | echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
|
---|
59 | echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
|
---|
60 | echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
|
---|
61 | echo "" >> /home/\$(LUSER)/.bashrc && \\
|
---|
62 | echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
---|
63 | echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
---|
64 | echo "" >> /home/\$(LUSER)/.bashrc && \\
|
---|
65 | echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
66 | echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
67 | echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
68 | echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
|
---|
69 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
---|
70 | touch envars && \\
|
---|
71 | chmod -R a+wt \$(MOUNT_PT) && \\
|
---|
72 | chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT)
|
---|
73 | @\$(call housekeeping)
|
---|
74 | EOF
|
---|
75 | ) >> $MKFILE.tmp
|
---|
76 | host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment"
|
---|
77 |
|
---|
78 | }
|
---|
79 |
|
---|
80 | #--------------------------------------#
|
---|
81 | cross_tools_Makefiles() { #
|
---|
82 | #--------------------------------------#
|
---|
83 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
---|
84 |
|
---|
85 | for file in cross-tools/* ; do
|
---|
86 | # Keep the script file name
|
---|
87 | this_script=`basename $file`
|
---|
88 | #
|
---|
89 | # Skip this script...
|
---|
90 | case $this_script in
|
---|
91 | *cflags* | *variables* ) # work done in host_prep_Makefiles
|
---|
92 | continue; ;;
|
---|
93 | *) ;;
|
---|
94 | esac
|
---|
95 | #
|
---|
96 | # Set the dependency for the first target.
|
---|
97 | if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
|
---|
98 |
|
---|
99 | # First append each name of the script files to a list (this will become
|
---|
100 | # the names of the targets in the Makefile
|
---|
101 | cross_tools="$cross_tools $this_script"
|
---|
102 |
|
---|
103 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
104 | # and binutils in chapter 5)
|
---|
105 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
106 | -e 's@-static@@' \
|
---|
107 | -e 's@-final@@' \
|
---|
108 | -e 's@-64@@' \
|
---|
109 | -e 's@-n32@@'`
|
---|
110 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
111 |
|
---|
112 | #--------------------------------------------------------------------#
|
---|
113 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
114 | #--------------------------------------------------------------------#
|
---|
115 | #
|
---|
116 | # Drop in the name of the target on a new line, and the previous target
|
---|
117 | # as a dependency. Also call the echo_message function.
|
---|
118 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
119 | #
|
---|
120 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
121 | #
|
---|
122 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
123 | #
|
---|
124 | LUSER_wrt_RunAsUser "${file}"
|
---|
125 | #
|
---|
126 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
127 | #
|
---|
128 | # Include a touch of the target name so make can check if it's already been made.
|
---|
129 | wrt_touch
|
---|
130 | #
|
---|
131 | #--------------------------------------------------------------------#
|
---|
132 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
133 | #--------------------------------------------------------------------#
|
---|
134 | #
|
---|
135 | # Keep the script file name for Makefile dependencies.
|
---|
136 | PREV=$this_script
|
---|
137 |
|
---|
138 | done # for file in ....
|
---|
139 | }
|
---|
140 |
|
---|
141 | #--------------------------------------#
|
---|
142 | temptools_Makefiles() { #
|
---|
143 | #--------------------------------------#
|
---|
144 | echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}"
|
---|
145 |
|
---|
146 | for file in temp-system/* ; do
|
---|
147 | # Keep the script file name
|
---|
148 | this_script=`basename $file`
|
---|
149 | #
|
---|
150 | # Deal with any odd scripts..
|
---|
151 | case $this_script in
|
---|
152 | *choose) # The choose script will fail if you cannot enter the new environment
|
---|
153 | # If the 'boot' build method was chosen don't run the script
|
---|
154 | [[ $METHOD = "boot" ]] && continue; ;;
|
---|
155 | *) ;;
|
---|
156 | esac
|
---|
157 |
|
---|
158 | #
|
---|
159 | # First append each name of the script files to a list (this will become
|
---|
160 | # the names of the targets in the Makefile
|
---|
161 | temptools="$temptools $this_script"
|
---|
162 |
|
---|
163 | #
|
---|
164 | # Grab the name of the target, strip id number, XXX-script
|
---|
165 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
166 | #
|
---|
167 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
168 |
|
---|
169 | #--------------------------------------------------------------------#
|
---|
170 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
171 | #--------------------------------------------------------------------#
|
---|
172 | #
|
---|
173 | # Drop in the name of the target on a new line, and the previous target
|
---|
174 | # as a dependency. Also call the echo_message function.
|
---|
175 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
176 | #
|
---|
177 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
178 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
179 | #
|
---|
180 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
181 | [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
182 | #
|
---|
183 | LUSER_wrt_RunAsUser "${file}"
|
---|
184 | #
|
---|
185 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
186 | #
|
---|
187 | # Include a touch of the target name so make can check if it's already been made.
|
---|
188 | wrt_touch
|
---|
189 | #
|
---|
190 | #--------------------------------------------------------------------#
|
---|
191 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
192 | #--------------------------------------------------------------------#
|
---|
193 | #
|
---|
194 | # Keep the script file name for Makefile dependencies.
|
---|
195 | PREV=$this_script
|
---|
196 | done # for file in ....
|
---|
197 | }
|
---|
198 |
|
---|
199 |
|
---|
200 | #--------------------------------------#
|
---|
201 | chroot_Makefiles() { #
|
---|
202 | #--------------------------------------#
|
---|
203 | echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}"
|
---|
204 |
|
---|
205 | for file in chroot/* ; do
|
---|
206 | # Keep the script file name
|
---|
207 | this_script=`basename $file`
|
---|
208 | #
|
---|
209 | # Skipping scripts is done now and not included in the build tree.
|
---|
210 | case $this_script in
|
---|
211 | *chroot*) continue ;;
|
---|
212 | esac
|
---|
213 |
|
---|
214 | #
|
---|
215 | # First append each name of the script files to a list (this will become
|
---|
216 | # the names of the targets in the Makefile
|
---|
217 | case "${this_script}" in
|
---|
218 | *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
219 | *) chroottools="$chroottools $this_script" ;;
|
---|
220 | esac
|
---|
221 |
|
---|
222 | # Grab the name of the target, strip id number, XXX-script
|
---|
223 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
224 |
|
---|
225 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
226 |
|
---|
227 | # This is very ugly:: util-linux is in /chroot but must be run under LUSER
|
---|
228 | # .. Customized makefile entry
|
---|
229 | case "${this_script}" in
|
---|
230 | *util-linux)
|
---|
231 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
232 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
233 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
234 | LUSER_wrt_RunAsUser "${file}"
|
---|
235 | LUSER_RemoveBuildDirs "${name}"
|
---|
236 | wrt_touch
|
---|
237 | temptools="$temptools $this_script"
|
---|
238 | continue ;;
|
---|
239 | esac
|
---|
240 |
|
---|
241 |
|
---|
242 | #--------------------------------------------------------------------#
|
---|
243 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
244 | #--------------------------------------------------------------------#
|
---|
245 | #
|
---|
246 | # Drop in the name of the target on a new line, and the previous target
|
---|
247 | # as a dependency. Also call the echo_message function.
|
---|
248 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
249 | #
|
---|
250 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
251 | # Insert instructions for unpacking the package and changing directories
|
---|
252 | #
|
---|
253 | if [ "$pkg_tarball" != "" ] ; then
|
---|
254 | CHROOT_Unpack "$pkg_tarball"
|
---|
255 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
256 | fi
|
---|
257 | #
|
---|
258 | # Select a script execution method
|
---|
259 | case $this_script in
|
---|
260 | *kernfs) wrt_RunAsRoot "${file}" ;;
|
---|
261 | *) CHROOT_wrt_RunAsRoot "${file}" ;;
|
---|
262 | esac
|
---|
263 | #
|
---|
264 | # Housekeeping...remove the build directory(ies), except if the package build fails.
|
---|
265 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
266 | #
|
---|
267 | # Include a touch of the target name so make can check if it's already been made.
|
---|
268 | wrt_touch
|
---|
269 | #
|
---|
270 | #--------------------------------------------------------------------#
|
---|
271 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
272 | #--------------------------------------------------------------------#
|
---|
273 | #
|
---|
274 | # Keep the script file name for Makefile dependencies.
|
---|
275 | PREV=$this_script
|
---|
276 |
|
---|
277 | done # for file in...
|
---|
278 | }
|
---|
279 |
|
---|
280 |
|
---|
281 | #--------------------------------------#
|
---|
282 | boot_Makefiles() { #
|
---|
283 | #--------------------------------------#
|
---|
284 |
|
---|
285 | echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
|
---|
286 | #
|
---|
287 | # Create a target bootable partition containing a compile environment. Later
|
---|
288 | # on we boot into this environment and contine the build.
|
---|
289 | #
|
---|
290 | for file in boot/* ; do
|
---|
291 | # Keep the script file name
|
---|
292 | this_script=`basename $file`
|
---|
293 |
|
---|
294 | # A little housekeeping on the scripts
|
---|
295 | case $this_script in
|
---|
296 | *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
|
---|
297 | *whatnext*) continue ;;
|
---|
298 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
299 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
300 | [[ -z $CONFIG ]] && continue
|
---|
301 | # Copy the config file to /sources with a standardized name
|
---|
302 | cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
|
---|
303 | ;;
|
---|
304 | esac
|
---|
305 | #
|
---|
306 | # First append each name of the script files to a list (this will become
|
---|
307 | # the names of the targets in the Makefile
|
---|
308 | case "${this_script}" in
|
---|
309 | *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
310 | *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
311 | *) boottools="$boottools $this_script" ;;
|
---|
312 | esac
|
---|
313 | #
|
---|
314 | # Grab the name of the target, strip id number and misc words.
|
---|
315 | case $this_script in
|
---|
316 | *kernel) name=linux ;;
|
---|
317 | *bootscripts) name="bootscripts-cross-lfs" ;;
|
---|
318 | *udev-rules) name="udev-cross-lfs" ;;
|
---|
319 | *grub-build) name=grub ;;
|
---|
320 | *-aboot-build) name=aboot ;;
|
---|
321 | *yaboot-build) name=yaboot ;;
|
---|
322 | *colo-build) name=colo ;;
|
---|
323 | *silo-build) name=silo ;;
|
---|
324 | *arcload-build) name=arcload ;;
|
---|
325 | *lilo-build) name=lilo ;;
|
---|
326 | *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
|
---|
327 | esac
|
---|
328 | # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
|
---|
329 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
330 |
|
---|
331 | #--------------------------------------------------------------------#
|
---|
332 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
333 | #--------------------------------------------------------------------#
|
---|
334 | #
|
---|
335 | # Drop in the name of the target on a new line, and the previous target
|
---|
336 | # as a dependency. Also call the echo_message function.
|
---|
337 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
338 | #
|
---|
339 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
340 | # Insert instructions for unpacking the package and changing directories
|
---|
341 | #
|
---|
342 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
343 | [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
344 | #
|
---|
345 | # Select a script execution method
|
---|
346 | case $this_script in
|
---|
347 | # The following 2 scripts are defined in the /boot directory but need
|
---|
348 | # to be run as a root user. Set them up here but run them in another phase
|
---|
349 | *changingowner*) wrt_RunAsRoot "${file}" ;;
|
---|
350 | *devices*) wrt_RunAsRoot "${file}" ;;
|
---|
351 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
352 | LUSER_wrt_CopyFstab
|
---|
353 | else
|
---|
354 | LUSER_wrt_RunAsUser "${file}"
|
---|
355 | fi
|
---|
356 | ;;
|
---|
357 | *) LUSER_wrt_RunAsUser "${file}" ;;
|
---|
358 | esac
|
---|
359 | #
|
---|
360 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
361 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
362 | #
|
---|
363 | # Include a touch of the target name so make can check if it's already been made.
|
---|
364 | wrt_touch
|
---|
365 | #
|
---|
366 | #--------------------------------------------------------------------#
|
---|
367 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
368 | #--------------------------------------------------------------------#
|
---|
369 | #
|
---|
370 | # Keep the script file name for Makefile dependencies.
|
---|
371 | PREV=$this_script
|
---|
372 |
|
---|
373 | done
|
---|
374 | }
|
---|
375 |
|
---|
376 |
|
---|
377 | #--------------------------------------#
|
---|
378 | testsuite_tools_Makefiles() { #
|
---|
379 | #--------------------------------------#
|
---|
380 |
|
---|
381 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
382 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
|
---|
383 | else
|
---|
384 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
|
---|
385 | PREV=""
|
---|
386 | fi
|
---|
387 |
|
---|
388 | for file in testsuite-tools/* ; do
|
---|
389 | # Keep the script file name
|
---|
390 | this_script=`basename $file`
|
---|
391 |
|
---|
392 | # First append each name of the script files to a list (this will become
|
---|
393 | # the names of the targets in the Makefile
|
---|
394 | testsuitetools="$testsuitetools $this_script"
|
---|
395 |
|
---|
396 | # Grab the name of the target, strip id number, XXX-script
|
---|
397 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
398 | -e 's@-64bit@@' \
|
---|
399 | -e 's@-64@@' \
|
---|
400 | -e 's@64@@' \
|
---|
401 | -e 's@n32@@'`
|
---|
402 |
|
---|
403 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
404 |
|
---|
405 | #--------------------------------------------------------------------#
|
---|
406 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
407 | #--------------------------------------------------------------------#
|
---|
408 | #
|
---|
409 | # Drop in the name of the target on a new line, and the previous target
|
---|
410 | # as a dependency. Also call the echo_message function.
|
---|
411 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
412 | #
|
---|
413 | CHROOT_Unpack "$pkg_tarball"
|
---|
414 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
415 | #
|
---|
416 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
417 | #
|
---|
418 | CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
419 | #
|
---|
420 | # Include a touch of the target name so make can check if it's already been made.
|
---|
421 | wrt_touch
|
---|
422 | #
|
---|
423 | #--------------------------------------------------------------------#
|
---|
424 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
425 | #--------------------------------------------------------------------#
|
---|
426 | #
|
---|
427 | # Keep the script file name for Makefile dependencies.
|
---|
428 | PREV=$this_script
|
---|
429 |
|
---|
430 | done
|
---|
431 | }
|
---|
432 |
|
---|
433 |
|
---|
434 | #--------------------------------------#
|
---|
435 | final_system_Makefiles() { #
|
---|
436 | #--------------------------------------#
|
---|
437 | # Set envars and scripts for iteration targets
|
---|
438 | if [[ -z "$1" ]] ; then
|
---|
439 | local N=""
|
---|
440 | # In boot method the makesys phase was initiated in testsuite_tools_makefile
|
---|
441 | [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
|
---|
442 | else
|
---|
443 | local N=-build_$1
|
---|
444 | local basicsystem=""
|
---|
445 | mkdir final-system$N
|
---|
446 | cp final-system/* final-system$N
|
---|
447 | for script in final-system$N/* ; do
|
---|
448 | # Overwrite existing symlinks, files, and dirs
|
---|
449 | sed -e 's/ln -sv/&f/g' \
|
---|
450 | -e 's/mv -v/&f/g' \
|
---|
451 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
452 | # Rename the scripts
|
---|
453 | mv ${script} ${script}$N
|
---|
454 | done
|
---|
455 | # Remove Bzip2 binaries before make install (CLFS-1.0 compatibility)
|
---|
456 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
|
---|
457 | # Delete *old Readline libraries just after make install
|
---|
458 | sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
|
---|
459 | fi
|
---|
460 |
|
---|
461 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
462 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
|
---|
463 | else
|
---|
464 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
|
---|
465 | fi
|
---|
466 |
|
---|
467 | for file in final-system$N/* ; do
|
---|
468 | # Keep the script file name
|
---|
469 | this_script=`basename $file`
|
---|
470 |
|
---|
471 | # Test if the stripping phase must be skipped.
|
---|
472 | # Skip alsp temp-perl for iterative runs
|
---|
473 | case $this_script in
|
---|
474 | *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
---|
475 | *temp-perl*) [[ -n "$N" ]] && continue ;;
|
---|
476 | esac
|
---|
477 |
|
---|
478 | # Grab the name of the target, strip id number, XXX-script
|
---|
479 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
480 | -e 's@temp-@@' \
|
---|
481 | -e 's@-64bit@@' \
|
---|
482 | -e 's@-64@@' \
|
---|
483 | -e 's@64@@' \
|
---|
484 | -e 's@n32@@' \
|
---|
485 | -e 's,'$N',,'`
|
---|
486 |
|
---|
487 | # Find the version of the command files, if it corresponds with the building of
|
---|
488 | # a specific package. We need this here to can skip scripts not needed for
|
---|
489 | # iterations rebuilds
|
---|
490 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
491 |
|
---|
492 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
493 | case "${this_script}" in
|
---|
494 | *stripping*) ;;
|
---|
495 | *) continue ;;
|
---|
496 | esac
|
---|
497 | fi
|
---|
498 |
|
---|
499 | # Append each name of the script files to a list (this will become
|
---|
500 | # the names of the targets in the Makefile
|
---|
501 | basicsystem="$basicsystem ${this_script}"
|
---|
502 |
|
---|
503 | #--------------------------------------------------------------------#
|
---|
504 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
505 | #--------------------------------------------------------------------#
|
---|
506 | #
|
---|
507 | # Drop in the name of the target on a new line, and the previous target
|
---|
508 | # as a dependency. Also call the echo_message function.
|
---|
509 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
510 |
|
---|
511 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
512 | if [ "$pkg_tarball" != "" ] ; then
|
---|
513 | CHROOT_Unpack "$pkg_tarball"
|
---|
514 | # If the testsuites must be run, initialize the log file
|
---|
515 | case $name in
|
---|
516 | binutils | gcc | glibc )
|
---|
517 | [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
518 | ;;
|
---|
519 | * )
|
---|
520 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
521 | ;;
|
---|
522 | esac
|
---|
523 | # If using optimizations, write the instructions
|
---|
524 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
525 | fi
|
---|
526 | #
|
---|
527 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
528 | #
|
---|
529 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
530 | #
|
---|
531 | # Include a touch of the target name so make can check if it's already been made.
|
---|
532 | wrt_touch
|
---|
533 | #
|
---|
534 | #--------------------------------------------------------------------#
|
---|
535 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
536 | #--------------------------------------------------------------------#
|
---|
537 | #
|
---|
538 | # Keep the script file name for Makefile dependencies.
|
---|
539 | PREV=${this_script}
|
---|
540 | # Set system_build envar for iteration targets
|
---|
541 | system_build=$basicsystem
|
---|
542 | done # for file in final-system/* ...
|
---|
543 | }
|
---|
544 |
|
---|
545 | #--------------------------------------#
|
---|
546 | bootscripts_Makefiles() { #
|
---|
547 | #--------------------------------------#
|
---|
548 |
|
---|
549 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
550 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
|
---|
551 | else
|
---|
552 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
|
---|
553 | fi
|
---|
554 |
|
---|
555 | for file in bootscripts/* ; do
|
---|
556 | # Keep the script file name
|
---|
557 | this_script=`basename $file`
|
---|
558 |
|
---|
559 | case $this_script in
|
---|
560 | *udev) continue ;; # This is not a script but a commentary, we want udev-rules
|
---|
561 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
562 | *) ;;
|
---|
563 | esac
|
---|
564 |
|
---|
565 | # First append each name of the script files to a list (this will become
|
---|
566 | # the names of the targets in the Makefile
|
---|
567 | bootscripttools="$bootscripttools $this_script"
|
---|
568 |
|
---|
569 | # Grab the name of the target, strip id number, XXX-script
|
---|
570 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
571 | -e 's@-64bit@@' \
|
---|
572 | -e 's@-64@@' \
|
---|
573 | -e 's@64@@' \
|
---|
574 | -e 's@n32@@'`
|
---|
575 | case $name in
|
---|
576 | *bootscripts*) name=bootscripts-cross-lfs ;;
|
---|
577 | *udev-rules) name=udev-cross-lfs ;;
|
---|
578 | esac
|
---|
579 |
|
---|
580 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
581 |
|
---|
582 | #--------------------------------------------------------------------#
|
---|
583 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
584 | #--------------------------------------------------------------------#
|
---|
585 | #
|
---|
586 | # Drop in the name of the target on a new line, and the previous target
|
---|
587 | # as a dependency. Also call the echo_message function.
|
---|
588 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
589 | #
|
---|
590 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
591 | #
|
---|
592 | [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
|
---|
593 | #
|
---|
594 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
595 | #
|
---|
596 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
597 | #
|
---|
598 | # Include a touch of the target name so make can check if it's already been made.
|
---|
599 | wrt_touch
|
---|
600 | #
|
---|
601 | #--------------------------------------------------------------------#
|
---|
602 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
603 | #--------------------------------------------------------------------#
|
---|
604 | #
|
---|
605 | # Keep the script file name for Makefile dependencies.
|
---|
606 | PREV=$this_script
|
---|
607 |
|
---|
608 | done # for file in bootscripts/* ...
|
---|
609 | }
|
---|
610 |
|
---|
611 | #--------------------------------------#
|
---|
612 | bootable_Makefiles() { #
|
---|
613 | #--------------------------------------#
|
---|
614 |
|
---|
615 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
616 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
|
---|
617 | else
|
---|
618 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
|
---|
619 | fi
|
---|
620 |
|
---|
621 |
|
---|
622 | for file in bootable/* ; do
|
---|
623 | # Keep the script file name
|
---|
624 | this_script=`basename $file`
|
---|
625 |
|
---|
626 | # A little housekeeping on the scripts
|
---|
627 | case $this_script in
|
---|
628 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
---|
629 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
630 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
631 | [[ -z $CONFIG ]] && continue
|
---|
632 | # Copy the config file to /sources with a standardized name
|
---|
633 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
634 | ;;
|
---|
635 | esac
|
---|
636 | #
|
---|
637 | # First append each name of the script files to a list (this will become
|
---|
638 | # the names of the targets in the Makefile
|
---|
639 | bootabletools="$bootabletools $this_script"
|
---|
640 | #
|
---|
641 | # Grab the name of the target, strip id number and misc words.
|
---|
642 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
643 | case $this_script in
|
---|
644 | *kernel*) name=linux
|
---|
645 | ;;
|
---|
646 | esac
|
---|
647 |
|
---|
648 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
649 |
|
---|
650 | #--------------------------------------------------------------------#
|
---|
651 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
652 | #--------------------------------------------------------------------#
|
---|
653 | #
|
---|
654 | # Drop in the name of the target on a new line, and the previous target
|
---|
655 | # as a dependency. Also call the echo_message function.
|
---|
656 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
657 | #
|
---|
658 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
659 | # Insert instructions for unpacking the package and changing directories
|
---|
660 | #
|
---|
661 | [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
|
---|
662 | #
|
---|
663 | # Select a script execution method
|
---|
664 | case $this_script in
|
---|
665 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
666 | CHROOT_wrt_CopyFstab
|
---|
667 | else
|
---|
668 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
669 | fi
|
---|
670 | ;;
|
---|
671 | *) CHROOT_wrt_RunAsRoot "${file}"
|
---|
672 | ;;
|
---|
673 | esac
|
---|
674 | #
|
---|
675 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
676 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
677 | #
|
---|
678 | # Include a touch of the target name so make can check if it's already been made.
|
---|
679 | wrt_touch
|
---|
680 | #
|
---|
681 | #--------------------------------------------------------------------#
|
---|
682 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
683 | #--------------------------------------------------------------------#
|
---|
684 | #
|
---|
685 | # Keep the script file name for Makefile dependencies.
|
---|
686 | PREV=$this_script
|
---|
687 |
|
---|
688 | done
|
---|
689 |
|
---|
690 | }
|
---|
691 |
|
---|
692 |
|
---|
693 | #--------------------------------------#
|
---|
694 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
695 | #--------------------------------------#
|
---|
696 | #
|
---|
697 | # Script crashes if error trapping is on
|
---|
698 | #
|
---|
699 | set +e
|
---|
700 | declare -f method_cmds
|
---|
701 | set -e
|
---|
702 |
|
---|
703 | echo "...Creating Makefile... ${BOLD}START${OFF}"
|
---|
704 |
|
---|
705 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
706 | # Start with a clean files
|
---|
707 | >$MKFILE
|
---|
708 | >$MKFILE.tmp
|
---|
709 |
|
---|
710 | method_cmds=${METHOD}_Makefiles
|
---|
711 |
|
---|
712 | host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
|
---|
713 | cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
|
---|
714 | temptools_Makefiles # mk_TEMP (LUSER) $temptools
|
---|
715 | $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
|
---|
716 | if [[ ! $TEST = "0" ]]; then
|
---|
717 | testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
|
---|
718 | fi
|
---|
719 | final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
|
---|
720 | # Add the iterations targets, if needed
|
---|
721 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
722 | bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
|
---|
723 | bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
|
---|
724 |
|
---|
725 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
726 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
727 | # Add the BLFS_TOOL targets, if needed
|
---|
728 | [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
---|
729 |
|
---|
730 | # Add a header, some variables and include the function file
|
---|
731 | # to the top of the real Makefile.
|
---|
732 | wrt_Makefile_header
|
---|
733 |
|
---|
734 | # Add chroot commands
|
---|
735 | if [ "$METHOD" = "chroot" ] ; then
|
---|
736 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
737 | chroot=`cat chroot/*chroot* | \
|
---|
738 | sed -e "s@chroot@$CHROOT_LOC@" \
|
---|
739 | -e '/#!\/bin\/bash/d' \
|
---|
740 | -e '/^export/d' \
|
---|
741 | -e '/^logout/d' \
|
---|
742 | -e 's@ \\\@ @g' | \
|
---|
743 | tr -d '\n' | \
|
---|
744 | sed -e 's/ */ /g' \
|
---|
745 | -e 's|\\$|&&|g' \
|
---|
746 | -e 's|exit||g' \
|
---|
747 | -e 's|$| -c|' \
|
---|
748 | -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
|
---|
749 | -e 's|set -e||' \
|
---|
750 | -e 's|set +h||'`
|
---|
751 | echo -e "CHROOT1= $chroot\n" >> $MKFILE
|
---|
752 | fi
|
---|
753 |
|
---|
754 | ################## CHROOT ####################
|
---|
755 |
|
---|
756 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
757 | (
|
---|
758 | cat << EOF
|
---|
759 |
|
---|
760 | all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
---|
761 | @sudo make do-housekeeping
|
---|
762 | @echo "$VERSION - jhalfs build" > clfs-release && \\
|
---|
763 | sudo mv clfs-release \$(MOUNT_PT)/etc
|
---|
764 | @\$(call echo_finished,$VERSION)
|
---|
765 |
|
---|
766 | ck_UID:
|
---|
767 | @if [ \`id -u\` = "0" ]; then \\
|
---|
768 | echo "+--------------------------------------------------+"; \\
|
---|
769 | echo "|You cannot run this makefile from the root account|"; \\
|
---|
770 | echo "+--------------------------------------------------+"; \\
|
---|
771 | exit 1; \\
|
---|
772 | fi
|
---|
773 |
|
---|
774 | #---------------AS ROOT
|
---|
775 | mk_SETUP:
|
---|
776 | @\$(call echo_SU_request)
|
---|
777 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
778 | @touch \$@
|
---|
779 |
|
---|
780 | #---------------AS LUSER
|
---|
781 | mk_CROSS: mk_SETUP
|
---|
782 | @\$(call echo_PHASE,Cross and Temporary Tools)
|
---|
783 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
|
---|
784 | @sudo make restore-luser-env
|
---|
785 | @touch \$@
|
---|
786 |
|
---|
787 | mk_SUDO: mk_CROSS
|
---|
788 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
789 | @touch \$@
|
---|
790 |
|
---|
791 | #---------------CHROOT JAIL
|
---|
792 | mk_SYSTOOLS: mk_SUDO
|
---|
793 | @\$(call echo_CHROOT_request)
|
---|
794 | @\$(call echo_PHASE, CHROOT JAIL )
|
---|
795 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) PREP_CHROOT_JAIL")
|
---|
796 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT_JAIL")
|
---|
797 | @touch \$@
|
---|
798 |
|
---|
799 | mk_CUSTOM_TOOLS: create-sbu_du-report
|
---|
800 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
801 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
802 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
803 | (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
804 | fi;
|
---|
805 | @touch \$@
|
---|
806 |
|
---|
807 | mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
---|
808 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
809 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
810 | sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
---|
811 | sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"; \\
|
---|
812 | fi;
|
---|
813 | @touch \$@
|
---|
814 |
|
---|
815 | SETUP: $host_prep
|
---|
816 | AS_LUSER: $cross_tools $temptools
|
---|
817 | SUDO: $orphan_scripts
|
---|
818 | PREP_CHROOT_JAIL: SHELL=/tools/bin/bash
|
---|
819 | PREP_CHROOT_JAIL: ${chroottools}
|
---|
820 | CHROOT_JAIL: SHELL=/tools/bin/bash
|
---|
821 | CHROOT_JAIL: $testsuitetools $basicsystem $bootscripttools $bootabletools
|
---|
822 | CUSTOM_TOOLS: $custom_list
|
---|
823 | BLFS_TOOL: $blfs_tool
|
---|
824 |
|
---|
825 |
|
---|
826 | create-sbu_du-report: mk_SYSTOOLS
|
---|
827 | @\$(call echo_message, Building)
|
---|
828 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
829 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
830 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
831 | fi;
|
---|
832 | @touch \$@
|
---|
833 |
|
---|
834 | do-housekeeping:
|
---|
835 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
836 | @-umount \$(MOUNT_PT)/dev/shm
|
---|
837 | @-umount \$(MOUNT_PT)/dev
|
---|
838 | @-umount \$(MOUNT_PT)/sys
|
---|
839 | @-umount \$(MOUNT_PT)/proc
|
---|
840 | @-rm /tools /cross-tools
|
---|
841 | @-if [ ! -f luser-exist ]; then \\
|
---|
842 | userdel \$(LUSER); \\
|
---|
843 | rm -rf /home/\$(LUSER); \\
|
---|
844 | fi;
|
---|
845 |
|
---|
846 | EOF
|
---|
847 | ) >> $MKFILE
|
---|
848 |
|
---|
849 | fi
|
---|
850 |
|
---|
851 | ################### BOOT #####################
|
---|
852 |
|
---|
853 | if [[ "${METHOD}" = "boot" ]]; then
|
---|
854 | (
|
---|
855 | cat << EOF
|
---|
856 |
|
---|
857 | all: ck_UID mk_SETUP mk_CROSS mk_SUDO
|
---|
858 | @sudo make restore-luser-env
|
---|
859 | @sudo make do-housekeeping
|
---|
860 | @\$(call echo_boot_finished,$VERSION)
|
---|
861 |
|
---|
862 | makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
---|
863 | @echo "$VERSION - jhalfs build" > /etc/clfs-release
|
---|
864 | @\$(call echo_finished,$VERSION)
|
---|
865 |
|
---|
866 |
|
---|
867 | ck_UID:
|
---|
868 | @if [ \`id -u\` = "0" ]; then \\
|
---|
869 | echo "+--------------------------------------------------+"; \\
|
---|
870 | echo "|You cannot run this makefile from the root account|"; \\
|
---|
871 | echo "|However, if this is the boot environment |"; \\
|
---|
872 | echo "| the command you are looking for is |"; \\
|
---|
873 | echo "| make makesys |"; \\
|
---|
874 | echo "| to finish off the build |"; \\
|
---|
875 | echo "+--------------------------------------------------+"; \\
|
---|
876 | exit 1; \\
|
---|
877 | fi
|
---|
878 |
|
---|
879 | #---------------AS ROOT
|
---|
880 |
|
---|
881 | mk_SETUP:
|
---|
882 | @\$(call echo_SU_request)
|
---|
883 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
884 | @touch \$@
|
---|
885 |
|
---|
886 | #---------------AS LUSER
|
---|
887 |
|
---|
888 | mk_CROSS: mk_SETUP
|
---|
889 | @\$(call echo_PHASE,Cross Tool)
|
---|
890 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
|
---|
891 | @touch \$@
|
---|
892 |
|
---|
893 | mk_SUDO: mk_CROSS
|
---|
894 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
895 | @touch \$@
|
---|
896 |
|
---|
897 | #---------------AS ROOT
|
---|
898 |
|
---|
899 | mk_FINAL:
|
---|
900 | @\$(call echo_PHASE,Final System)
|
---|
901 | @( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) AS_ROOT )
|
---|
902 | @touch \$@
|
---|
903 |
|
---|
904 | mk_CUSTOM_TOOLS: mk_FINAL
|
---|
905 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
906 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
907 | mkdir -p ${TRACKING_DIR}; \\
|
---|
908 | ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS ); \\
|
---|
909 | fi;
|
---|
910 | @touch \$@
|
---|
911 |
|
---|
912 | mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
---|
913 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
914 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
915 | mkdir -p $TRACKING_DIR; \\
|
---|
916 | ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL ); \\
|
---|
917 | fi
|
---|
918 | @touch \$@
|
---|
919 |
|
---|
920 | SETUP: $host_prep
|
---|
921 | AS_LUSER: $cross_tools $temptools ${boottools}
|
---|
922 | SUDO: $orphan_scripts
|
---|
923 | AS_ROOT: SHELL=/tools/bin/bash
|
---|
924 | AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
|
---|
925 | CUSTOM_TOOLS: $custom_list
|
---|
926 | BLFS_TOOL: $blfs_tool
|
---|
927 |
|
---|
928 | do-housekeeping:
|
---|
929 | @-rm /tools /cross-tools
|
---|
930 | @-if [ ! -f luser-exist ]; then \\
|
---|
931 | userdel \$(LUSER); \\
|
---|
932 | rm -rf /home/\$(LUSER); \\
|
---|
933 | fi;
|
---|
934 |
|
---|
935 | EOF
|
---|
936 | ) >> $MKFILE
|
---|
937 | fi
|
---|
938 |
|
---|
939 | (
|
---|
940 | cat << EOF
|
---|
941 |
|
---|
942 | restore-luser-env:
|
---|
943 | @\$(call echo_message, Building)
|
---|
944 | @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
945 | mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
---|
946 | fi;
|
---|
947 | @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
948 | mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
---|
949 | fi;
|
---|
950 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
---|
951 | touch \$@ && \\
|
---|
952 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
953 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
954 |
|
---|
955 | ########################################################
|
---|
956 |
|
---|
957 |
|
---|
958 | EOF
|
---|
959 | ) >> $MKFILE
|
---|
960 |
|
---|
961 | # Bring over the items from the Makefile.tmp
|
---|
962 | cat $MKFILE.tmp >> $MKFILE
|
---|
963 | rm $MKFILE.tmp
|
---|
964 |
|
---|
965 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
966 | }
|
---|