forked from sifive/wake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
94 lines (71 loc) · 3.59 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Bootstrap build file
VERSION := $(shell if test -f manifest.wake; then sed -n "/publish releaseAs/ s/^[^']*'\([^']*\)'.*/\1/p" manifest.wake; else git describe --tags --dirty; fi)
CC := cc -std=c11
CXX := c++ -std=c++11
CFLAGS := -Wall -O2 -DVERSION=$(VERSION)
LDFLAGS :=
DESTDIR ?= /usr/local
LOCAL_CFLAGS := -Ivendor -Isrc
FUSE_CFLAGS := $(shell pkg-config --silence-errors --cflags fuse)
CORE_CFLAGS := $(shell pkg-config --silence-errors --cflags sqlite3) \
$(shell pkg-config --silence-errors --cflags gmp-6) \
$(shell pkg-config --silence-errors --cflags re2) \
$(shell pkg-config --silence-errors --cflags-only-I ncurses)
FUSE_LDFLAGS := $(shell pkg-config --silence-errors --libs fuse || echo -lfuse)
CORE_LDFLAGS := $(shell pkg-config --silence-errors --libs sqlite3 || echo -lsqlite3) \
$(shell pkg-config --silence-errors --libs gmp-6 || echo -lgmp) \
$(shell pkg-config --silence-errors --libs re2 || echo -lre2) \
$(shell pkg-config --silence-errors --libs ncurses tinfo || pkg-config --silence-errors --libs ncurses || echo -lncurses)
COMMON_DIRS := src/compat src/util src/json
COMMON_C := $(foreach dir,$(COMMON_DIRS),$(wildcard $(dir)/*.c)) \
vendor/whereami/whereami.c
COMMON_CPP := $(foreach dir,$(COMMON_DIRS),$(wildcard $(dir)/*.cpp))
COMMON_OBJS := src/json/jlexer.o \
$(patsubst %.cpp,%.o,$(COMMON_CPP)) $(patsubst %.c,%.o,$(COMMON_C))
WAKE_DIRS := $(COMMON_DIRS) src/dst src/optimizer src/parser src/runtime src/types tools/wake
WAKE_C := $(foreach dir,$(WAKE_DIRS),$(wildcard $(dir)/*.c)) \
vendor/blake2/blake2b-ref.c vendor/utf8proc/utf8proc.c \
vendor/siphash/siphash.c vendor/whereami/whereami.c \
vendor/gopt/gopt.c vendor/gopt/gopt-errors.c vendor/gopt/gopt-arg.c
WAKE_CPP := $(foreach dir,$(WAKE_DIRS),$(wildcard $(dir)/*.cpp))
WAKE_OBJS := src/parser/lexer.o src/parser/parser.o src/json/jlexer.o \
$(patsubst %.cpp,%.o,$(WAKE_CPP)) $(patsubst %.c,%.o,$(WAKE_C))
WAKE_ENV := WAKE_PATH=$(shell dirname $(shell which $(firstword $(CC))))
all: wake.db
$(WAKE_ENV) ./bin/wake build default
clean:
rm -f bin/* lib/wake/* */*.o common/jlexer.cpp src/frontend/lexer.cpp src/frontend/parser.cpp src/version.h wake.db
touch bin/stamp lib/wake/stamp
wake.db: bin/wake bin/fuse-wake lib/wake/fuse-waked lib/wake/shim-wake
test -f $@ || ./bin/wake --init .
install: all
$(WAKE_ENV) ./bin/wake install $(DESTDIR)
test: wake.db
$(WAKE_ENV) ./bin/wake --in test_wake runTests
tarball: wake.db
$(WAKE_ENV) ./bin/wake build tarball
vscode: wake.db
$(WAKE_ENV) ./bin/wake vscode
static: wake.db
$(WAKE_ENV) ./bin/wake static
bin/wake: $(WAKE_OBJS)
$(CXX) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(CORE_LDFLAGS)
bin/fuse-wake: tools/fuse-wake/fuse-wake.cpp src/wakefs/*.cpp $(COMMON_OBJS)
$(CXX) $(CFLAGS) $(LOCAL_CFLAGS) $^ -o $@ $(LDFLAGS)
lib/wake/fuse-waked: tools/fuse-waked/fuse-waked.cpp $(COMMON_OBJS)
$(CXX) $(CFLAGS) $(LOCAL_CFLAGS) $(FUSE_CFLAGS) $^ -o $@ $(LDFLAGS) $(FUSE_LDFLAGS)
lib/wake/shim-wake: tools/shim-wake/shim.o vendor/blake2/blake2b-ref.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.cpp $(filter-out src/parser/parser.h,$(wildcard */*/*.h)) | src/parser/parser.h
$(CXX) $(CFLAGS) $(LOCAL_CFLAGS) $(CORE_CFLAGS) -o $@ -c $<
%.o: %.c $(filter-out src/version.h,$(wildcard */*.h))
$(CC) $(CFLAGS) $(LOCAL_CFLAGS) -o $@ -c $<
# Rely on wake to recreate this file if re2c is available
%.cpp: %.cpp.gz
gzip -dc $^ > [email protected]
mv -f [email protected] $@
%.h: %.h.gz
gzip -dc $^ > [email protected]
mv -f [email protected] $@
.PRECIOUS: src/parser/lexer.cpp src/parser/parser.cpp src/parser/parser.h src/json/jlexer.cpp
.SUFFIXES: