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