summaryrefslogtreecommitdiff
path: root/mk/install_script.sh
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-08-07 18:15:09 -0400
committerBen Gamari <ben@smart-cactus.org>2022-08-08 19:19:36 -0400
commit82eeb5f1025d1f93b287db163329ce9d715ab6e1 (patch)
treee64b59419ca6f302a04573109e8fbb40ce9cd8c7 /mk/install_script.sh
parent7bd11fad5490abbff3e22434522ca2514ae1dbf3 (diff)
downloadhaskell-wip/bindist-install.tar.gz
hadrian: Fix bindist installation on Darwinwip/bindist-install
It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does.
Diffstat (limited to 'mk/install_script.sh')
-rwxr-xr-xmk/install_script.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/mk/install_script.sh b/mk/install_script.sh
new file mode 100755
index 0000000000..9118795cb9
--- /dev/null
+++ b/mk/install_script.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# $1 = executable name
+# $2 = wrapper path
+# $3 = bindir
+# $4 = ghcbindir
+# $5 = Executable binary path
+# $6 = Library Directory
+# $7 = Docs Directory
+# $8 = Includes Directory
+# We are installing wrappers to programs by searching corresponding
+# wrappers. If wrapper is not found, we are attaching the common wrapper
+# to it. This implementation is a bit hacky and depends on consistency
+# of program names. For hadrian build this will work as programs have a
+# consistent naming procedure.
+
+echo "Installing $1 -> $2"
+if [ -L "wrappers/$1" ]; then
+ cp -RP "wrappers/$1" "$2"
+else
+ rm -f "$2" &&
+ touch "$2" &&
+ echo "#!$SHELL" >> "$2" &&
+ echo "exedir=\"$4\"" >> "$2" &&
+ echo "exeprog=\"$1\"" >> "$2" &&
+ echo "executablename=\"$5\"" >> "$2" &&
+ echo "bindir=\"$3\"" >> "$2" &&
+ echo "libdir=\"$6\"" >> "$2" &&
+ echo "docdir=\"$7\"" >> "$2" &&
+ echo "includedir=\"$8\"" >> "$2" &&
+ echo "" >> "$2" &&
+ cat "wrappers/$1" >> "$2" &&
+ chmod 755 "$2"
+fi