2023-01-17 15:49:57 +00:00
|
|
|
#!/bin/bash
|
2023-01-14 03:59:06 +00:00
|
|
|
|
|
|
|
# SMEM needs to be set here if dkms build is not initiated by install-driver.sh
|
2023-01-15 07:49:17 +00:00
|
|
|
SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
|
2023-01-14 03:59:06 +00:00
|
|
|
|
2023-01-17 15:49:57 +00:00
|
|
|
# sproc needs to be set here if dkms build is not initiated by install-driver.sh
|
|
|
|
sproc=$(nproc)
|
2023-01-14 03:59:06 +00:00
|
|
|
|
|
|
|
# Avoid Out of Memory condition in low-RAM systems by limiting core usage.
|
2023-01-25 11:35:30 +00:00
|
|
|
if [ "$sproc" -gt 1 ]; then
|
|
|
|
if [ "$SMEM" -lt 1400000 ]; then
|
2023-01-17 15:49:57 +00:00
|
|
|
sproc=2
|
2023-01-14 03:59:06 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
kernelver=${kernelver:-$(uname -r)}
|
2023-01-17 15:49:57 +00:00
|
|
|
make "-j$sproc" "KVER=$kernelver" "KSRC=/lib/modules/$kernelver/build"
|
2023-01-15 07:49:17 +00:00
|
|
|
|
|
|
|
exit 0
|