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