]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - tools/make-functions
Revert "make.sh: Use -pipe in CFLAGS when host has >1GB of memory"
[ipfire-2.x.git] / tools / make-functions
index 676b9710120c9bd94fb8972b187cbea3407f3c86..b7e957e1856bc65c4ef4c91dff11686b7a76bf77 100644 (file)
@@ -142,14 +142,28 @@ configure_build() {
        # Enables hardening
        HARDENING_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4"
 
-       CFLAGS="-O2 -Wall -fexceptions -fPIC ${CFLAGS_ARCH}"
+       CFLAGS="-O2 -pipe -Wall -fexceptions -fPIC ${CFLAGS_ARCH}"
+       CXXFLAGS="${CFLAGS}"
 
-       # Run compiler and assembler simultaneously on systems that have enough memory
-       if [ ${HOST_MEM} -ge 1024 ]; then
-               CFLAGS="${CFLAGS} -pipe"
-       fi
+       # Determine parallelism
+       if [ -z "${MAKETUNING}" ]; then
+               # We assume that each process consumes about
+               # 192MB of memory. Therefore we find out how
+               # many processes fit into memory.
+               local mem_max=$(( ${HOST_MEM} / 192 ))
 
-       CXXFLAGS="${CFLAGS}"
+               local processors="$(system_processors)"
+               local cpu_max=$(( ${processors} * 2 ))
+
+               local parallelism
+               if [ ${mem_max} -lt ${cpu_max} ]; then
+                       parallelism=${mem_max}
+               else
+                       parallelism=${cpu_max}
+               fi
+
+               MAKETUNING="-j${parallelism}"
+       fi
 }
 
 configure_build_guess() {