Add some comments on the alternative layout rule state
[ghc-hetmet.git] / rules / build-perl.mk
index 48694e4..669f3d7 100644 (file)
@@ -1,3 +1,15 @@
+# -----------------------------------------------------------------------------
+#
+# (c) 2009 The University of Glasgow
+#
+# This file is part of the GHC build system.
+#
+# To understand how the build system works and how to modify it, see
+#      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
+#      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
+#
+# -----------------------------------------------------------------------------
+
 
 # Build a perl script.  Invoke like this:
 #
@@ -10,8 +22,8 @@ define build-perl
 # $1 = dir
 # $2 = distdir
 
-ifeq "$$($1_$2_LIBEXEC)" "YES"
-$1_$2_INPLACE = $(INPLACE_LIB)/$$($1_$2_PROG)
+ifeq "$$($1_$2_TOPDIR)" "YES"
+$1_$2_INPLACE = $(INPLACE_TOPDIR)/$$($1_$2_PROG)
 else
 $1_$2_INPLACE = $(INPLACE_BIN)/$$($1_$2_PROG)
 endif
@@ -22,24 +34,23 @@ $(call clean-target,$1,$2,$1/$2 $$($1_$2_INPLACE))
 .PHONY: clean_$1
 clean_$1 : clean_$1_$2
 
+# INPLACE_BIN etc. might be empty if we're cleaning
+ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
 ifneq "$$(BINDIST)" "YES"
-$1/$2/$$($1_$2_PROG).prl: $1/$$($1_PERL_SRC) $$(UNLIT)
-       $$(MKDIRHIER) $1/$2
-       $$(RM) -f $$@
-       $$(UNLIT) $$(UNLIT_OPTS) $$< $$@
+$1/$2/$$($1_$2_PROG).prl: $1/$$($1_PERL_SRC) $$(UNLIT) | $$$$(dir $$$$@)/.
+       "$$(UNLIT)" $$(UNLIT_OPTS) $$< $$@
 
 $1/$2/$$($1_$2_PROG): $1/$2/$$($1_$2_PROG).prl
-       $$(RM) -f $$@
+       "$$(RM)" $$(RM_OPTS) $$@
        echo '#!$$(PERL)'                                  >> $$@
        echo '$$$$TARGETPLATFORM  = "$$(TARGETPLATFORM)";' >> $$@
        cat $$<                                            >> $$@
        $$(EXECUTABLE_FILE) $$@
 
-$$($1_$2_INPLACE): $1/$2/$$($1_$2_PROG)
-       $$(MKDIRHIER) $$(dir $$@)
-       $$(RM) -f $$@
-       $$(CP) $$< $$@
+$$($1_$2_INPLACE): $1/$2/$$($1_$2_PROG) | $$$$(dir $$$$@)/.
+       "$$(CP)" $$< $$@
        $$(EXECUTABLE_FILE) $$@
 endif
+endif
 
 endef