source: CLFS/master.sh@ 27f165a

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 27f165a was 46758a2, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Using fuser instead of pidof to watch that make is alive.

  • Property mode set to 100755
File size: 40.9 KB
Line 
1#!/bin/sh
2# $Id$
3
4###################################
5### FUNCTIONS ###
6###################################
7
8
9
10#----------------------------#
11host_prep_Makefiles() { # Initialization of the system
12#----------------------------#
13 local LFS_HOST
14
15 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files${R_arrow}"
16
17 # defined here, only for ease of reading
18 LFS_HOST="`echo ${MACHTYPE} | sed -e 's/unknown/cross/g' -e 's/-pc-/-cross-/g'`"
19(
20cat << EOF
21023-creatingtoolsdir:
22 @\$(call echo_message, Building)
23 @mkdir -v \$(MOUNT_PT)/tools && \\
24 rm -fv /tools && \\
25 ln -sv \$(MOUNT_PT)/tools /
26 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
27 mkdir \$(MOUNT_PT)/sources; \\
28 fi;
29 @chmod a+wt \$(MOUNT_PT)/sources && \\
30 touch \$@
31
32024-creatingcrossdir: 023-creatingtoolsdir
33 @mkdir -v \$(MOUNT_PT)/cross-tools && \\
34 rm -fv /cross-tools && \\
35 ln -sv \$(MOUNT_PT)/cross-tools /
36 @touch \$@
37
38025-addinguser: 024-creatingcrossdir
39 @\$(call echo_message, Building)
40 @if [ ! -d /home/lfs ]; then \\
41 groupadd lfs; \\
42 useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
43 else \\
44 touch user-lfs-exist; \\
45 fi;
46 @chown lfs \$(MOUNT_PT) && \\
47 chown lfs \$(MOUNT_PT)/tools && \\
48 chown lfs \$(MOUNT_PT)/cross-tools && \\
49 chown lfs \$(MOUNT_PT)/sources && \\
50 touch \$@
51
52026-settingenvironment: 025-addinguser
53 @\$(call echo_message, Building)
54 @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
55 mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
56 fi;
57 @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
58 mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
59 fi;
60 @echo "set +h" > /home/lfs/.bashrc && \\
61 echo "umask 022" >> /home/lfs/.bashrc && \\
62 echo "LFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
63 echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
64 echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
65 echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
66 echo "" >> /home/lfs/.bashrc && \\
67 echo "unset CFLAGS" >> /home/lfs/.bashrc && \\
68 echo "unset CXXFLAGS" >> /home/lfs/.bashrc && \\
69 echo "" >> /home/lfs/.bashrc && \\
70 echo "export LFS_HOST=\"${LFS_HOST}\"" >> /home/lfs/.bashrc && \\
71 echo "export LFS_TARGET=\"${TARGET}\"" >> /home/lfs/.bashrc && \\
72 echo "export LFS_TARGET32=\"${TARGET32}\"" >> /home/lfs/.bashrc && \\
73 echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc
74 @chown lfs:lfs /home/lfs/.bashrc && \\
75 touch envars && \\
76 touch \$@
77EOF
78) >> $MKFILE.tmp
79
80}
81
82
83
84#-----------------------------#
85cross_tools_Makefiles() { #
86#-----------------------------#
87 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}"
88
89 for file in cross-tools/* ; do
90 # Keep the script file name
91 this_script=`basename $file`
92 #
93 # Skip this script...
94 case $this_script in
95 *cflags* | *variables* ) # work done in host_prep_Makefiles
96 continue; ;;
97 *) ;;
98 esac
99 #
100 # Set the dependency for the first target.
101 if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
102
103 # First append each name of the script files to a list (this will become
104 # the names of the targets in the Makefile
105 cross_tools="$cross_tools $this_script"
106
107 # Grab the name of the target (minus the -headers or -cross in the case of gcc
108 # and binutils in chapter 5)
109 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
110 -e 's@-static@@' \
111 -e 's@-final@@' \
112 -e 's@-headers@@' \
113 -e 's@-64@@' \
114 -e 's@-n32@@'`
115 # Adjust 'name' and patch a few scripts on the fly..
116 case $name in
117 linux-libc) name=linux-libc-headers ;;
118 esac
119 #
120 # Find the version of the command files, if it corresponds with the building of a specific package
121 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
122
123
124 #--------------------------------------------------------------------#
125 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
126 #--------------------------------------------------------------------#
127 #
128 # Drop in the name of the target on a new line, and the previous target
129 # as a dependency. Also call the echo_message function.
130 wrt_target "${this_script}" "$PREV"
131 #
132 # If $vrs isn't empty, we've got a package...
133 #
134 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
135 #
136 wrt_run_as_su "${this_script}" "${file}"
137 #
138 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
139 #
140 # Include a touch of the target name so make can check if it's already been made.
141 echo -e '\t@touch $@' >> $MKFILE.tmp
142 #
143 #--------------------------------------------------------------------#
144 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
145 #--------------------------------------------------------------------#
146 #
147 # Keep the script file name for Makefile dependencies.
148 PREV=$this_script
149
150 done # for file in ....
151}
152
153
154#-----------------------------#
155temptools_Makefiles() { #
156#-----------------------------#
157 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system${R_arrow}"
158
159 for file in temp-system/* ; do
160 # Keep the script file name
161 this_script=`basename $file`
162 #
163 # First append each name of the script files to a list (this will become
164 # the names of the targets in the Makefile
165 temptools="$temptools $this_script"
166
167 #
168 # Grab the name of the target, strip id number, XXX-script
169 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
170 #
171 # Find the version of the command files, if it corresponds with the building of a specific package
172 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
173
174
175 #--------------------------------------------------------------------#
176 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
177 #--------------------------------------------------------------------#
178 #
179 # Drop in the name of the target on a new line, and the previous target
180 # as a dependency. Also call the echo_message function.
181 wrt_target "${this_script}" "$PREV"
182 #
183 # If $vrs isn't empty, we've got a package...
184 # Insert instructions for unpacking the package and to set the PKGDIR variable.
185 #
186 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
187 [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
188 #
189 wrt_run_as_su "${this_script}" "${file}"
190 #
191 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
192 #
193 # Include a touch of the target name so make can check if it's already been made.
194 echo -e '\t@touch $@' >> $MKFILE.tmp
195 #
196 #--------------------------------------------------------------------#
197 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
198 #--------------------------------------------------------------------#
199 #
200 # Keep the script file name for Makefile dependencies.
201 PREV=$this_script
202 done # for file in ....
203}
204
205
206#-----------------------------#
207boot_Makefiles() { #
208#-----------------------------#
209 echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}"
210
211 for file in boot/* ; do
212 # Keep the script file name
213 this_script=`basename $file`
214
215 # A little housekeeping on the scripts
216 case $this_script in
217 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
218 *whatnext*) continue ;;
219 *kernel) # if there is no kernel config file do not build the kernel
220 [[ -z $CONFIG ]] && continue
221 # Copy the config file to /sources with a standardized name
222 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
223 ;;
224 esac
225 #
226 # First append each name of the script files to a list (this will become
227 # the names of the targets in the Makefile
228 boottools="$boottools $this_script"
229 #
230 # Grab the name of the target, strip id number and misc words.
231 case $this_script in
232 *kernel) name=linux ;;
233 *bootscripts) name="bootscripts-cross-lfs" ;;
234 *udev-rules) name="udev-cross-lfs" ;;
235 *grub-build) name=grub ;;
236 *-aboot-build) name=aboot ;;
237 *yaboot-build) name=yaboot ;;
238 *colo-build) name=colo ;;
239 *silo-build) name=silo ;;
240 *arcload-build) name=arcload ;;
241 *lilo-build) name=lilo ;;
242 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
243 esac
244
245 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
246
247 #--------------------------------------------------------------------#
248 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
249 #--------------------------------------------------------------------#
250 #
251 # Drop in the name of the target on a new line, and the previous target
252 # as a dependency. Also call the echo_message function.
253 wrt_target "${this_script}" "$PREV"
254 #
255 # If $vrs isn't empty, we've got a package...
256 # Insert instructions for unpacking the package and changing directories
257 #
258 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
259 [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
260 #
261 # Select a script execution method
262 case $this_script in
263 *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;;
264 *devices*) wrt_run_as_root "${this_script}" "${file}" ;;
265 *fstab*) if [[ -n "$FSTAB" ]]; then
266 wrt_copy_fstab "${this_script}"
267 else
268 wrt_run_as_su "${this_script}" "${file}"
269 fi
270 ;;
271 *) wrt_run_as_su "${this_script}" "${file}" ;;
272 esac
273 #
274 # Housekeeping...remove any build directory(ies) except if the package build fails.
275 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
276 #
277 # Include a touch of the target name so make can check if it's already been made.
278 echo -e '\t@touch $@' >> $MKFILE.tmp
279 #
280 #--------------------------------------------------------------------#
281 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
282 #--------------------------------------------------------------------#
283 #
284 # Keep the script file name for Makefile dependencies.
285 PREV=$this_script
286
287 done
288}
289
290
291#-----------------------------#
292chroot_Makefiles() { #
293#-----------------------------#
294 echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}"
295
296 for file in chroot/* ; do
297 # Keep the script file name
298 this_script=`basename $file`
299 #
300 # Skipping scripts is done now and not included in the build tree.
301 case $this_script in
302 *chroot*) continue ;;
303 esac
304
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 chroottools="$chroottools $this_script"
309
310 # Grab the name of the target, strip id number, XXX-script
311 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
312 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
313
314 #--------------------------------------------------------------------#
315 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
316 #--------------------------------------------------------------------#
317 #
318 # Drop in the name of the target on a new line, and the previous target
319 # as a dependency. Also call the echo_message function.
320 wrt_target "${this_script}" "$PREV"
321 #
322 # If $vrs isn't empty, we've got a package...
323 # Insert instructions for unpacking the package and changing directories
324 #
325 if [ "$vrs" != "" ] ; then
326 case $this_script in
327 *util-linux) wrt_unpack "$name-$vrs.tar.*" ;;
328 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
329 esac
330 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
331 fi
332 #
333 # Select a script execution method
334 case $this_script in
335 *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
336 *util-linux) wrt_run_as_su "${this_script}" "${file}" ;;
337 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
338 esac
339 #
340 # Housekeeping...remove the build directory(ies), except if the package build fails.
341 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
342 #
343 # Include a touch of the target name so make can check if it's already been made.
344 echo -e '\t@touch $@' >> $MKFILE.tmp
345 #
346 #--------------------------------------------------------------------#
347 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
348 #--------------------------------------------------------------------#
349 #
350 # Keep the script file name for Makefile dependencies.
351 PREV=$this_script
352
353 done # for file in...
354}
355
356
357#-----------------------------#
358testsuite_tools_Makefiles() { #
359#-----------------------------#
360 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
361
362 for file in testsuite-tools/* ; do
363 # Keep the script file name
364 this_script=`basename $file`
365
366 # First append each name of the script files to a list (this will become
367 # the names of the targets in the Makefile
368 testsuitetools="$testsuitetools $this_script"
369
370 # Grab the name of the target, strip id number, XXX-script
371 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
372 -e 's@-64bit@@' \
373 -e 's@-64@@' \
374 -e 's@64@@' \
375 -e 's@n32@@'`
376
377 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
378
379 #--------------------------------------------------------------------#
380 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
381 #--------------------------------------------------------------------#
382 #
383 # Drop in the name of the target on a new line, and the previous target
384 # as a dependency. Also call the echo_message function.
385 wrt_target "${this_script}" "$PREV"
386 #
387 case $name in
388 tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;;
389 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
390 esac
391 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
392 #
393 wrt_run_as_chroot1 "${this_script}" "${file}"
394 #
395 wrt_remove_build_dirs "${name}"
396 #
397 # Include a touch of the target name so make can check if it's already been made.
398 echo -e '\t@touch $@' >> $MKFILE.tmp
399 #
400 #--------------------------------------------------------------------#
401 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
402 #--------------------------------------------------------------------#
403 #
404 # Keep the script file name for Makefile dependencies.
405 PREV=$this_script
406
407 done
408}
409
410
411#--------------------------------#
412bm_testsuite_tools_Makefiles() { #
413#--------------------------------#
414 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}"
415
416 for file in testsuite-tools/* ; do
417 # Keep the script file name
418 this_script=`basename $file`
419
420 # First append each name of the script files to a list (this will become
421 # the names of the targets in the Makefile
422 PREV=
423 testsuitetools="$testsuitetools $this_script"
424
425 # Grab the name of the target, strip id number, XXX-script
426 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
427 -e 's@-64bit@@' \
428 -e 's@-64@@' \
429 -e 's@64@@' \
430 -e 's@n32@@'`
431
432 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
433
434 #--------------------------------------------------------------------#
435 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
436 #--------------------------------------------------------------------#
437 #
438 # Drop in the name of the target on a new line, and the previous target
439 # as a dependency. Also call the echo_message function.
440 wrt_target "${this_script}" "$PREV"
441 #
442 case $name in
443 tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;;
444 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
445 esac
446 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
447 #
448 wrt_run_as_root2 "${this_script}" "${file}"
449 #
450 wrt_remove_build_dirs2 "${name}"
451 #
452 # Include a touch of the target name so make can check if it's already been made.
453 echo -e '\t@touch $@' >> $MKFILE.tmp
454 #
455 #--------------------------------------------------------------------#
456 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
457 #--------------------------------------------------------------------#
458 #
459 # Keep the script file name for Makefile dependencies.
460 PREV=$this_script
461
462 done
463}
464
465
466#-----------------------------#
467final_system_Makefiles() { #
468#-----------------------------#
469 # Set envars and scripts for iteration targets
470 LOGS="" # Start with an empty global LOGS envar
471 if [[ -z "$1" ]] ; then
472 local N=""
473 else
474 local N=-build_$1
475 local basicsystem=""
476 mkdir final-system$N
477 cp final-system/* final-system$N
478 for script in final-system$N/* ; do
479 # Overwrite existing symlinks, files, and dirs
480 sed -e 's/ln -sv/&f/g' \
481 -e 's/mv -v/&f/g' \
482 -e 's/mkdir -v/&p/g' -i ${script}
483 done
484 # Remove Bzip2 binaries before make install
485 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
486 # Fix how Module-Init-Tools do the install target
487 sed -e 's@make install@make INSTALL=install install@' -i final-system$N/*-module-init-tools
488 # Delete *old Readline libraries just after make install
489 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
490 fi
491
492 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N${R_arrow}"
493
494 for file in final-system$N/* ; do
495 # Keep the script file name
496 this_script=`basename $file`
497
498 # Test if the stripping phase must be skipped.
499 # Skip alsp temp-perl for iterative runs
500 case $this_script in
501 *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
502 *temp-perl*) [[ -n "$N" ]] && continue ;;
503 esac
504
505 # Grab the name of the target, strip id number, XXX-script
506 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
507 -e 's@temp-@@' \
508 -e 's@-64bit@@' \
509 -e 's@-64@@' \
510 -e 's@64@@' \
511 -e 's@n32@@'`
512
513 # Find the version of the command files, if it corresponds with the building of
514 # a specific package. We need this here to can skip scripts not needed for
515 # iterations rebuilds
516 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
517
518 if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
519 case "${this_script}" in
520 *stripping*) ;;
521 *) continue ;;
522 esac
523 fi
524
525 # Append each name of the script files to a list (this will become
526 # the names of the targets in the Makefile
527 basicsystem="$basicsystem ${this_script}${N}"
528
529 # Append each name of the script files to a list (this will become
530 # the names of the logs to be moved for each iteration)
531 LOGS="$LOGS ${this_script}"
532
533 #--------------------------------------------------------------------#
534 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
535 #--------------------------------------------------------------------#
536 #
537 # Drop in the name of the target on a new line, and the previous target
538 # as a dependency. Also call the echo_message function.
539 wrt_target "${this_script}${N}" "$PREV"
540
541 # If $vrs isn't empty, we've got a package...
542 if [ "$vrs" != "" ] ; then
543 FILE="$name-$vrs.tar.*"
544 wrt_unpack2 "$FILE"
545 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
546 fi
547 #
548 wrt_run_as_chroot1 "${this_script}" "${file}"
549 #
550 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
551 #
552 # Include a touch of the target name so make can check if it's already been made.
553 echo -e '\t@touch $@' >> $MKFILE.tmp
554 #
555 #--------------------------------------------------------------------#
556 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
557 #--------------------------------------------------------------------#
558 #
559 # Keep the script file name for Makefile dependencies.
560 PREV=${this_script}${N}
561 # Set system_build envar for iteration targets
562 system_build=$basicsystem
563 done # for file in final-system/* ...
564}
565
566
567#-----------------------------#
568bm_final_system_Makefiles() { #
569#-----------------------------#
570 # Set envars and scripts for iteration targets
571 LOGS="" # Start with an empty global LOGS envar
572 if [[ -z "$1" ]] ; then
573 local N=""
574 # The makesys phase was initiated in bm_testsuite_tools_makefile
575 [[ "$TEST" = 0 ]] && PREV=""
576 else
577 local N=-build_$1
578 local basicsystem=""
579 mkdir final-system$N
580 cp final-system/* final-system$N
581 for script in final-system$N/* ; do
582 # Overwrite existing symlinks, files, and dirs
583 sed -e 's/ln -sv/&f/g' \
584 -e 's/mv -v/&f/g' \
585 -e 's/mkdir -v/&p/g' -i ${script}
586 done
587 # Remove Bzip2 binaries before make install
588 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
589 # Fix how Module-Init-Tools do the install target
590 sed -e 's@make install@make INSTALL=install install@' -i final-system$N/*-module-init-tools
591 # Delete *old Readline libraries just after make install
592 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
593 fi
594
595 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N${R_arrow}"
596
597 for file in final-system$N/* ; do
598 # Keep the script file name
599 this_script=`basename $file`
600
601 # Test if the stripping phase must be skipped
602 # Skip alsp temp-perl for iterative runs
603 case $this_script in
604 *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
605 *temp-perl*) [[ -n "$N" ]] && continue ;;
606 esac
607
608 # Grab the name of the target, strip id number, XXX-script
609 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
610 -e 's@temp-@@' \
611 -e 's@-64bit@@' \
612 -e 's@-64@@' \
613 -e 's@64@@' \
614 -e 's@n32@@'`
615
616 # Find the version of the command files, if it corresponds with the building of
617 # a specific package. We need this here to can skip scripts not needed for
618 # iterations rebuilds
619 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
620
621 if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
622 case "${this_script}" in
623 *stripping*) ;;
624 *) continue ;;
625 esac
626 fi
627
628 # Append each name of the script files to a list (this will become
629 # the names of the targets in the Makefile
630 basicsystem="$basicsystem ${this_script}${N}"
631
632 # Append each name of the script files to a list (this will become
633 # the names of the logs to be moved for each iteration)
634 LOGS="$LOGS ${this_script}"
635
636 #--------------------------------------------------------------------#
637 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
638 #--------------------------------------------------------------------#
639 #
640 # Drop in the name of the target on a new line, and the previous target
641 # as a dependency. Also call the echo_message function.
642 wrt_target "${this_script}${N}" "$PREV"
643
644 # If $vrs isn't empty, we've got a package...
645 if [ "$vrs" != "" ] ; then
646 FILE="$name-$vrs.tar.*"
647 wrt_unpack3 "$FILE"
648 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
649 fi
650 #
651 wrt_run_as_root2 "${this_script}" "${file}"
652 #
653 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
654 #
655 # Include a touch of the target name so make can check if it's already been made.
656 echo -e '\t@touch $@' >> $MKFILE.tmp
657 #
658 #--------------------------------------------------------------------#
659 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
660 #--------------------------------------------------------------------#
661 #
662 # Keep the script file name for Makefile dependencies.
663 PREV=${this_script}${N}
664 # Set system_build envar for iteration targets
665 system_build=$basicsystem
666 done # for file in final-system/* ...
667}
668
669
670#-----------------------------#
671bootscripts_Makefiles() { #
672#-----------------------------#
673 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
674
675 for file in bootscripts/* ; do
676 # Keep the script file name
677 this_script=`basename $file`
678
679 case $this_script in
680 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
681 *console*) continue ;; # Use the files that came with the bootscripts
682 *) ;;
683 esac
684
685 # First append each name of the script files to a list (this will become
686 # the names of the targets in the Makefile
687 bootscripttools="$bootscripttools $this_script"
688
689 # Grab the name of the target, strip id number, XXX-script
690 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
691 -e 's@-64bit@@' \
692 -e 's@-64@@' \
693 -e 's@64@@' \
694 -e 's@n32@@'`
695 case $name in
696 *bootscripts*) name=bootscripts-cross-lfs ;;
697 *udev-rules) name=udev-cross-lfs ;;
698 esac
699 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
700
701 #--------------------------------------------------------------------#
702 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
703 #--------------------------------------------------------------------#
704 #
705 # Drop in the name of the target on a new line, and the previous target
706 # as a dependency. Also call the echo_message function.
707 wrt_target "${this_script}" "$PREV"
708 #
709 # If $vrs isn't empty, we've got a package...
710 #
711 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
712 #
713 wrt_run_as_chroot1 "${this_script}" "${file}"
714 #
715 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
716 #
717 # Include a touch of the target name so make can check if it's already been made.
718 echo -e '\t@touch $@' >> $MKFILE.tmp
719 #
720 #--------------------------------------------------------------------#
721 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
722 #--------------------------------------------------------------------#
723 #
724 # Keep the script file name for Makefile dependencies.
725 PREV=$this_script
726
727 done # for file in bootscripts/* ...
728
729}
730
731#-----------------------------#
732bm_bootscripts_Makefiles() { #
733#-----------------------------#
734 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
735
736 for file in bootscripts/* ; do
737 # Keep the script file name
738 this_script=`basename $file`
739
740 case $this_script in
741 *udev*) continue ;; # This is not a script but a commentary
742 *console*) continue ;; # Use the files that came with the bootscripts
743 *) ;;
744 esac
745
746 # First append each name of the script files to a list (this will become
747 # the names of the targets in the Makefile
748 bootscripttools="$bootscripttools $this_script"
749
750 # Grab the name of the target, strip id number, XXX-script
751 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
752 -e 's@-64bit@@' \
753 -e 's@-64@@' \
754 -e 's@64@@' \
755 -e 's@n32@@'`
756 case $name in
757 *bootscripts*) name=bootscripts-cross-lfs
758 ;;
759 esac
760 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
761
762 #--------------------------------------------------------------------#
763 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
764 #--------------------------------------------------------------------#
765 #
766 # Drop in the name of the target on a new line, and the previous target
767 # as a dependency. Also call the echo_message function.
768 wrt_target "${this_script}" "$PREV"
769 #
770 # If $vrs isn't empty, we've got a package...
771 #
772 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
773 #
774 wrt_run_as_root2 "${this_script}" "${file}"
775 #
776 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
777 #
778 # Include a touch of the target name so make can check if it's already been made.
779 echo -e '\t@touch $@' >> $MKFILE.tmp
780 #
781 #--------------------------------------------------------------------#
782 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
783 #--------------------------------------------------------------------#
784 #
785 # Keep the script file name for Makefile dependencies.
786 PREV=$this_script
787
788 done # for file in bootscripts/* ...
789
790}
791
792
793
794#-----------------------------#
795bootable_Makefiles() { #
796#-----------------------------#
797 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
798
799 for file in {bootable,the-end}/* ; do
800 # Keep the script file name
801 this_script=`basename $file`
802
803 # A little housekeeping on the scripts
804 case $this_script in
805 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
806 *kernel) # if there is no kernel config file do not build the kernel
807 [[ -z $CONFIG ]] && continue
808 # Copy the config file to /sources with a standardized name
809 cp $CONFIG $BUILDDIR/sources/kernel-config
810 ;;
811 esac
812 #
813 # First append each name of the script files to a list (this will become
814 # the names of the targets in the Makefile
815 bootabletools="$bootabletools $this_script"
816 #
817 # Grab the name of the target, strip id number and misc words.
818 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
819 case $this_script in
820 *kernel*) name=linux
821 ;;
822 esac
823 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
824
825 #--------------------------------------------------------------------#
826 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
827 #--------------------------------------------------------------------#
828 #
829 # Drop in the name of the target on a new line, and the previous target
830 # as a dependency. Also call the echo_message function.
831 wrt_target "${this_script}" "$PREV"
832 #
833 # If $vrs isn't empty, we've got a package...
834 # Insert instructions for unpacking the package and changing directories
835 #
836 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
837 #
838 # Select a script execution method
839 case $this_script in
840 *fstab*) if [[ -n "$FSTAB" ]]; then
841 wrt_copy_fstab "${this_script}"
842 else
843 wrt_run_as_chroot1 "${this_script}" "${file}"
844 fi
845 ;;
846 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
847 esac
848 #
849 # Housekeeping...remove any build directory(ies) except if the package build fails.
850 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
851 #
852 # Include a touch of the target name so make can check if it's already been made.
853 echo -e '\t@touch $@' >> $MKFILE.tmp
854 #
855 #--------------------------------------------------------------------#
856 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
857 #--------------------------------------------------------------------#
858 #
859 # Keep the script file name for Makefile dependencies.
860 PREV=$this_script
861
862 done
863
864 # Add SBU-disk_usage report target if required
865 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
866
867}
868
869
870
871#-----------------------------#
872bm_bootable_Makefiles() { #
873#-----------------------------#
874 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}"
875
876 for file in {bootable,the-end}/* ; do
877 # Keep the script file name
878 this_script=`basename $file`
879
880 # A little housekeeping on the scripts
881 case $this_script in
882 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
883 *kernel) # if there is no kernel config file do not build the kernel
884 [[ -z $CONFIG ]] && continue
885 # Copy the named config file to /sources with a standardized name
886 cp $CONFIG $BUILDDIR/sources/kernel-config
887 ;;
888 esac
889 #
890 # First append each name of the script files to a list (this will become
891 # the names of the targets in the Makefile
892 bootabletools="$bootabletools $this_script"
893 #
894 # Grab the name of the target, strip id number and misc words.
895 case $this_script in
896 *kernel) name=linux
897 ;;
898 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
899 esac
900
901 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
902
903 #--------------------------------------------------------------------#
904 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
905 #--------------------------------------------------------------------#
906 #
907 # Drop in the name of the target on a new line, and the previous target
908 # as a dependency. Also call the echo_message function.
909 wrt_target "${this_script}" "$PREV"
910 #
911 # If $vrs isn't empty, we've got a package...
912 # Insert instructions for unpacking the package and changing directories
913 #
914 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
915 #
916 # Select a script execution method
917 case $this_script in
918 *fstab*) if [[ -n "$FSTAB" ]]; then
919 # Minimal boot mode has no access to original file, store in /sources
920 cp $FSTAB $BUILDDIR/sources/fstab
921 wrt_copy_fstab2 "${this_script}"
922 else
923 wrt_run_as_root2 "${this_script}" "${file}"
924 fi
925 ;;
926 *) wrt_run_as_root2 "${this_script}" "${file}" ;;
927 esac
928 #
929 # Housekeeping...remove any build directory(ies) except if the package build fails.
930 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
931 #
932 # Include a touch of the target name so make can check if it's already been made.
933 echo -e '\t@touch $@' >> $MKFILE.tmp
934 #
935 #--------------------------------------------------------------------#
936 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
937 #--------------------------------------------------------------------#
938 #
939 # Keep the script file name for Makefile dependencies.
940 PREV=$this_script
941
942 done
943
944 # Add SBU-disk_usage report target if required
945 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
946
947}
948
949
950#-----------------------------#
951build_Makefile() { # Construct a Makefile from the book scripts
952#-----------------------------#
953 echo "Creating Makefile... ${BOLD}START${OFF}"
954
955 cd $JHALFSDIR/${PROGNAME}-commands
956 # Start with a clean Makefile.tmp file
957 >$MKFILE.tmp
958
959 host_prep_Makefiles
960 cross_tools_Makefiles # $cross_tools
961 temptools_Makefiles # $temptools
962 if [[ $METHOD = "chroot" ]]; then
963 chroot_Makefiles # $chroottools
964 if [[ ! $TEST = "0" ]]; then
965 testsuite_tools_Makefiles # $testsuitetools
966 fi
967 final_system_Makefiles # $basicsystem
968 # Add the iterations targets, if needed
969 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
970 bootscripts_Makefiles # $bootscripttools
971 bootable_Makefiles # $bootabletools
972 else
973 boot_Makefiles # $boottools
974 if [[ ! $TEST = "0" ]]; then
975 bm_testsuite_tools_Makefiles # $testsuitetools
976 fi
977 bm_final_system_Makefiles # $basicsystem
978 # Add the iterations targets, if needed
979 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
980 bm_bootscripts_Makefiles # $bootscipttools
981 bm_bootable_Makefiles # $bootabletoosl
982 fi
983# the_end_Makefiles
984
985
986 # Add a header, some variables and include the function file
987 # to the top of the real Makefile.
988(
989 cat << EOF
990$HEADER
991
992SRC= /sources
993MOUNT_PT= $BUILDDIR
994PKG_LST= $PKG_LST
995
996include makefile-functions
997
998EOF
999) > $MKFILE
1000
1001 # Add chroot commands
1002 if [ "$METHOD" = "chroot" ] ; then
1003 chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
1004 -e '/^export/d' \
1005 -e '/^logout/d' \
1006 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
1007 -e 's|\\$|&&|g' \
1008 -e 's|exit||g' \
1009 -e 's|$| -c|' \
1010 -e 's|"$$LFS"|$(MOUNT_PT)|'\
1011 -e 's|set -e||'`
1012 echo -e "CHROOT1= $chroot\n" >> $MKFILE
1013 fi
1014
1015 # Drop in the main target 'all:' and the chapter targets with each sub-target
1016 # as a dependency.
1017if [[ "${METHOD}" = "chroot" ]]; then
1018(
1019 cat << EOF
1020all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8 do-housekeeping
1021 @\$(call echo_finished,$VERSION)
1022
1023chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
1024
1025chapter3: chapter2 $cross_tools
1026
1027chapter4: chapter3 $temptools
1028
1029chapter5: chapter4 $chroottools $testsuitetools
1030
1031chapter6: chapter5 $basicsystem
1032
1033chapter7: chapter6 $bootscripttools
1034
1035chapter8: chapter7 $bootabletools
1036
1037clean-all: clean
1038 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
1039
1040clean: clean-chapter4 clean-chapter3 clean-chapter2
1041
1042clean-chapter2:
1043 -if [ ! -f user-lfs-exist ]; then \\
1044 userdel lfs; \\
1045 rm -rf /home/lfs; \\
1046 fi;
1047 rm -rf \$(MOUNT_PT)/tools
1048 rm -f /tools
1049 rm -rf \$(MOUNT_PT)/cross-tools
1050 rm -f /cross-tools
1051 rm -f envars user-lfs-exist
1052 rm -f 02* logs/02*.log
1053
1054clean-chapter3:
1055 rm -rf \$(MOUNT_PT)/tools/*
1056 rm -f $cross_tools restore-lfs-env sources-dir
1057 cd logs && rm -f $cross_tools && cd ..
1058
1059clean-chapter4:
1060 -umount \$(MOUNT_PT)/sys
1061 -umount \$(MOUNT_PT)/proc
1062 -umount \$(MOUNT_PT)/dev/shm
1063 -umount \$(MOUNT_PT)/dev/pts
1064 -umount \$(MOUNT_PT)/dev
1065 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1066 rm -f $temptools
1067 cd logs && rm -f $temptools && cd ..
1068
1069
1070restore-lfs-env:
1071 @\$(call echo_message, Building)
1072 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1073 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1074 fi;
1075 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1076 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1077 fi;
1078 @chown lfs:lfs /home/lfs/.bash* && \\
1079 touch \$@
1080
1081do-housekeeping:
1082 -umount \$(MOUNT_PT)/dev/pts
1083 -umount \$(MOUNT_PT)/dev/shm
1084 -umount \$(MOUNT_PT)/dev
1085 -umount \$(MOUNT_PT)/sys
1086 -umount \$(MOUNT_PT)/proc
1087 -if [ ! -f user-lfs-exist ]; then \\
1088 userdel lfs; \\
1089 rm -rf /home/lfs; \\
1090 fi;
1091
1092EOF
1093) >> $MKFILE
1094fi
1095
1096
1097if [[ "${METHOD}" = "boot" ]]; then
1098(
1099 cat << EOF
1100
1101all: makeboot
1102
1103makeboot: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment \
1104 $cross_tools\
1105 $temptools \
1106 $chroottools \
1107 $boottools
1108 @\$(call echo_boot_finished,$VERSION)
1109
1110makesys: $testsuitetools $basicsystem $bootscripttools $bootabletools
1111 @\$(call echo_finished,$VERSION)
1112
1113
1114clean-all: clean
1115 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
1116
1117clean: clean-makesys clean-makeboot clean-jhalfs
1118
1119clean-jhalfs:
1120 -if [ ! -f user-lfs-exist ]; then \\
1121 userdel lfs; \\
1122 rm -rf /home/lfs; \\
1123 fi;
1124 rm -rf \$(MOUNT_PT)/tools
1125 rm -f /tools
1126 rm -rf \$(MOUNT_PT)/cross-tools
1127 rm -f /cross-tools
1128 rm -f envars user-lfs-exist
1129 rm -f 02* logs/02*.log
1130
1131clean-makeboot:
1132 rm -rf /tools/*
1133 rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools
1134 rm -f restore-lfs-env sources-dir
1135 cd logs && rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools && cd ..
1136
1137clean-makesys:
1138 -umount \$(MOUNT_PT)/sys
1139 -umount \$(MOUNT_PT)/proc
1140 -umount \$(MOUNT_PT)/dev/shm
1141 -umount \$(MOUNT_PT)/dev/pts
1142 -umount \$(MOUNT_PT)/dev
1143 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1144 rm -f $basicsystem
1145 rm -f $bootscripttools
1146 rm -f $bootabletools
1147 cd logs && rm -f $basicsystem && rm -f $bootscripttools && rm -f $bootabletools && cd ..
1148
1149
1150restore-lfs-env:
1151 @\$(call echo_message, Building)
1152 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1153 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1154 fi;
1155 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1156 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1157 fi;
1158 @chown lfs:lfs /home/lfs/.bash* && \\
1159 touch \$@
1160
1161
1162EOF
1163) >> $MKFILE
1164fi
1165
1166 # Bring over the items from the Makefile.tmp
1167 cat $MKFILE.tmp >> $MKFILE
1168 rm $MKFILE.tmp
1169 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1170
1171}
1172
Note: See TracBrowser for help on using the repository browser.