-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (61 loc) · 2.36 KB
/
Copy pathMakefile
File metadata and controls
80 lines (61 loc) · 2.36 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
72
73
74
75
76
77
78
79
80
target = eggscript
library_target = libeggscript.a
library_include_c_target = include.c/ts.h
library_include_cpp_target = include.cpp/ts.h
cclibs = -lpthread
ifneq ($(OS),Windows_NT)
cclibs += -lreadline
endif
CC = g++
override CPPFLAGS := $(CPPFLAGS) -O2 -Wall -Wno-switch -Wno-class-memaccess -Wno-delete-incomplete -Wno-attributes -Bsymbolic -fno-semantic-interposition -std=c++17 -Werror=return-type
soflags =
ldflags =
cpp_source = $(shell find src -type f -name "*.cc" ! -path "src/include*")
cpp_source_tmp = $(subst src, tmp, $(cpp_source))
cpp_source_without = $(subst src\/, , $(cpp_source))
cpp_headers = $(shell find src -type f -name "*.h" ! -path "src/include*")
cpp_headers_tmp = $(subst src, tmp, $(cpp_headers))
cpp_objects = $(patsubst %.cc, %.o, $(cpp_source))
cpp_objects_tmp = $(patsubst %.cc, %.o, $(cpp_source_tmp))
cpp_objects_without = $(patsubst src\/, , $(cpp_source))
.PHONY: default clean
# force synchronization for preprocessor
default:
@"$(MAKE)" preprocessor --no-print-directory
@"$(MAKE)" dist/$(target) --no-print-directory
library:
@"$(MAKE)" preprocessor --no-print-directory
@"$(MAKE)" dist/$(library_target) --no-print-directory soflags="-fPIC" ldflags="-Wl,--version-script=libeggscript.map"
preprocessor:
@echo -e " PY tools/preprocessor.py"
@python3.10 tools/preprocessor.py
$(cpp_objects_tmp) : %.o : %.h
$(cpp_objects_tmp) : %.o : %.cc
@mkdir -p $(dir $@)
@echo -e " CC $<"
@$(CC) $(CPPFLAGS) $(soflags) -c $< -o $@
dist/$(target): $(cpp_objects_tmp)
@mkdir -p $(dir dist/$(target))
@echo -e " CC $@"
@$(CC) $(cpp_objects_tmp) -Wall $(cclibs) -o $@
dist/$(library_target): $(cpp_objects_tmp)
@mkdir -p $(dir dist/$(library_target))
@echo -e " CC $@"
@$(CC) $(cpp_objects_tmp) -Wall $(cclibs) -shared $(ldflags) -o $@
@ar rcs $(library_target) $(cpp_objects_tmp)
@mv $(library_target) $@
test: dist/$(target)
cd dist && ./$(target) --test
build-tests: dist/$(target)
cd dist && ./$(target) --test --overwrite-results
clean:
@echo -e " RM tmp"
@rm -Rf tmp
@echo -e " RM dist/$(library_include_c_target)"
@rm -Rf dist/$(library_include_c_target)
@echo -e " RM dist/$(library_include_cpp_target)"
@rm -Rf dist/$(library_include_cpp_target)
@echo -e " RM dist/$(target)"
@rm -f dist/$(target)
@echo -e " RM dist/$(library_target)"
@rm -f dist/$(library_target)