source: CLFS/master.sh@ bc54cbe

experimental
Last change on this file since bc54cbe was bc54cbe, checked in by George Boudreau <georgeb@…>, 18 years ago

CLFS/master.sh, removed ALL cmd script manipulation. Allow Manuel to tackle script issues via xsl first

  • Property mode set to 100755
File size: 40.8 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 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
131 #
132 # If $vrs isn't empty, we've got a package...
133 #
134 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
135 #
136 wrt_run_as_lfs "${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 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
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.*" && echo -e '\ttrue' >> $MKFILE.tmp
187 #
188 wrt_run_as_lfs "${this_script}" "${file}"
189 #
190 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
191 #
192 # Include a touch of the target name so make can check if it's already been made.
193 echo -e '\t@touch $@' >> $MKFILE.tmp
194 #
195 #--------------------------------------------------------------------#
196 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
197 #--------------------------------------------------------------------#
198 #
199 # Keep the script file name for Makefile dependencies.
200 PREV=$this_script
201 done # for file in ....
202}
203
204
205#-----------------------------#
206boot_Makefiles() { #
207#-----------------------------#
208 echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}"
209
210 for file in boot/* ; do
211 # Keep the script file name
212 this_script=`basename $file`
213
214 # A little housekeeping on the scripts
215 case $this_script in
216 *grub*) continue ;;
217 *whatnext*) continue ;;
218 *settingenvironment*) sed 's@PS1=@set +h\nPS1=@' -i $file ;;
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# sed "s|make mrproper|make mrproper\ncp /sources/bootkernel-config .config|" -i $file
224 # You cannot run menuconfig from within the makefile
225# sed 's|menuconfig|oldconfig|' -i $file
226 #If defined include the keymap in the kernel
227# if [[ -n "$KEYMAP" ]]; then
228# sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
229# else
230# sed '/loadkeys -m/d' -i $file
231# sed '/drivers\/char/d' -i $file
232# fi
233 ;;
234 esac
235 #
236 # First append each name of the script files to a list (this will become
237 # the names of the targets in the Makefile
238 boottools="$boottools $this_script"
239 #
240 # Grab the name of the target, strip id number and misc words.
241 case $this_script in
242 *kernel) name=linux ;;
243 *bootscripts) name="bootscripts-cross-lfs" ;;
244 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
245 esac
246
247 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
248
249 #--------------------------------------------------------------------#
250 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
251 #--------------------------------------------------------------------#
252 #
253 # Drop in the name of the target on a new line, and the previous target
254 # as a dependency. Also call the echo_message function.
255 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
256 #
257 # If $vrs isn't empty, we've got a package...
258 # Insert instructions for unpacking the package and changing directories
259 #
260 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
261 #
262 # Select a script execution method
263 case $this_script in
264 *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;;
265 *devices*) wrt_run_as_root "${this_script}" "${file}" ;;
266 *fstab*) if [[ -n "$FSTAB" ]]; then
267 wrt_copy_fstab "${this_script}"
268 else
269 wrt_run_as_lfs "${this_script}" "${file}"
270 fi
271 ;;
272 *) wrt_run_as_lfs "${this_script}" "${file}" ;;
273 esac
274 #
275 # Housekeeping...remove any build directory(ies) except if the package build fails.
276 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
277 #
278 # Include a touch of the target name so make can check if it's already been made.
279 echo -e '\t@touch $@' >> $MKFILE.tmp
280 #
281 #--------------------------------------------------------------------#
282 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
283 #--------------------------------------------------------------------#
284 #
285 # Keep the script file name for Makefile dependencies.
286 PREV=$this_script
287
288 done
289 # This will force the Makefile to exit and not allow it to be restarted with
290 # the command <make>, The user will have to issue the cmd <make chapterXX>
291 echo -e "\t@\$(call echo_boot_finished,$VERSION) && \\" >> $MKFILE.tmp
292 echo -e "\tfalse" >> $MKFILE.tmp
293}
294
295
296#-----------------------------#
297chroot_Makefiles() { #
298#-----------------------------#
299 echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}"
300
301 for file in chroot/* ; do
302 # Keep the script file name
303 this_script=`basename $file`
304 #
305 # Skipping scripts is done now and not included in the build tree.
306 [[ `_IS_ $this_script chroot` ]] && continue
307
308 #
309 # First append each name of the script files to a list (this will become
310 # the names of the targets in the Makefile
311 chroottools="$chroottools $this_script"
312
313 #
314 # A little housekeeping on the script contents
315 case $this_script in
316 *kernfs*) sed '/exit/d' -i $file ;;
317 *pwdgroup*) sed '/exec/d' -i $file ;;
318 esac
319 #
320 # Grab the name of the target, strip id number, XXX-script
321 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
322 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
323
324 #--------------------------------------------------------------------#
325 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
326 #--------------------------------------------------------------------#
327 #
328 # Drop in the name of the target on a new line, and the previous target
329 # as a dependency. Also call the echo_message function.
330 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
331 #
332 # If $vrs isn't empty, we've got a package...
333 # Insert instructions for unpacking the package and changing directories
334 #
335 if [ "$vrs" != "" ] ; then
336 case $this_script in
337 *util-linux) wrt_unpack "$name-$vrs.tar.*"
338 echo -e '\ttrue' >> $MKFILE.tmp
339 ;;
340 *) wrt_unpack2 "$name-$vrs.tar.*"
341 ;;
342 esac
343 fi
344 #
345 # Select a script execution method
346 case $this_script in
347 *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
348 *util-linux) wrt_run_as_lfs "${this_script}" "${file}" ;;
349 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
350 esac
351 #
352 # Housekeeping...remove the build directory(ies), except if the package build fails.
353 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
354 #
355 # Include a touch of the target name so make can check if it's already been made.
356 echo -e '\t@touch $@' >> $MKFILE.tmp
357 #
358 #--------------------------------------------------------------------#
359 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
360 #--------------------------------------------------------------------#
361 #
362 # Keep the script file name for Makefile dependencies.
363 PREV=$this_script
364
365 done # for file in...
366}
367
368
369#-----------------------------#
370testsuite_tools_Makefiles() { #
371#-----------------------------#
372 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
373
374 for file in testsuite-tools/* ; do
375 # Keep the script file name
376 this_script=`basename $file`
377
378 # First append each name of the script files to a list (this will become
379 # the names of the targets in the Makefile
380 testsuitetools="$testsuitetools $this_script"
381
382 # Grab the name of the target, strip id number, XXX-script
383 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
384 -e 's@-64bit@@' \
385 -e 's@-64@@' \
386 -e 's@64@@' \
387 -e 's@n32@@'`
388
389 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
390
391 #--------------------------------------------------------------------#
392 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
393 #--------------------------------------------------------------------#
394 #
395 # Drop in the name of the target on a new line, and the previous target
396 # as a dependency. Also call the echo_message function.
397 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
398 #
399 case $name in
400 tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;;
401 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
402 esac
403 #
404 wrt_run_as_chroot1 "${this_script}" "${file}"
405 #
406 wrt_remove_build_dirs "${name}"
407 #
408 # Include a touch of the target name so make can check if it's already been made.
409 echo -e '\t@touch $@' >> $MKFILE.tmp
410 #
411 #--------------------------------------------------------------------#
412 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
413 #--------------------------------------------------------------------#
414 #
415 # Keep the script file name for Makefile dependencies.
416 PREV=$this_script
417
418 done
419}
420
421
422#--------------------------------#
423bm_testsuite_tools_Makefiles() { #
424#--------------------------------#
425 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}"
426
427 for file in testsuite-tools/* ; do
428 # Keep the script file name
429 this_script=`basename $file`
430
431 # First append each name of the script files to a list (this will become
432 # the names of the targets in the Makefile
433 testsuitetools="$testsuitetools $this_script"
434
435 # Grab the name of the target, strip id number, XXX-script
436 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
437 -e 's@-64bit@@' \
438 -e 's@-64@@' \
439 -e 's@64@@' \
440 -e 's@n32@@'`
441
442 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
443
444 #--------------------------------------------------------------------#
445 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
446 #--------------------------------------------------------------------#
447 #
448 # Drop in the name of the target on a new line, and the previous target
449 # as a dependency. Also call the echo_message function.
450 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
451 #
452 case $name in
453 tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;;
454 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
455 esac
456 #
457 wrt_run_as_root2 "${this_script}" "${file}"
458 #
459 wrt_remove_build_dirs2 "${name}"
460 #
461 # Include a touch of the target name so make can check if it's already been made.
462 echo -e '\t@touch $@' >> $MKFILE.tmp
463 #
464 #--------------------------------------------------------------------#
465 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
466 #--------------------------------------------------------------------#
467 #
468 # Keep the script file name for Makefile dependencies.
469 PREV=$this_script
470
471 done
472}
473
474
475#-----------------------------#
476final_system_Makefiles() { #
477#-----------------------------#
478 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system${R_arrow}"
479
480 for file in final-system/* ; do
481 # Keep the script file name
482 this_script=`basename $file`
483
484 # Skipping scripts is done now so they are not included in the Makefile.
485 case $this_script in
486 *stripping*) continue ;;
487 *grub*) continue ;;
488 esac
489 #
490 # First append each name of the script files to a list (this will become
491 # the names of the targets in the Makefile
492 basicsystem="$basicsystem $this_script"
493 #
494 # A little customizing via sed scripts first..
495 if [[ $TEST = "0" ]]; then
496 # Drop any package checks..
497 sed -e '/make check/d' -e '/make test/d' -i $file
498 fi
499 case $this_script_BLOCKED in
500 *coreutils*) sed 's@set -e@set -e; set +h@' -i $file ;;
501 *groff*) sed "s@\*\*EDITME.*EDITME\*\*@$PAGE@" -i $file ;;
502 *vim*) sed '/vim -c/d' -i $file ;;
503 *bash*) sed '/exec /d' -i $file ;;
504 *shadow*) sed -e '/grpconv/d' -e '/pwconv/d' -e '/passwd root/d' -i $file
505 sed '/sed -i libtool/d' -i $file
506 sed '/search_path/d' -i $file
507 ;;
508 *glibc*) sed '/tzselect/d' -i $file
509 sed "s@\*\*EDITME.*EDITME\*\*@$TIMEZONE@" -i $file
510 # Manipulate glibc's test to work with Makefile
511 sed -e 's/glibc-check-log.*//' \
512 -e 's@make -k check >@make -k check >glibc-check-log 2>\&1 || true\ngrep Error glibc-check-log || true@' -i $file
513 ;;
514 *binutils*) sed '/expect /d' -i $file
515 if [[ $TOOLCHAINTEST = "0" ]]; then
516 sed '/make check/d' -i $file
517 fi
518 ;;
519 *gcc*) # Ignore all gcc testing for now..
520 sed -e '/make -k check/d' -i $file
521 sed -e '/test_summary/d' -i $file
522 ;;
523 *texinfo*) # This sucks as a way to trim a script
524 sed -e '/cd \/usr/d' \
525 -e '/rm dir/d' \
526 -e '/for f in/d' \
527 -e '/do inst/d' \
528 -e '/done/d' -i $file
529 ;;
530 esac
531
532 # Grab the name of the target, strip id number, XXX-script
533 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
534 -e 's@temp-@@' \
535 -e 's@-64bit@@' \
536 -e 's@-64@@' \
537 -e 's@64@@' \
538 -e 's@n32@@'`
539
540 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
541
542 #--------------------------------------------------------------------#
543 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
544 #--------------------------------------------------------------------#
545 #
546 # Drop in the name of the target on a new line, and the previous target
547 # as a dependency. Also call the echo_message function.
548 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
549
550 # If $vrs isn't empty, we've got a package...
551 if [ "$vrs" != "" ] ; then
552 case $name in
553 temp-perl) wrt_unpack2 "perl-$vrs.tar.*" ;;
554 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
555 esac
556 fi
557 #
558 wrt_run_as_chroot1 "${this_script}" "${file}"
559 #
560 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
561 #
562 # Include a touch of the target name so make can check if it's already been made.
563 echo -e '\t@touch $@' >> $MKFILE.tmp
564 #
565 #--------------------------------------------------------------------#
566 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
567 #--------------------------------------------------------------------#
568 #
569 # Keep the script file name for Makefile dependencies.
570 PREV=$this_script
571
572 done # for file in final-system/* ...
573}
574
575
576#-----------------------------#
577bm_final_system_Makefiles() { #
578#-----------------------------#
579 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system${R_arrow}"
580
581 for file in final-system/* ; do
582 # Keep the script file name
583 this_script=`basename $file`
584
585 # Skipping scripts is done now so they are not included in the Makefile.
586 case $this_script in
587 *stripping*) continue ;;
588 *grub*) continue ;;
589 esac
590
591 # First append each name of the script files to a list (this will become
592 # the names of the targets in the Makefile
593 basicsystem="$basicsystem $this_script"
594
595 #
596 # A little customizing via sed scripts first..
597 if [[ $TEST = "0" ]]; then
598 # Drop any package checks..
599 sed -e '/make check/d' -e '/make test/d' -i $file
600 fi
601 case $this_script_BLOCKED in
602 *coreutils*) sed 's@set -e@set -e; set +h@' -i $file ;;
603 *groff*) sed "s@\*\*EDITME.*EDITME\*\*@$PAGE@" -i $file ;;
604 *vim*) sed '/vim -c/d' -i $file ;;
605 *bash*) sed '/exec /d' -i $file ;;
606 *shadow*) sed -e '/grpconv/d' \
607 -e '/pwconv/d' \
608 -e '/passwd root/d' -i $file
609 sed '/sed -i libtool/d' -i $file
610 sed '/search_path/d' -i $file
611 ;;
612 *psmisc*) # Build fails on creation of this link. <pidof> installed in sysvinit
613 sed -e 's/^ln -s/#ln -s/' -i $file
614 ;;
615 *glibc*) sed '/tzselect/d' -i $file
616 sed "s@\*\*EDITME.*EDITME\*\*@$TIMEZONE@" -i $file
617 # Manipulate glibc's test to work with Makefile
618 sed -e 's/glibc-check-log.*//' -e 's@make -k check >@make -k check >glibc-check-log 2>\&1 || true\ngrep Error glibc-check-log || true@' -i $file
619 ;;
620 *binutils*) sed '/expect /d' -i $file
621 if [[ $TOOLCHAINTEST = "0" ]]; then
622 sed '/make check/d' -i $file
623 fi
624 ;;
625 *gcc*) # Ignore all gcc testing for now..
626 sed -e '/make -k check/d' -i $file
627 sed -e '/test_summary/d' -i $file
628 ;;
629 *texinfo*) # This sucks as a way to trim a script
630 sed -e '/cd \/usr/d' \
631 -e '/rm dir/d' \
632 -e '/for f in/d' \
633 -e '/do inst/d' \
634 -e '/done/d' -i $file
635 ;;
636 esac
637
638 # Grab the name of the target, strip id number, XXX-script
639 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
640 -e 's@temp-@@' \
641 -e 's@-64bit@@' \
642 -e 's@-64@@' \
643 -e 's@64@@' \
644 -e 's@n32@@'`
645
646 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
647
648 #--------------------------------------------------------------------#
649 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
650 #--------------------------------------------------------------------#
651 #
652 # Drop in the name of the target on a new line, and the previous target
653 # as a dependency. Also call the echo_message function.
654 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
655
656 # If $vrs isn't empty, we've got a package...
657 if [ "$vrs" != "" ] ; then
658 case $name in
659 temp-perl) wrt_unpack3 "perl-$vrs.tar.*" ;;
660 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
661 esac
662 #
663 # Export a few 'config' vars..
664 case $this_script in
665 *glibc*) # For glibc we can set then TIMEZONE envar.
666 echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp ;;
667 *groff*) # For Groff we need to set PAGE envar.
668 echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp ;;
669 esac
670 fi
671 #
672 wrt_run_as_root2 "${this_script}" "${file}"
673 #
674 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
675 #
676 # Include a touch of the target name so make can check if it's already been made.
677 echo -e '\t@touch $@' >> $MKFILE.tmp
678 #
679 #--------------------------------------------------------------------#
680 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
681 #--------------------------------------------------------------------#
682 #
683 # Keep the script file name for Makefile dependencies.
684 PREV=$this_script
685
686 done # for file in final-system/* ...
687}
688
689
690#-----------------------------#
691bootscripts_Makefiles() { #
692#-----------------------------#
693 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
694
695 for file in bootscripts/* ; do
696 # Keep the script file name
697 this_script=`basename $file`
698
699 case $this_script in
700 *udev*) continue ;; # This is not a script but a commentary
701 *console*) continue ;; # Use the files that came with the bootscripts
702 *) ;;
703 esac
704
705 # First append each name of the script files to a list (this will become
706 # the names of the targets in the Makefile
707 bootscripttools="$bootscripttools $this_script"
708
709 # A little bit of script modification
710 case $this_script_BLOCKED in
711 *profile*) # Over-ride the book cmds, write our own simple one.
712(
713cat <<- EOF
714 cat > /etc/profile << "_EOF_"
715 # Begin /etc/profile
716
717 export LC_ALL=${LC_ALL}
718 export LANG=${LANG}
719 export INPUTRC=/etc/inputrc
720
721 # End /etc/profile
722 _EOF_
723EOF
724) > $file
725 ;;
726 esac
727
728 # Grab the name of the target, strip id number, XXX-script
729 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
730 -e 's@-64bit@@' \
731 -e 's@-64@@' \
732 -e 's@64@@' \
733 -e 's@n32@@'`
734 if [[ `_IS_ $name bootscripts` ]]; then name=bootscripts-cross-lfs; fi
735
736 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
737
738 #--------------------------------------------------------------------#
739 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
740 #--------------------------------------------------------------------#
741 #
742 # Drop in the name of the target on a new line, and the previous target
743 # as a dependency. Also call the echo_message function.
744 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
745 #
746 # If $vrs isn't empty, we've got a package...
747 #
748 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
749 #
750 wrt_run_as_chroot1 "${this_script}" "${file}"
751 #
752 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
753 #
754 # Include a touch of the target name so make can check if it's already been made.
755 echo -e '\t@touch $@' >> $MKFILE.tmp
756 #
757 #--------------------------------------------------------------------#
758 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
759 #--------------------------------------------------------------------#
760 #
761 # Keep the script file name for Makefile dependencies.
762 PREV=$this_script
763
764 done # for file in bootscripts/* ...
765
766}
767
768#-----------------------------#
769bm_bootscripts_Makefiles() { #
770#-----------------------------#
771 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
772
773 for file in bootscripts/* ; do
774 # Keep the script file name
775 this_script=`basename $file`
776
777 case $this_script in
778 *udev*) continue ;; # This is not a script but a commentary
779 *console*) continue ;; # Use the files that came with the bootscripts
780 *) ;;
781 esac
782
783 # First append each name of the script files to a list (this will become
784 # the names of the targets in the Makefile
785 bootscripttools="$bootscripttools $this_script"
786
787 # A little bit of script modification
788 case $this_script_BLOCKED in
789 *profile*) # Over-ride the book cmds, write our own simple one.
790(
791cat <<- EOF
792 cat > /etc/profile << "_EOF_"
793 # Begin /etc/profile
794
795 export LC_ALL=${LC_ALL}
796 export LANG=${LANG}
797 export INPUTRC=/etc/inputrc
798
799 # End /etc/profile
800 _EOF_
801EOF
802) > $file
803 ;;
804 esac
805
806 # Grab the name of the target, strip id number, XXX-script
807 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
808 -e 's@-64bit@@' \
809 -e 's@-64@@' \
810 -e 's@64@@' \
811 -e 's@n32@@'`
812 if [[ `_IS_ $name bootscripts` ]]; then name=lfs-bootscripts; fi
813
814 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
815
816 #--------------------------------------------------------------------#
817 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
818 #--------------------------------------------------------------------#
819 #
820 # Drop in the name of the target on a new line, and the previous target
821 # as a dependency. Also call the echo_message function.
822 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
823 #
824 # If $vrs isn't empty, we've got a package...
825 #
826 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
827 #
828 wrt_run_as_root2 "${this_script}" "${file}"
829 #
830 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
831 #
832 # Include a touch of the target name so make can check if it's already been made.
833 echo -e '\t@touch $@' >> $MKFILE.tmp
834 #
835 #--------------------------------------------------------------------#
836 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
837 #--------------------------------------------------------------------#
838 #
839 # Keep the script file name for Makefile dependencies.
840 PREV=$this_script
841
842 done # for file in bootscripts/* ...
843
844}
845
846
847
848#-----------------------------#
849bootable_Makefiles() { #
850#-----------------------------#
851 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
852
853 for file in bootable/* ; do
854 # Keep the script file name
855 this_script=`basename $file`
856
857 # A little housekeeping on the scripts
858 case $this_script in
859 *grub*) continue ;;
860 *kernel) # if there is no kernel config file do not build the kernel
861 [[ -z $CONFIG ]] && continue
862 # Copy the config file to /sources with a standardized name
863 cp $CONFIG $BUILDDIR/sources/kernel-config
864 ;;
865 esac
866 #
867 # First append each name of the script files to a list (this will become
868 # the names of the targets in the Makefile
869 bootabletools="$bootabletools $this_script"
870 #
871 # Grab the name of the target, strip id number and misc words.
872 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
873 [[ `_IS_ $this_script "kernel"` ]] && name=linux
874
875 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
876
877 #--------------------------------------------------------------------#
878 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
879 #--------------------------------------------------------------------#
880 #
881 # Drop in the name of the target on a new line, and the previous target
882 # as a dependency. Also call the echo_message function.
883 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
884 #
885 # If $vrs isn't empty, we've got a package...
886 # Insert instructions for unpacking the package and changing directories
887 #
888 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
889 #
890 # Select a script execution method
891 case $this_script in
892 *fstab*) if [[ -n "$FSTAB" ]]; then
893 wrt_copy_fstab "${this_script}"
894 else
895 wrt_run_as_chroot1 "${this_script}" "${file}"
896 fi
897 ;;
898 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
899 esac
900 #
901 # Housekeeping...remove any build directory(ies) except if the package build fails.
902 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
903 #
904 # Include a touch of the target name so make can check if it's already been made.
905 echo -e '\t@touch $@' >> $MKFILE.tmp
906 #
907 #--------------------------------------------------------------------#
908 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
909 #--------------------------------------------------------------------#
910 #
911 # Keep the script file name for Makefile dependencies.
912 PREV=$this_script
913
914 done
915
916}
917
918
919
920#-----------------------------#
921bm_bootable_Makefiles() { #
922#-----------------------------#
923 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}"
924
925 for file in bootable/* ; do
926 # Keep the script file name
927 this_script=`basename $file`
928
929 # A little housekeeping on the scripts
930 case $this_script in
931 *grub*) continue ;;
932 *kernel) # if there is no kernel config file do not build the kernel
933 [[ -z $CONFIG ]] && continue
934 # Copy the named config file to /sources with a standardized name
935 cp $CONFIG $BUILDDIR/sources/kernel-config
936# sed "s|make mrproper|make mrproper\ncp ../kernel-config .config|" -i $file
937 # You cannot run menuconfig from within the makefile
938# sed 's|menuconfig|oldconfig|' -i $file
939 # If defined include the keymap in the kernel
940# if [[ -n "$KEYMAP" ]]; then
941# sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
942# else
943# sed '/loadkeys -m/d' -i $file
944# sed '/drivers\/char/d' -i $file
945# fi
946 ;;
947 esac
948 #
949 # First append each name of the script files to a list (this will become
950 # the names of the targets in the Makefile
951 bootabletools="$bootabletools $this_script"
952 #
953 # Grab the name of the target, strip id number and misc words.
954 case $this_script in
955 *kernel) name=linux
956 ;;
957 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
958 esac
959
960 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
961
962 #--------------------------------------------------------------------#
963 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
964 #--------------------------------------------------------------------#
965 #
966 # Drop in the name of the target on a new line, and the previous target
967 # as a dependency. Also call the echo_message function.
968 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
969 #
970 # If $vrs isn't empty, we've got a package...
971 # Insert instructions for unpacking the package and changing directories
972 #
973 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
974 #
975 # Select a script execution method
976 case $this_script in
977 *fstab*) if [[ -n "$FSTAB" ]]; then
978 # Minimal boot mode has no access to original file, store in /sources
979 cp $FSTAB $BUILDDIR/sources/fstab
980 wrt_copy_fstab2 "${this_script}"
981 else
982 wrt_run_as_root2 "${this_script}" "${file}"
983 fi
984 ;;
985 *) wrt_run_as_root2 "${this_script}" "${file}" ;;
986 esac
987 #
988 # Housekeeping...remove any build directory(ies) except if the package build fails.
989 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
990 #
991 # Include a touch of the target name so make can check if it's already been made.
992 echo -e '\t@touch $@' >> $MKFILE.tmp
993 #
994 #--------------------------------------------------------------------#
995 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
996 #--------------------------------------------------------------------#
997 #
998 # Keep the script file name for Makefile dependencies.
999 PREV=$this_script
1000
1001 done
1002
1003}
1004
1005
1006
1007#-----------------------------#
1008the_end_Makefiles() { #
1009#-----------------------------#
1010 echo "${tab_}${GREEN}Processing... ${L_arrow}THE END${R_arrow}"
1011}
1012
1013
1014#-----------------------------#
1015build_Makefile() { # Construct a Makefile from the book scripts
1016#-----------------------------#
1017 echo "Creating Makefile... ${BOLD}START${OFF}"
1018
1019 cd $JHALFSDIR/${PROGNAME}-commands
1020 # Start with a clean Makefile.tmp file
1021 >$MKFILE.tmp
1022
1023 host_prep_Makefiles
1024 cross_tools_Makefiles
1025 temptools_Makefiles
1026 if [[ $METHOD = "chroot" ]]; then
1027 chroot_Makefiles
1028 if [[ $TOOLCHAINTEST = "1" ]]; then
1029 testsuite_tools_Makefiles
1030 fi
1031 final_system_Makefiles
1032 bootscripts_Makefiles
1033 bootable_Makefiles
1034 else
1035 boot_Makefiles # This phase must die at the end of its run..
1036 if [[ $TOOLCHAINTEST = "1" ]]; then
1037 bm_testsuite_tools_Makefiles
1038 fi
1039 bm_final_system_Makefiles
1040 bm_bootscripts_Makefiles
1041 bm_bootable_Makefiles
1042 fi
1043# the_end_Makefiles
1044
1045
1046 # Add a header, some variables and include the function file
1047 # to the top of the real Makefile.
1048(
1049 cat << EOF
1050$HEADER
1051
1052SRC= /sources
1053MOUNT_PT= $BUILDDIR
1054
1055include makefile-functions
1056
1057EOF
1058) > $MKFILE
1059
1060 # Add chroot commands
1061 if [ "$METHOD" = "chroot" ] ; then
1062 chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
1063 -e '/^export/d' \
1064 -e '/^logout/d' \
1065 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
1066 -e 's|\\$|&&|g' \
1067 -e 's|exit||g' \
1068 -e 's|$| -c|' \
1069 -e 's|"$$LFS"|$(MOUNT_PT)|'\
1070 -e 's|set -e||'`
1071 echo -e "CHROOT1= $chroot\n" >> $MKFILE
1072 fi
1073
1074 # Drop in the main target 'all:' and the chapter targets with each sub-target
1075 # as a dependency.
1076(
1077 cat << EOF
1078all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8
1079 @\$(call echo_finished,$VERSION)
1080
1081chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
1082
1083chapter3: chapter2 $cross_tools
1084
1085chapter4: chapter3 $temptools
1086
1087chapter5: chapter4 $chroottools $boottools
1088
1089chapter6: chapter5 $basicsystem
1090
1091chapter7: chapter6 $bootscripttools
1092
1093chapter8: chapter7 $bootabletools
1094
1095clean-all: clean
1096 rm -rf ./{${PROGNAME}-commands,logs,Makefile,dump-clfs-scripts.xsl,functions,packages,patches}
1097
1098clean: clean-chapter4 clean-chapter3 clean-chapter2
1099
1100clean-chapter2:
1101 -if [ ! -f user-lfs-exist ]; then \\
1102 userdel lfs; \\
1103 rm -rf /home/lfs; \\
1104 fi;
1105 rm -rf \$(MOUNT_PT)/tools
1106 rm -f /tools
1107 rm -rf \$(MOUNT_PT)/cross-tools
1108 rm -f /cross-tools
1109 rm -f envars user-lfs-exist
1110 rm -f 02* logs/02*.log
1111
1112clean-chapter3:
1113 rm -rf \$(MOUNT_PT)/tools/*
1114 rm -f $cross_tools restore-lfs-env sources-dir
1115 cd logs && rm -f $cross_tools && cd ..
1116
1117clean-chapter4:
1118 -umount \$(MOUNT_PT)/sys
1119 -umount \$(MOUNT_PT)/proc
1120 -umount \$(MOUNT_PT)/dev/shm
1121 -umount \$(MOUNT_PT)/dev/pts
1122 -umount \$(MOUNT_PT)/dev
1123 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1124 rm -f $temptools
1125 cd logs && rm -f $temptools && cd ..
1126
1127
1128restore-lfs-env:
1129 @\$(call echo_message, Building)
1130 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1131 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1132 fi;
1133 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1134 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1135 fi;
1136 @chown lfs:lfs /home/lfs/.bash* && \\
1137 touch \$@
1138
1139EOF
1140) >> $MKFILE
1141
1142
1143 # Bring over the items from the Makefile.tmp
1144 cat $MKFILE.tmp >> $MKFILE
1145 rm $MKFILE.tmp
1146 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1147
1148}
1149
Note: See TracBrowser for help on using the repository browser.