aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/setup-machine-arch.sh
blob: 3af06f4b5190ff896f3180b7a061802026bf10d4 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/sh

if [ "$1" = "-quiet" ] ; then
    quiet=1
    shift 1
else
    quiet=0
fi

kernel=`uname -s`
os=`uname -o`
machine=`uname -m`

case "$os" in
    "FreeBSD") 
        os_name="freebsd"
    ;;
    "GNU/Linux") 
        os_name="linux"
    ;;
    "Linux") 
        os_name="linux"
    ;;
    *) 
        echo "Unsupported os $os"
        exit 1
    ;;
esac

case "$machine" in
    "arm") 
        cpu="arm"
        cpufamily="arm"
        archabi="armhf"
        case "$os_name" in
            "linux")
                syslibdir="arm-${os_name}-gnueabihf"
            ;;
            *) 
                syslibdir=""
            ;;
        esac
    ;;
    "armv7l")
        cpu="armv7l"
        cpufamily="arm"
        archabi="armhf"
        case "$os_name" in
            "linux")
                syslibdir="arm-${os_name}-gnueabihf"
            ;;
            *) 
                syslibdir=""
            ;;
        esac
    ;;
    "aarch64")
        cpu="aarch64"
        cpufamily="arm"
        archabi="arm64"
        case "$os_name" in
            "linux")
                syslibdir="aarch64-${os_name}-gnu"
            ;;
            *) 
                syslibdir=""
            ;;
        esac
    ;;
    "amd64")
        cpu="x86_64"
        cpufamily="x86"
        archabi="amd64"
        case "$os_name" in
            "linux")
                syslibdir="x86_64-${os_name}-gnu"
            ;;
            *) 
                syslibdir=""
            ;;
        esac
    ;;
    "x86_64")
        cpu="x86_64"
        cpufamily="x86"
        archabi="amd64"
        case "$os_name" in
            "linux")
                syslibdir="x86_64-${os_name}-gnu"
            ;;
            *) 
                syslibdir=""
            ;;
        esac
    ;;
    *) 
        echo "Unsupported machine $machine"
        exit 1
    ;;
esac

if [ $quiet -eq 0 ] ; then
    echo kernel $kernel
    echo os $os
    echo machine $machine
    echo os_name $os_name
    echo cpu $cpu
    echo cpufamily $cpufamily
    echo archabi $archabi
    echo syslibdir $syslibdir
fi

if [ -z "$JAVA_HOME" -o ! -e "$JAVA_HOME" ] ; then
    if [ $quiet -eq 0 ] ; then
        echo "JAVA_HOME: Searching for OpenJDK"
    fi
    if [ -e /usr/lib/jvm/default-jvm-$archabi ] ; then
        export JAVA_HOME=/usr/lib/jvm/default-jvm-$archabi
    elif [ -e /usr/lib/jvm/java-17-openjdk-$archabi ] ; then
        export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-$archabi
    elif [ -e /usr/lib/jvm/java-11-openjdk-$archabi ] ; then
        export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-$archabi
    elif [ -e /usr/lib/jvm/default-jvm ] ; then
        export JAVA_HOME=/usr/lib/jvm/default-jvm
    elif [ -e /usr/lib/jvm/java-17-openjdk ] ; then
        export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
    elif [ -e /usr/lib/jvm/java-11-openjdk ] ; then
        export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
    elif [ -e /usr/local/openjdk17 ] ; then
        export JAVA_HOME=/usr/local/openjdk17
    elif [ -e /usr/local/openjdk11 ] ; then
        export JAVA_HOME=/usr/local/openjdk11
    fi
    if [ $quiet -eq 0 ] ; then
        if [ -z "$JAVA_HOME" -o ! -e "$JAVA_HOME" ] ; then
            echo "JAVA_HOME: Warning: Not Found"
        else
            echo "JAVA_HOME: Found $JAVA_HOME"
        fi
    fi
fi

if [ -z "$JUNIT_CP" -o ! -e "$JUNIT_CP" ] ; then
    if [ $quiet -eq 0 ] ; then
        echo "JUNIT_CP: Searching for junit"
    fi
    for prefix_spath in /usr/share/java /usr/local/share/java/classes ; do
        for junit_jarfile in junit4.jar junit.jar ; do
            if [ -e $prefix_spath/$junit_jarfile ] ; then
                JUNIT_CP=$prefix_spath/$junit_jarfile
                for hamcrest_jarfile in hamcrest-all.jar hamcrest.jar ; do
                    if [ -e $prefix_spath/$hamcrest_jarfile ] ; then
                        JUNIT_CP=$JUNIT_CP:$prefix_spath/$hamcrest_jarfile
                    fi
                done
                break
            fi
        done
    done
    if [ $quiet -eq 0 ] ; then
        if [ -z "$JUNIT_CP" ] ; then
            echo "JUNIT_CP: Warning: Not Found"
        else
            echo "JUNIT_CP: Found $JUNIT_CP"
        fi
    fi
fi