-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (65 loc) · 1.99 KB
/
Makefile
File metadata and controls
72 lines (65 loc) · 1.99 KB
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
65
66
67
68
69
70
71
#DEBUG_LOG - enable printing of the ast
CFLAGS := -ggdb -DDEBUG_FREE=0
LDFLAGS :=
MAIN := src/main.c
TEST_MAIN := tests/test_main.c
TEST_SOURCES := tests/munit/munit.c
SOURCES := src/interpreter.c src/interpreter_builtins.c\
src/svimpl.c \
src/convert.c src/tokenizer.c src/parser.c \
src/ast_print.c src/ast_free.c \
src/b_stacktrace_impl.c
GETOPT_SOURCES := gengetopt/cmdline.c
BIN := spaz
#default install directory
ifndef INSTALL_DIR
INSTALL_DIR := /usr/local/bin/
endif
.PHONY: clean always install
.PHONY: build-all build-interpreter build-tests
.PHONY: run-tests
.PHONY: gengetopt
.PHONY: debug
.PHONY: info info-deps info-nondeps
# ===============
# UTILITY targets
# ===============
clean:
-rm -r out
-rm gengetopt/cmdline.*
always: gengetopt
mkdir -p out
build-all: build-interpreter build-tests
build-interpreter: clean always out/main
build-tests: clean always out/test_main
run-tests: build-tests
./out/test_main
# ===============
# DEBUG targets
# ===============
debug:
docker run --rm -it -v $(shell pwd):$(shell pwd) -w $(shell pwd) alpine sh -c "gcc $(SOURCES) $(GETOPT_SOURCES) $(CFLAGS) -o out/$(BIN)_x86"
docker run --rm -it -e DISPLAY=192.168.1.142:0 -v $(shell pwd):$(shell pwd) -w $(shell pwd) alpine gf2 ./out/$(BIN)_x86
info: info-deps info-nondeps
info-deps:
cloc --by-file src/ --match-f="sv.h|cvector.h"
info-nondeps:
cloc --by-file src/ --not-match-f="sv.h|cvector.h"
# ===============
# INSTALL targets
# ===============
install:
@echo "Installing to $(INSTALL_DIR)"
sudo install -d $(INSTALL_DIR)
sudo install -m 557 out/$(BIN) $(INSTALL_DIR)
# ===============
# BUILD targets
# ===============
gengetopt:
mkdir -p gengetopt
gengetopt --input=config.ggo --include-getopt
mv cmdline.* gengetopt/
out/main:
gcc $(MAIN) $(SOURCES) $(GETOPT_SOURCES) $(CFLAGS) -o out/$(BIN) -lm
out/test_main:
gcc $(TEST_MAIN) $(TEST_SOURCES) $(SOURCES) $(GETOPT_SOURCES) $(CFLAGS) -o out/test_main -lm