summaryrefslogtreecommitdiff
path: root/rules/build-perl.mk
blob: 48694e460ee5c7d7d49086a95c0bbe000be3f4d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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