4 ###################################
6 ###################################
9 #----------------------------#
10 host_prep_Makefiles
() { # Initialization of the system
11 #----------------------------#
14 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
16 # defined here, only for ease of reading
17 CLFS_HOST
="$(echo $MACHTYPE | sed "s
/$
(echo $MACHTYPE | cut
-d- -f2)/cross
/")"
22 @\$(call echo_message, Building)
23 @if [ ! -d \$(LUSER_HOME) ]; then \\
24 groupadd \$(LGROUP); \\
25 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
29 @\$(call housekeeping)
31 026-settingenvironment: 025-addinguser
32 @\$(call echo_message, Building)
33 @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
34 mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
36 @if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
37 mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
39 @echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
40 echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
41 echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
42 echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
43 echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
44 echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
45 echo "" >> \$(LUSER_HOME)/.bashrc && \\
46 echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
47 echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
48 echo "" >> \$(LUSER_HOME)/.bashrc && \\
49 echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\
50 echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\
51 echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc
52 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
54 chown \$(LUSER):\$(LGROUP) envars
55 @\$(call housekeeping)
57 027-create-directories: 026-settingenvironment
58 @\$(call echo_message, Building)
60 @mkdir -p \$(MOUNT_PT)/{bin,boot,dev,{etc/,}opt,home,lib,mnt}
61 @mkdir -p \$(MOUNT_PT)/{proc,media/{floppy,cdrom},sbin,srv,sys}
62 @mkdir -p \$(MOUNT_PT)/var/{lock,log,mail,run,spool}
63 @mkdir -p \$(MOUNT_PT)/var/{opt,cache,lib/{misc,locate},local}
64 @install -d -m 0750 \$(MOUNT_PT)/root
65 @install -d -m 1777 \$(MOUNT_PT){/var,}/tmp
66 @mkdir -p \$(MOUNT_PT)/usr/{,local/}{bin,include,lib,sbin,src}
67 @mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{doc,info,locale,man}
68 @mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{misc,terminfo,zoneinfo}
69 @mkdir -p \$(MOUNT_PT)/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
70 @for dir in \$(MOUNT_PT)/usr{,/local}; do \\
71 ln -s share/{man,doc,info} \$\$dir ; \\
73 @\$(call housekeeping)
75 028-creating-sysfile: 027-create-directories
76 @\$(call echo_message, Building)
78 @touch \$(MOUNT_PT)/etc/mtab
79 @echo "root::0:0:root:/root:/bin/bash" >> \$(MOUNT_PT)/etc/passwd
80 @echo "root:x:0:" >> \$(MOUNT_PT)/etc/group
81 @echo "bin:x:1:" >> \$(MOUNT_PT)/etc/group
82 @echo "sys:x:2:" >> \$(MOUNT_PT)/etc/group
83 @echo "kmem:x:3" >> \$(MOUNT_PT)/etc/group
84 @echo "tty:x:4:" >> \$(MOUNT_PT)/etc/group
85 @echo "tape:x:5:" >> \$(MOUNT_PT)/etc/group
86 @echo "daemon:x:6:" >> \$(MOUNT_PT)/etc/group
87 @echo "floppy:x:7:" >> \$(MOUNT_PT)/etc/group
88 @echo "disk:x:8:" >> \$(MOUNT_PT)/etc/group
89 @echo "lp:x:9:" >> \$(MOUNT_PT)/etc/group
90 @echo "dialout:x:10:" >> \$(MOUNT_PT)/etc/group
91 @echo "audio:x:11:" >> \$(MOUNT_PT)/etc/group
92 @echo "video:x:12:" >> \$(MOUNT_PT)/etc/group
93 @echo "utmp:x:13:" >> \$(MOUNT_PT)/etc/group
94 @echo "usb:x:14:" >> \$(MOUNT_PT)/etc/group
95 @echo "cdrom:x:15:" >> \$(MOUNT_PT)/etc/group
97 @touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp}
98 @chmod 664 \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/lastlog
99 @chown -R \$(LUSER) \$(MOUNT_PT) && \\
100 chmod -R a+w \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
101 chmod -R a+w \$(SRCSDIR)
102 @\$(call housekeeping)
107 host_prep
=" 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
111 #-----------------------------#
112 cross_tools_Makefiles
() { #
113 #-----------------------------#
114 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
116 for file in cross-tools
/* ; do
117 # Keep the script file name
118 this_script
=`basename $file`
120 # Skip this script...
122 *cflags
* |
*variables
* ) # work done in host_prep_Makefiles
128 # Set the dependency for the first target.
129 if [ -z $PREV ] ; then PREV
=028-creating-sysfile ; fi
131 # First append each name of the script files to a list (this will become
132 # the names of the targets in the Makefile
133 cross_tools
="$cross_tools $this_script"
135 # Grab the name of the target (minus the -headers or -cross in the case of gcc
136 # and binutils in chapter 5)
137 name
=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
143 glibc-headers
) name
="glibc" ;;
145 pkg_tarball
=$
(get_package_tarball_name
$name)
146 #--------------------------------------------------------------------#
147 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
148 #--------------------------------------------------------------------#
150 # Drop in the name of the target on a new line, and the previous target
151 # as a dependency. Also call the echo_message function.
152 LUSER_wrt_target
"${this_script}" "$PREV"
154 # If $pkg_tarball isn't empty, we've got a package...
155 if [ "$pkg_tarball" != "" ] ; then
156 LUSER_wrt_unpack
"$pkg_tarball"
157 # If using optimizations, write the instructions
158 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize
"$name" && wrt_makeflags
"$name"
161 LUSER_wrt_RunAsUser
"${file}"
163 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs
"${name}"
165 # Include a touch of the target name so make can check if it's already been made.
168 #--------------------------------------------------------------------#
169 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
170 #--------------------------------------------------------------------#
172 # Keep the script file name for Makefile dependencies.
175 done # for file in ....
180 #-----------------------------#
181 final_system_Makefiles
() { #
182 #-----------------------------#
183 echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
185 for file in final-system
/* ; do
186 # Keep the script file name
187 this_script
=`basename $file`
189 # Test if the stripping phase must be skipped.
190 # Skip alsp temp-perl for iterative runs
192 *stripping
*) [[ "$STRIP" = "n" ]] && continue ;;
195 # Grab the name of the target, strip id number, XXX-script
196 name
=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
203 # Find the version of the command files, if it corresponds with the building of
204 # a specific package.
205 pkg_tarball
=$
(get_package_tarball_name
$name)
207 # Append each name of the script files to a list (this will become
208 # the names of the targets in the Makefile
209 basicsystem
="$basicsystem ${this_script}"
211 #--------------------------------------------------------------------#
212 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
213 #--------------------------------------------------------------------#
215 # Drop in the name of the target on a new line, and the previous target
216 # as a dependency. Also call the echo_message function.
217 LUSER_wrt_target
"${this_script}" "$PREV"
219 # If $pkg_tarball isn't empty, we've got a package...
220 if [ "$pkg_tarball" != "" ] ; then
221 # Touch timestamp file if installed files logs will be created.
222 # But only for the firt build when running iterative builds.
223 if [ "${INSTALL_LOG}" = "y" ] ; then
224 LUSER_wrt_TouchTimestamp
226 LUSER_wrt_unpack
"$pkg_tarball"
227 # If using optimizations, write the instructions
228 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize
"$name" && wrt_makeflags
"$name"
231 LUSER_wrt_RunAsUser
"${file}"
233 # Write installed files log and remove the build directory(ies)
234 # except if the package build fails.
235 if [ "$pkg_tarball" != "" ] ; then
236 LUSER_RemoveBuildDirs
"${name}"
237 if [ "${INSTALL_LOG}" = "y" ] ; then
238 LUSER_wrt_LogNewFiles
"$name"
242 # Include a touch of the target name so make can check if it's already been made.
245 #--------------------------------------------------------------------#
246 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
247 #--------------------------------------------------------------------#
249 # Keep the script file name for Makefile dependencies.
251 done # for file in final-system/* ...
256 #-----------------------------#
257 bootscripts_Makefiles
() { #
258 #-----------------------------#
259 echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
261 for file in bootscripts
/* ; do
262 # Keep the script file name
263 this_script
=`basename $file`
266 *udev
) continue ;; # This is not a script but a commentary, we want udev-rules
267 *console
*) continue ;; # Use the files that came with the bootscripts
268 *network
*) continue ;; # Manually create these files
272 # First append each name of the script files to a list (this will become
273 # the names of the targets in the Makefile
274 bootscripttools
="$bootscripttools $this_script"
276 # Grab the name of the target, strip id number, XXX-script
277 name
=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
283 *bootscripts
*) name
=bootscripts-cross-lfs
;;
284 *udev-rules
) name
=udev-cross-lfs
;;
287 pkg_tarball
=$
(get_package_tarball_name
$name)
289 #--------------------------------------------------------------------#
290 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
291 #--------------------------------------------------------------------#
293 # Drop in the name of the target on a new line, and the previous target
294 # as a dependency. Also call the echo_message function.
295 LUSER_wrt_target
"${this_script}" "$PREV"
297 # If $pkg_tarball isn't empty, we've got a package...
298 if [ "$pkg_tarball" != "" ] ; then
299 LUSER_wrt_unpack
"$pkg_tarball"
300 if [ "${INSTALL_LOG}" = "y" ] ; then
301 LUSER_wrt_TouchTimestamp
305 LUSER_wrt_RunAsUser
"${file}"
307 if [ "$pkg_tarball" != "" ] ; then
308 LUSER_RemoveBuildDirs
"${name}"
309 if [ "${INSTALL_LOG}" = "y" ] ; then
310 LUSER_wrt_LogNewFiles
"$name"
314 # Include a touch of the target name so make can check if it's already been made.
317 #--------------------------------------------------------------------#
318 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
319 #--------------------------------------------------------------------#
321 # Keep the script file name for Makefile dependencies.
324 done # for file in bootscripts/* ...
329 #-----------------------------#
330 bootable_Makefiles
() { #
331 #-----------------------------#
332 echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
334 for file in bootable
/* ; do
335 # Keep the script file name
336 this_script
=`basename $file`
338 # A little housekeeping on the scripts
340 *grub |
*aboot |
*colo |
*silo |
*arcload |
*lilo |
*reboot
* ) continue ;;
341 *fstab
) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources
/fstab
;;
342 *kernel
) # if there is no kernel config file do not build the kernel
343 [[ -z $CONFIG ]] && continue
344 # Copy the config file to /sources with a standardized name
345 cp $CONFIG $BUILDDIR/sources
/kernel-config
349 # First append each name of the script files to a list (this will become
350 # the names of the targets in the Makefile
351 # NOTE: new makfile format forces the last script, *chowning, into a separate
353 case ${this_script} in
354 *chowning
) chowning
=" ${this_script}" ;;
355 *) bootable
="$bootable $this_script" ;;
358 # Grab the name of the target, strip id number and misc words.
359 name
=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
365 pkg_tarball
=$
(get_package_tarball_name
$name)
367 #--------------------------------------------------------------------#
368 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
369 #--------------------------------------------------------------------#
371 # Drop in the name of the target on a new line, and the previous target
372 # as a dependency. Also call the echo_message function.
373 LUSER_wrt_target
"${this_script}" "$PREV"
375 # If $pkg_tarball isn't empty, we've got a package...
376 if [ "$pkg_tarball" != "" ] ; then
377 LUSER_wrt_unpack
"$pkg_tarball"
378 if [ "${INSTALL_LOG}" = "y" ] ; then
379 LUSER_wrt_TouchTimestamp
383 # Select a script execution method
385 *fstab
*) if [[ -n "$FSTAB" ]]; then
388 LUSER_wrt_RunAsUser
"${file}"
391 *chowning
) wrt_RunAsRoot
"${file}"
393 *) LUSER_wrt_RunAsUser
"${file}"
397 # Housekeeping...remove any build directory(ies) except if the package build fails.
398 if [ "$pkg_tarball" != "" ] ; then
399 LUSER_RemoveBuildDirs
"${name}"
400 if [ "${INSTALL_LOG}" = "y" ] ; then
401 LUSER_wrt_LogNewFiles
"$name"
405 # Include a touch of the target name so make can check if it's already been made.
408 #--------------------------------------------------------------------#
409 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
410 #--------------------------------------------------------------------#
412 # Keep the script file name for Makefile dependencies.
420 #-----------------------------#
421 build_Makefile
() { # Construct a Makefile from the book scripts
422 #-----------------------------#
423 echo "Creating Makefile... ${BOLD}START${OFF}"
425 cd $JHALFSDIR/${PROGNAME}-commands
426 # Start with a clean Makefile.tmp file
430 cross_tools_Makefiles
# $cross_tools
431 final_system_Makefiles
# $basicsystem
432 bootscripts_Makefiles
# $bootscripttools
433 bootable_Makefiles
# $bootable
434 # Add the CUSTOM_TOOLS targets, if needed
435 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
436 # Add the BLFS_TOOL targets, if needed.
437 [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
439 # Add a header, some variables and include the function file
440 # to the top of the real Makefile.
443 # Drop in the main target 'all:' and the chapter targets with each sub-target
448 all: ck_UID mk_SETUP mk_LUSER create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL mk_ROOT
449 @sudo make restore-luser-env
450 @sudo make do-housekeeping
451 @\$(call echo_finished,$VERSION)
454 @if [ \`id -u\` = "0" ]; then \\
455 echo "--------------------------------------------------"; \\
456 echo "You cannot run this makefile from the root account"; \\
457 echo "--------------------------------------------------"; \\
462 @\$(call echo_SU_request)
463 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
467 @\$(call echo_SULUSER_request)
468 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
471 mk_CUSTOM_TOOLS: create-sbu_du-report
472 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
473 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
474 (sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
475 (sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
479 mk_BLFS_TOOL: mk_CUSTOM_TOOLS
480 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
481 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
482 (sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
483 (sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
487 mk_ROOT: create-sbu_du-report
488 @\$(call echo_SU_request)
489 @echo "$VERSION-sysroot - jhalfs build" > clfs-release && \\
490 sudo mv clfs-release \$(MOUNT_PT)/etc
491 @sudo make BREAKPOINT=\$(BREAKPOINT) ROOT
495 LUSER: $cross_tools $basicsystem $bootscripttools $bootable
496 CUSTOM_TOOLS: $custom_list
497 BLFS_TOOL: $blfs_tool
501 create-sbu_du-report: mk_LUSER
502 @\$(call echo_message, Building)
503 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
504 ./create-sbu_du-report.sh logs $VERSION; \\
505 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
510 @\$(call echo_message, Building)
511 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
512 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
514 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
515 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
517 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
519 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
520 echo --------------------------------------------------------------------------------\$(WHITE)
523 @-if [ ! -f luser-exist ]; then \\
524 userdel \$(LUSER); \\
525 rm -rf \$(LUSER_HOME); \\
531 # Bring over the items from the Makefile.tmp
532 cat $MKFILE.tmp
>> $MKFILE
534 echo "Creating Makefile... ${BOLD}DONE${OFF}"