File: lambda2.in

package info (click to toggle)
lambda-align2 2.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 976 kB
  • sloc: cpp: 6,980; sh: 118; makefile: 42
file content (46 lines) | stat: -rw-r--r-- 1,728 bytes parent folder | download
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

CURDIR="$(cd "$(dirname "$0")" && pwd -P)/"
SYSTEM_BIN_DIR="@CMAKE_INSTALL_FULL_BINDIR@/"

if [ "${CURDIR}" = "${SYSTEM_BIN_DIR}" ]; then          # we are installed
    PREFIX="@CMAKE_INSTALL_FULL_LIBEXECDIR@"
else                                                    # we are just unpacked
    PREFIX="${CURDIR}/../@CMAKE_INSTALL_LIBEXECDIR@"
fi

BIN_FAILSAFE=${PREFIX}/lambda2
BIN_SSE4=${PREFIX}/lambda2-sse4

# failsafe is default
BIN=${BIN_FAILSAFE}

case $(uname) in
    "Linux")
        grep -E "flags.* popcnt "  -q /proc/cpuinfo 2>/dev/null && \
        grep -E "flags.* sse4_1 "  -q /proc/cpuinfo 2>/dev/null && \
        grep -E "flags.* sse4_2 "  -q /proc/cpuinfo 2>/dev/null && \
        export BIN=${BIN_SSE4}
        ;;
    "FreeBSD")
        grep -E "Feature.*POPCNT"  -q /var/run/dmesg.boot 2>/dev/null && \
        grep -E "Feature.*SSE4\.1" -q /var/run/dmesg.boot 2>/dev/null && \
        grep -E "Feature.*SSE4\.2" -q /var/run/dmesg.boot 2>/dev/null && \
        export BIN=${BIN_SSE4}
        ;;
## OpenBSD doesn't yet support POPCNT software side (although it does detect the cpu feature)
#     "OpenBSD")
#         grep -E "cpu.*POPCNT"  -q /var/run/dmesg.boot 2>/dev/null && \
#         grep -E "cpu.*SSE4\.1" -q /var/run/dmesg.boot 2>/dev/null && \
#         grep -E "cpu.*SSE4\.2" -q /var/run/dmesg.boot 2>/dev/null && \
#         export BIN=${BIN_SSE4}
#         ;;
    "Darwin")
        sysctl machdep.cpu.features 2>&1 | grep -E "POPCNT"  -q 2>/dev/null && \
        sysctl machdep.cpu.features 2>&1 | grep -E "SSE4\.1" -q 2>/dev/null && \
        sysctl machdep.cpu.features 2>&1 | grep -E "SSE4\.2" -q 2>/dev/null && \
        export BIN=${BIN_SSE4}
        ;;
esac

exec "${BIN}" "${@}"