summaryrefslogtreecommitdiff
path: root/rules/shell-wrapper.mk
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-09-27 19:11:09 +0100
committerIan Lynagh <ian@well-typed.com>2012-10-01 21:36:56 +0100
commit483c763341360f810ed2136b95591db1486d0533 (patch)
tree2f29466a1fd60c2037e3863b99eccf1e314db6d6 /rules/shell-wrapper.mk
parentd106284b4018efeb1f3cf2249a4a713539150376 (diff)
downloadhaskell-483c763341360f810ed2136b95591db1486d0533.tar.gz
Refactor the shell-wrapper-creation logic
Diffstat (limited to 'rules/shell-wrapper.mk')
-rw-r--r--rules/shell-wrapper.mk39
1 files changed, 33 insertions, 6 deletions
diff --git a/rules/shell-wrapper.mk b/rules/shell-wrapper.mk
index 6601e3cb05..34b803e063 100644
--- a/rules/shell-wrapper.mk
+++ b/rules/shell-wrapper.mk
@@ -16,13 +16,37 @@ $(call profStart, shell-wrapper($1,$2))
# $1 = dir
# $2 = distdir
-ifeq "$$($1_$2_SHELL_WRAPPER) $$(Windows)" "YES NO"
+ifeq "$$(Windows)" "YES"
+$1_$2_WANT_INPLACE_WRAPPER = NO
+else ifeq "$$($1_$2_INSTALL_INPLACE)" "NO"
+$1_$2_WANT_INPLACE_WRAPPER = NO
+else ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+# We need to set LD_LIBRARY_PATH for all programs, so always need
+# a shell wrapper
+$1_$2_WANT_INPLACE_WRAPPER = YES
+else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
+$1_$2_WANT_INPLACE_WRAPPER = YES
+else
+$1_$2_WANT_INPLACE_WRAPPER = NO
+endif
+
+ifeq "$$(Windows)" "YES"
+$1_$2_WANT_INSTALLED_WRAPPER = NO
+else ifeq "$$($1_$2_INSTALL)" "NO"
+$1_$2_WANT_INSTALLED_WRAPPER = NO
+else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
+$1_$2_WANT_INSTALLED_WRAPPER = YES
+else
+$1_$2_WANT_INSTALLED_WRAPPER = NO
+endif
+
+
+ifeq "$$($1_$2_WANT_INPLACE_WRAPPER)" "YES"
ifeq "$$($1_$2_SHELL_WRAPPER_NAME)" ""
$1_$2_SHELL_WRAPPER_NAME = $1/$$($1_$2_PROG).wrapper
endif
-ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
all_$1_$2 : $$(INPLACE_BIN)/$$($1_$2_PROG)
$$(INPLACE_BIN)/$$($1_$2_PROG): WRAPPER=$$@
@@ -36,11 +60,16 @@ $$(INPLACE_BIN)/$$($1_$2_PROG): $$($1_$2_INPLACE) $$($1_$2_SHELL_WRAPPER_NAME)
echo 'pgmgcc="$$(WhatGccIsCalled)"' >> $$@
$$($1_$2_SHELL_WRAPPER_EXTRA)
$$($1_$2_INPLACE_SHELL_WRAPPER_EXTRA)
+ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
cat $$($1_$2_SHELL_WRAPPER_NAME) >> $$@
+else
+ echo 'exec "$executablename" $$$${1+"$$$$@"}' >> $$@
+endif
$$(EXECUTABLE_FILE) $$@
+
endif
-ifeq "$$($1_$2_INSTALL)" "YES"
+ifeq "$$($1_$2_WANT_INSTALLED_WRAPPER)" "YES"
ifeq "$$($1_$2_INSTALL_SHELL_WRAPPER_NAME)" ""
$1_$2_INSTALL_SHELL_WRAPPER_NAME = $$($1_$2_PROG)
@@ -70,9 +99,7 @@ install_$1_$2_wrapper:
cat $$($1_$2_SHELL_WRAPPER_NAME) >> "$$(WRAPPER)"
$$(EXECUTABLE_FILE) "$$(WRAPPER)"
-endif # $1_$2_INSTALL
-
-endif # $1_$2_SHELL_WRAPPER && !Windows
+endif
$(call profEnd, shell-wrapper($1,$2))
endef