[91ff6a9] | 1 | #!/bin/bash
|
---|
[7432834] | 2 | # $Id$
|
---|
| 3 |
|
---|
| 4 | ###################################
|
---|
| 5 | ### FUNCTIONS ###
|
---|
| 6 | ###################################
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | #----------------------------#
|
---|
| 10 | host_prep_Makefiles() { # Initialization of the system
|
---|
| 11 | #----------------------------#
|
---|
| 12 | local CLFS_HOST
|
---|
| 13 |
|
---|
[045b2dc] | 14 | echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
|
---|
[7432834] | 15 |
|
---|
| 16 | # defined here, only for ease of reading
|
---|
| 17 | CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
|
---|
| 18 | (
|
---|
| 19 | cat << EOF
|
---|
| 20 |
|
---|
[9ae0875] | 21 | 025-addinguser:
|
---|
[7432834] | 22 | @\$(call echo_message, Building)
|
---|
[962793a] | 23 | @if [ ! -d \$(LUSER_HOME) ]; then \\
|
---|
[6ad5a2f] | 24 | groupadd \$(LGROUP); \\
|
---|
| 25 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
[7432834] | 26 | else \\
|
---|
[6ad5a2f] | 27 | touch luser-exist; \\
|
---|
[7432834] | 28 | fi;
|
---|
[dbcdfd7] | 29 | @\$(call housekeeping)
|
---|
[7432834] | 30 |
|
---|
| 31 | 026-settingenvironment: 025-addinguser
|
---|
| 32 | @\$(call echo_message, Building)
|
---|
[962793a] | 33 | @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 34 | mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
|
---|
[7432834] | 35 | fi;
|
---|
[962793a] | 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; \\
|
---|
[7432834] | 38 | fi;
|
---|
[962793a] | 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 && \\
|
---|
[045b2dc] | 53 | touch envars && \\
|
---|
[9ae0875] | 54 | chown \$(LUSER):\$(LGROUP) envars
|
---|
[dbcdfd7] | 55 | @\$(call housekeeping)
|
---|
[7432834] | 56 |
|
---|
| 57 | 027-create-directories: 026-settingenvironment
|
---|
| 58 | @\$(call echo_message, Building)
|
---|
| 59 |
|
---|
| 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 ; \\
|
---|
| 72 | done
|
---|
[dbcdfd7] | 73 | @\$(call housekeeping)
|
---|
[7432834] | 74 |
|
---|
| 75 | 028-creating-sysfile: 027-create-directories
|
---|
| 76 | @\$(call echo_message, Building)
|
---|
| 77 |
|
---|
| 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
|
---|
| 96 |
|
---|
| 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
|
---|
[de22e80] | 99 | @chown -R \$(LUSER) \$(MOUNT_PT) && \\
|
---|
| 100 | chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT)
|
---|
[dbcdfd7] | 101 | @\$(call housekeeping)
|
---|
[7432834] | 102 |
|
---|
| 103 | EOF
|
---|
| 104 | ) >> $MKFILE.tmp
|
---|
[045b2dc] | 105 |
|
---|
[9ae0875] | 106 | host_prep=" 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
|
---|
[7432834] | 107 | }
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | #-----------------------------#
|
---|
| 111 | cross_tools_Makefiles() { #
|
---|
| 112 | #-----------------------------#
|
---|
[045b2dc] | 113 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
---|
[7432834] | 114 |
|
---|
| 115 | for file in cross-tools/* ; do
|
---|
| 116 | # Keep the script file name
|
---|
| 117 | this_script=`basename $file`
|
---|
| 118 | #
|
---|
| 119 | # Skip this script...
|
---|
| 120 | case $this_script in
|
---|
| 121 | *cflags* | *variables* ) # work done in host_prep_Makefiles
|
---|
[6ad5a2f] | 122 | continue ;;
|
---|
[7432834] | 123 | *) ;;
|
---|
| 124 | esac
|
---|
[6ad5a2f] | 125 |
|
---|
[7432834] | 126 | #
|
---|
| 127 | # Set the dependency for the first target.
|
---|
[f3fcecc] | 128 | if [ -z $PREV ] ; then PREV=028-creating-sysfile ; fi
|
---|
[7432834] | 129 |
|
---|
| 130 | # First append each name of the script files to a list (this will become
|
---|
| 131 | # the names of the targets in the Makefile
|
---|
| 132 | cross_tools="$cross_tools $this_script"
|
---|
| 133 |
|
---|
| 134 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
| 135 | # and binutils in chapter 5)
|
---|
| 136 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 137 | -e 's@-static@@' \
|
---|
| 138 | -e 's@-final@@' \
|
---|
| 139 | -e 's@-64@@' \
|
---|
| 140 | -e 's@-n32@@'`
|
---|
| 141 | case $name in
|
---|
| 142 | glibc-headers) name="glibc" ;;
|
---|
| 143 | esac
|
---|
| 144 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 145 | #--------------------------------------------------------------------#
|
---|
| 146 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 147 | #--------------------------------------------------------------------#
|
---|
| 148 | #
|
---|
| 149 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 150 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 151 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[7432834] | 152 | #
|
---|
| 153 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 154 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[045b2dc] | 155 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
[7432834] | 156 | # If using optimizations, write the instructions
|
---|
| 157 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 158 | fi
|
---|
| 159 | #
|
---|
[045b2dc] | 160 | LUSER_wrt_RunAsUser "${file}"
|
---|
[7432834] | 161 | #
|
---|
[045b2dc] | 162 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[7432834] | 163 | #
|
---|
| 164 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 165 | wrt_touch
|
---|
| 166 | #
|
---|
| 167 | #--------------------------------------------------------------------#
|
---|
| 168 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 169 | #--------------------------------------------------------------------#
|
---|
| 170 | #
|
---|
| 171 | # Keep the script file name for Makefile dependencies.
|
---|
| 172 | PREV=$this_script
|
---|
| 173 |
|
---|
| 174 | done # for file in ....
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 |
|
---|
| 178 |
|
---|
| 179 | #-----------------------------#
|
---|
| 180 | final_system_Makefiles() { #
|
---|
| 181 | #-----------------------------#
|
---|
[045b2dc] | 182 | echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
|
---|
[7432834] | 183 |
|
---|
[2dd88c4] | 184 | for file in final-system/* ; do
|
---|
[7432834] | 185 | # Keep the script file name
|
---|
| 186 | this_script=`basename $file`
|
---|
| 187 |
|
---|
| 188 | # Test if the stripping phase must be skipped.
|
---|
| 189 | # Skip alsp temp-perl for iterative runs
|
---|
| 190 | case $this_script in
|
---|
[401f81e] | 191 | *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
---|
[7432834] | 192 | esac
|
---|
| 193 |
|
---|
| 194 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 195 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 196 | -e 's@temp-@@' \
|
---|
| 197 | -e 's@-64bit@@' \
|
---|
| 198 | -e 's@-64@@' \
|
---|
| 199 | -e 's@64@@' \
|
---|
| 200 | -e 's@n32@@'`
|
---|
| 201 |
|
---|
| 202 | # Find the version of the command files, if it corresponds with the building of
|
---|
[2dd88c4] | 203 | # a specific package.
|
---|
[7432834] | 204 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 205 |
|
---|
| 206 | # Append each name of the script files to a list (this will become
|
---|
| 207 | # the names of the targets in the Makefile
|
---|
[2dd88c4] | 208 | basicsystem="$basicsystem ${this_script}"
|
---|
[7432834] | 209 |
|
---|
| 210 | #--------------------------------------------------------------------#
|
---|
| 211 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 212 | #--------------------------------------------------------------------#
|
---|
| 213 | #
|
---|
| 214 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 215 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 216 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[7432834] | 217 | #
|
---|
| 218 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 219 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[f546320] | 220 | # Touch timestamp file if installed files logs will be created.
|
---|
| 221 | # But only for the firt build when running iterative builds.
|
---|
| 222 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 223 | LUSER_wrt_TouchTimestamp
|
---|
| 224 | fi
|
---|
[045b2dc] | 225 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
[7432834] | 226 | # If using optimizations, write the instructions
|
---|
| 227 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 228 | fi
|
---|
| 229 | #
|
---|
[045b2dc] | 230 | LUSER_wrt_RunAsUser "${file}"
|
---|
[7432834] | 231 | #
|
---|
[f546320] | 232 | # Write installed files log and remove the build directory(ies)
|
---|
| 233 | # except if the package build fails.
|
---|
| 234 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 235 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 236 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 237 | LUSER_wrt_LogNewFiles "$name"
|
---|
| 238 | fi
|
---|
| 239 | fi
|
---|
[7432834] | 240 | #
|
---|
| 241 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 242 | wrt_touch
|
---|
| 243 | #
|
---|
| 244 | #--------------------------------------------------------------------#
|
---|
| 245 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 246 | #--------------------------------------------------------------------#
|
---|
| 247 | #
|
---|
| 248 | # Keep the script file name for Makefile dependencies.
|
---|
[2dd88c4] | 249 | PREV=${this_script}
|
---|
[7432834] | 250 | done # for file in final-system/* ...
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 |
|
---|
| 254 |
|
---|
| 255 | #-----------------------------#
|
---|
| 256 | bootscripts_Makefiles() { #
|
---|
| 257 | #-----------------------------#
|
---|
[045b2dc] | 258 | echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
|
---|
[7432834] | 259 |
|
---|
| 260 | for file in bootscripts/* ; do
|
---|
| 261 | # Keep the script file name
|
---|
| 262 | this_script=`basename $file`
|
---|
| 263 |
|
---|
| 264 | case $this_script in
|
---|
| 265 | *udev) continue ;; # This is not a script but a commentary, we want udev-rules
|
---|
| 266 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
[31e78bd] | 267 | *network*) continue ;; # Manually create these files
|
---|
[7432834] | 268 | *) ;;
|
---|
| 269 | esac
|
---|
| 270 |
|
---|
| 271 | # First append each name of the script files to a list (this will become
|
---|
| 272 | # the names of the targets in the Makefile
|
---|
| 273 | bootscripttools="$bootscripttools $this_script"
|
---|
| 274 |
|
---|
| 275 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 276 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
| 277 | -e 's@-64bit@@' \
|
---|
| 278 | -e 's@-64@@' \
|
---|
| 279 | -e 's@64@@' \
|
---|
| 280 | -e 's@n32@@'`
|
---|
| 281 | case $name in
|
---|
| 282 | *bootscripts*) name=bootscripts-cross-lfs ;;
|
---|
| 283 | *udev-rules) name=udev-cross-lfs ;;
|
---|
| 284 | esac
|
---|
| 285 |
|
---|
| 286 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 287 |
|
---|
| 288 | #--------------------------------------------------------------------#
|
---|
| 289 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 290 | #--------------------------------------------------------------------#
|
---|
| 291 | #
|
---|
| 292 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 293 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 294 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[7432834] | 295 | #
|
---|
| 296 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[f546320] | 297 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 298 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
| 299 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 300 | LUSER_wrt_TouchTimestamp
|
---|
| 301 | fi
|
---|
| 302 | fi
|
---|
[7432834] | 303 | #
|
---|
[045b2dc] | 304 | LUSER_wrt_RunAsUser "${file}"
|
---|
[7432834] | 305 | #
|
---|
[f546320] | 306 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 307 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 308 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 309 | LUSER_wrt_LogNewFiles "$name"
|
---|
| 310 | fi
|
---|
| 311 | fi
|
---|
[7432834] | 312 | #
|
---|
| 313 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 314 | wrt_touch
|
---|
| 315 | #
|
---|
| 316 | #--------------------------------------------------------------------#
|
---|
| 317 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 318 | #--------------------------------------------------------------------#
|
---|
| 319 | #
|
---|
| 320 | # Keep the script file name for Makefile dependencies.
|
---|
| 321 | PREV=$this_script
|
---|
| 322 |
|
---|
| 323 | done # for file in bootscripts/* ...
|
---|
| 324 |
|
---|
| 325 | }
|
---|
| 326 |
|
---|
| 327 |
|
---|
| 328 | #-----------------------------#
|
---|
| 329 | bootable_Makefiles() { #
|
---|
| 330 | #-----------------------------#
|
---|
[045b2dc] | 331 | echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
|
---|
[7432834] | 332 |
|
---|
| 333 | for file in bootable/* ; do
|
---|
| 334 | # Keep the script file name
|
---|
| 335 | this_script=`basename $file`
|
---|
| 336 |
|
---|
| 337 | # A little housekeeping on the scripts
|
---|
| 338 | case $this_script in
|
---|
| 339 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
---|
[045b2dc] | 340 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[7432834] | 341 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
| 342 | [[ -z $CONFIG ]] && continue
|
---|
| 343 | # Copy the config file to /sources with a standardized name
|
---|
| 344 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
| 345 | ;;
|
---|
| 346 | esac
|
---|
| 347 | #
|
---|
| 348 | # First append each name of the script files to a list (this will become
|
---|
| 349 | # the names of the targets in the Makefile
|
---|
[045b2dc] | 350 | # NOTE: new makfile format forces the last script, *chowning, into a separate
|
---|
| 351 | # phase.
|
---|
| 352 | case ${this_script} in
|
---|
[936efa8] | 353 | *chowning) chowning=" ${this_script}" ;;
|
---|
[045b2dc] | 354 | *) bootable="$bootable $this_script" ;;
|
---|
| 355 | esac
|
---|
[7432834] | 356 | #
|
---|
| 357 | # Grab the name of the target, strip id number and misc words.
|
---|
| 358 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
| 359 | case $this_script in
|
---|
| 360 | *kernel*) name=linux
|
---|
| 361 | ;;
|
---|
| 362 | esac
|
---|
| 363 |
|
---|
| 364 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 365 |
|
---|
| 366 | #--------------------------------------------------------------------#
|
---|
| 367 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 368 | #--------------------------------------------------------------------#
|
---|
| 369 | #
|
---|
| 370 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 371 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 372 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[7432834] | 373 | #
|
---|
| 374 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[f546320] | 375 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 376 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
| 377 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 378 | LUSER_wrt_TouchTimestamp
|
---|
| 379 | fi
|
---|
| 380 | fi
|
---|
[7432834] | 381 | #
|
---|
| 382 | # Select a script execution method
|
---|
| 383 | case $this_script in
|
---|
| 384 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
[045b2dc] | 385 | LUSER_wrt_CopyFstab
|
---|
[7432834] | 386 | else
|
---|
[045b2dc] | 387 | LUSER_wrt_RunAsUser "${file}"
|
---|
[7432834] | 388 | fi
|
---|
| 389 | ;;
|
---|
[8f2c086] | 390 | *chowning) wrt_RunAsRoot "${file}"
|
---|
[6ad5a2f] | 391 | ;;
|
---|
[045b2dc] | 392 | *) LUSER_wrt_RunAsUser "${file}"
|
---|
[6ad5a2f] | 393 | ;;
|
---|
[7432834] | 394 | esac
|
---|
| 395 | #
|
---|
| 396 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
[f546320] | 397 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 398 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 399 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 400 | LUSER_wrt_LogNewFiles "$name"
|
---|
| 401 | fi
|
---|
| 402 | fi
|
---|
[7432834] | 403 | #
|
---|
| 404 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 405 | wrt_touch
|
---|
| 406 | #
|
---|
| 407 | #--------------------------------------------------------------------#
|
---|
| 408 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 409 | #--------------------------------------------------------------------#
|
---|
| 410 | #
|
---|
| 411 | # Keep the script file name for Makefile dependencies.
|
---|
| 412 | PREV=$this_script
|
---|
| 413 |
|
---|
| 414 | done
|
---|
| 415 |
|
---|
| 416 | }
|
---|
| 417 |
|
---|
| 418 |
|
---|
| 419 | #-----------------------------#
|
---|
| 420 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
| 421 | #-----------------------------#
|
---|
| 422 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
| 423 |
|
---|
| 424 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 425 | # Start with a clean Makefile.tmp file
|
---|
| 426 | >$MKFILE.tmp
|
---|
| 427 |
|
---|
| 428 | host_prep_Makefiles
|
---|
| 429 | cross_tools_Makefiles # $cross_tools
|
---|
| 430 | final_system_Makefiles # $basicsystem
|
---|
| 431 | bootscripts_Makefiles # $bootscripttools
|
---|
| 432 | bootable_Makefiles # $bootable
|
---|
[3e7ceed] | 433 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
| 434 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
| 435 | # Add the BLFS_TOOL targets, if needed.
|
---|
| 436 | [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
---|
[7432834] | 437 |
|
---|
| 438 | # Add a header, some variables and include the function file
|
---|
| 439 | # to the top of the real Makefile.
|
---|
[195ed9f] | 440 | wrt_Makefile_header
|
---|
[7432834] | 441 |
|
---|
| 442 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 443 | # as a dependency.
|
---|
| 444 | (
|
---|
[045b2dc] | 445 | cat << EOF
|
---|
| 446 |
|
---|
[3bc6078] | 447 | all: ck_UID mk_SETUP mk_LUSER create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL mk_ROOT
|
---|
[cd4466f] | 448 | @sudo make restore-luser-env
|
---|
[045b2dc] | 449 | @sudo make do-housekeeping
|
---|
[7432834] | 450 | @\$(call echo_finished,$VERSION)
|
---|
| 451 |
|
---|
[045b2dc] | 452 | ck_UID:
|
---|
| 453 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 454 | echo "--------------------------------------------------"; \\
|
---|
| 455 | echo "You cannot run this makefile from the root account"; \\
|
---|
| 456 | echo "--------------------------------------------------"; \\
|
---|
| 457 | exit 1; \\
|
---|
| 458 | fi
|
---|
[7432834] | 459 |
|
---|
[045b2dc] | 460 | mk_SETUP:
|
---|
| 461 | @\$(call echo_SU_request)
|
---|
[dbcdfd7] | 462 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
[045b2dc] | 463 | @touch \$@
|
---|
[7432834] | 464 |
|
---|
[045b2dc] | 465 | mk_LUSER: mk_SETUP
|
---|
| 466 | @\$(call echo_SULUSER_request)
|
---|
[dbcdfd7] | 467 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
---|
[045b2dc] | 468 | @touch \$@
|
---|
[7432834] | 469 |
|
---|
[3e7ceed] | 470 | mk_CUSTOM_TOOLS: create-sbu_du-report
|
---|
[b4cf321] | 471 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 472 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
[3e7ceed] | 473 | (sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
|
---|
[dbcdfd7] | 474 | (sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
[3e7ceed] | 475 | fi;
|
---|
| 476 | @touch \$@
|
---|
| 477 |
|
---|
| 478 | mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
---|
| 479 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 480 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
[cd4466f] | 481 | (sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
|
---|
[dbcdfd7] | 482 | (sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
---|
[cd4466f] | 483 | fi;
|
---|
| 484 | @touch \$@
|
---|
| 485 |
|
---|
[ddca240] | 486 | mk_ROOT: create-sbu_du-report
|
---|
[3e7ceed] | 487 | @\$(call echo_SU_request)
|
---|
[de22e80] | 488 | @echo "$VERSION-sysroot - jhalfs build" > clfs-release && \\
|
---|
| 489 | sudo mv clfs-release \$(MOUNT_PT)/etc
|
---|
[dbcdfd7] | 490 | @sudo make BREAKPOINT=\$(BREAKPOINT) ROOT
|
---|
[045b2dc] | 491 | @touch \$@
|
---|
[7432834] | 492 |
|
---|
[3e7ceed] | 493 | SETUP: $host_prep
|
---|
| 494 | LUSER: $cross_tools $basicsystem $bootscripttools $bootable
|
---|
| 495 | CUSTOM_TOOLS: $custom_list
|
---|
| 496 | BLFS_TOOL: $blfs_tool
|
---|
| 497 | ROOT: $chowning
|
---|
[7432834] | 498 |
|
---|
| 499 |
|
---|
[cd4466f] | 500 | create-sbu_du-report: mk_LUSER
|
---|
[1838bc7] | 501 | @\$(call echo_message, Building)
|
---|
| 502 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
| 503 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
| 504 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
| 505 | fi;
|
---|
| 506 | @touch \$@
|
---|
[7432834] | 507 |
|
---|
[6ad5a2f] | 508 | restore-luser-env:
|
---|
[7432834] | 509 | @\$(call echo_message, Building)
|
---|
[962793a] | 510 | @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 511 | mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
---|
[7432834] | 512 | fi;
|
---|
[962793a] | 513 | @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
| 514 | mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
---|
[7432834] | 515 | fi;
|
---|
[962793a] | 516 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
|
---|
[7432834] | 517 | touch \$@ && \\
|
---|
| 518 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 519 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 520 |
|
---|
| 521 | do-housekeeping:
|
---|
[6ad5a2f] | 522 | @-if [ ! -f luser-exist ]; then \\
|
---|
| 523 | userdel \$(LUSER); \\
|
---|
[962793a] | 524 | rm -rf \$(LUSER_HOME); \\
|
---|
[7432834] | 525 | fi;
|
---|
| 526 |
|
---|
| 527 | EOF
|
---|
| 528 | ) >> $MKFILE
|
---|
| 529 |
|
---|
| 530 | # Bring over the items from the Makefile.tmp
|
---|
| 531 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 532 | rm $MKFILE.tmp
|
---|
| 533 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 534 |
|
---|
| 535 | }
|
---|