Import Upstream version 20180207
[hcoop/debian/mlton.git] / mlton / front-end / Makefile
1 ## Copyright (C) 2009,2014-2015 Matthew Fluet.
2 # Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
3 # Jagannathan, and Stephen Weeks.
4 # Copyright (C) 1997-2000 NEC Research Institute.
5 #
6 # MLton is released under a BSD-style license.
7 # See the file MLton-LICENSE for details.
8 ##
9
10 SED := sed
11
12 ######################################################################
13 ######################################################################
14
15 SRC := $(shell cd ../.. && pwd)
16 BUILD := $(SRC)/build
17 BIN := $(BUILD)/bin
18
19 PATH := $(BIN):$(shell echo $$PATH)
20
21 ######################################################################
22
23 .PHONY: all
24 all: ml.lex.sml ml.grm.sig ml.grm.sml mlb.lex.sml mlb.grm.sig mlb.grm.sml
25
26 .PHONY: clean
27 clean:
28 ../../bin/clean
29
30
31 ifeq (mllex, $(shell if mllex >/dev/null 2>&1 || [ $$? != 127 ] ; then echo mllex; fi))
32 MLLEX := mllex
33 else
34 ifeq (ml-lex, $(shell if ml-lex >/dev/null 2>&1 || [ $$? != 127 ] ; then echo ml-lex; fi))
35 MLLEX := ml-lex
36 else
37 MLLEX := no-mllex
38 endif
39 endif
40
41 %.lex.sml: %.lex
42 rm -f $<.*
43 $(MLLEX) $<
44 mv $<.sml $<.sml.in
45 $(SED) -e 's/val s = List.map f (List.rev (tl (List.rev s)))/val s = Pervasive.List.map f (Pervasive.List.rev (tl (Pervasive.List.rev s)))/' $<.sml.in > $<.sml
46 mv $<.sml $<.sml.in
47 $(SED) -e 's/in Vector.fromList(List.map g/in Vector.fromList(Pervasive.List.map g/' $<.sml.in > $<.sml
48 rm -f $<.sml.in
49 chmod -w $<.*
50
51
52 ifeq (mlyacc, $(shell if mlyacc >/dev/null 2>&1 || [ $$? != 127 ] ; then echo mlyacc; fi))
53 MLYACC := mlyacc
54 else
55 ifeq (ml-yacc, $(shell if ml-lex >/dev/null 2>&1 || [ $$? != 127 ] ; then echo ml-yacc; fi))
56 MLYACC := ml-yacc
57 else
58 MLYACC := no-mlyacc
59 endif
60 endif
61
62 %.grm.sig %.grm.sml: %.grm
63 rm -f $<.*
64 $(MLYACC) $<
65 mv $<.sml $<.sml.in
66 $(SED) -e 's/in f 0 handle General.Subscript => ()/in f 0 handle Pervasive.General.Subscript => ()/' $<.sml.in > $<.sml
67 mv $<.sml $<.sml.in
68 $(SED) -e 's/in Array.fromList(List.map actionRowLookUp actionRowNumbers)/in Array.fromList(Pervasive.List.map actionRowLookUp actionRowNumbers)/' $<.sml.in > $<.sml
69 rm -f $<.sml.in
70 chmod -w $<.*