Add more quoting to distrib/MacOS/installer-scripts/create-links
[ghc-hetmet.git] / distrib / MacOS / installer-scripts / create-links
1 #!/bin/sh
2
3 # GHC framework post-install script
4 # * Add links to all executables into the standard bin/ directory
5 # * Add link to the man page into the standard man/man1/ directory
6 # * Add link to the HTML docs into the standard share/doc/ directory
7
8 # The binary links are careful not to use Current, because that will be
9 # rebound to the current version on every reinstall.
10
11 # It probably won't ever happen, but this should work correctly if the install
12 # destination has a space on it.
13
14 # See apple "Install Operations" documentation for how this script is called.
15
16 INSTALL_DEST="$2"
17 INSTALL_BASE="$3"
18
19 if [ "$INSTALL_BASE" = / ]; then
20   INSTALL_BASE=/usr
21 fi
22
23 ProjectVersionInt=$(readlink "$INSTALL_DEST/GHC.framework/Versions/Current")
24 GHC_BASE="$INSTALL_DEST/GHC.framework/Versions/$ProjectVersionInt"
25
26 INSTALL_BIN="$INSTALL_BASE/bin"
27 mkdir -p "$INSTALL_BIN"
28 if [ -d "$GHC_BASE/usr/bin" ]; then
29   ln -sf "$GHC_BASE"/usr/bin/* "$INSTALL_BIN/"
30 fi
31
32 INSTALL_MAN1="$INSTALL_BASE"/share/man/man1
33 INSTALL_HTML="$INSTALL_BASE"/share/doc
34 mkdir -p "$INSTALL_MAN1"
35 if [ -d "$GHC_BASE"/usr/share/man/man1 ]; then
36   ln -sf "$GHC_BASE"/usr/share/man/man1/* "$INSTALL_MAN1/"
37   ln -sf "$GHC_BASE"/usr/share/doc/ghc.$ProjectVersionInt "$INSTALL_HTML/"
38 fi