summaryrefslogtreecommitdiff
path: root/rules/build-perl.mk
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-04-26 11:42:15 +0000
committerIan Lynagh <igloo@earth.li>2009-04-26 11:42:15 +0000
commit34cc75e1a62638f2833815746ebce0a9114dc26b (patch)
treeef21e8fd7af1356beea9cce7d6efb8a65374e24c /rules/build-perl.mk
parent74e1368d4688ee16f6decdf2cd3ebe27506b26ba (diff)
downloadhaskell-34cc75e1a62638f2833815746ebce0a9114dc26b.tar.gz
GHC new build system megapatch
Diffstat (limited to 'rules/build-perl.mk')
-rw-r--r--rules/build-perl.mk45
1 files changed, 45 insertions, 0 deletions
diff --git a/rules/build-perl.mk b/rules/build-perl.mk
new file mode 100644
index 0000000000..48694e460e
--- /dev/null
+++ b/rules/build-perl.mk
@@ -0,0 +1,45 @@
+
+# Build a perl script. Invoke like this:
+#
+# driver/mangler_PERL_SRC = ghc-asm.lprl
+# driver/mangler_dist_PROG = ghc-asm
+#
+# $(eval $(call build-perl,driver/mangler,dist))
+
+define build-perl
+# $1 = dir
+# $2 = distdir
+
+ifeq "$$($1_$2_LIBEXEC)" "YES"
+$1_$2_INPLACE = $(INPLACE_LIB)/$$($1_$2_PROG)
+else
+$1_$2_INPLACE = $(INPLACE_BIN)/$$($1_$2_PROG)
+endif
+
+$(call all-target,$$($1_$2_INPLACE))
+
+$(call clean-target,$1,$2,$1/$2 $$($1_$2_INPLACE))
+.PHONY: clean_$1
+clean_$1 : clean_$1_$2
+
+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): $1/$2/$$($1_$2_PROG).prl
+ $$(RM) -f $$@
+ echo '#!$$(PERL)' >> $$@
+ echo '$$$$TARGETPLATFORM = "$$(TARGETPLATFORM)";' >> $$@
+ cat $$< >> $$@
+ $$(EXECUTABLE_FILE) $$@
+
+$$($1_$2_INPLACE): $1/$2/$$($1_$2_PROG)
+ $$(MKDIRHIER) $$(dir $$@)
+ $$(RM) -f $$@
+ $$(CP) $$< $$@
+ $$(EXECUTABLE_FILE) $$@
+endif
+
+endef