ghc.mk: Use the same conditional install logic from unlit
[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_INPLACE = YES
9
10 utils/hsc2hs_dist-install_SHELL_WRAPPER = YES
11 utils/hsc2hs_dist-install_INSTALL_INPLACE = NO
12
13 ifeq "$(Stage1Only)" "YES"
14 utils/hsc2hs_dist_INSTALL = YES
15 utils/hsc2hs_dist-install_INSTALL = NO
16 else
17 utils/hsc2hs_dist_INSTALL = NO
18 utils/hsc2hs_dist-install_INSTALL = YES
19 endif
20
21 $(eval $(call build-prog,utils/hsc2hs,dist,0))
22 $(eval $(call build-prog,utils/hsc2hs,dist-install,1))
23
24 # After build-prog above
25 utils/hsc2hs_dist-install_MODULES = $(utils/hsc2hs_dist_MODULES)
26
27 utils/hsc2hs_template=$(INPLACE_TOPDIR)/template-hsc.h
28
29 # Here we encode the cc and linker options into the wrapper for the released
30 # hsc2hs binary using a HSC2HS_EXTRA variable.
31 # For the stage0 wrapper (built in dist), we don't do this, because the build
32 # system uses it for all stages and passes the right options for each stage
33 # on the command line
34 define utils/hsc2hs_dist-install_SHELL_WRAPPER_EXTRA
35 echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> "$(WRAPPER)"
36 endef
37
38 ifneq "$(BINDIST)" "YES"
39
40 $(hsc2hs_INPLACE) : | $(utils/hsc2hs_template)
41
42 # When invoked in the source tree, hsc2hs will try to link in
43 # extra-libs from the packages, including libgmp.a. So we need a
44 # dependency to ensure these libs are built before we invoke hsc2hs:
45 $(hsc2hs_INPLACE) : $(OTHER_LIBS)
46
47 $(utils/hsc2hs_template) : utils/hsc2hs/template-hsc.h | $$(dir $$@)/.
48 "$(CP)" $< $@
49
50 endif
51
52 install: install_utils/hsc2hs_dist_install
53
54 .PHONY: install_utils/hsc2hs_dist_install
55 install_utils/hsc2hs_dist_install: utils/hsc2hs/template-hsc.h
56 $(INSTALL_HEADER) $(INSTALL_OPTS) $< "$(DESTDIR)$(topdir)"
57
58 BINDIST_EXTRAS += utils/hsc2hs/template-hsc.h
59