File: rip-environment.in

package info (click to toggle)
linuxcnc 1%3A2.9.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 285,604 kB
  • sloc: python: 202,568; ansic: 109,036; cpp: 99,239; tcl: 16,054; xml: 10,631; sh: 10,303; makefile: 1,255; javascript: 138; sql: 72; asm: 15
file content (136 lines) | stat: -rw-r--r-- 4,677 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
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
#!/bin/bash
# Execute this file in the context of your shell, such as with
#  . @EMC2_HOME@/scripts/rip-environment
# and your shell environment will be properly configured to run commands like
# halcompile, halcmd, halrun, iosh, and python with the emc modules available.
#
# Alternately, use it as a wrapper to invoke a linuxcnc command that requires
# the environment to be set:
#  @EMC2_HOME@/scripts/rip-environment latency-test
#
#    Copyright 2006, 2007, 2008, 2009, 2014 Jeff Epler <jepler@unpythonic.net>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

case "$0" in
    rip-environment|*/rip-environment)
        as_command=true
        if [ $# -eq 0 ]; then
                cat <<-EOF
			This script can be used in one of two ways.

			It can be loaded in the context of your shell, by executing
			    . $0
			after this, commands like 'linuxcnc', 'halrun' and so on refer to the
			version in this directory, instead of to an installed version of
			linuxcnc (if any)

			Second, it can be used to run a command in this directory without
			modifying the environment of the calling shell:
			    $0 command...
			such as
			    $0 halrun foo.hal
			    $0 linuxcnc configs/.../foo.ini
		EOF
	exit 1
        fi ;;
    *) as_command=false
esac

if ! test "xyes" = "x@RUN_IN_PLACE@"; then
    echo "This script is only useful on run-in-place systems."
    return
fi

case "$PATH" in
    @EMC2_BIN_DIR@:*|*:@EMC2_BIN_DIR@:*)
        if ! $as_command; then
            echo "This script only needs to be run once per shell session."
            return
        fi ;;
esac

EMC2_HOME=@EMC2_HOME@; export EMC2_HOME
EMC2VERSION="@EMC2VERSION@"; export EMC2VERSION
LINUXCNCVERSION="@EMC2VERSION@"; export LINUXCNCVERSION
LINUXCNC_NCFILES_DIR="@EMC2_NCFILES_DIR@"; export LINUXCNC_NCFILES_DIR
LINUXCNC_EMCSH=@WISH@; export LINUXCNC_EMCSH
PATH=@EMC2_BIN_DIR@:$EMC2_HOME/scripts:$EMC2_HOME/tcl:"$PATH"
GLADE_ICON_THEME_PATH=$EMC2_HOME/share/glade/pixmaps:"$GLADE_ICON_THEME_PATH"; export GLADE_ICON_THEME_PATH

if [ -z "$TCLLIBPATH" ]; then
    TCLLIBPATH=$EMC2_HOME/tcl
else
    TCLLIBPATH=$EMC2_HOME/tcl:$TCLLIBPATH
fi

if [ -z "$LD_LIBRARY_PATH" ]; then
    LD_LIBRARY_PATH=$EMC2_HOME/lib
else
    LD_LIBRARY_PATH=$EMC2_HOME/lib:"$LD_LIBRARY_PATH"
fi

if [ -z "$PYTHONPATH" ]; then
    PYTHONPATH=$EMC2_HOME/lib/python
else
    PYTHONPATH=$EMC2_HOME/lib/python:"$PYTHONPATH"
fi

if [ -z "$MANPATH" ]; then
    if type -path manpath > /dev/null 2>&1; then
	MANPATH=$EMC2_HOME/docs/man:"$(manpath)"
    else
	MANPATH=$EMC2_HOME/docs/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    fi
else
    MANPATH=$EMC2_HOME/docs/man:"$MANPATH"
fi

if [ -z "$GLADE_CATALOG_SEARCH_PATH" ]; then
    GLADE_CATALOG_SEARCH_PATH=$EMC2_HOME/lib/python/gladevcp
else
    GLADE_CATALOG_SEARCH_PATH=$EMC2_HOME/lib/python/gladevcp:"$GLADE_CATALOG_SEARCH_PATH"
fi

if ! $as_command; then
    # TODO: if these completion directives give trouble for any versions
    # of bash actively in use, protect them with checks of BASH_VERSINFO
    if [ $BASH_VERSINFO -eq 2 ]; then
        complete -o dirnames -f -X '!*.ini' emc axis mdi
        complete -o dirnames -f -X '!*.hal' halrun halcmd
        complete -W 'start stop restart status' realtime
        complete -C "halcmd -C" halcmd
    else
        _iningc () {
            case "$3" in
            *.ini) COMPREPLY=($(compgen -o plusdirs -f -X '!*.ngc' -- "$2")) ;;
            *) COMPREPLY=($(compgen -o plusdirs -f -X '!*.ini' -- "$2"))
            esac
        }
        complete -o plusdirs -F _iningc emc axis
        complete -o plusdirs -f -X '!*.ini' mdi
        complete -o plusdirs -f -X '!*.hal' halrun halcmd
        complete -W 'start stop restart status' realtime
        complete -C "halcmd -C" halcmd
    fi

    if [ -f $EMC2_HOME/src/Makefile ]; then
        build () { make -C $EMC2_HOME/src "$@"; }
    fi
fi

export PYTHONPATH MANPATH LD_LIBRARY_PATH TCLLIBPATH GLADE_CATALOG_SEARCH_PATH

if $as_command; then exec "$@"; fi