2006-11-11 12:39:16 +01:00
|
|
|
#!/bin/bash
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
###################################
|
|
|
|
### FUNCTIONS ###
|
|
|
|
###################################
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
host_prep_Makefiles() { # Initialization of the system
|
|
|
|
#----------------------------#
|
|
|
|
local CLFS_HOST
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
# defined here, only for ease of reading
|
|
|
|
CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
|
2006-12-11 14:14:54 +01:00
|
|
|
025-addinguser:
|
2006-07-23 16:44:13 +02:00
|
|
|
@\$(call echo_message, Building)
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ ! -d \$(LUSER_HOME) ]; then \\
|
2006-08-08 19:26:40 +02:00
|
|
|
groupadd \$(LGROUP); \\
|
|
|
|
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
2006-07-23 16:44:13 +02:00
|
|
|
else \\
|
2006-08-08 19:26:40 +02:00
|
|
|
touch luser-exist; \\
|
2006-07-23 16:44:13 +02:00
|
|
|
fi;
|
2007-03-18 11:14:04 +01:00
|
|
|
@\$(call housekeeping)
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
026-settingenvironment: 025-addinguser
|
|
|
|
@\$(call echo_message, Building)
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
|
|
|
mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
|
2006-07-23 16:44:13 +02:00
|
|
|
fi;
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
|
|
|
mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
|
2006-07-23 16:44:13 +02:00
|
|
|
fi;
|
2007-04-13 22:40:38 +02:00
|
|
|
@echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
|
2015-12-28 18:49:20 +01:00
|
|
|
echo "unset PKG_CONFIG_PATH" >> \$(LUSER_HOME)/.bashrc && \\
|
2007-04-13 22:40:38 +02:00
|
|
|
echo "" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\
|
|
|
|
echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc
|
|
|
|
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
|
2006-10-02 21:32:06 +02:00
|
|
|
touch envars && \\
|
2006-12-11 14:14:54 +01:00
|
|
|
chown \$(LUSER):\$(LGROUP) envars
|
2007-03-18 11:14:04 +01:00
|
|
|
@\$(call housekeeping)
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
027-create-directories: 026-settingenvironment
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
|
|
|
|
@mkdir -p \$(MOUNT_PT)/{bin,boot,dev,{etc/,}opt,home,lib,mnt}
|
|
|
|
@mkdir -p \$(MOUNT_PT)/{proc,media/{floppy,cdrom},sbin,srv,sys}
|
|
|
|
@mkdir -p \$(MOUNT_PT)/var/{lock,log,mail,run,spool}
|
|
|
|
@mkdir -p \$(MOUNT_PT)/var/{opt,cache,lib/{misc,locate},local}
|
|
|
|
@install -d -m 0750 \$(MOUNT_PT)/root
|
|
|
|
@install -d -m 1777 \$(MOUNT_PT){/var,}/tmp
|
|
|
|
@mkdir -p \$(MOUNT_PT)/usr/{,local/}{bin,include,lib,sbin,src}
|
|
|
|
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{doc,info,locale,man}
|
|
|
|
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{misc,terminfo,zoneinfo}
|
|
|
|
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
|
|
|
|
@for dir in \$(MOUNT_PT)/usr{,/local}; do \\
|
|
|
|
ln -s share/{man,doc,info} \$\$dir ; \\
|
|
|
|
done
|
2007-03-18 11:14:04 +01:00
|
|
|
@\$(call housekeeping)
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
028-creating-sysfile: 027-create-directories
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
|
|
|
|
@touch \$(MOUNT_PT)/etc/mtab
|
|
|
|
@echo "root::0:0:root:/root:/bin/bash" >> \$(MOUNT_PT)/etc/passwd
|
|
|
|
@echo "root:x:0:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "bin:x:1:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "sys:x:2:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "kmem:x:3" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "tty:x:4:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "tape:x:5:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "daemon:x:6:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "floppy:x:7:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "disk:x:8:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "lp:x:9:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "dialout:x:10:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "audio:x:11:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "video:x:12:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "utmp:x:13:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "usb:x:14:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
@echo "cdrom:x:15:" >> \$(MOUNT_PT)/etc/group
|
|
|
|
|
|
|
|
@touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp}
|
|
|
|
@chmod 664 \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/lastlog
|
2006-12-11 16:48:26 +01:00
|
|
|
@chown -R \$(LUSER) \$(MOUNT_PT) && \\
|
2007-07-02 20:51:01 +02:00
|
|
|
chmod -R a+w \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
|
|
|
chmod -R a+w \$(SRCSDIR)
|
2007-03-18 11:14:04 +01:00
|
|
|
@\$(call housekeeping)
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2006-10-02 21:32:06 +02:00
|
|
|
|
2006-12-11 14:14:54 +01:00
|
|
|
host_prep=" 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
|
2006-07-23 16:44:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------#
|
|
|
|
cross_tools_Makefiles() { #
|
|
|
|
#-----------------------------#
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
for file in cross-tools/* ; do
|
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
#
|
|
|
|
# Skip this script...
|
|
|
|
case $this_script in
|
|
|
|
*cflags* | *variables* ) # work done in host_prep_Makefiles
|
2006-08-08 19:26:40 +02:00
|
|
|
continue ;;
|
2006-07-23 16:44:13 +02:00
|
|
|
*) ;;
|
|
|
|
esac
|
2006-08-08 19:26:40 +02:00
|
|
|
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# Set the dependency for the first target.
|
2006-08-06 10:53:03 +02:00
|
|
|
if [ -z $PREV ] ; then PREV=028-creating-sysfile ; fi
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
|
|
|
cross_tools="$cross_tools $this_script"
|
|
|
|
|
|
|
|
# Grab the name of the target (minus the -headers or -cross in the case of gcc
|
|
|
|
# and binutils in chapter 5)
|
|
|
|
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
|
|
|
-e 's@-static@@' \
|
|
|
|
-e 's@-final@@' \
|
|
|
|
-e 's@-64@@' \
|
|
|
|
-e 's@-n32@@'`
|
|
|
|
case $name in
|
|
|
|
glibc-headers) name="glibc" ;;
|
|
|
|
esac
|
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
|
|
|
# as a dependency. Also call the echo_message function.
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_target "${this_script}" "$PREV"
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# If $pkg_tarball isn't empty, we've got a package...
|
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_unpack "$pkg_tarball"
|
2006-07-23 16:44:13 +02:00
|
|
|
# If using optimizations, write the instructions
|
|
|
|
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
|
|
|
fi
|
|
|
|
#
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_RunAsUser "${file}"
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
2006-10-02 21:32:06 +02:00
|
|
|
[[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# Include a touch of the target name so make can check if it's already been made.
|
|
|
|
wrt_touch
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=$this_script
|
|
|
|
|
|
|
|
done # for file in ....
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------#
|
|
|
|
final_system_Makefiles() { #
|
|
|
|
#-----------------------------#
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
|
2006-07-23 16:44:13 +02:00
|
|
|
|
2006-08-05 20:53:03 +02:00
|
|
|
for file in final-system/* ; do
|
2006-07-23 16:44:13 +02:00
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
# Test if the stripping phase must be skipped.
|
|
|
|
# Skip alsp temp-perl for iterative runs
|
|
|
|
case $this_script in
|
2006-08-16 19:42:54 +02:00
|
|
|
*stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
2006-07-23 16:44:13 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Grab the name of the target, strip id number, XXX-script
|
|
|
|
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
|
|
|
-e 's@temp-@@' \
|
|
|
|
-e 's@-64bit@@' \
|
|
|
|
-e 's@-64@@' \
|
|
|
|
-e 's@64@@' \
|
|
|
|
-e 's@n32@@'`
|
|
|
|
|
|
|
|
# Find the version of the command files, if it corresponds with the building of
|
2006-08-05 20:53:03 +02:00
|
|
|
# a specific package.
|
2006-07-23 16:44:13 +02:00
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
|
|
|
|
|
|
|
# Append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
2006-08-05 20:53:03 +02:00
|
|
|
basicsystem="$basicsystem ${this_script}"
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
|
|
|
# as a dependency. Also call the echo_message function.
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_target "${this_script}" "$PREV"
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# If $pkg_tarball isn't empty, we've got a package...
|
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
2007-06-03 11:06:13 +02:00
|
|
|
# Touch timestamp file if installed files logs will be created.
|
|
|
|
# But only for the firt build when running iterative builds.
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
LUSER_wrt_TouchTimestamp
|
|
|
|
fi
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_unpack "$pkg_tarball"
|
2006-07-23 16:44:13 +02:00
|
|
|
# If using optimizations, write the instructions
|
|
|
|
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
|
|
|
fi
|
|
|
|
#
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_RunAsUser "${file}"
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
2007-06-03 11:06:13 +02:00
|
|
|
# Write installed files log and remove the build directory(ies)
|
|
|
|
# except if the package build fails.
|
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
|
|
|
LUSER_RemoveBuildDirs "${name}"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
LUSER_wrt_LogNewFiles "$name"
|
|
|
|
fi
|
|
|
|
fi
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# Include a touch of the target name so make can check if it's already been made.
|
|
|
|
wrt_touch
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
2006-08-05 20:53:03 +02:00
|
|
|
PREV=${this_script}
|
2006-07-23 16:44:13 +02:00
|
|
|
done # for file in final-system/* ...
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------#
|
|
|
|
bootscripts_Makefiles() { #
|
|
|
|
#-----------------------------#
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
for file in bootscripts/* ; do
|
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
case $this_script in
|
|
|
|
*udev) continue ;; # This is not a script but a commentary, we want udev-rules
|
|
|
|
*console*) continue ;; # Use the files that came with the bootscripts
|
2006-08-11 22:57:47 +02:00
|
|
|
*network*) continue ;; # Manually create these files
|
2006-07-23 16:44:13 +02:00
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
|
|
|
bootscripttools="$bootscripttools $this_script"
|
|
|
|
|
|
|
|
# Grab the name of the target, strip id number, XXX-script
|
|
|
|
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
|
|
|
-e 's@-64bit@@' \
|
|
|
|
-e 's@-64@@' \
|
|
|
|
-e 's@64@@' \
|
|
|
|
-e 's@n32@@'`
|
|
|
|
case $name in
|
|
|
|
*bootscripts*) name=bootscripts-cross-lfs ;;
|
|
|
|
*udev-rules) name=udev-cross-lfs ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
|
|
|
# as a dependency. Also call the echo_message function.
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_target "${this_script}" "$PREV"
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# If $pkg_tarball isn't empty, we've got a package...
|
2007-06-03 11:06:13 +02:00
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
|
|
|
LUSER_wrt_unpack "$pkg_tarball"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
LUSER_wrt_TouchTimestamp
|
|
|
|
fi
|
|
|
|
fi
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_RunAsUser "${file}"
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
2007-06-03 11:06:13 +02:00
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
|
|
|
LUSER_RemoveBuildDirs "${name}"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
LUSER_wrt_LogNewFiles "$name"
|
|
|
|
fi
|
|
|
|
fi
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# Include a touch of the target name so make can check if it's already been made.
|
|
|
|
wrt_touch
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=$this_script
|
|
|
|
|
|
|
|
done # for file in bootscripts/* ...
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------#
|
|
|
|
bootable_Makefiles() { #
|
|
|
|
#-----------------------------#
|
2006-10-02 21:32:06 +02:00
|
|
|
echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
for file in bootable/* ; do
|
|
|
|
# Keep the script file name
|
|
|
|
this_script=`basename $file`
|
|
|
|
|
|
|
|
# A little housekeeping on the scripts
|
|
|
|
case $this_script in
|
|
|
|
*grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
2006-10-02 21:32:06 +02:00
|
|
|
*fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
2006-07-23 16:44:13 +02:00
|
|
|
*kernel) # if there is no kernel config file do not build the kernel
|
|
|
|
[[ -z $CONFIG ]] && continue
|
|
|
|
# Copy the config file to /sources with a standardized name
|
|
|
|
cp $CONFIG $BUILDDIR/sources/kernel-config
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
#
|
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
2006-10-02 21:32:06 +02:00
|
|
|
# NOTE: new makfile format forces the last script, *chowning, into a separate
|
|
|
|
# phase.
|
|
|
|
case ${this_script} in
|
2006-12-11 14:59:08 +01:00
|
|
|
*chowning) chowning=" ${this_script}" ;;
|
2006-10-02 21:32:06 +02:00
|
|
|
*) bootable="$bootable $this_script" ;;
|
|
|
|
esac
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# Grab the name of the target, strip id number and misc words.
|
|
|
|
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
|
|
|
case $this_script in
|
|
|
|
*kernel*) name=linux
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
pkg_tarball=$(get_package_tarball_name $name)
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
|
|
|
# as a dependency. Also call the echo_message function.
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_target "${this_script}" "$PREV"
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# If $pkg_tarball isn't empty, we've got a package...
|
2007-06-03 11:06:13 +02:00
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
|
|
|
LUSER_wrt_unpack "$pkg_tarball"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
LUSER_wrt_TouchTimestamp
|
|
|
|
fi
|
|
|
|
fi
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# Select a script execution method
|
|
|
|
case $this_script in
|
|
|
|
*fstab*) if [[ -n "$FSTAB" ]]; then
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_CopyFstab
|
2006-07-23 16:44:13 +02:00
|
|
|
else
|
2006-10-02 21:32:06 +02:00
|
|
|
LUSER_wrt_RunAsUser "${file}"
|
2006-07-23 16:44:13 +02:00
|
|
|
fi
|
|
|
|
;;
|
2006-11-11 22:20:15 +01:00
|
|
|
*chowning) wrt_RunAsRoot "${file}"
|
2006-08-08 19:26:40 +02:00
|
|
|
;;
|
2006-10-02 21:32:06 +02:00
|
|
|
*) LUSER_wrt_RunAsUser "${file}"
|
2006-08-08 19:26:40 +02:00
|
|
|
;;
|
2006-07-23 16:44:13 +02:00
|
|
|
esac
|
|
|
|
#
|
|
|
|
# Housekeeping...remove any build directory(ies) except if the package build fails.
|
2007-06-03 11:06:13 +02:00
|
|
|
if [ "$pkg_tarball" != "" ] ; then
|
|
|
|
LUSER_RemoveBuildDirs "${name}"
|
|
|
|
if [ "${INSTALL_LOG}" = "y" ] ; then
|
|
|
|
LUSER_wrt_LogNewFiles "$name"
|
|
|
|
fi
|
|
|
|
fi
|
2006-07-23 16:44:13 +02:00
|
|
|
#
|
|
|
|
# Include a touch of the target name so make can check if it's already been made.
|
|
|
|
wrt_touch
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=$this_script
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------#
|
|
|
|
build_Makefile() { # Construct a Makefile from the book scripts
|
|
|
|
#-----------------------------#
|
|
|
|
echo "Creating Makefile... ${BOLD}START${OFF}"
|
|
|
|
|
|
|
|
cd $JHALFSDIR/${PROGNAME}-commands
|
|
|
|
# Start with a clean Makefile.tmp file
|
|
|
|
>$MKFILE.tmp
|
|
|
|
|
|
|
|
host_prep_Makefiles
|
|
|
|
cross_tools_Makefiles # $cross_tools
|
|
|
|
final_system_Makefiles # $basicsystem
|
|
|
|
bootscripts_Makefiles # $bootscripttools
|
|
|
|
bootable_Makefiles # $bootable
|
2006-12-15 11:53:10 +01:00
|
|
|
# Add the CUSTOM_TOOLS targets, if needed
|
|
|
|
[[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
|
|
|
# Add the BLFS_TOOL targets, if needed.
|
|
|
|
[[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
# Add a header, some variables and include the function file
|
|
|
|
# to the top of the real Makefile.
|
2006-11-11 20:55:13 +01:00
|
|
|
wrt_Makefile_header
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
# Drop in the main target 'all:' and the chapter targets with each sub-target
|
|
|
|
# as a dependency.
|
|
|
|
(
|
2006-10-02 21:32:06 +02:00
|
|
|
cat << EOF
|
|
|
|
|
2007-03-03 13:18:07 +01:00
|
|
|
all: ck_UID mk_SETUP mk_LUSER create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL mk_ROOT
|
2006-12-11 19:21:16 +01:00
|
|
|
@sudo make restore-luser-env
|
2006-10-02 21:32:06 +02:00
|
|
|
@sudo make do-housekeeping
|
2006-07-23 16:44:13 +02:00
|
|
|
@\$(call echo_finished,$VERSION)
|
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
ck_UID:
|
|
|
|
@if [ \`id -u\` = "0" ]; then \\
|
|
|
|
echo "--------------------------------------------------"; \\
|
|
|
|
echo "You cannot run this makefile from the root account"; \\
|
|
|
|
echo "--------------------------------------------------"; \\
|
|
|
|
exit 1; \\
|
|
|
|
fi
|
2006-07-23 16:44:13 +02:00
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
mk_SETUP:
|
|
|
|
@\$(call echo_SU_request)
|
2007-03-18 11:14:04 +01:00
|
|
|
@sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
2006-10-02 21:32:06 +02:00
|
|
|
@touch \$@
|
2006-07-23 16:44:13 +02:00
|
|
|
|
2006-10-02 21:32:06 +02:00
|
|
|
mk_LUSER: mk_SETUP
|
|
|
|
@\$(call echo_SULUSER_request)
|
2007-03-18 11:14:04 +01:00
|
|
|
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
2006-10-02 21:32:06 +02:00
|
|
|
@touch \$@
|
2006-07-23 16:44:13 +02:00
|
|
|
|
2006-12-15 11:53:10 +01:00
|
|
|
mk_CUSTOM_TOOLS: create-sbu_du-report
|
2007-02-16 01:58:47 +01:00
|
|
|
@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
2007-03-03 13:18:07 +01:00
|
|
|
\$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
2006-12-15 11:53:10 +01:00
|
|
|
(sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
|
2007-03-18 11:14:04 +01:00
|
|
|
(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
2006-12-15 11:53:10 +01:00
|
|
|
fi;
|
|
|
|
@touch \$@
|
|
|
|
|
|
|
|
mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
|
|
|
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
2007-03-03 13:18:07 +01:00
|
|
|
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
2006-12-11 19:21:16 +01:00
|
|
|
(sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
|
2007-03-18 11:14:04 +01:00
|
|
|
(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
2006-12-11 19:21:16 +01:00
|
|
|
fi;
|
|
|
|
@touch \$@
|
|
|
|
|
2007-02-16 22:34:04 +01:00
|
|
|
mk_ROOT: create-sbu_du-report
|
2006-12-15 11:53:10 +01:00
|
|
|
@\$(call echo_SU_request)
|
2006-12-11 16:48:26 +01:00
|
|
|
@echo "$VERSION-sysroot - jhalfs build" > clfs-release && \\
|
|
|
|
sudo mv clfs-release \$(MOUNT_PT)/etc
|
2007-03-18 11:14:04 +01:00
|
|
|
@sudo make BREAKPOINT=\$(BREAKPOINT) ROOT
|
2006-10-02 21:32:06 +02:00
|
|
|
@touch \$@
|
2006-07-23 16:44:13 +02:00
|
|
|
|
2006-12-15 11:53:10 +01:00
|
|
|
SETUP: $host_prep
|
|
|
|
LUSER: $cross_tools $basicsystem $bootscripttools $bootable
|
|
|
|
CUSTOM_TOOLS: $custom_list
|
|
|
|
BLFS_TOOL: $blfs_tool
|
|
|
|
ROOT: $chowning
|
2006-07-23 16:44:13 +02:00
|
|
|
|
|
|
|
|
2006-12-11 19:21:16 +01:00
|
|
|
create-sbu_du-report: mk_LUSER
|
2006-11-12 14:50:34 +01:00
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
2017-06-29 18:45:31 +02:00
|
|
|
./create-sbu_du-report.sh logs $VERSION $(date --iso-8601); \\
|
2006-11-12 14:50:34 +01:00
|
|
|
\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
|
|
|
fi;
|
|
|
|
@touch \$@
|
2006-07-23 16:44:13 +02:00
|
|
|
|
2006-08-08 19:26:40 +02:00
|
|
|
restore-luser-env:
|
2006-07-23 16:44:13 +02:00
|
|
|
@\$(call echo_message, Building)
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
|
|
|
mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
2006-07-23 16:44:13 +02:00
|
|
|
fi;
|
2007-04-13 22:40:38 +02:00
|
|
|
@if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
|
|
|
mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
2006-07-23 16:44:13 +02:00
|
|
|
fi;
|
2007-04-13 22:40:38 +02:00
|
|
|
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
|
2006-07-23 16:44:13 +02:00
|
|
|
touch \$@ && \\
|
|
|
|
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
|
|
|
|
|
|
|
do-housekeeping:
|
2006-08-08 19:26:40 +02:00
|
|
|
@-if [ ! -f luser-exist ]; then \\
|
|
|
|
userdel \$(LUSER); \\
|
2007-04-13 22:40:38 +02:00
|
|
|
rm -rf \$(LUSER_HOME); \\
|
2006-07-23 16:44:13 +02:00
|
|
|
fi;
|
|
|
|
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
|
|
|
|
|
|
|
# Bring over the items from the Makefile.tmp
|
|
|
|
cat $MKFILE.tmp >> $MKFILE
|
|
|
|
rm $MKFILE.tmp
|
|
|
|
echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
|
|
|
|
|
|
|
}
|