2023-01-25 23:17:49 +11:00
|
|
|
#!/bin/sh
|
2023-01-13 21:59:06 -06:00
|
|
|
|
2023-09-25 10:04:26 -05:00
|
|
|
# Warning: Do not run this script in a terminal. It is designed to be
|
|
|
|
|
# run from another script.
|
|
|
|
|
|
2023-01-13 21:59:06 -06:00
|
|
|
# SMEM needs to be set here if dkms build is not initiated by install-driver.sh
|
2023-11-25 15:25:49 -06:00
|
|
|
SMEM=$(LC_ALL=C free | awk '/Mem:/ { print $2 }')
|
2023-01-13 21:59:06 -06:00
|
|
|
|
2023-01-17 09:49:57 -06:00
|
|
|
# sproc needs to be set here if dkms build is not initiated by install-driver.sh
|
|
|
|
|
sproc=$(nproc)
|
2023-01-13 21:59:06 -06:00
|
|
|
|
2023-01-26 11:52:27 -06:00
|
|
|
# avoid Out of Memory condition in low-RAM systems by limiting core usage
|
2023-01-25 22:35:30 +11:00
|
|
|
if [ "$sproc" -gt 1 ]; then
|
|
|
|
|
if [ "$SMEM" -lt 1400000 ]; then
|
2023-01-17 09:49:57 -06:00
|
|
|
sproc=2
|
2023-01-13 21:59:06 -06:00
|
|
|
fi
|
2023-09-25 10:04:26 -05:00
|
|
|
if [ "$SMEM" -lt 700000 ]; then
|
|
|
|
|
sproc=1
|
|
|
|
|
fi
|
2023-01-13 21:59:06 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
kernelver=${kernelver:-$(uname -r)}
|
2023-01-17 09:49:57 -06:00
|
|
|
make "-j$sproc" "KVER=$kernelver" "KSRC=/lib/modules/$kernelver/build"
|