| 1 | ## Copyright (C) 2009,2013,2018 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 | MLTON_RUNTIME_ARGS := |
| 11 | MLTON_COMPILE_ARGS := |
| 12 | |
| 13 | DIFF := diff |
| 14 | |
| 15 | ###################################################################### |
| 16 | ###################################################################### |
| 17 | |
| 18 | SRC := $(shell cd .. && pwd) |
| 19 | BUILD := $(SRC)/build |
| 20 | BIN := $(BUILD)/bin |
| 21 | |
| 22 | PATH := $(BIN):$(shell echo $$PATH) |
| 23 | |
| 24 | TARGET := self |
| 25 | |
| 26 | ###################################################################### |
| 27 | |
| 28 | MLTON := mlton |
| 29 | NAME := mllex |
| 30 | |
| 31 | all: $(NAME) |
| 32 | |
| 33 | $(NAME): $(NAME).mlb $(shell PATH="$(BIN):$$PATH" && "$(MLTON)" -stop f $(NAME).mlb) |
| 34 | @echo 'Compiling $(NAME)' |
| 35 | "$(MLTON)" @MLton $(MLTON_RUNTIME_ARGS) -- $(MLTON_COMPILE_ARGS) -target $(TARGET) $(NAME).mlb |
| 36 | |
| 37 | .PHONY: clean |
| 38 | clean: |
| 39 | ../bin/clean |
| 40 | |
| 41 | |
| 42 | PDFLATEX := pdflatex |
| 43 | |
| 44 | lexgen.pdf: lexgen.tex |
| 45 | $(PDFLATEX) lexgen.tex |
| 46 | $(PDFLATEX) lexgen.tex |
| 47 | $(PDFLATEX) lexgen.tex |
| 48 | |
| 49 | mllex.pdf: lexgen.pdf |
| 50 | cp lexgen.pdf mllex.pdf |
| 51 | |
| 52 | DOCS := |
| 53 | ifneq ($(shell which $(PDFLATEX) 2> /dev/null),) |
| 54 | DOCS += mllex.pdf |
| 55 | endif |
| 56 | |
| 57 | .PHONY: docs |
| 58 | docs: $(DOCS) |
| 59 | |
| 60 | |
| 61 | .PHONY: test |
| 62 | test: $(NAME) |
| 63 | cp -p ../mlton/front-end/ml.lex . \ |
| 64 | $(NAME) ml.lex && \ |
| 65 | $(DIFF) ml.lex.sml ../mlton/front-end/ml.lex.sml \ |
| 66 | rm -f ml.lex ml.lex.sml |