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))
18 ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
20 ifeq "$$(Windows)" "YES"
22 ifeq "$$($1_$2_INSTALL_SHELL_WRAPPER)" "YES"
23 # Just install the binary on Windows
29 ifeq "$$($1_$2_SHELL_WRAPPER_NAME)" ""
30 $1_$2_SHELL_WRAPPER_NAME = $1/$$($1_$2_PROG).wrapper
33 ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
34 all_$1_$2 : $$(INPLACE_BIN)/$$($1_$2_PROG)
36 $$(INPLACE_BIN)/$$($1_$2_PROG): WRAPPER=$$@
37 $$(INPLACE_BIN)/$$($1_$2_PROG): $$($1_$2_INPLACE) $$($1_$2_SHELL_WRAPPER_NAME)
38 "$$(RM)" $$(RM_OPTS) $$@
39 echo '#!$$(SHELL)' >> $$@
40 echo 'executablename="$$(TOP)/$$<"' >> $$@
41 echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"' >> $$@
42 echo 'bindir="$$(TOP)/$$(INPLACE_BIN)"' >> $$@
43 echo 'topdir="$$(TOP)/$$(INPLACE_TOPDIR)"' >> $$@
44 echo 'pgmgcc="$$(WhatGccIsCalled)"' >> $$@
45 $$($1_$2_SHELL_WRAPPER_EXTRA)
46 $$($1_$2_INPLACE_SHELL_WRAPPER_EXTRA)
47 cat $$($1_$2_SHELL_WRAPPER_NAME) >> $$@
48 $$(EXECUTABLE_FILE) $$@
51 ifeq "$$($1_$2_INSTALL_SHELL_WRAPPER)" "YES"
53 ifeq "$$($1_$2_INSTALL_SHELL_WRAPPER_NAME)" ""
54 $1_$2_INSTALL_SHELL_WRAPPER_NAME = $$($1_$2_PROG)
57 # Install the binary in $(libexecdir), and install a shell wrapper in $(bindir)
58 INSTALL_LIBEXECS += $1/$2/build/tmp/$$($1_$2_PROG)
59 BINDIST_WRAPPERS += $$($1_$2_SHELL_WRAPPER_NAME)
61 install: install_$1_$2_wrapper
63 .PHONY: install_$1_$2_wrapper
64 install_$1_$2_wrapper: WRAPPER=$$(DESTDIR)$$(bindir)/$$($1_$2_INSTALL_SHELL_WRAPPER_NAME)
65 install_$1_$2_wrapper:
66 $$(INSTALL_DIR) "$$(DESTDIR)$$(bindir)"
67 "$$(RM)" $$(RM_OPTS) "$$(WRAPPER)"
68 $$(CREATE_SCRIPT) "$$(WRAPPER)"
69 echo '#!$$(SHELL)' >> "$$(WRAPPER)"
70 echo 'exedir="$$(ghclibexecdir)"' >> "$$(WRAPPER)"
71 echo 'exeprog="$$($1_$2_PROG)"' >> "$$(WRAPPER)"
72 echo 'executablename="$$$$exedir/$$$$exeprog"' >> "$$(WRAPPER)"
73 echo 'datadir="$$(datadir)"' >> "$$(WRAPPER)"
74 echo 'bindir="$$(bindir)"' >> "$$(WRAPPER)"
75 echo 'topdir="$$(topdir)"' >> "$$(WRAPPER)"
76 echo 'pgmgcc="$$(WhatGccIsCalled)"' >> "$$(WRAPPER)"
77 $$($1_$2_SHELL_WRAPPER_EXTRA)
78 $$($1_$2_INSTALL_SHELL_WRAPPER_EXTRA)
79 cat $$($1_$2_SHELL_WRAPPER_NAME) >> "$$(WRAPPER)"
80 $$(EXECUTABLE_FILE) "$$(WRAPPER)"
82 endif # $1_$2_INSTALL_SHELL_WRAPPER
86 endif # $1_$2_SHELL_WRAPPER