On Cygwin, use a Cygwin-style path for /bin/install's destination
[ghc.git] / rules / build-perl.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
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
10 #
11 # -----------------------------------------------------------------------------
12
13
14 # Build a perl script. Invoke like this:
15 #
16 # driver/mangler_PERL_SRC = ghc-asm.lprl
17 # driver/mangler_dist_PROG = ghc-asm
18 #
19 # $(eval $(call build-perl,driver/mangler,dist))
20
21 define build-perl
22 $(call trace, build-perl($1,$2))
23 # $1 = dir
24 # $2 = distdir
25
26 ifeq "$$($1_$2_TOPDIR)" "YES"
27 $1_$2_INPLACE = $$(INPLACE_TOPDIR)/$$($1_$2_PROG)
28 else
29 $1_$2_INPLACE = $$(INPLACE_BIN)/$$($1_$2_PROG)
30 endif
31
32 $(call all-target,$1_$2,$$($1_$2_INPLACE))
33
34 $(call clean-target,$1,$2,$1/$2 $$($1_$2_INPLACE))
35 .PHONY: clean_$1
36 clean_$1 : clean_$1_$2
37
38 # INPLACE_BIN etc. might be empty if we're cleaning
39 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
40 ifneq "$$(BINDIST)" "YES"
41 $1/$2/$$($1_$2_PROG).prl: $1/$$($1_PERL_SRC) $$(UNLIT) | $$$$(dir $$$$@)/.
42 "$$(UNLIT)" $$(UNLIT_OPTS) $$< $$@
43 endif
44
45 $1/$2/$$($1_$2_PROG): $1/$2/$$($1_$2_PROG).prl
46 "$$(RM)" $$(RM_OPTS) $$@
47 echo '#!$$(PERL)' >> $$@
48 echo '$$$$TARGETPLATFORM = "$$(TARGETPLATFORM)";' >> $$@
49 echo '$$$$TABLES_NEXT_TO_CODE = "$(GhcEnableTablesNextToCode)";' >> $$@
50 cat $$< >> $$@
51
52 $$($1_$2_INPLACE): $1/$2/$$($1_$2_PROG) | $$$$(dir $$$$@)/.
53 "$$(CP)" $$< $$@
54 $$(EXECUTABLE_FILE) $$@
55
56 ifneq "$$($1_$2_INSTALL_IN)" ""
57 BINDIST_PERL_SOURCES += $1/$2/$$($1_$2_PROG).prl
58
59 install: install_$1_$2
60
61 .PHONY: install_$1_$2
62 install_$1_$2: $1/$2/$$($1_$2_PROG)
63 $$(call INSTALL_DIR,"$$($1_$2_INSTALL_IN)")
64 $$(call INSTALL_SCRIPT,$$(INSTALL_OPTS),$$<,"$$($1_$2_INSTALL_IN)")
65 endif
66 endif
67
68 endef