summaryrefslogtreecommitdiffstats
path: root/helper/system.inc
blob: c37368cb0c4a44dd9605abc15d0fe769f505015d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Helper to determine various system information

#
# determine architecture triplet from the path of libc needed by the executing shell.
# please try not to use this to find/fetch libs in /lib or /usr/lib.
# Use ARCH_LIB_DIR, like "$ARCH_LIB_DIR/somefile.so" or "/usr$ARCH_LIB_DIR/somefile.so"
ARCH_TRIPLET=$(ldd $SHELL|grep "libc.so" | awk -F "/" '{print $3}')
#[ -z "$ARCH_TRIPLET" ] && pwarning "Could not determine arch triplet."
[[ $ARCH_TRIPLET == *\(*\) ]] && ARCH_TRIPLET=""

ARCH_LIB_DIR=$(ldd $SHELL | grep "libc.so" | sed -r 's#^.*(/lib.*)/libc.so.*$#\1#g')
[ -z "$ARCH_LIB_DIR" -o ! -d "$ARCH_LIB_DIR" ] && perror "Could not determine arch dependent lib dir (where libc.so resides)"

# determine kernel version
KERNEL_VERSION=$(uname -r)
[ ! -z $KERNEL_VERSION ] || pwarning "Could not determine kernel version."

# determine number of CPU cores
CPU_CORES=$(cat /proc/cpuinfo | grep processor | wc -l)
export MAKEFLAGS="-j$CPU_CORES"

# Determine if we have lib64
if [ "$(uname -m)x" = "x86_64x" ]; then
	LIB64="lib64"
else
	LIB64="lib"
fi