c5f7473196c4818f962d8c7635a7465241c6130b
[hsc2hs.git] / ghc.mk
1 utils/hsc2hs_USES_CABAL = YES
2 utils/hsc2hs_PACKAGE = hsc2hs
3
4 utils/hsc2hs_dist_PROGNAME = hsc2hs
5 utils/hsc2hs_dist-install_PROGNAME = hsc2hs
6
7 utils/hsc2hs_dist_SHELL_WRAPPER = YES
8 utils/hsc2hs_dist_INSTALL = NO
9 utils/hsc2hs_dist_INSTALL_INPLACE = YES
10
11 utils/hsc2hs_dist-install_SHELL_WRAPPER = YES
12 utils/hsc2hs_dist-install_INSTALL = YES
13 utils/hsc2hs_dist-install_INSTALL_INPLACE = NO
14
15 $(eval $(call build-prog,utils/hsc2hs,dist,0))
16
17 # When CrossCompiling, we want to ship the binary for the
18 # host, not for the target. As such we need to compile
19 # with the Bootstrap compiler rather than with the in-tree
20 # stage1 compiler, which would result in a binary that
21 # won't run on the host.
22 ifeq "$(CrossCompiling)" "YES"
23 # compile with stage 0 (bootstrap compiler)
24 $(eval $(call build-prog,utils/hsc2hs,dist-install,0))
25 else
26 $(eval $(call build-prog,utils/hsc2hs,dist-install,1))
27 endif
28
29 # After build-prog above
30 utils/hsc2hs_dist_MODULES += Paths_hsc2hs
31 utils/hsc2hs_dist-install_MODULES = $(utils/hsc2hs_dist_MODULES)
32
33 utils/hsc2hs_template=$(INPLACE_TOPDIR)/template-hsc.h
34
35 # Here we encode the cc and linker options into the wrapper for the released
36 # hsc2hs binary using a HSC2HS_EXTRA variable.
37 # For the stage0 wrapper (built in dist), we don't do this, because the build
38 # system uses it for all stages and passes the right options for each stage
39 # on the command line
40 define utils/hsc2hs_dist-install_SHELL_WRAPPER_EXTRA
41 echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> "$(WRAPPER)"
42 endef
43
44 ifneq "$(BINDIST)" "YES"
45
46 $(hsc2hs_INPLACE) : | $(utils/hsc2hs_template)
47
48 # When invoked in the source tree, hsc2hs will try to link in
49 # extra-libs from the packages, including libgmp.a. So we need a
50 # dependency to ensure these libs are built before we invoke hsc2hs:
51 $(hsc2hs_INPLACE) : $(OTHER_LIBS)
52
53 $(utils/hsc2hs_template) : utils/hsc2hs/template-hsc.h | $$(dir $$@)/.
54 "$(CP)" $< $@
55
56 endif
57
58 install: install_utils/hsc2hs_dist_install
59
60 .PHONY: install_utils/hsc2hs_dist_install
61 install_utils/hsc2hs_dist_install: utils/hsc2hs/template-hsc.h
62 $(INSTALL_HEADER) $(INSTALL_OPTS) $< "$(DESTDIR)$(topdir)"
63
64 BINDIST_EXTRAS += utils/hsc2hs/template-hsc.h
65