diff --git a/CLFS/master.sh b/CLFS/master.sh index a6c2543..8d535ef 100755 --- a/CLFS/master.sh +++ b/CLFS/master.sh @@ -184,7 +184,7 @@ temptools_Makefiles() { # # Insert instructions for unpacking the package and to set the PKGDIR variable. # [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" - [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" # wrt_run_as_su "${this_script}" "${file}" # @@ -256,7 +256,7 @@ boot_Makefiles() { # # Insert instructions for unpacking the package and changing directories # [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" - [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" # # Select a script execution method case $this_script in @@ -327,7 +327,7 @@ chroot_Makefiles() { # *util-linux) wrt_unpack "$name-$vrs.tar.*" ;; *) wrt_unpack2 "$name-$vrs.tar.*" ;; esac - [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi # # Select a script execution method @@ -388,7 +388,7 @@ testsuite_tools_Makefiles() { # tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;; *) wrt_unpack2 "$name-$vrs.tar.*" ;; esac - [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" # wrt_run_as_chroot1 "${this_script}" "${file}" # @@ -443,7 +443,7 @@ bm_testsuite_tools_Makefiles() { # tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;; *) wrt_unpack3 "$name-$vrs.tar.*" ;; esac - [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" # wrt_run_as_root2 "${this_script}" "${file}" # @@ -542,7 +542,7 @@ final_system_Makefiles() { # if [ "$vrs" != "" ] ; then FILE="$name-$vrs.tar.*" wrt_unpack2 "$FILE" - [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi # wrt_run_as_chroot1 "${this_script}" "${file}" @@ -645,7 +645,7 @@ bm_final_system_Makefiles() { # if [ "$vrs" != "" ] ; then FILE="$name-$vrs.tar.*" wrt_unpack3 "$FILE" - [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi # wrt_run_as_root2 "${this_script}" "${file}" diff --git a/HLFS/master.sh b/HLFS/master.sh index 719ad7d..0b935ad 100755 --- a/HLFS/master.sh +++ b/HLFS/master.sh @@ -142,7 +142,7 @@ chapter5_Makefiles() { # Bootstrap or temptools phase esac # Insert instructions for unpacking the package and to set the PKGDIR variable. wrt_unpack "$FILE" - [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi case $this_script in @@ -309,7 +309,7 @@ chapter6_Makefiles() { # sysroot or chroot build phase esac wrt_unpack2 "$FILE" wrt_target_vars - [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi case $this_script in diff --git a/LFS/master.sh b/LFS/master.sh index a92e84a..b0a88a7 100755 --- a/LFS/master.sh +++ b/LFS/master.sh @@ -112,7 +112,7 @@ chapter5_Makefiles() { # Insert instructions for unpacking the package and to set the PKGDIR variable. wrt_unpack "$FILE" - [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi # Insert date and disk usage at the top of the log file, the script run @@ -216,7 +216,7 @@ chapter6_Makefiles() { if [ "$vrs" != "" ] ; then FILE="$name-$vrs.tar.*" wrt_unpack2 "$FILE" - [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags + [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi # In the mount of kernel filesystems we need to set LFS diff --git a/optimize/opt_config b/optimize/opt_config index d900aca..495b2cb 100644 --- a/optimize/opt_config +++ b/optimize/opt_config @@ -13,11 +13,11 @@ MAKEFLAGS="-j3" #--- Default optimization mode -# This level is overridden by definitions in opt_override; +# This mode is overridden by definitions in opt_override; # in this way, packages can be tuned independently. For example, # if you have trouble building a package in mode defOpt, add # the package to opt_override with a different mode. -DEF_OPT_LVL=defOpt +DEF_OPT_MODE=O3pipe #--- Active optimization variables @@ -28,11 +28,12 @@ ACTIVE_OPT_VARS="CFLAGS CXXFLAGS LDFLAGS \ #--- Load optimization modes # To add modes, create a working template.. -# cp opt_config.d/defOpt opt_config.d/newMode +# cp opt_config.d/O3pipe opt_config.d/newMode # ..and edit it as desired. # -# To inherit another mode and add to it, see opt_config.d/defOpt_march -# as an example. Given opt_config.d/modeA_modeB_modeC, modeB inherits +# To inherit another mode and add to it, see opt_config.d/O3pipe_march +# or opt_config.d/defOpt_fPIC as examples for two different ways of +# doing it. Given opt_config.d/modeA_modeB_modeC, modeB inherits # the optimizations of modeA by sourcing it, and modeC inherits those # of modeB (which includes those of modeA). # diff --git a/optimize/opt_config.d/O3pipe b/optimize/opt_config.d/O3pipe new file mode 100644 index 0000000..0074647 --- /dev/null +++ b/optimize/opt_config.d/O3pipe @@ -0,0 +1,20 @@ +# +#$Id$ +# +##### +# +# MODE O3pipe configuration +# +# Usage: - Apply optimization string to each variable +# - "unset" will cause the variable to be not set +# instead of just set to null. +# +##### + +CFLAGS_O3pipe="-O3 -pipe" +CXXFLAGS_O3pipe=$CFLAGS_O3pipe +LDFLAGS_O3pipe="unset" + +OTHER_CFLAGS_O3pipe=$CFLAGS_O3pipe +OTHER_CXXFLAGS_O3pipe=$CXXFLAGS_O3pipe +OTHER_LDFLAGS_O3pipe=$LDFLAGS_O3pipe diff --git a/optimize/opt_config.d/O3pipe_march b/optimize/opt_config.d/O3pipe_march new file mode 100644 index 0000000..96a4460 --- /dev/null +++ b/optimize/opt_config.d/O3pipe_march @@ -0,0 +1,23 @@ +# +#$Id$ +# +##### +# +# MODE O3pipe_march configuration +# +# Usage: - Apply optimization string to each variable +# - "unset" will cause the variable to be not set +# instead of just set to null. +# +##### + +# Inherit optimizations from O3pipe +source optimize/opt_config.d/O3pipe + +CFLAGS_O3pipe_march=$CFLAGS_O3pipe" -march=pentium4" +CXXFLAGS_O3pipe_march=$CFLAGS_O3pipe" -march=pentium4" +LDFLAGS_O3pipe_march=$LDFLAGS_O3pipe + +OTHER_CFLAGS_O3pipe_march=$CFLAGS_O3pipe" -march=pentium4" +OTHER_CXXFLAGS_O3pipe_march=$CXXFLAGS_O3pipe" -march=pentium4" +OTHER_LDFLAGS_O3pipe_march=$LDFLAGS_O3pipe diff --git a/optimize/opt_config.d/Zlib b/optimize/opt_config.d/Zlib deleted file mode 100644 index 7503400..0000000 --- a/optimize/opt_config.d/Zlib +++ /dev/null @@ -1,56 +0,0 @@ -# -#$Id$ -# -##### -# -# MODE Zlib configuration -# -# Usage: - Apply optimization string to each variable -# - "unset" will cause the variable to be not set -# instead of just set to null. -# -##### - -# Inherit optimizations from DEF_OPT_LVL -source optimize/opt_config.d/$DEF_OPT_LVL - -eval CFLAGS_Zlib_base=\$CFLAGS_${DEF_OPT_LVL} -eval CXXFLAGS_Zlib_base=\$CXXFLAGS_${DEF_OPT_LVL} -eval LDFLAGS_Zlib_base=\$LDFLAGS_${DEF_OPT_LVL} - -eval OTHER_CFLAGS_Zlib_base=\$CFLAGS_${DEF_OPT_LVL} -eval OTHER_CXXFLAGS_Zlib_base=\$OTHER_CXXFLAGS_${DEF_OPT_LVL} -eval OTHER_LDFLAGS_Zlib_base=\$OTHER_LDFLAGS_${DEF_OPT_LVL} - -# Set the actual values for Zlib mode -if [[ "$CFLAGS_Zlib_base" != "unset" ]]; then - CFLAGS_Zlib=$CFLAGS_Zlib_base" -fPIC" -else - CFLAGS_Zlib="unset" -fi -if [[ "$CXXFLAGS_Zlib_base" != "unset" ]]; then - CXXFLAGS_Zlib=$CXXFLAGS_Zlib_base" -fPIC" -else - CXXFLAGS_Zlib="unset" -fi -if [[ "$LDFLAGS_Zlib_base" != "unset" ]]; then - LDFLAGS_Zlib=$LDFLAGS_Zlib_base -else - LDFLAGS_Zlib="unset" -fi - -if [[ "$OTHER_CFLAGS_Zlib_base" != "unset" ]]; then - OTHER_CFLAGS_Zlib=$OTHER_CFLAGS_Zlib_base" -fPIC" -else - OTHER_CFLAGS_Zlib="unset" -fi -if [[ "$OTHER_CXXFLAGS_Zlib_base" != "unset" ]]; then - OTHER_CXXFLAGS_Zlib=$OTHER_CXXFLAGS_Zlib_base" -fPIC" -else - OTHER_CXXFLAGS_Zlib="unset" -fi -if [[ "$OTHER_LDFLAGS_Zlib_base" != "unset" ]]; then - OTHER_LDFLAGS_Zlib=$OTHER_LDFLAGS_Zlib_base -else - OTHER_LDFLAGS_Zlib="unset" -fi diff --git a/optimize/opt_config.d/defOpt b/optimize/opt_config.d/defOpt deleted file mode 100644 index 2f84ecb..0000000 --- a/optimize/opt_config.d/defOpt +++ /dev/null @@ -1,20 +0,0 @@ -# -#$Id$ -# -##### -# -# MODE defOpt configuration -# -# Usage: - Apply optimization string to each variable -# - "unset" will cause the variable to be not set -# instead of just set to null. -# -##### - -CFLAGS_defOpt="-O3 -pipe" -CXXFLAGS_defOpt=$CFLAGS_defOpt -LDFLAGS_defOpt="unset" - -OTHER_CFLAGS_defOpt=$CFLAGS_defOpt -OTHER_CXXFLAGS_defOpt=$CXXFLAGS_defOpt -OTHER_LDFLAGS_defOpt=$LDFLAGS_defOpt diff --git a/optimize/opt_config.d/defOpt_fPIC b/optimize/opt_config.d/defOpt_fPIC new file mode 100644 index 0000000..c83f53e --- /dev/null +++ b/optimize/opt_config.d/defOpt_fPIC @@ -0,0 +1,28 @@ +##### +# +# MODE defOpt_fPIC configuration +# +# Usage: - Apply optimization string to each variable +# - "unset" will cause the variable to be not set +# instead of just set to null. +# +##### + +# Inherit optimizations from DEF_OPT_MODE +source optimize/opt_config.d/${DEF_OPT_MODE} + +# Append " -fPIC" to default *C{,XX}FLAGS and retain other defaults +for OPT_VAR in $ACTIVE_OPT_VARS ; do + case $OPT_VAR in + CFLAGS | CXXFLAGS | OTHER_CFLAGS | OTHER_CXXFLAGS) + if [[ "$(eval "echo \$${OPT_VAR}_${DEF_OPT_MODE}")" != "unset" ]] ; then + eval ${OPT_VAR}_defOpt_fPIC=\$${OPT_VAR}_${DEF_OPT_MODE}\" -fPIC\" + else + eval ${OPT_VAR}_defOpt_fPIC="unset" + fi + ;; + *) + eval ${OPT_VAR}_defOpt_fPIC=\$${OPT_VAR}_${DEF_OPT_MODE} + ;; + esac +done diff --git a/optimize/opt_config.d/defOpt_march b/optimize/opt_config.d/defOpt_march deleted file mode 100644 index 5df8e91..0000000 --- a/optimize/opt_config.d/defOpt_march +++ /dev/null @@ -1,23 +0,0 @@ -# -#$Id$ -# -##### -# -# MODE defOpt_march configuration -# -# Usage: - Apply optimization string to each variable -# - "unset" will cause the variable to be not set -# instead of just set to null. -# -##### - -# Inherit optimizations from defOpt -source optimize/opt_config.d/defOpt - -CFLAGS_defOpt_march=$CFLAGS_defOpt" -march=pentium4" -CXXFLAGS_defOpt_march=$CFLAGS_defOpt" -march=pentium4" -LDFLAGS_defOpt_march=$LDFLAGS_defOpt - -OTHER_CFLAGS_defOpt_march=$CFLAGS_defOpt" -march=pentium4" -OTHER_CXXFLAGS_defOpt_march=$CXXFLAGS_defOpt" -march=pentium4" -OTHER_LDFLAGS_defOpt_march=$LDFLAGS_defOpt diff --git a/optimize/opt_config.d/noOpt b/optimize/opt_config.d/noOpt index 26c2502..39abdb3 100644 --- a/optimize/opt_config.d/noOpt +++ b/optimize/opt_config.d/noOpt @@ -10,7 +10,7 @@ # of packages known to have build or runtime failure. # # Also, if you what to use MAKEFLAGS but no build -# optimizations, set this mode in DEF_OPT_LVL +# optimizations, set this mode in DEF_OPT_MODE # # Usage: - Apply optimization string to each variable # - "unset" will cause the variable to be not set diff --git a/optimize/opt_config.d/noSymbols b/optimize/opt_config.d/noSymbols index e018bc6..e43baf0 100644 --- a/optimize/opt_config.d/noSymbols +++ b/optimize/opt_config.d/noSymbols @@ -11,8 +11,8 @@ # ##### # -# NOTE: If using this mode in DEF_OPT_LVL (alone or combined with -# other mode) please set STRIP=0 in common/config +# NOTE: If using this mode in DEF_OPT_MODE (alone or combined with +# other modes) please set STRIP=0 in common/config # CFLAGS_noSymbols="-s" CXXFLAGS_noSymbols=$CFLAGS_noSymbols diff --git a/optimize/opt_override b/optimize/opt_override index e681aee..05f8637 100644 --- a/optimize/opt_override +++ b/optimize/opt_override @@ -2,4 +2,4 @@ binutils noOpt gcc noOpt glibc noOpt grub noOpt -zlib Zlib +zlib defOpt_fPIC diff --git a/optimize/optimize_functions b/optimize/optimize_functions index 14beca1..c6ca3f9 100644 --- a/optimize/optimize_functions +++ b/optimize/optimize_functions @@ -11,14 +11,14 @@ validate_opt_settings() { # Show optimize setting and wait user agreeme local OPT_VAR optVal echo -e "MAKEFLAGS: ${L_arrow}${BOLD}${MAKEFLAGS}${OFF}${R_arrow}\n" - echo -e "DEF_OPT_LVL: ${L_arrow}${BOLD}${DEF_OPT_LVL}${OFF}${R_arrow}\n" + echo -e "DEF_OPT_MODE: ${L_arrow}${BOLD}${DEF_OPT_MODE}${OFF}${R_arrow}\n" for OPT_VAR in $ACTIVE_OPT_VARS ; do - eval optVal=\$${OPT_VAR}_${DEF_OPT_LVL} + eval optVal=\$${OPT_VAR}_${DEF_OPT_MODE} echo -e "${OPT_VAR}: ${L_arrow}${BOLD}${optVal}${OFF}${R_arrow}" done - echo -e "\nOverrided packages:" + echo -e "\nOverridden packages:" cat optimize/opt_override echo "${nl_}${SD_BORDER}${nl_}" @@ -35,15 +35,15 @@ validate_opt_settings() { # Show optimize setting and wait user agreeme wrt_optimize() { # Apply pkg specific opt's to build #----------------------------------# local pkg=$1 - local optLvl optVal OPT_VAR + local optMode optVal OPT_VAR - optLvl=`awk -v pkg="$pkg" '$1 == pkg { print $2 }' $JHALFSDIR/opt_override` - if [[ "$optLvl" = "" ]] ; then - optLvl=$DEF_OPT_LVL; + optMode=`awk -v pkg="$pkg" '$1 == pkg { print $2 }' $JHALFSDIR/opt_override` + if [[ "$optMode" = "" ]] ; then + optMode=$DEF_OPT_MODE; fi for OPT_VAR in $ACTIVE_OPT_VARS ; do - eval optVal=\$${OPT_VAR}_$optLvl + eval optVal=\$${OPT_VAR}_$optMode if [[ "$optVal" != "unset" ]]; then ( @@ -60,13 +60,21 @@ EOF #----------------------------------# wrt_makeflags() { # Apply MAKEFLAGS to build #----------------------------------# - if [[ "$MAKEFLAGS" != "unset" ]]; then + local pkg=$1 + + case $pkg in + gettext | groff ) # Don't support -jX for now + ;; + *) + if [[ "$MAKEFLAGS" != "unset" ]]; then ( cat << EOF @echo "export MAKEFLAGS=\"$MAKEFLAGS\"" >> envars EOF ) >> $MKFILE.tmp - else - continue - fi + else + continue + fi + ;; + esac }