forked from sifive/wake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (57 loc) · 2.87 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
# 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=c99
CXX := c++ -std=c++11
CFLAGS := -Wall -O2 -DVERSION=$(VERSION)
LDFLAGS :=
LOCAL_CFLAGS := -Iutf8proc -Igopt -Icommon
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 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 := common/jlexer.o $(patsubst %.cpp,%.o,$(wildcard common/*.cpp))
WAKE_ENV := WAKE_PATH=$(shell dirname $(shell which $(firstword $(CC))))
# If FUSE is unavalable during wake build, allow a linux-specific work-around
ifeq ($(USE_FUSE_WAKE),0)
EXTRA := lib/wake/libpreload-wake.so lib/wake/preload-wake
endif
all: wake.db
$(WAKE_ENV) ./bin/wake all default
clean:
rm -f bin/* lib/wake/* */*.o common/jlexer.cpp src/symbol.cpp src/version.h wake.db
touch bin/stamp lib/wake/stamp
wake.db: bin/wake lib/wake/fuse-wake lib/wake/fuse-waked lib/wake/shim-wake $(EXTRA)
test -f $@ || ./bin/wake --init .
install: all
$(WAKE_ENV) ./bin/wake install '"install"'
tarball: wake.db
$(WAKE_ENV) ./bin/wake tarball Unit
bin/wake: src/symbol.o $(COMMON) \
$(patsubst %.cpp,%.o,$(wildcard src/*.cpp)) \
$(patsubst %.c,%.o,utf8proc/utf8proc.c gopt/gopt.c gopt/gopt-errors.c)
$(CXX) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(CORE_LDFLAGS)
lib/wake/fuse-wake: fuse/fuse.cpp $(COMMON)
$(CXX) $(CFLAGS) $(LOCAL_CFLAGS) $^ -o $@ $(LDFLAGS)
lib/wake/fuse-waked: fuse/daemon.cpp $(COMMON)
$(CXX) $(CFLAGS) $(LOCAL_CFLAGS) $(FUSE_CFLAGS) $^ -o $@ $(LDFLAGS) $(FUSE_LDFLAGS)
lib/wake/shim-wake: $(patsubst %.c,%.o,$(wildcard shim/*.c))
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
lib/wake/preload-wake: preload/wrap.cpp $(COMMON)
$(CXX) $(CFLAGS) $(LOCAL_CFLAGS) -DEXT=so -DENV=LD_PRELOAD -o $@ $^ $(LDFLAGS)
lib/wake/libpreload-wake.so: preload/open.c
$(CC) $(CFLAGS) -fpic -shared -o $@ $^ $(LFDLAGS) -ldl
%.o: %.cpp $(filter-out src/version.h,$(wildcard */*.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] $@
.PRECIOUS: src/symbol.cpp common/jlexer.cpp