1 # -----------------------------------------------------------------------------
3 # (c) 2009 The University of Glasgow
5 # This file is part of the GHC build system.
7 # To understand how the build system works and how to modify it, see
8 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
11 # -----------------------------------------------------------------------------
14 $(call trace, shell-wrapper($1,$2))
15 $(call profStart, shell-wrapper($1,$2))
19 ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
21 ifeq "$$(Windows)" "YES"
23 ifeq "$$($1_$2_INSTALL_SHELL_WRAPPER)" "YES"
24 # Just install the binary on Windows
30 ifeq "$$($1_$2_SHELL_WRAPPER_NAME)" ""
31 $1_$2_SHELL_WRAPPER_NAME = $1/$$($1_$2_PROG).wrapper
34 ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
35 all_$1_$2 : $$(INPLACE_BIN)/$$($1_$2_PROG)
37 $$(INPLACE_BIN)/$$($1_$2_PROG): WRAPPER=$$@
38 $$(INPLACE_BIN)/$$($1_$2_PROG): $$($1_$2_INPLACE) $$($1_$2_SHELL_WRAPPER_NAME)
39 "$$(RM)" $$(RM_OPTS) $$@
40 echo '#!$$(SHELL)' >> $$@
41 echo 'executablename="$$(TOP)/$$<"' >> $$@
42 echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"' >> $$@
43 echo 'bindir="$$(TOP)/$$(INPLACE_BIN)"' >> $$@
44 echo 'topdir="$$(TOP)/$$(INPLACE_TOPDIR)"' >> $$@
45 echo 'pgmgcc="$$(WhatGccIsCalled)"' >> $$@
46 $$($1_$2_SHELL_WRAPPER_EXTRA)
47 $$($1_$2_INPLACE_SHELL_WRAPPER_EXTRA)
48 cat $$($1_$2_SHELL_WRAPPER_NAME) >> $$@
49 $$(EXECUTABLE_FILE) $$@
52 ifeq "$$($1_$2_INSTALL_SHELL_WRAPPER)" "YES"
54 ifeq "$$($1_$2_INSTALL_SHELL_WRAPPER_NAME)" ""
55 $1_$2_INSTALL_SHELL_WRAPPER_NAME = $$($1_$2_PROG)
58 # Install the binary in $(libexecdir), and install a shell wrapper in $(bindir)
59 INSTALL_LIBEXECS += $1/$2/build/tmp/$$($1_$2_PROG)
60 BINDIST_WRAPPERS += $$($1_$2_SHELL_WRAPPER_NAME)
62 install: install_$1_$2_wrapper
64 .PHONY: install_$1_$2_wrapper
65 install_$1_$2_wrapper: WRAPPER=$$(DESTDIR)$$(bindir)/$$($1_$2_INSTALL_SHELL_WRAPPER_NAME)
66 install_$1_$2_wrapper:
67 $$(call INSTALL_DIR,"$$(DESTDIR)$$(bindir)")
68 "$$(RM)" $$(RM_OPTS) "$$(WRAPPER)"
69 $$(CREATE_SCRIPT) "$$(WRAPPER)"
70 echo '#!$$(SHELL)' >> "$$(WRAPPER)"
71 echo 'exedir="$$(ghclibexecdir)"' >> "$$(WRAPPER)"
72 echo 'exeprog="$$($1_$2_PROG)"' >> "$$(WRAPPER)"
73 echo 'executablename="$$$$exedir/$$$$exeprog"' >> "$$(WRAPPER)"
74 echo 'datadir="$$(datadir)"' >> "$$(WRAPPER)"
75 echo 'bindir="$$(bindir)"' >> "$$(WRAPPER)"
76 echo 'topdir="$$(topdir)"' >> "$$(WRAPPER)"
77 echo 'pgmgcc="$$(WhatGccIsCalled)"' >> "$$(WRAPPER)"
78 $$($1_$2_SHELL_WRAPPER_EXTRA)
79 $$($1_$2_INSTALL_SHELL_WRAPPER_EXTRA)
80 cat $$($1_$2_SHELL_WRAPPER_NAME) >> "$$(WRAPPER)"
81 $$(EXECUTABLE_FILE) "$$(WRAPPER)"
83 endif # $1_$2_INSTALL_SHELL_WRAPPER
87 endif # $1_$2_SHELL_WRAPPER
89 $(call profEnd, shell-wrapper($1,$2))