Merge "Merge release-4-6 into release-5-0" into release-5-0
[alexxy/gromacs.git] / scripts / GMXRC.bash.cmakein
1 # sh/bash/zsh configuration file for Gromacs
2 # First we remove old gromacs stuff from the paths
3 # by selecting everything else.
4 # This is not 100% necessary, but very useful when we
5 # repeatedly switch between gmx versions in a shell.
6
7 #we make use of IFS, which needs shwordsplit in zsh
8 test -n "${ZSH_VERSION+set}" && setopt shwordsplit
9 old_IFS="$IFS"
10 IFS=":"
11
12 # First remove gromacs part of ld_library_path
13 tmppath=""
14 for i in $LD_LIBRARY_PATH; do
15   if test "$i" != "$GMXLDLIB"; then
16     tmppath="${tmppath}${tmppath:+:}${i}"
17   fi
18 done
19 LD_LIBRARY_PATH=$tmppath
20
21 # remove gromacs part of PKG_CONFIG_PATH
22 tmppath=""
23 for i in $PKG_CONFIG_PATH; do
24   if test "$i" != "$GMXLDLIB/pkgconfig"; then
25     tmppath="${tmppath}${tmppath:+:}${i}"
26   fi
27 done
28 PKG_CONFIG_PATH=$tmppath
29
30 # remove gromacs part of path
31 tmppath=""
32 for i in $PATH; do
33   if test "$i" != "$GMXBIN"; then
34     tmppath="${tmppath}${tmppath:+:}${i}"
35   fi
36 done
37 PATH=$tmppath
38
39 # and remove the gmx part of manpath
40 tmppath=""
41 for i in $MANPATH; do
42   if test "$i" != "$GMXMAN"; then
43     tmppath="${tmppath}${tmppath:+:}${i}"
44   fi
45 done
46 MANPATH=$tmppath
47
48 ##########################################################
49 # This is the real configuration part. We save the Gromacs
50 # things in separate vars, so we can remove them later.
51 # If you move gromacs, change the first line.
52 ##########################################################
53 GMXPREFIX=@CMAKE_INSTALL_PREFIX@
54 GMXBIN=${GMXPREFIX}/@BIN_INSTALL_DIR@
55 GMXLDLIB=${GMXPREFIX}/@LIB_INSTALL_DIR@
56 GMXMAN=${GMXPREFIX}/@MAN_INSTALL_DIR@
57 GMXDATA=${GMXPREFIX}/@DATA_INSTALL_DIR@
58
59 LD_LIBRARY_PATH=${GMXLDLIB}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}
60 PKG_CONFIG_PATH=${GMXLDLIB}/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}
61 PATH=${GMXBIN}${PATH:+:}${PATH}
62 #debian/ubuntu needs a : at the end
63 MANPATH=${GMXMAN}:${MANPATH}
64
65 # export should be separate, so /bin/sh understands it
66 export GMXBIN GMXLDLIB GMXMAN GMXDATA LD_LIBRARY_PATH PATH MANPATH PKG_CONFIG_PATH
67
68 IFS="$old_IFS"
69 unset old_IFS
70
71 # read bash completions if understand how to use them
72 # and this shell supports extended globbing
73 if test -n "${BASH_VERSION+set}" && (complete) > /dev/null 2>&1; then
74   if (shopt -s extglob) > /dev/null 2>&1; then
75     if [ -f $GMXBIN/gmx-completion.bash ]; then
76       source $GMXBIN/gmx-completion.bash
77       for cfile in $GMXBIN/gmx-completion-*.bash ; do
78         source $cfile
79       done
80     fi
81   fi
82 # read zsh completions if understand how to use them
83 # Currently disabled, since the completions don't work with the new
84 # gmx binary with subcommands.
85 # Contributions to get the functionality back are welcome.
86 #elif test -n "${ZSH_VERSION+set}" && compctl >& /dev/null; then
87 #  if [ -f $GMXBIN/gmx-completion.zsh ]; then
88 #    source $GMXBIN/gmx-completion.zsh;
89 #  fi
90 fi