1 | #!/bin/sh
|
---|
2 |
|
---|
3 | ###################################
|
---|
4 | ### FUNCTIONS ###
|
---|
5 | ###################################
|
---|
6 |
|
---|
7 | unset extract_commands
|
---|
8 | #----------------------------#
|
---|
9 | extract_commands() { #
|
---|
10 | #----------------------------#
|
---|
11 |
|
---|
12 | #Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
13 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
14 | exit 1"
|
---|
15 |
|
---|
16 | cd $JHALFSDIR
|
---|
17 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
18 |
|
---|
19 | # Start clean
|
---|
20 | if [ -d ${PROGNAME}-commands ]; then
|
---|
21 | rm -rf ${PROGNAME}-commands
|
---|
22 | else
|
---|
23 | mkdir -v ${PROGNAME}-commands
|
---|
24 | fi
|
---|
25 | echo "Extracting commands... ${BOLD}START${OFF}"
|
---|
26 |
|
---|
27 | echo "${tab_}Extracting commands for ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
28 | xsltproc --xinclude \
|
---|
29 | --nonet \
|
---|
30 | --output ./${PROGNAME}-commands/ \
|
---|
31 | $BOOK/stylesheets/dump-commands.xsl $BOOK/$ARCH-index.xml
|
---|
32 |
|
---|
33 | # Grab the patches and package names.
|
---|
34 | cd $JHALFSDIR
|
---|
35 |
|
---|
36 | echo "${tab_}Creating the packages and patches files" ;
|
---|
37 | for i in patches packages ; do rm -f $i ; done
|
---|
38 |
|
---|
39 | grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
|
---|
40 | -e 's@">@"@' \
|
---|
41 | -e '/generic/d' >> packages
|
---|
42 |
|
---|
43 | # Download the vim-lang package if it must be installed
|
---|
44 | if [ "$VIMLANG" = "1" ] ; then
|
---|
45 | echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
|
---|
46 | fi
|
---|
47 |
|
---|
48 | grep "^<\!ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
|
---|
49 | # Needed for Groff patchlevel patch
|
---|
50 | GROFFLEVEL=`grep "groff-patchlevel" $BOOK/general.ent | sed -e 's/groff-patchlevel //' \
|
---|
51 | -e 's/"//g' \
|
---|
52 | -e 's@<!ENTITY @@' \
|
---|
53 | -e 's|>||'`
|
---|
54 | sed -i 's|&groff-patchlevel;|'$GROFFLEVEL'|' patches
|
---|
55 |
|
---|
56 |
|
---|
57 | # Preprocess the cmd scripts..
|
---|
58 | echo "${tab_}Preprocessing the cmd scripts"
|
---|
59 | #
|
---|
60 | local file this_script package vrs URLs
|
---|
61 | #
|
---|
62 | # Create a list of URLs..
|
---|
63 | echo "${tab_}${tab_}Writing a list of URLs to filelist_.wget "
|
---|
64 | xsltproc --nonet \
|
---|
65 | --xinclude \
|
---|
66 | -o filelist_.wget \
|
---|
67 | $BOOK/stylesheets/wget.xsl \
|
---|
68 | $BOOK/$ARCH-index.xml > /dev/null 2>&1
|
---|
69 | #
|
---|
70 | # Loop through all the command scripts
|
---|
71 | echo "${tab_}${tab_}Modifying the cmd scripts"
|
---|
72 | for file in `ls ${PROGNAME}-commands/*/*`;do
|
---|
73 | #
|
---|
74 | # 1. Compress the script file (remove blank lines)
|
---|
75 | # 2. Add a variable header and a footer to selected scripts
|
---|
76 | this_script=`basename $file`
|
---|
77 | #
|
---|
78 | # DO NOT play with the chroot scripts.. they are used as is later
|
---|
79 | [[ `_IS_ $this_script "chroot"` ]] && continue
|
---|
80 | #
|
---|
81 | # Strip leading index number and misc test.. This is a miserable method
|
---|
82 | package=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
83 | -e 's@-static@@' \
|
---|
84 | -e 's@-final@@' \
|
---|
85 | -e 's@temp-@@' \
|
---|
86 | -e 's@-64bit@@' \
|
---|
87 | -e 's@-64@@' \
|
---|
88 | -e 's@64@@' \
|
---|
89 | -e 's@-n32@@' \
|
---|
90 | -e 's@-build@@' \
|
---|
91 | -e 's@glibc-headers@glibc@'`
|
---|
92 | #
|
---|
93 | # Find the package version of the command files
|
---|
94 | #
|
---|
95 | # A little package name manipulation
|
---|
96 | case $package in
|
---|
97 | bootscripts) package="lfs-bootscripts" ;;
|
---|
98 | kernel) package="linux" ;;
|
---|
99 | esac
|
---|
100 | vrs=`grep "^$package-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
101 | #
|
---|
102 | # If $vrs isn't empty, we've got a package...
|
---|
103 | # NOTE: The included \n causes the separator to be written
|
---|
104 | # on the next line. This is for cosmetic purposes only...
|
---|
105 | #
|
---|
106 | # Set the appropriate 'sha-bang'.. depending of the phase..
|
---|
107 | case $package in
|
---|
108 | *introduction* | \
|
---|
109 | *changingowner* | \
|
---|
110 | *creatingdirs* | \
|
---|
111 | *createfiles* ) sha_bang=''
|
---|
112 | ;;
|
---|
113 | *) sha_bang='#!/bin/bash'
|
---|
114 | ;;
|
---|
115 | esac
|
---|
116 | #
|
---|
117 | #
|
---|
118 | if [ "$vrs" != "" ] ; then
|
---|
119 | HEADER_STR="cd \$PKGDIR${nl_}#------------------"
|
---|
120 | FOOTER_STR="#------------------${nl_}exit"
|
---|
121 | else
|
---|
122 | HEADER_STR="#------------------"
|
---|
123 | FOOTER_STR="#------------------${nl_}exit"
|
---|
124 | fi
|
---|
125 | PKG_URL=`grep -e "$package-$vrs.*tar." $JHALFSDIR/filelist_.wget` && true
|
---|
126 | PATCHES=`grep "$package-$vrs.*patch" $JHALFSDIR/filelist_.wget` && true
|
---|
127 | #
|
---|
128 | # There would be no URL for a cmd only script, reset package name
|
---|
129 | if [[ $PKG_URL = "" ]]; then
|
---|
130 | package=""
|
---|
131 | fi
|
---|
132 | (
|
---|
133 | cat << EOF
|
---|
134 | ${sha_bang}
|
---|
135 | set -e
|
---|
136 |
|
---|
137 | #####################################
|
---|
138 | NAME=${this_script}
|
---|
139 | PACKAGE=${package}
|
---|
140 | VERSION=${vrs}
|
---|
141 | PKG_URL=( ${PKG_URL} )
|
---|
142 | PATCHES=( ${PATCHES} )
|
---|
143 | #####################################
|
---|
144 |
|
---|
145 | ${HEADER_STR}
|
---|
146 | `grep '.' ${file}`
|
---|
147 | ${FOOTER_STR}
|
---|
148 | EOF
|
---|
149 | ) > tmp.script
|
---|
150 | mv tmp.script ${file}
|
---|
151 |
|
---|
152 | done # for file in `ls $PROGNAME-commands/*/*`
|
---|
153 | #
|
---|
154 | # Make the scripts executable.
|
---|
155 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
156 |
|
---|
157 | # Done. Moving on...
|
---|
158 | echo "Extracting commands... ${BOLD}DONE${OFF}"
|
---|
159 | get_sources
|
---|
160 |
|
---|
161 | }
|
---|
162 |
|
---|
163 |
|
---|
164 |
|
---|
165 | #----------------------------#
|
---|
166 | host_prep_Makefiles() { # Initialization of the system
|
---|
167 | #----------------------------#
|
---|
168 | local LFS_HOST
|
---|
169 |
|
---|
170 | echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files${R_arrow}"
|
---|
171 |
|
---|
172 | # defined here, only for ease of reading
|
---|
173 | LFS_HOST="`echo ${MACHTYPE} | sed -e 's/unknown/cross/g' -e 's/-pc-/-cross-/g'`"
|
---|
174 | (
|
---|
175 | cat << EOF
|
---|
176 | 023-creatingtoolsdir:
|
---|
177 | @\$(call echo_message, Building)
|
---|
178 | @mkdir -v \$(MOUNT_PT)/tools && \\
|
---|
179 | rm -fv /tools && \\
|
---|
180 | ln -sv \$(MOUNT_PT)/tools /
|
---|
181 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
182 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
183 | fi;
|
---|
184 | @chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
185 | touch \$@
|
---|
186 |
|
---|
187 | 024-creatingcrossdir: 023-creatingtoolsdir
|
---|
188 | @mkdir -v \$(MOUNT_PT)/cross-tools && \\
|
---|
189 | rm -fv /cross-tools && \\
|
---|
190 | ln -sv \$(MOUNT_PT)/cross-tools /
|
---|
191 | @touch \$@
|
---|
192 |
|
---|
193 | 025-addinguser: 024-creatingcrossdir
|
---|
194 | @\$(call echo_message, Building)
|
---|
195 | @if [ ! -d /home/lfs ]; then \\
|
---|
196 | groupadd lfs; \\
|
---|
197 | useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
---|
198 | else \\
|
---|
199 | touch user-lfs-exist; \\
|
---|
200 | fi;
|
---|
201 | @chown lfs \$(MOUNT_PT) && \\
|
---|
202 | chown lfs \$(MOUNT_PT)/tools && \\
|
---|
203 | chown lfs \$(MOUNT_PT)/cross-tools && \\
|
---|
204 | chown lfs \$(MOUNT_PT)/sources && \\
|
---|
205 | touch \$@
|
---|
206 |
|
---|
207 | 026-settingenvironment: 025-addinguser
|
---|
208 | @\$(call echo_message, Building)
|
---|
209 | @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
210 | mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
---|
211 | fi;
|
---|
212 | @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
213 | mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
---|
214 | fi;
|
---|
215 | @echo "set +h" > /home/lfs/.bashrc && \\
|
---|
216 | echo "umask 022" >> /home/lfs/.bashrc && \\
|
---|
217 | echo "LFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
|
---|
218 | echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
---|
219 | echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
---|
220 | echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
---|
221 | echo "" >> /home/lfs/.bashrc && \\
|
---|
222 | echo "unset CFLAGS" >> /home/lfs/.bashrc && \\
|
---|
223 | echo "unset CXXFLAGS" >> /home/lfs/.bashrc && \\
|
---|
224 | echo "" >> /home/lfs/.bashrc && \\
|
---|
225 | echo "export LFS_HOST=\"${LFS_HOST}\"" >> /home/lfs/.bashrc && \\
|
---|
226 | echo "export LFS_TARGET=\"${TARGET}\"" >> /home/lfs/.bashrc && \\
|
---|
227 | echo "export LFS_TARGET32=\"${TARGET32}\"" >> /home/lfs/.bashrc && \\
|
---|
228 | echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc
|
---|
229 | @chown lfs:lfs /home/lfs/.bashrc && \\
|
---|
230 | touch envars && \\
|
---|
231 | touch \$@
|
---|
232 | EOF
|
---|
233 | ) >> $MKFILE.tmp
|
---|
234 |
|
---|
235 | }
|
---|
236 |
|
---|
237 |
|
---|
238 |
|
---|
239 | #-----------------------------#
|
---|
240 | cross_tools_Makefiles() { #
|
---|
241 | #-----------------------------#
|
---|
242 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}"
|
---|
243 |
|
---|
244 | for file in cross-tools/* ; do
|
---|
245 | # Keep the script file name
|
---|
246 | this_script=`basename $file`
|
---|
247 | #
|
---|
248 | # Skip this script...
|
---|
249 | case $this_script in
|
---|
250 | *cflags* | *variables* ) # work done in host_prep_Makefiles
|
---|
251 | continue; ;;
|
---|
252 | *) ;;
|
---|
253 | esac
|
---|
254 | #
|
---|
255 | # Set the dependency for the first target.
|
---|
256 | if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
|
---|
257 |
|
---|
258 | # First append each name of the script files to a list (this will become
|
---|
259 | # the names of the targets in the Makefile
|
---|
260 | cross_tools="$cross_tools $this_script"
|
---|
261 |
|
---|
262 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
263 | # and binutils in chapter 5)
|
---|
264 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
265 | -e 's@-static@@' \
|
---|
266 | -e 's@-final@@' \
|
---|
267 | -e 's@-headers@@' \
|
---|
268 | -e 's@-64@@' \
|
---|
269 | -e 's@-n32@@'`
|
---|
270 | # Adjust 'name' and patch a few scripts on the fly..
|
---|
271 | case $name in
|
---|
272 | linux-libc) name=linux-libc-headers ;;
|
---|
273 | esac
|
---|
274 | #
|
---|
275 | # Find the version of the command files, if it corresponds with the building of a specific package
|
---|
276 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
277 |
|
---|
278 |
|
---|
279 | #--------------------------------------------------------------------#
|
---|
280 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
281 | #--------------------------------------------------------------------#
|
---|
282 | #
|
---|
283 | # Drop in the name of the target on a new line, and the previous target
|
---|
284 | # as a dependency. Also call the echo_message function.
|
---|
285 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
286 | #
|
---|
287 | # If $vrs isn't empty, we've got a package...
|
---|
288 | #
|
---|
289 | [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar"
|
---|
290 | #
|
---|
291 | wrt_run_as_lfs "${this_script}" "${file}"
|
---|
292 | #
|
---|
293 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
294 | #
|
---|
295 | # Include a touch of the target name so make can check if it's already been made.
|
---|
296 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
297 | #
|
---|
298 | #--------------------------------------------------------------------#
|
---|
299 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
300 | #--------------------------------------------------------------------#
|
---|
301 | #
|
---|
302 | # Keep the script file name for Makefile dependencies.
|
---|
303 | PREV=$this_script
|
---|
304 |
|
---|
305 | done # for file in ....
|
---|
306 | }
|
---|
307 |
|
---|
308 |
|
---|
309 | #-----------------------------#
|
---|
310 | temptools_Makefiles() { #
|
---|
311 | #-----------------------------#
|
---|
312 | echo "${tab_}${GREEN}Processing... ${L_arrow}temp system${R_arrow}"
|
---|
313 |
|
---|
314 | for file in temp-system/* ; do
|
---|
315 | # Keep the script file name
|
---|
316 | this_script=`basename $file`
|
---|
317 | #
|
---|
318 | # First append each name of the script files to a list (this will become
|
---|
319 | # the names of the targets in the Makefile
|
---|
320 | temptools="$temptools $this_script"
|
---|
321 |
|
---|
322 | #
|
---|
323 | # Grab the name of the target, strip id number, XXX-script
|
---|
324 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
325 | #
|
---|
326 | # Find the version of the command files, if it corresponds with the building of a specific package
|
---|
327 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
328 |
|
---|
329 |
|
---|
330 | #--------------------------------------------------------------------#
|
---|
331 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
332 | #--------------------------------------------------------------------#
|
---|
333 | #
|
---|
334 | # Drop in the name of the target on a new line, and the previous target
|
---|
335 | # as a dependency. Also call the echo_message function.
|
---|
336 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
337 | #
|
---|
338 | # If $vrs isn't empty, we've got a package...
|
---|
339 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
340 | #
|
---|
341 | [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar"
|
---|
342 | #
|
---|
343 | wrt_run_as_lfs "${this_script}" "${file}"
|
---|
344 | #
|
---|
345 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
346 | #
|
---|
347 | # Include a touch of the target name so make can check if it's already been made.
|
---|
348 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
349 | #
|
---|
350 | #--------------------------------------------------------------------#
|
---|
351 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
352 | #--------------------------------------------------------------------#
|
---|
353 | #
|
---|
354 | # Keep the script file name for Makefile dependencies.
|
---|
355 | PREV=$this_script
|
---|
356 | done # for file in ....
|
---|
357 | }
|
---|
358 |
|
---|
359 |
|
---|
360 | #-----------------------------#
|
---|
361 | boot_Makefiles() { #
|
---|
362 | #-----------------------------#
|
---|
363 | echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}"
|
---|
364 |
|
---|
365 | for file in boot/* ; do
|
---|
366 | # Keep the script file name
|
---|
367 | this_script=`basename $file`
|
---|
368 |
|
---|
369 | # A little housekeeping on the scripts
|
---|
370 | case $this_script in
|
---|
371 | *grub*) continue ;;
|
---|
372 | *whatnext*) continue ;;
|
---|
373 | *settingenvironment*) sed 's@PS1=@set +h\nPS1=@' -i $file ;;
|
---|
374 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
375 | [[ -z $CONFIG ]] && continue
|
---|
376 | sed "s|make mrproper|make mrproper\ncp $CONFIG .config|" -i $file
|
---|
377 | # You cannot run menuconfig from within the makefile
|
---|
378 | sed 's|menuconfig|oldconfig|' -i $file
|
---|
379 | #If defined include the keymap in the kernel
|
---|
380 | if [[ -n "$KEYMAP" ]]; then
|
---|
381 | sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
|
---|
382 | else
|
---|
383 | sed '/loadkeys -m/d' -i $file
|
---|
384 | sed '/drivers\/char/d' -i $file
|
---|
385 | fi
|
---|
386 | ;;
|
---|
387 | esac
|
---|
388 | #
|
---|
389 | # First append each name of the script files to a list (this will become
|
---|
390 | # the names of the targets in the Makefile
|
---|
391 | boottools="$boottools $this_script"
|
---|
392 | #
|
---|
393 | # Grab the name of the target, strip id number and misc words.
|
---|
394 | case $this_script in
|
---|
395 | *kernel) name=linux ;;
|
---|
396 | *bootscripts) name=lfs-bootscripts ;;
|
---|
397 | *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
|
---|
398 | esac
|
---|
399 |
|
---|
400 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
401 |
|
---|
402 | #--------------------------------------------------------------------#
|
---|
403 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
404 | #--------------------------------------------------------------------#
|
---|
405 | #
|
---|
406 | # Drop in the name of the target on a new line, and the previous target
|
---|
407 | # as a dependency. Also call the echo_message function.
|
---|
408 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
409 | #
|
---|
410 | # If $vrs isn't empty, we've got a package...
|
---|
411 | # Insert instructions for unpacking the package and changing directories
|
---|
412 | #
|
---|
413 | [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
|
---|
414 | #
|
---|
415 | # Select a script execution method
|
---|
416 | case $this_script in
|
---|
417 | *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;;
|
---|
418 | *devices*) wrt_run_as_root "${this_script}" "${file}" ;;
|
---|
419 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
420 | wrt_copy_fstab "${this_script}"
|
---|
421 | else
|
---|
422 | wrt_run_as_lfs "${this_script}" "${file}"
|
---|
423 | fi
|
---|
424 | ;;
|
---|
425 | *) wrt_run_as_lfs "${this_script}" "${file}" ;;
|
---|
426 | esac
|
---|
427 | #
|
---|
428 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
429 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
430 | #
|
---|
431 | # Include a touch of the target name so make can check if it's already been made.
|
---|
432 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
433 | #
|
---|
434 | #--------------------------------------------------------------------#
|
---|
435 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
436 | #--------------------------------------------------------------------#
|
---|
437 | #
|
---|
438 | # Keep the script file name for Makefile dependencies.
|
---|
439 | PREV=$this_script
|
---|
440 |
|
---|
441 | done
|
---|
442 | # This will force the Makefile to exit and not allow it to be restarted with
|
---|
443 | # the command <make>, The user will have to issue the cmd <make chapterXX>
|
---|
444 | echo -e "\t@\$(call echo_boot_finished,$VERSION) && \\" >> $MKFILE.tmp
|
---|
445 | echo -e "\tfalse" >> $MKFILE.tmp
|
---|
446 | }
|
---|
447 |
|
---|
448 |
|
---|
449 | #-----------------------------#
|
---|
450 | chroot_Makefiles() { #
|
---|
451 | #-----------------------------#
|
---|
452 | echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}"
|
---|
453 |
|
---|
454 | for file in chroot/* ; do
|
---|
455 | # Keep the script file name
|
---|
456 | this_script=`basename $file`
|
---|
457 | #
|
---|
458 | # Skipping scripts is done now and not included in the build tree.
|
---|
459 | [[ `_IS_ $this_script chroot` ]] && continue
|
---|
460 |
|
---|
461 | #
|
---|
462 | # First append each name of the script files to a list (this will become
|
---|
463 | # the names of the targets in the Makefile
|
---|
464 | chroottools="$chroottools $this_script"
|
---|
465 |
|
---|
466 | #
|
---|
467 | # A little housekeeping on the script contents
|
---|
468 | case $this_script in
|
---|
469 | *kernfs*) sed '/exit/d' -i $file ;;
|
---|
470 | *pwdgroup*) sed '/exec/d' -i $file ;;
|
---|
471 | esac
|
---|
472 | #
|
---|
473 | # Grab the name of the target, strip id number, XXX-script
|
---|
474 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
475 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
476 |
|
---|
477 | #--------------------------------------------------------------------#
|
---|
478 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
479 | #--------------------------------------------------------------------#
|
---|
480 | #
|
---|
481 | # Drop in the name of the target on a new line, and the previous target
|
---|
482 | # as a dependency. Also call the echo_message function.
|
---|
483 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
484 | #
|
---|
485 | # If $vrs isn't empty, we've got a package...
|
---|
486 | # Insert instructions for unpacking the package and changing directories
|
---|
487 | #
|
---|
488 | if [ "$vrs" != "" ] ; then
|
---|
489 | case $this_script in
|
---|
490 | *util-linux) wrt_unpack "$name-$vrs.tar" ;;
|
---|
491 | *) wrt_unpack2 "$name-$vrs.tar.*" ;;
|
---|
492 | esac
|
---|
493 | fi
|
---|
494 | #
|
---|
495 | # Select a script execution method
|
---|
496 | case $this_script in
|
---|
497 | *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
|
---|
498 | *util-linux) wrt_run_as_lfs "${this_script}" "${file}" ;;
|
---|
499 | *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
|
---|
500 | esac
|
---|
501 | #
|
---|
502 | # Housekeeping...remove the build directory(ies), except if the package build fails.
|
---|
503 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
504 | #
|
---|
505 | # Include a touch of the target name so make can check if it's already been made.
|
---|
506 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
507 | #
|
---|
508 | #--------------------------------------------------------------------#
|
---|
509 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
510 | #--------------------------------------------------------------------#
|
---|
511 | #
|
---|
512 | # Keep the script file name for Makefile dependencies.
|
---|
513 | PREV=$this_script
|
---|
514 |
|
---|
515 | done # for file in...
|
---|
516 | }
|
---|
517 |
|
---|
518 |
|
---|
519 | #-----------------------------#
|
---|
520 | testsuite_tools_Makefiles() { #
|
---|
521 | #-----------------------------#
|
---|
522 | echo "${tab_}${GREEN}Processing... ${L_arrow}testsuite tools${R_arrow}"
|
---|
523 |
|
---|
524 | for file in testsuite-tools/* ; do
|
---|
525 | # Keep the script file name
|
---|
526 | this_script=`basename $file`
|
---|
527 |
|
---|
528 | # First append each name of the script files to a list (this will become
|
---|
529 | # the names of the targets in the Makefile
|
---|
530 | testsuitetools="$testsuitetools $this_script"
|
---|
531 |
|
---|
532 | # Grab the name of the target, strip id number, XXX-script
|
---|
533 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
534 | -e 's@-64bit@@' \
|
---|
535 | -e 's@-64@@' \
|
---|
536 | -e 's@64@@' \
|
---|
537 | -e 's@n32@@'`
|
---|
538 |
|
---|
539 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
540 |
|
---|
541 | #--------------------------------------------------------------------#
|
---|
542 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
543 | #--------------------------------------------------------------------#
|
---|
544 | #
|
---|
545 | # Drop in the name of the target on a new line, and the previous target
|
---|
546 | # as a dependency. Also call the echo_message function.
|
---|
547 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
548 | #
|
---|
549 | case $name in
|
---|
550 | tcl) wrt_unpack2 "$name$vrs-src.tar" ;;
|
---|
551 | *) wrt_unpack2 "$name-$vrs.tar" ;;
|
---|
552 | esac
|
---|
553 | #
|
---|
554 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
555 | #
|
---|
556 | wrt_remove_build_dirs "${name}"
|
---|
557 | #
|
---|
558 | # Include a touch of the target name so make can check if it's already been made.
|
---|
559 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
560 | #
|
---|
561 | #--------------------------------------------------------------------#
|
---|
562 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
563 | #--------------------------------------------------------------------#
|
---|
564 | #
|
---|
565 | # Keep the script file name for Makefile dependencies.
|
---|
566 | PREV=$this_script
|
---|
567 |
|
---|
568 | done
|
---|
569 | }
|
---|
570 |
|
---|
571 |
|
---|
572 | #--------------------------------#
|
---|
573 | bm_testsuite_tools_Makefiles() { #
|
---|
574 | #--------------------------------#
|
---|
575 | echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) testsuite tools${R_arrow}"
|
---|
576 |
|
---|
577 | for file in testsuite-tools/* ; do
|
---|
578 | # Keep the script file name
|
---|
579 | this_script=`basename $file`
|
---|
580 |
|
---|
581 | # First append each name of the script files to a list (this will become
|
---|
582 | # the names of the targets in the Makefile
|
---|
583 | testsuitetools="$testsuitetools $this_script"
|
---|
584 |
|
---|
585 | # Grab the name of the target, strip id number, XXX-script
|
---|
586 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
587 | -e 's@-64bit@@' \
|
---|
588 | -e 's@-64@@' \
|
---|
589 | -e 's@64@@' \
|
---|
590 | -e 's@n32@@'`
|
---|
591 |
|
---|
592 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
593 |
|
---|
594 | #--------------------------------------------------------------------#
|
---|
595 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
596 | #--------------------------------------------------------------------#
|
---|
597 | #
|
---|
598 | # Drop in the name of the target on a new line, and the previous target
|
---|
599 | # as a dependency. Also call the echo_message function.
|
---|
600 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
601 | #
|
---|
602 | case $name in
|
---|
603 | tcl) wrt_unpack4 "$name$vrs-src.tar.*" ;;
|
---|
604 | *) wrt_unpack4 "$name-$vrs.tar.*" ;;
|
---|
605 | esac
|
---|
606 | #
|
---|
607 | wrt_run_as_root2 "${this_script}" "${file}"
|
---|
608 | #
|
---|
609 | wrt_remove_build_dirs2 "${name}"
|
---|
610 | #
|
---|
611 | # Include a touch of the target name so make can check if it's already been made.
|
---|
612 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
613 | #
|
---|
614 | #--------------------------------------------------------------------#
|
---|
615 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
616 | #--------------------------------------------------------------------#
|
---|
617 | #
|
---|
618 | # Keep the script file name for Makefile dependencies.
|
---|
619 | PREV=$this_script
|
---|
620 |
|
---|
621 | done
|
---|
622 | }
|
---|
623 |
|
---|
624 |
|
---|
625 | #-----------------------------#
|
---|
626 | final_system_Makefiles() { #
|
---|
627 | #-----------------------------#
|
---|
628 | echo "${tab_}${GREEN}Processing... ${L_arrow}final system${R_arrow}"
|
---|
629 |
|
---|
630 | for file in final-system/* ; do
|
---|
631 | # Keep the script file name
|
---|
632 | this_script=`basename $file`
|
---|
633 |
|
---|
634 | # Skipping scripts is done now so they are not included in the Makefile.
|
---|
635 | case $this_script in
|
---|
636 | *stripping*) continue ;;
|
---|
637 | *grub*) continue ;;
|
---|
638 | esac
|
---|
639 | #
|
---|
640 | # First append each name of the script files to a list (this will become
|
---|
641 | # the names of the targets in the Makefile
|
---|
642 | basicsystem="$basicsystem $this_script"
|
---|
643 | #
|
---|
644 | # A little customizing via sed scripts first..
|
---|
645 | if [[ $TEST = "0" ]]; then
|
---|
646 | # Drop any package checks..
|
---|
647 | sed -e '/make check/d' -e '/make test/d' -i $file
|
---|
648 | fi
|
---|
649 | case $this_script in
|
---|
650 | *coreutils*) sed 's@set -e@set -e; set +h@' -i $file ;;
|
---|
651 | *groff*) sed "s@\*\*EDITME.*EDITME\*\*@$PAGE@" -i $file ;;
|
---|
652 | *vim*) sed '/vim -c/d' -i $file ;;
|
---|
653 | *bash*) sed '/exec /d' -i $file ;;
|
---|
654 | *shadow*) sed -e '/grpconv/d' -e '/pwconv/d' -e '/passwd root/d' -i $file
|
---|
655 | sed '/sed -i libtool/d' -i $file
|
---|
656 | sed '/search_path/d' -i $file
|
---|
657 | ;;
|
---|
658 | *glibc*) sed '/tzselect/d' -i $file
|
---|
659 | sed "s@\*\*EDITME.*EDITME\*\*@$TIMEZONE@" -i $file
|
---|
660 | # Manipulate glibc's test to work with Makefile
|
---|
661 | sed -e 's/glibc-check-log.*//' \
|
---|
662 | -e 's@make -k check >@make -k check >glibc-check-log 2>\&1 || true\ngrep Error glibc-check-log || true@' -i $file
|
---|
663 | ;;
|
---|
664 | *binutils*) sed '/expect /d' -i $file
|
---|
665 | if [[ $TOOLCHAINTEST = "0" ]]; then
|
---|
666 | sed '/make check/d' -i $file
|
---|
667 | fi
|
---|
668 | ;;
|
---|
669 | *gcc*) # Ignore all gcc testing for now..
|
---|
670 | sed -e '/make -k check/d' -i $file
|
---|
671 | sed -e '/test_summary/d' -i $file
|
---|
672 | ;;
|
---|
673 | *texinfo*) # This sucks as a way to trim a script
|
---|
674 | sed -e '/cd \/usr/d' \
|
---|
675 | -e '/rm dir/d' \
|
---|
676 | -e '/for f in/d' \
|
---|
677 | -e '/do inst/d' \
|
---|
678 | -e '/done/d' -i $file
|
---|
679 | ;;
|
---|
680 | esac
|
---|
681 |
|
---|
682 | # Grab the name of the target, strip id number, XXX-script
|
---|
683 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
684 | -e 's@temp-@@' \
|
---|
685 | -e 's@-64bit@@' \
|
---|
686 | -e 's@-64@@' \
|
---|
687 | -e 's@64@@' \
|
---|
688 | -e 's@n32@@'`
|
---|
689 |
|
---|
690 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
691 |
|
---|
692 | #--------------------------------------------------------------------#
|
---|
693 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
694 | #--------------------------------------------------------------------#
|
---|
695 | #
|
---|
696 | # Drop in the name of the target on a new line, and the previous target
|
---|
697 | # as a dependency. Also call the echo_message function.
|
---|
698 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
699 |
|
---|
700 | # If $vrs isn't empty, we've got a package...
|
---|
701 | if [ "$vrs" != "" ] ; then
|
---|
702 | case $name in
|
---|
703 | temp-perl) wrt_unpack2 "perl-$vrs.tar.*" ;;
|
---|
704 | *) wrt_unpack2 "$name-$vrs.tar.*" ;;
|
---|
705 | esac
|
---|
706 | #
|
---|
707 | # Export a few 'config' vars..
|
---|
708 | case $this_script in
|
---|
709 | *glibc*) # For glibc we can set then TIMEZONE envar.
|
---|
710 | wrt_export_timezone ;;
|
---|
711 | *groff*) # For Groff we need to set PAGE envar.
|
---|
712 | wrt_export_pagesize ;;
|
---|
713 | esac
|
---|
714 | fi
|
---|
715 | #
|
---|
716 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
717 | #
|
---|
718 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
719 | #
|
---|
720 | # Include a touch of the target name so make can check if it's already been made.
|
---|
721 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
722 | #
|
---|
723 | #--------------------------------------------------------------------#
|
---|
724 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
725 | #--------------------------------------------------------------------#
|
---|
726 | #
|
---|
727 | # Keep the script file name for Makefile dependencies.
|
---|
728 | PREV=$this_script
|
---|
729 |
|
---|
730 | done # for file in final-system/* ...
|
---|
731 | }
|
---|
732 |
|
---|
733 |
|
---|
734 | #-----------------------------#
|
---|
735 | bm_final_system_Makefiles() { #
|
---|
736 | #-----------------------------#
|
---|
737 | echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) final system${R_arrow}"
|
---|
738 |
|
---|
739 | for file in final-system/* ; do
|
---|
740 | # Keep the script file name
|
---|
741 | this_script=`basename $file`
|
---|
742 |
|
---|
743 | # Skipping scripts is done now so they are not included in the Makefile.
|
---|
744 | case $this_script in
|
---|
745 | *stripping*) continue ;;
|
---|
746 | *grub*) continue ;;
|
---|
747 | esac
|
---|
748 |
|
---|
749 | # First append each name of the script files to a list (this will become
|
---|
750 | # the names of the targets in the Makefile
|
---|
751 | basicsystem="$basicsystem $this_script"
|
---|
752 |
|
---|
753 | #
|
---|
754 | # A little customizing via sed scripts first..
|
---|
755 | if [[ $TEST = "0" ]]; then
|
---|
756 | # Drop any package checks..
|
---|
757 | sed -e '/make check/d' -e '/make test/d' -i $file
|
---|
758 | fi
|
---|
759 | case $this_script in
|
---|
760 | *coreutils*) sed 's@set -e@set -e; set +h@' -i $file ;;
|
---|
761 | *groff*) sed "s@\*\*EDITME.*EDITME\*\*@$PAGE@" -i $file ;;
|
---|
762 | *vim*) sed '/vim -c/d' -i $file ;;
|
---|
763 | *bash*) sed '/exec /d' -i $file ;;
|
---|
764 | *shadow*) sed -e '/grpconv/d' \
|
---|
765 | -e '/pwconv/d' \
|
---|
766 | -e '/passwd root/d' -i $file
|
---|
767 | sed '/sed -i libtool/d' -i $file
|
---|
768 | sed '/search_path/d' -i $file
|
---|
769 | ;;
|
---|
770 | *psmisc*) # Build fails on creation of this link. <pidof> installed in sysvinit
|
---|
771 | sed -e 's/^ln -s/#ln -s/' -i $file
|
---|
772 | ;;
|
---|
773 | *glibc*) sed '/tzselect/d' -i $file
|
---|
774 | sed "s@\*\*EDITME.*EDITME\*\*@$TIMEZONE@" -i $file
|
---|
775 | # Manipulate glibc's test to work with Makefile
|
---|
776 | sed -e 's/glibc-check-log.*//' -e 's@make -k check >@make -k check >glibc-check-log 2>\&1 || true\ngrep Error glibc-check-log || true@' -i $file
|
---|
777 | ;;
|
---|
778 | *binutils*) sed '/expect /d' -i $file
|
---|
779 | if [[ $TOOLCHAINTEST = "0" ]]; then
|
---|
780 | sed '/make check/d' -i $file
|
---|
781 | fi
|
---|
782 | ;;
|
---|
783 | *gcc*) # Ignore all gcc testing for now..
|
---|
784 | sed -e '/make -k check/d' -i $file
|
---|
785 | sed -e '/test_summary/d' -i $file
|
---|
786 | ;;
|
---|
787 | *texinfo*) # This sucks as a way to trim a script
|
---|
788 | sed -e '/cd \/usr/d' \
|
---|
789 | -e '/rm dir/d' \
|
---|
790 | -e '/for f in/d' \
|
---|
791 | -e '/do inst/d' \
|
---|
792 | -e '/done/d' -i $file
|
---|
793 | ;;
|
---|
794 | esac
|
---|
795 |
|
---|
796 | # Grab the name of the target, strip id number, XXX-script
|
---|
797 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
798 | -e 's@temp-@@' \
|
---|
799 | -e 's@-64bit@@' \
|
---|
800 | -e 's@-64@@' \
|
---|
801 | -e 's@64@@' \
|
---|
802 | -e 's@n32@@'`
|
---|
803 |
|
---|
804 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
805 |
|
---|
806 | #--------------------------------------------------------------------#
|
---|
807 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
808 | #--------------------------------------------------------------------#
|
---|
809 | #
|
---|
810 | # Drop in the name of the target on a new line, and the previous target
|
---|
811 | # as a dependency. Also call the echo_message function.
|
---|
812 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
813 |
|
---|
814 | # If $vrs isn't empty, we've got a package...
|
---|
815 | if [ "$vrs" != "" ] ; then
|
---|
816 | case $name in
|
---|
817 | temp-perl) wrt_unpack4 "perl-$vrs.tar.*" ;;
|
---|
818 | *) wrt_unpack4 "$name-$vrs.tar.*" ;;
|
---|
819 | esac
|
---|
820 | #
|
---|
821 | # Export a few 'config' vars..
|
---|
822 | case $this_script in
|
---|
823 | *glibc*) # For glibc we can set then TIMEZONE envar.
|
---|
824 | echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp ;;
|
---|
825 | *groff*) # For Groff we need to set PAGE envar.
|
---|
826 | echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp ;;
|
---|
827 | esac
|
---|
828 | fi
|
---|
829 | #
|
---|
830 | wrt_run_as_root2 "${this_script}" "${file}"
|
---|
831 | #
|
---|
832 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
|
---|
833 | #
|
---|
834 | # Include a touch of the target name so make can check if it's already been made.
|
---|
835 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
836 | #
|
---|
837 | #--------------------------------------------------------------------#
|
---|
838 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
839 | #--------------------------------------------------------------------#
|
---|
840 | #
|
---|
841 | # Keep the script file name for Makefile dependencies.
|
---|
842 | PREV=$this_script
|
---|
843 |
|
---|
844 | done # for file in final-system/* ...
|
---|
845 | }
|
---|
846 |
|
---|
847 |
|
---|
848 | #-----------------------------#
|
---|
849 | bootscripts_Makefiles() { #
|
---|
850 | #-----------------------------#
|
---|
851 | echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts${R_arrow}"
|
---|
852 |
|
---|
853 | for file in bootscripts/* ; do
|
---|
854 | # Keep the script file name
|
---|
855 | this_script=`basename $file`
|
---|
856 |
|
---|
857 | case $this_script in
|
---|
858 | *udev*) continue ;; # This is not a script but a commentary
|
---|
859 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
860 | *) ;;
|
---|
861 | esac
|
---|
862 |
|
---|
863 | # First append each name of the script files to a list (this will become
|
---|
864 | # the names of the targets in the Makefile
|
---|
865 | bootscripttools="$bootscripttools $this_script"
|
---|
866 |
|
---|
867 | # A little bit of script modification
|
---|
868 | case $this_script in
|
---|
869 | *profile*) # Over-ride the book cmds, write our own simple one.
|
---|
870 | (
|
---|
871 | cat <<- EOF
|
---|
872 | cat > /etc/profile << "_EOF_"
|
---|
873 | # Begin /etc/profile
|
---|
874 |
|
---|
875 | export LC_ALL=${LC_ALL}
|
---|
876 | export LANG=${LANG}
|
---|
877 | export INPUTRC=/etc/inputrc
|
---|
878 |
|
---|
879 | # End /etc/profile
|
---|
880 | _EOF_
|
---|
881 | EOF
|
---|
882 | ) > $file
|
---|
883 | ;;
|
---|
884 | esac
|
---|
885 |
|
---|
886 | # Grab the name of the target, strip id number, XXX-script
|
---|
887 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
888 | -e 's@-64bit@@' \
|
---|
889 | -e 's@-64@@' \
|
---|
890 | -e 's@64@@' \
|
---|
891 | -e 's@n32@@'`
|
---|
892 | if [[ `_IS_ $name bootscripts` ]]; then name=lfs-bootscripts; fi
|
---|
893 |
|
---|
894 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
895 |
|
---|
896 | #--------------------------------------------------------------------#
|
---|
897 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
898 | #--------------------------------------------------------------------#
|
---|
899 | #
|
---|
900 | # Drop in the name of the target on a new line, and the previous target
|
---|
901 | # as a dependency. Also call the echo_message function.
|
---|
902 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
903 | #
|
---|
904 | # If $vrs isn't empty, we've got a package...
|
---|
905 | #
|
---|
906 | [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
|
---|
907 | #
|
---|
908 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
909 | #
|
---|
910 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
911 | #
|
---|
912 | # Include a touch of the target name so make can check if it's already been made.
|
---|
913 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
914 | #
|
---|
915 | #--------------------------------------------------------------------#
|
---|
916 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
917 | #--------------------------------------------------------------------#
|
---|
918 | #
|
---|
919 | # Keep the script file name for Makefile dependencies.
|
---|
920 | PREV=$this_script
|
---|
921 |
|
---|
922 | done # for file in bootscripts/* ...
|
---|
923 |
|
---|
924 | }
|
---|
925 |
|
---|
926 | #-----------------------------#
|
---|
927 | bm_bootscripts_Makefiles() { #
|
---|
928 | #-----------------------------#
|
---|
929 | echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) bootscripts${R_arrow}"
|
---|
930 |
|
---|
931 | for file in bootscripts/* ; do
|
---|
932 | # Keep the script file name
|
---|
933 | this_script=`basename $file`
|
---|
934 |
|
---|
935 | case $this_script in
|
---|
936 | *udev*) continue ;; # This is not a script but a commentary
|
---|
937 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
938 | *) ;;
|
---|
939 | esac
|
---|
940 |
|
---|
941 | # First append each name of the script files to a list (this will become
|
---|
942 | # the names of the targets in the Makefile
|
---|
943 | bootscripttools="$bootscripttools $this_script"
|
---|
944 |
|
---|
945 | # A little bit of script modification
|
---|
946 | case $this_script in
|
---|
947 | *profile*) # Over-ride the book cmds, write our own simple one.
|
---|
948 | (
|
---|
949 | cat <<- EOF
|
---|
950 | cat > /etc/profile << "_EOF_"
|
---|
951 | # Begin /etc/profile
|
---|
952 |
|
---|
953 | export LC_ALL=${LC_ALL}
|
---|
954 | export LANG=${LANG}
|
---|
955 | export INPUTRC=/etc/inputrc
|
---|
956 |
|
---|
957 | # End /etc/profile
|
---|
958 | _EOF_
|
---|
959 | EOF
|
---|
960 | ) > $file
|
---|
961 | ;;
|
---|
962 | esac
|
---|
963 |
|
---|
964 | # Grab the name of the target, strip id number, XXX-script
|
---|
965 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
966 | -e 's@-64bit@@' \
|
---|
967 | -e 's@-64@@' \
|
---|
968 | -e 's@64@@' \
|
---|
969 | -e 's@n32@@'`
|
---|
970 | if [[ `_IS_ $name bootscripts` ]]; then name=lfs-bootscripts; fi
|
---|
971 |
|
---|
972 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
973 |
|
---|
974 | #--------------------------------------------------------------------#
|
---|
975 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
976 | #--------------------------------------------------------------------#
|
---|
977 | #
|
---|
978 | # Drop in the name of the target on a new line, and the previous target
|
---|
979 | # as a dependency. Also call the echo_message function.
|
---|
980 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
981 | #
|
---|
982 | # If $vrs isn't empty, we've got a package...
|
---|
983 | #
|
---|
984 | [[ "$vrs" != "" ]] && wrt_unpack4 "$name-$vrs.tar.*"
|
---|
985 | #
|
---|
986 | wrt_run_as_root2 "${this_script}" "${file}"
|
---|
987 | #
|
---|
988 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
|
---|
989 | #
|
---|
990 | # Include a touch of the target name so make can check if it's already been made.
|
---|
991 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
992 | #
|
---|
993 | #--------------------------------------------------------------------#
|
---|
994 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
995 | #--------------------------------------------------------------------#
|
---|
996 | #
|
---|
997 | # Keep the script file name for Makefile dependencies.
|
---|
998 | PREV=$this_script
|
---|
999 |
|
---|
1000 | done # for file in bootscripts/* ...
|
---|
1001 |
|
---|
1002 | }
|
---|
1003 |
|
---|
1004 |
|
---|
1005 |
|
---|
1006 | #-----------------------------#
|
---|
1007 | bootable_Makefiles() { #
|
---|
1008 | #-----------------------------#
|
---|
1009 | echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable${R_arrow}"
|
---|
1010 |
|
---|
1011 | for file in bootable/* ; do
|
---|
1012 | # Keep the script file name
|
---|
1013 | this_script=`basename $file`
|
---|
1014 |
|
---|
1015 | # A little housekeeping on the scripts
|
---|
1016 | case $this_script in
|
---|
1017 | *grub*) continue ;;
|
---|
1018 | *kernel)
|
---|
1019 | # if there is no kernel config file do not build the kernel
|
---|
1020 | [[ -z $CONFIG ]] && continue
|
---|
1021 | sed "s|make mrproper|make mrproper\ncp $CONFIG .config|" -i $file
|
---|
1022 | # You cannot run menuconfig from within the makefile
|
---|
1023 | sed 's|menuconfig|oldconfig|' -i $file
|
---|
1024 | # If defined include the keymap in the kernel
|
---|
1025 | if [[ -n "$KEYMAP" ]]; then
|
---|
1026 | sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
|
---|
1027 | else
|
---|
1028 | sed '/loadkeys -m/d' -i $file
|
---|
1029 | sed '/drivers\/char/d' -i $file
|
---|
1030 | fi
|
---|
1031 | ;;
|
---|
1032 | esac
|
---|
1033 | #
|
---|
1034 | # First append each name of the script files to a list (this will become
|
---|
1035 | # the names of the targets in the Makefile
|
---|
1036 | bootabletools="$bootabletools $this_script"
|
---|
1037 | #
|
---|
1038 | # Grab the name of the target, strip id number and misc words.
|
---|
1039 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
1040 | [[ `_IS_ $this_script "kernel"` ]] && name=linux
|
---|
1041 |
|
---|
1042 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
1043 |
|
---|
1044 | #--------------------------------------------------------------------#
|
---|
1045 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
1046 | #--------------------------------------------------------------------#
|
---|
1047 | #
|
---|
1048 | # Drop in the name of the target on a new line, and the previous target
|
---|
1049 | # as a dependency. Also call the echo_message function.
|
---|
1050 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
1051 | #
|
---|
1052 | # If $vrs isn't empty, we've got a package...
|
---|
1053 | # Insert instructions for unpacking the package and changing directories
|
---|
1054 | #
|
---|
1055 | [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
|
---|
1056 | #
|
---|
1057 | # Select a script execution method
|
---|
1058 | case $this_script in
|
---|
1059 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
1060 | wrt_copy_fstab "${this_script}"
|
---|
1061 | else
|
---|
1062 | wrt_run_as_lfs "${this_script}" "${file}"
|
---|
1063 | fi
|
---|
1064 | ;;
|
---|
1065 | *) wrt_run_as_lfs "${this_script}" "${file}" ;;
|
---|
1066 | esac
|
---|
1067 | #
|
---|
1068 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
1069 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
1070 | #
|
---|
1071 | # Include a touch of the target name so make can check if it's already been made.
|
---|
1072 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
1073 | #
|
---|
1074 | #--------------------------------------------------------------------#
|
---|
1075 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
1076 | #--------------------------------------------------------------------#
|
---|
1077 | #
|
---|
1078 | # Keep the script file name for Makefile dependencies.
|
---|
1079 | PREV=$this_script
|
---|
1080 |
|
---|
1081 | done
|
---|
1082 |
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 |
|
---|
1086 |
|
---|
1087 | #-----------------------------#
|
---|
1088 | bm_bootable_Makefiles() { #
|
---|
1089 | #-----------------------------#
|
---|
1090 | echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) make bootable${R_arrow}"
|
---|
1091 |
|
---|
1092 | for file in bootable/* ; do
|
---|
1093 | # Keep the script file name
|
---|
1094 | this_script=`basename $file`
|
---|
1095 |
|
---|
1096 | # A little housekeeping on the scripts
|
---|
1097 | case $this_script in
|
---|
1098 | *grub*) continue ;;
|
---|
1099 | *kernel)
|
---|
1100 | # if there is no kernel config file do not build the kernel
|
---|
1101 | [[ -z $CONFIG ]] && continue
|
---|
1102 | cfg_file="/sources/`basename $CONFIG`"
|
---|
1103 | sed "s|make mrproper|make mrproper\ncp $cfg_file .config|" -i $file
|
---|
1104 | # You cannot run menuconfig from within the makefile
|
---|
1105 | sed 's|menuconfig|oldconfig|' -i $file
|
---|
1106 | # If defined include the keymap in the kernel
|
---|
1107 | if [[ -n "$KEYMAP" ]]; then
|
---|
1108 | sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
|
---|
1109 | else
|
---|
1110 | sed '/loadkeys -m/d' -i $file
|
---|
1111 | sed '/drivers\/char/d' -i $file
|
---|
1112 | fi
|
---|
1113 | ;;
|
---|
1114 | esac
|
---|
1115 | #
|
---|
1116 | # First append each name of the script files to a list (this will become
|
---|
1117 | # the names of the targets in the Makefile
|
---|
1118 | bootabletools="$bootabletools $this_script"
|
---|
1119 | #
|
---|
1120 | # Grab the name of the target, strip id number and misc words.
|
---|
1121 | case $this_script in
|
---|
1122 | *kernel) name=linux
|
---|
1123 | ;;
|
---|
1124 | *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
|
---|
1125 | esac
|
---|
1126 |
|
---|
1127 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
1128 |
|
---|
1129 | #--------------------------------------------------------------------#
|
---|
1130 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
1131 | #--------------------------------------------------------------------#
|
---|
1132 | #
|
---|
1133 | # Drop in the name of the target on a new line, and the previous target
|
---|
1134 | # as a dependency. Also call the echo_message function.
|
---|
1135 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
1136 | #
|
---|
1137 | # If $vrs isn't empty, we've got a package...
|
---|
1138 | # Insert instructions for unpacking the package and changing directories
|
---|
1139 | #
|
---|
1140 | [[ "$vrs" != "" ]] && wrt_unpack4 "$name-$vrs.tar.*"
|
---|
1141 | #
|
---|
1142 | # Select a script execution method
|
---|
1143 | case $this_script in
|
---|
1144 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
1145 | wrt_copy_fstab2 "${this_script}"
|
---|
1146 | else
|
---|
1147 | wrt_run_as_root2 "${this_script}" "${file}"
|
---|
1148 | fi
|
---|
1149 | ;;
|
---|
1150 | *) wrt_run_as_root2 "${this_script}" "${file}" ;;
|
---|
1151 | esac
|
---|
1152 | #
|
---|
1153 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
1154 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
|
---|
1155 | #
|
---|
1156 | # Include a touch of the target name so make can check if it's already been made.
|
---|
1157 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
1158 | #
|
---|
1159 | #--------------------------------------------------------------------#
|
---|
1160 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
1161 | #--------------------------------------------------------------------#
|
---|
1162 | #
|
---|
1163 | # Keep the script file name for Makefile dependencies.
|
---|
1164 | PREV=$this_script
|
---|
1165 |
|
---|
1166 | done
|
---|
1167 |
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 |
|
---|
1171 |
|
---|
1172 | #-----------------------------#
|
---|
1173 | the_end_Makefiles() { #
|
---|
1174 | #-----------------------------#
|
---|
1175 | echo "${tab_}${GREEN}Processing... ${L_arrow}THE END${R_arrow}"
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 |
|
---|
1179 | #-----------------------------#
|
---|
1180 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
1181 | #-----------------------------#
|
---|
1182 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
1183 |
|
---|
1184 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
1185 | # Start with a clean Makefile.tmp file
|
---|
1186 | >$MKFILE.tmp
|
---|
1187 |
|
---|
1188 | host_prep_Makefiles
|
---|
1189 | cross_tools_Makefiles
|
---|
1190 | temptools_Makefiles
|
---|
1191 | if [[ $BOOTMINIMAL = "0" ]]; then
|
---|
1192 | chroot_Makefiles
|
---|
1193 | if [[ $TOOLCHAINTEST = "1" ]]; then
|
---|
1194 | testsuite_tools_Makefiles
|
---|
1195 | fi
|
---|
1196 | final_system_Makefiles
|
---|
1197 | bootscripts_Makefiles
|
---|
1198 | bootable_Makefiles
|
---|
1199 | else
|
---|
1200 | boot_Makefiles # This phase must die at the end of its run..
|
---|
1201 | if [[ $TOOLCHAINTEST = "1" ]]; then
|
---|
1202 | bm_testsuite_tools_Makefiles
|
---|
1203 | fi
|
---|
1204 | bm_final_system_Makefiles
|
---|
1205 | bm_bootscripts_Makefiles
|
---|
1206 | bm_bootable_Makefiles
|
---|
1207 | fi
|
---|
1208 | # the_end_Makefiles
|
---|
1209 |
|
---|
1210 |
|
---|
1211 | # Add a header, some variables and include the function file
|
---|
1212 | # to the top of the real Makefile.
|
---|
1213 | (
|
---|
1214 | cat << EOF
|
---|
1215 | $HEADER
|
---|
1216 |
|
---|
1217 | SRC= /sources
|
---|
1218 | MOUNT_PT= $BUILDDIR
|
---|
1219 | PAGE= $PAGE
|
---|
1220 | TIMEZONE= $TIMEZONE
|
---|
1221 |
|
---|
1222 | include makefile-functions
|
---|
1223 |
|
---|
1224 | EOF
|
---|
1225 | ) > $MKFILE
|
---|
1226 |
|
---|
1227 | # Add chroot commands
|
---|
1228 | i=1
|
---|
1229 | for file in chroot/*chroot* ; do
|
---|
1230 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
---|
1231 | -e '/^export/d' \
|
---|
1232 | -e '/^logout/d' \
|
---|
1233 | -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
---|
1234 | -e 's|\\$|&&|g' \
|
---|
1235 | -e 's|exit||g' \
|
---|
1236 | -e 's|$| -c|' \
|
---|
1237 | -e 's|"$$LFS"|$(MOUNT_PT)|'\
|
---|
1238 | -e 's|set -e||'`
|
---|
1239 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
1240 | i=`expr $i + 1`
|
---|
1241 | done
|
---|
1242 |
|
---|
1243 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
1244 | # as a dependency.
|
---|
1245 | (
|
---|
1246 | cat << EOF
|
---|
1247 | all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8
|
---|
1248 | @\$(call echo_finished,$VERSION)
|
---|
1249 |
|
---|
1250 | chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
|
---|
1251 |
|
---|
1252 | chapter3: chapter2 $cross_tools
|
---|
1253 |
|
---|
1254 | chapter4: chapter3 $temptools
|
---|
1255 |
|
---|
1256 | chapter5: chapter4 $chroottools $boottools
|
---|
1257 |
|
---|
1258 | chapter6: chapter5 $basicsystem
|
---|
1259 |
|
---|
1260 | chapter7: chapter6 $bootscripttools
|
---|
1261 |
|
---|
1262 | chapter8: chapter7 $bootabletools
|
---|
1263 |
|
---|
1264 | clean-all: clean
|
---|
1265 | rm -rf ./{${PROGNAME}-commands,logs,Makefile,dump-clfs-scripts.xsl,functions,packages,patches}
|
---|
1266 |
|
---|
1267 | clean: clean-chapter4 clean-chapter3 clean-chapter2
|
---|
1268 |
|
---|
1269 | clean-chapter2:
|
---|
1270 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
1271 | userdel lfs; \\
|
---|
1272 | rm -rf /home/lfs; \\
|
---|
1273 | fi;
|
---|
1274 | rm -rf \$(MOUNT_PT)/tools
|
---|
1275 | rm -f /tools
|
---|
1276 | rm -rf \$(MOUNT_PT)/cross-tools
|
---|
1277 | rm -f /cross-tools
|
---|
1278 | rm -f envars user-lfs-exist
|
---|
1279 | rm -f 02* logs/02*.log
|
---|
1280 |
|
---|
1281 | clean-chapter3:
|
---|
1282 | rm -rf \$(MOUNT_PT)/tools/*
|
---|
1283 | rm -f $cross_tools restore-lfs-env sources-dir
|
---|
1284 | cd logs && rm -f $cross_tools && cd ..
|
---|
1285 |
|
---|
1286 | clean-chapter4:
|
---|
1287 | -umount \$(MOUNT_PT)/sys
|
---|
1288 | -umount \$(MOUNT_PT)/proc
|
---|
1289 | -umount \$(MOUNT_PT)/dev/shm
|
---|
1290 | -umount \$(MOUNT_PT)/dev/pts
|
---|
1291 | -umount \$(MOUNT_PT)/dev
|
---|
1292 | rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
1293 | rm -f $temptools
|
---|
1294 | cd logs && rm -f $temptools && cd ..
|
---|
1295 |
|
---|
1296 |
|
---|
1297 | restore-lfs-env:
|
---|
1298 | @\$(call echo_message, Building)
|
---|
1299 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
1300 | mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
---|
1301 | fi;
|
---|
1302 | @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
1303 | mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
---|
1304 | fi;
|
---|
1305 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
1306 | touch \$@
|
---|
1307 |
|
---|
1308 | EOF
|
---|
1309 | ) >> $MKFILE
|
---|
1310 |
|
---|
1311 |
|
---|
1312 | # Bring over the items from the Makefile.tmp
|
---|
1313 | cat $MKFILE.tmp >> $MKFILE
|
---|
1314 | rm $MKFILE.tmp
|
---|
1315 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
1316 |
|
---|
1317 | }
|
---|
1318 |
|
---|