source: CLFS/master.sh@ 1d756b0

experimental
Last change on this file since 1d756b0 was 7161bc9, checked in by George Boudreau <georgeb@…>, 19 years ago

Remove custom func extract_commands from master.sh..

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