source: CLFS/master.sh@ 87b93b4

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

CLFS/master.sh, removed kernel script manipulation- should be done via xsl

  • Property mode set to 100755
File size: 40.8 KB
RevLine 
[0170229]1#!/bin/sh
[1ce084e]2# $Id$
[0170229]3
4###################################
5### FUNCTIONS ###
6###################################
7
8
9
10#----------------------------#
[fcaf131]11host_prep_Makefiles() { # Initialization of the system
[0170229]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 #
[c3c4e1d]134 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
[0170229]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 #
[c3c4e1d]186 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
[0170229]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 ;;
[0271c0c]219 *kernel) # if there is no kernel config file do not build the kernel
[4845f38]220 [[ -z $CONFIG ]] && continue
[0271c0c]221 # Copy the config file to /sources with a standardized name
[6eef5ef]222 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
223 sed "s|make mrproper|make mrproper\ncp /sources/bootkernel-config .config|" -i $file
[0271c0c]224 # You cannot run menuconfig from within the makefile
[4845f38]225 sed 's|menuconfig|oldconfig|' -i $file
[0271c0c]226 #If defined include the keymap in the kernel
[4845f38]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
[0170229]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 ;;
[fcaf131]243 *bootscripts) name="bootscripts-cross-lfs" ;;
[0170229]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 #
[c3c4e1d]260 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
[0170229]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
[c3c4e1d]337 *util-linux) wrt_unpack "$name-$vrs.tar.*"
[7d018d1]338 echo -e '\ttrue' >> $MKFILE.tmp
339 ;;
340 *) wrt_unpack2 "$name-$vrs.tar.*"
341 ;;
[0170229]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#-----------------------------#
[afd0232]372 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
[0170229]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
[c3c4e1d]400 tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;;
401 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
[0170229]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#--------------------------------#
[afd0232]425 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}"
[0170229]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
[c3c4e1d]453 tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;;
454 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
[0170229]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#-----------------------------#
[afd0232]478 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system${R_arrow}"
[0170229]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 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#-----------------------------#
[afd0232]579 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system${R_arrow}"
[0170229]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 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
[c3c4e1d]659 temp-perl) wrt_unpack3 "perl-$vrs.tar.*" ;;
660 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
[0170229]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#-----------------------------#
[afd0232]693 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
[0170229]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 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@@'`
[fcaf131]734 if [[ `_IS_ $name bootscripts` ]]; then name=bootscripts-cross-lfs; fi
[0170229]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#-----------------------------#
[afd0232]771 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
[0170229]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 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 #
[c3c4e1d]826 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
[0170229]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#-----------------------------#
[afd0232]851 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
[0170229]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
[87b93b4]859 *grub*) continue ;;
860 *kernel) # if there is no kernel config file do not build the kernel
[4845f38]861 [[ -z $CONFIG ]] && continue
[0271c0c]862 # Copy the config file to /sources with a standardized name
[1917cad]863 cp $CONFIG $BUILDDIR/sources/kernel-config
[87b93b4]864 ;;
[0170229]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 #
[c3c4e1d]888 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
[0170229]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
[fcaf131]895 wrt_run_as_chroot1 "${this_script}" "${file}"
[0170229]896 fi
897 ;;
[fcaf131]898 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
[0170229]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#-----------------------------#
[afd0232]923 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}"
[0170229]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 ;;
[c3c4e1d]932 *kernel)
[0271c0c]933 # if there is no kernel config file do not build the kernel
[4845f38]934 [[ -z $CONFIG ]] && continue
[0271c0c]935 # Copy the named config file to /sources with a standardized name
[1917cad]936 cp $CONFIG $BUILDDIR/sources/kernel-config
[0271c0c]937 sed "s|make mrproper|make mrproper\ncp ../kernel-config .config|" -i $file
938 # You cannot run menuconfig from within the makefile
[0170229]939 sed 's|menuconfig|oldconfig|' -i $file
[0271c0c]940 # If defined include the keymap in the kernel
[0170229]941 if [[ -n "$KEYMAP" ]]; then
942 sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
943 else
944 sed '/loadkeys -m/d' -i $file
945 sed '/drivers\/char/d' -i $file
946 fi
947 ;;
948 esac
949 #
950 # First append each name of the script files to a list (this will become
951 # the names of the targets in the Makefile
952 bootabletools="$bootabletools $this_script"
953 #
954 # Grab the name of the target, strip id number and misc words.
955 case $this_script in
956 *kernel) name=linux
957 ;;
958 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
959 esac
960
961 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
962
963 #--------------------------------------------------------------------#
964 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
965 #--------------------------------------------------------------------#
966 #
967 # Drop in the name of the target on a new line, and the previous target
968 # as a dependency. Also call the echo_message function.
969 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
970 #
971 # If $vrs isn't empty, we've got a package...
972 # Insert instructions for unpacking the package and changing directories
973 #
[c3c4e1d]974 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
[0170229]975 #
976 # Select a script execution method
977 case $this_script in
978 *fstab*) if [[ -n "$FSTAB" ]]; then
[a9490ab]979 # Minimal boot mode has no access to original file, store in /sources
980 cp $FSTAB $BUILDDIR/sources/fstab
[0170229]981 wrt_copy_fstab2 "${this_script}"
982 else
983 wrt_run_as_root2 "${this_script}" "${file}"
984 fi
985 ;;
986 *) wrt_run_as_root2 "${this_script}" "${file}" ;;
987 esac
988 #
989 # Housekeeping...remove any build directory(ies) except if the package build fails.
990 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
991 #
992 # Include a touch of the target name so make can check if it's already been made.
993 echo -e '\t@touch $@' >> $MKFILE.tmp
994 #
995 #--------------------------------------------------------------------#
996 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
997 #--------------------------------------------------------------------#
998 #
999 # Keep the script file name for Makefile dependencies.
1000 PREV=$this_script
1001
1002 done
1003
1004}
1005
1006
1007
1008#-----------------------------#
1009the_end_Makefiles() { #
1010#-----------------------------#
1011 echo "${tab_}${GREEN}Processing... ${L_arrow}THE END${R_arrow}"
1012}
1013
1014
1015#-----------------------------#
1016build_Makefile() { # Construct a Makefile from the book scripts
1017#-----------------------------#
1018 echo "Creating Makefile... ${BOLD}START${OFF}"
1019
1020 cd $JHALFSDIR/${PROGNAME}-commands
1021 # Start with a clean Makefile.tmp file
1022 >$MKFILE.tmp
1023
1024 host_prep_Makefiles
1025 cross_tools_Makefiles
1026 temptools_Makefiles
[afd0232]1027 if [[ $METHOD = "chroot" ]]; then
[0170229]1028 chroot_Makefiles
1029 if [[ $TOOLCHAINTEST = "1" ]]; then
1030 testsuite_tools_Makefiles
1031 fi
1032 final_system_Makefiles
1033 bootscripts_Makefiles
1034 bootable_Makefiles
1035 else
1036 boot_Makefiles # This phase must die at the end of its run..
1037 if [[ $TOOLCHAINTEST = "1" ]]; then
1038 bm_testsuite_tools_Makefiles
1039 fi
1040 bm_final_system_Makefiles
1041 bm_bootscripts_Makefiles
1042 bm_bootable_Makefiles
1043 fi
1044# the_end_Makefiles
1045
1046
1047 # Add a header, some variables and include the function file
1048 # to the top of the real Makefile.
1049(
1050 cat << EOF
1051$HEADER
1052
1053SRC= /sources
1054MOUNT_PT= $BUILDDIR
1055
1056include makefile-functions
1057
1058EOF
1059) > $MKFILE
1060
1061 # Add chroot commands
[e676ffa]1062 if [ "$METHOD" = "chroot" ] ; then
1063 chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
[0170229]1064 -e '/^export/d' \
1065 -e '/^logout/d' \
1066 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
1067 -e 's|\\$|&&|g' \
1068 -e 's|exit||g' \
1069 -e 's|$| -c|' \
1070 -e 's|"$$LFS"|$(MOUNT_PT)|'\
1071 -e 's|set -e||'`
[e676ffa]1072 echo -e "CHROOT1= $chroot\n" >> $MKFILE
1073 fi
[0170229]1074
1075 # Drop in the main target 'all:' and the chapter targets with each sub-target
1076 # as a dependency.
1077(
1078 cat << EOF
1079all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8
1080 @\$(call echo_finished,$VERSION)
1081
1082chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
1083
1084chapter3: chapter2 $cross_tools
1085
1086chapter4: chapter3 $temptools
1087
1088chapter5: chapter4 $chroottools $boottools
1089
1090chapter6: chapter5 $basicsystem
1091
1092chapter7: chapter6 $bootscripttools
1093
1094chapter8: chapter7 $bootabletools
1095
1096clean-all: clean
1097 rm -rf ./{${PROGNAME}-commands,logs,Makefile,dump-clfs-scripts.xsl,functions,packages,patches}
1098
1099clean: clean-chapter4 clean-chapter3 clean-chapter2
1100
1101clean-chapter2:
1102 -if [ ! -f user-lfs-exist ]; then \\
1103 userdel lfs; \\
1104 rm -rf /home/lfs; \\
1105 fi;
1106 rm -rf \$(MOUNT_PT)/tools
1107 rm -f /tools
1108 rm -rf \$(MOUNT_PT)/cross-tools
1109 rm -f /cross-tools
1110 rm -f envars user-lfs-exist
1111 rm -f 02* logs/02*.log
1112
1113clean-chapter3:
1114 rm -rf \$(MOUNT_PT)/tools/*
1115 rm -f $cross_tools restore-lfs-env sources-dir
1116 cd logs && rm -f $cross_tools && cd ..
1117
1118clean-chapter4:
1119 -umount \$(MOUNT_PT)/sys
1120 -umount \$(MOUNT_PT)/proc
1121 -umount \$(MOUNT_PT)/dev/shm
1122 -umount \$(MOUNT_PT)/dev/pts
1123 -umount \$(MOUNT_PT)/dev
1124 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1125 rm -f $temptools
1126 cd logs && rm -f $temptools && cd ..
1127
1128
1129restore-lfs-env:
1130 @\$(call echo_message, Building)
1131 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1132 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1133 fi;
1134 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1135 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1136 fi;
1137 @chown lfs:lfs /home/lfs/.bash* && \\
1138 touch \$@
1139
1140EOF
1141) >> $MKFILE
1142
1143
1144 # Bring over the items from the Makefile.tmp
1145 cat $MKFILE.tmp >> $MKFILE
1146 rm $MKFILE.tmp
1147 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1148
1149}
1150
Note: See TracBrowser for help on using the repository browser.