aboutsummaryrefslogtreecommitdiff
path: root/link_versions.sh
blob: 47a704903f094bcedfcd55c78c65be5e79788f92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
TOMO_PREFIX="$(awk -F= '/PREFIX/{print $2}' config.mk)"
cd "$TOMO_PREFIX/bin"

commands="$(ls | awk -F '[v.]' '
    /^tomo_v/{
        if ($2 >= max_major) max_major=$2;
        if ($3 >= max_minor[$2]) max_minor[$2] = $3;
        link_tomo=1
    }
    END {
        for (major in max_minor) {
            if (max_major > 0) print "ln -fs tomo_v"major"."max_minor[major]" tomo"major
        }
        if (link_tomo) print "ln -fs tomo_v"max_major"."max_minor[max_major]" tomo"
    }')"
eval "$commands"