]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - tools/make-functions
make.sh: Use -pipe in CFLAGS when host has >1GB of memory
[ipfire-2.x.git] / tools / make-functions
index b419253fa8cd9ea577d65c73e08f4cc811bec128..1ff4613f3ea5c435c3a856cb6a2f6bc6dce85f3c 100644 (file)
@@ -60,6 +60,20 @@ WARN="\\033[1;35m"
 FAIL="\\033[1;31m"
 NORMAL="\\033[0;39m"
 
+system_memory() {
+       local key val unit
+
+       while read -r key val unit; do
+               case "${key}" in
+                       MemTotal:*)
+                               # Convert to MB
+                               echo "$(( ${val} / 1024 ))"
+                               break
+                               ;;
+               esac
+       done < /proc/meminfo
+}
+
 configure_build() {
        local build_arch="${1}"
 
@@ -124,7 +138,13 @@ configure_build() {
        # Enables hardening
        HARDENING_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4"
 
-       CFLAGS="-O2 -pipe -Wall -fexceptions -fPIC ${CFLAGS_ARCH}"
+       CFLAGS="-O2 -Wall -fexceptions -fPIC ${CFLAGS_ARCH}"
+
+       # Run compiler and assembler simultaneously on systems that have enough memory
+       if [ ${HOST_MEM} -ge 1024 ]; then
+               CFLAGS="${CFLAGS} -pipe"
+       fi
+
        CXXFLAGS="${CFLAGS}"
 }