From acb5f0b617f1b887cc8ea5bc2473fdf9c0ca3b1c Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Sun, 15 Jan 2017 03:24:31 +0200 Subject: [PATCH] Externalized the additional CFLAGS. Removed the isohybrid functionality. These changes haven't been tested yet. --- src/.config | 6 +++++- src/02_build_kernel.sh | 5 ++++- src/04_build_glibc.sh | 5 ++++- src/07_build_busybox.sh | 5 ++++- src/12_generate_iso.sh | 4 ---- src/overlay_00_clean.sh | 7 +++---- src/overlay_dropbear_02_build.sh | 5 ++++- src/overlay_links_02_build.sh | 5 ++++- 8 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/.config b/src/.config index b2e414290..5cd09b09f 100644 --- a/src/.config +++ b/src/.config @@ -45,7 +45,7 @@ SYSLINUX_SOURCE_URL=http://kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.0 # # http://links.twibright.com # -LINKS_SOURCE_URL=http://links.twibright.com/download/links-2.13.tar.bz2 +LINKS_SOURCE_URL=http://links.twibright.com/download/links-2.14.tar.bz2 # You can find the latest Dropbear source bundles here: # @@ -166,3 +166,7 @@ USE_BOOT_LOGO=true # value '2' and if your CPU has 4 cores, then the number of 'make' jobs will be # 4 * 2 = 8. Don't change this property unless you know what 'make' jobs are! JOB_FACTOR=1 + +# This property defines the default GCC flags to be used during the compilation +# process. You can use your own flags here or even completely remove the flags. +CFLAGS=-Os -s -fno-stack-protector -fomit-frame-pointer -U_FORTIFY_SOURCE diff --git a/src/02_build_kernel.sh b/src/02_build_kernel.sh index 7d2dcaa12..e2dad5af0 100755 --- a/src/02_build_kernel.sh +++ b/src/02_build_kernel.sh @@ -7,6 +7,9 @@ SRC_DIR=$(pwd) # Read the 'JOB_FACTOR' property from '.config' JOB_FACTOR="$(grep -i ^JOB_FACTOR .config | cut -f2 -d'=')" +# Read the 'CFLAGS' property from '.config' +CFLAGS="$(grep -i ^CFLAGS .config | cut -f2 -d'=')" + # Find the number of available CPU cores. NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) @@ -91,7 +94,7 @@ fi # http://unix.stackexchange.com/questions/5518/what-is-the-difference-between-the-following-kernel-makefile-terms-vmlinux-vmlinux echo "Building kernel..." make \ - CFLAGS="-Os -s -fno-stack-protector -U_FORTIFY_SOURCE" \ + CFLAGS="$CFLAGS" \ bzImage -j $NUM_JOBS # Install the kernel file. diff --git a/src/04_build_glibc.sh b/src/04_build_glibc.sh index 3230d79a9..a1518a470 100755 --- a/src/04_build_glibc.sh +++ b/src/04_build_glibc.sh @@ -7,6 +7,9 @@ SRC_DIR=$(pwd) # Read the 'JOB_FACTOR' property from '.config' JOB_FACTOR="$(grep -i ^JOB_FACTOR .config | cut -f2 -d'=')" +# Read the 'CFLAGS' property from '.config' +CFLAGS="$(grep -i ^CFLAGS .config | cut -f2 -d'=')" + # Find the number of available CPU cores. NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) @@ -50,7 +53,7 @@ $GLIBC_SRC/configure \ --without-gd \ --without-selinux \ --disable-werror \ - CFLAGS="-Os -s -fno-stack-protector -U_FORTIFY_SOURCE -fomit-frame-pointer" + CFLAGS="$CFLAGS" # Compile glibc with optimization for "parallel jobs" = "number of processors". echo "Building glibc..." diff --git a/src/07_build_busybox.sh b/src/07_build_busybox.sh index 96cf7214f..03c3761be 100755 --- a/src/07_build_busybox.sh +++ b/src/07_build_busybox.sh @@ -58,10 +58,13 @@ GLIBC_PREPARED_ESCAPED=$(echo \"$GLIBC_PREPARED\" | sed 's/\//\\\//g') # Now we tell BusyBox to use the glibc prepared area. sed -i "s/.*CONFIG_SYSROOT.*/CONFIG_SYSROOT=$GLIBC_PREPARED_ESCAPED/" .config +# Read the 'CFLAGS' property from '.config' +CFLAGS="$(grep -i ^CFLAGS .config | cut -f2 -d'=')" + # Compile busybox with optimization for "parallel jobs" = "number of processors". echo "Building BusyBox..." make \ - EXTRA_CFLAGS="-Os -s -fno-stack-protector -U_FORTIFY_SOURCE" \ + EXTRA_CFLAGS="$CFLAGS" \ busybox -j $NUM_JOBS # Create the symlinks for busybox. The file 'busybox.links' is used for this. diff --git a/src/12_generate_iso.sh b/src/12_generate_iso.sh index 670a2c5ac..1b2403567 100755 --- a/src/12_generate_iso.sh +++ b/src/12_generate_iso.sh @@ -153,10 +153,6 @@ genisoimage \ -boot-info-table \ ./ -# This allows the ISO image to be bootable if it is burned on USB flash drive. -# The -u option is used in EFI boot mode and it reduces the ISO image size. -isohybrid -u ../minimal_linux_live.iso 2>/dev/null || true - # Copy the ISO image to the root project folder. cp ../minimal_linux_live.iso ../../ diff --git a/src/overlay_00_clean.sh b/src/overlay_00_clean.sh index 38c913a63..a77a83955 100755 --- a/src/overlay_00_clean.sh +++ b/src/overlay_00_clean.sh @@ -6,15 +6,14 @@ echo "Cleaning up the overlay work area. This may take a while..." rm -rf work/overlay mkdir -p work/overlay -# Just in case we execute the overlay software generation script before we -# execute the main build script. mkdir -p work/src/minimal_overlay -# -p stops errors if the directory already exists +# -p stops errors if the directory already exists. mkdir -p source/overlay -cd minimal_overlay +cd work/src/minimal_overlay +# Remove all previously prepared overlay artifacts. for dir in $(ls -d */ 2>/dev/null) ; do rm -rf $dir echo "Overlay folder '$dir' has been removed." diff --git a/src/overlay_dropbear_02_build.sh b/src/overlay_dropbear_02_build.sh index 8744b7be2..cf00fba18 100755 --- a/src/overlay_dropbear_02_build.sh +++ b/src/overlay_dropbear_02_build.sh @@ -5,6 +5,9 @@ SRC_DIR=$(pwd) # Read the 'JOB_FACTOR' property from '.config' JOB_FACTOR="$(grep -i ^JOB_FACTOR .config | cut -f2 -d'=')" +# Read the 'CFLAGS' property from '.config' +CFLAGS="$(grep -i ^CFLAGS .config | cut -f2 -d'=')" + # Find the number of available CPU cores. NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) @@ -31,7 +34,7 @@ echo "Configuring Dropbear..." --prefix=$SRC_DIR/work/overlay/dropbear/dropbear_installed \ --disable-zlib \ --disable-loginfunc \ - CFLAGS="-Os -s -fno-stack-protector -U_FORTIFY_SOURCE" + CFLAGS="$CFLAGS" echo "Building Dropbear..." make -j $NUM_JOBS diff --git a/src/overlay_links_02_build.sh b/src/overlay_links_02_build.sh index f6bcb1853..bd2faf19c 100755 --- a/src/overlay_links_02_build.sh +++ b/src/overlay_links_02_build.sh @@ -5,6 +5,9 @@ SRC_DIR=$(pwd) # Read the 'JOB_FACTOR' property from '.config' JOB_FACTOR="$(grep -i ^JOB_FACTOR .config | cut -f2 -d'=')" +# Read the 'CFLAGS' property from '.config' +CFLAGS="$(grep -i ^CFLAGS .config | cut -f2 -d'=')" + # Find the number of available CPU cores. NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) @@ -32,7 +35,7 @@ echo "Configuring Links..." --without-x # Set CFLAGS directly in Makefile. -sed -i "s/^CFLAGS = .*/CFLAGS = \\-Os \\-s \\-fno\\-stack\\-protector \\-U_FORTIFY_SOURCE/" Makefile +sed -i "s/^CFLAGS = .*/CFLAGS = $CFLAGS/" Makefile echo "Building Links..." make -j $NUM_JOBS