-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
49 lines (38 loc) · 1013 Bytes
/
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
TARGET = ryx
SOURCE = ryx.cc codegen.cc
OBJECT = $(SOURCE:%.cc=%.o)
CXX = clang++
LINK = $(CXX)
CFLAGS = -Weverything -Wno-padded -Wno-switch-enum -Wno-unused-macros -Wno-unused-function
CXXFLAGS = -std=c++14 -Wno-c++98-compat -Wno-c++98-compat-pedantic
LINKFLAGS =
HOST = $(shell uname)
NJOB = 1
# Linux
ifeq ($(HOST),Linux)
ifeq ($(shell sh -c 'if which nproc > /dev/null 2>&1; then echo 1; else echo 0; fi'),1)
NJOB = $(shell nproc)
endif
endif
# Mac OS X
ifeq ($(HOST),Darwin)
NJOB = $(shell sysctl -n hw.ncpu)
endif
# Windows
ifneq ($(findstring MINGW,$(HOST)),)
ifeq ($(shell sh -c 'if which nproc > /dev/null 2>&1; then echo 1; else echo 0; fi'),1)
NJOB = $(shell nproc)
endif
endif
default: in_parallel
.PHONY: in_parallel
in_parallel:
@$(MAKE) $(TARGET) -j $(NJOB)
$(TARGET): $(OBJECT)
$(LINK) $(LINKFLAGS) $^ -o $@
%.o: %.cc
$(CXX) $(CFLAGS) $(CXXFLAGS) $< -o $@ -c
.PHONY: clean
clean:
rm -f $(TARGET) $(OBJECT) ryx_parse*
codegen.o: codegen.h