-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
64 lines (47 loc) · 1.17 KB
/
Makefile
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
SOURCES := $(shell find src -name '*.rs')
PARSER_GRAMMARS := $(wildcard src/parser/gmrs/*.gr)
LEXER_GRAMMARS := $(wildcard src/parser/gmrs/*.lx)
PARSER_GRAMMAR_TARGETS := $(patsubst %.gr,%.cgr,$(PARSER_GRAMMARS))
LEXER_GRAMMAR_TARGETS := $(patsubst %.lx,%.clx,$(LEXER_GRAMMARS))
DESTDIR ?=
PREFIX ?= /usr/local
BINDIR = $(DESTDIR)$(PREFIX)/bin
BUILD_FLAGS :=
ifdef RELEASE
TARGET := out/beans
ACTUAL_LOCATION := target/release/beans
BUILD_FLAGS += --release
else
TARGET := out/beans-debug
ACTUAL_LOCATION := target/debug/beans
endif
all: build
build: $(TARGET)
check:
@cargo clippy
clean:
cargo clean
$(RM) out
grammars: $(PARSER_GRAMMAR_TARGETS) $(LEXER_GRAMMAR_TARGETS)
install: out/beans
install -D -m755 $< $(BINDIR)/beans
run: build
@./$(TARGET)
test:
@cargo test
out:
@mkdir out
out/%: target/release/% | out
@cp $< $@
out/%-debug: target/debug/% | out
@cp $< $@
target/release/beans: $(SOURCES)
cargo build --release
target/debug/beans: $(SOURCES)
cargo build
%.clx: %.lx $(TARGET)
$(TARGET) compile lexer -o $@ $<
%.cgr: %.gr %.clx $(TARGET)
$(TARGET) compile parser --lexer $(word 2,$^) -o $@ $<
.PHONY: all build check clean grammars run test
.SUFFIXES: