Build: remove unnecessary CLEANING/=YES check
[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://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.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_PROGNAME = ghc-asm
18 #
19 # $(eval $(call build-perl,driver/mangler,dist))
20
21 define build-perl
22 $(call trace, build-perl($1,$2))
23 $(call profStart, build-perl($1,$2))
24 # $1 = dir
25 # $2 = distdir
26
27 ifneq "$$(CLEANING)" "YES"
28 ifeq "$$($1_$2_PROGNAME)" ""
29 $$(error $1_$2_PROGNAME is not set)
30 endif
31 ifneq "$$($1_$2_PROG)" ""
32 $$(error $1_$2_PROG is set)
33 endif
34 $1_$2_PROG = $$($1_$2_PROGNAME)
35
36 ifneq "$$($$($1_$2_PROG)_INPLACE)" ""
37 $$(error $$($1_$2_PROG)_INPLACE defined twice)
38 endif
39 ifeq "$$($1_$2_TOPDIR)" "YES"
40 $$($1_$2_PROG)_INPLACE = $$(INPLACE_TOPDIR)/$$($1_$2_PROG)
41 else
42 $$($1_$2_PROG)_INPLACE = $$(INPLACE_BIN)/$$($1_$2_PROG)
43 endif
44 endif
45
46 $1_$2_INPLACE = $$($$($1_$2_PROG)_INPLACE)
47
48 $(call all-target,$1_$2,$$($1_$2_INPLACE))
49
50 $(call clean-target,$1,$2,$1/$2 $$($1_$2_INPLACE))
51 .PHONY: clean_$1
52 clean_$1 : clean_$1_$2
53
54 ifneq "$$(BINDIST)" "YES"
55 $1/$2/$$($1_$2_PROG).prl: $1/$$($1_PERL_SRC) $$$$(unlit_INPLACE) | $$$$(dir $$$$@)/.
56 "$$(unlit_INPLACE)" $$(UNLIT_OPTS) $$< $$@
57
58 $1/$2/$$($1_$2_PROG): $1/$2/$$($1_$2_PROG).prl
59 $$(call removeFiles,$$@)
60 echo '#!$$(PERL)' >> $$@
61 echo '$$$$TARGETPLATFORM = "$$(TARGETPLATFORM)";' >> $$@
62 echo '$$$$TABLES_NEXT_TO_CODE = "$(GhcEnableTablesNextToCode)";' >> $$@
63 cat $$< >> $$@
64
65 $$($1_$2_INPLACE): $1/$2/$$($1_$2_PROG) | $$$$(dir $$$$@)/.
66 "$$(CP)" $$< $$@
67 $$(EXECUTABLE_FILE) $$@
68 endif
69
70 ifeq "$$($1_$2_INSTALL)" "YES"
71 ifeq "$$($1_$2_TOPDIR)" "YES"
72 INSTALL_TOPDIRS += $$($1_$2_INPLACE)
73 else
74 INSTALL_BINS += $$($1_$2_INPLACE)
75 endif
76 endif
77
78 $(call profEnd, build-perl($1,$2))
79 endef