summaryrefslogtreecommitdiffstats
path: root/tools/mxe-activate
blob: db707b2667d447bfa1850e6677040f7a739965a0 (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
export MXE_DIR=`pwd`
export PATH=$MXE_DIR/usr/bin:$PATH
alias mxe='env -i PATH=$PATH make -C $MXE_DIR'

SED=`gsed --help >/dev/null 2>&1 && echo g`sed

unset `grep '^unexport' Makefile | $SED -n 's,unexport,,p' | tr '\n' ' '`

_mxe()
{
    local cur prev pkgs tgts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    pkgs=$( for x in `ls -l $MXE_DIR/src/*.mk | $SED -n 's,.*src/\(.*\)\.mk,\1,p'`; do echo ${x} ; done )
    tgts="i686-pc-mingw32 x86_64-w64-mingw32 i686-w64-mingw32"

    case "${cur}" in
    build-only-*_*)
        local base=`echo ${cur} | $SED -n 's,\(.*_\).*,\1,p'`
        local _tgts=$( for x in ${tgts}; do echo $base${x} ; done )
        COMPREPLY=( $(compgen -W "${_tgts}" -- ${cur}) )
        return 0
        ;;
    build-only-*)
        local _pkgs=$( for x in ${pkgs}; do echo build-only-${x} ; done )
        COMPREPLY=( $(compgen -W "${_pkgs}" -- ${cur}) )
        return 0
        ;;
    download-*)
        local _pkgs=$( for x in ${pkgs}; do echo download-${x} ; done )
        COMPREPLY=( $(compgen -W "${_pkgs}" -- ${cur}) )
        return 0
        ;;
    update-checksum-*)
        local _pkgs=$( for x in ${pkgs}; do echo update-checksum-${x} ; done )
        COMPREPLY=( $(compgen -W "${_pkgs}" -- ${cur}) )
        return 0
        ;;
    [!-]*)
        pkgs+=" build-only- check-requirements clean clean-pkg download download- update-checksum-"
        COMPREPLY=( $(compgen -W "${pkgs}" -- ${cur}) )
        return 0
        ;;
    esac

}
complete -o nospace -o default -F _mxe mxe make gmake