forked from intel/yarpgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (57 loc) · 2.12 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
###############################################################################
#
# Copyright (c) 2015-2016, Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###############################################################################
BUILD_DATE=$(shell date +%Y:%m:%d)
GIT_REV=$(shell git log --abbrev-commit --abbrev=16 2>/dev/null | head -1)
ifeq (${GIT_REV},)
BUILD_VERSION="no_version_info"
else
BUILD_VERSION=$(GIT_REV)
endif
CXX=clang++
CXXFLAGS=-std=c++11 -Wall -Wpedantic -Werror -DBUILD_DATE="\"$(BUILD_DATE)\"" -DBUILD_VERSION="\"$(BUILD_VERSION)\""
OPT=-O3
LDFLAGS=-L./ -std=c++11
LIBSOURCES=type.cpp variable.cpp expr.cpp stmt.cpp gen_policy.cpp sym_table.cpp master.cpp
SOURCES=main.cpp $(LIBSOURCES) self-test.cpp
LIBSOURCES_SRC=$(addprefix src/, $(LIBSOURCES))
SOURCES_SRC=$(addprefix src/, $(SOURCES))
LIBOBJS=$(addprefix objs/, $(LIBSOURCES:.cpp=.o))
OBJS=$(addprefix objs/, $(SOURCES:.cpp=.o))
HEADERS=type.h variable.h ir_node.h expr.h stmt.h gen_policy.h sym_table.h master.h
HEADERS_SRC=$(addprefix src/, $(HEADERS))
EXECUTABLE=yarpgen
default: $(EXECUTABLE)
$(EXECUTABLE): dir $(SOURCES_SRC) $(HEADERS_SRC) $(OBJS) libyarpgen
$(CXX) $(OPT) $(LDFLAGS) -o $@ $(OBJS)
libyarpgen: dir $(LIBSOURCES_SRC) $(HEADERS_SRC) $(LIBOBJS)
ar rcs $@.a $(LIBOBJS)
dir:
/bin/mkdir -p objs
clean:
/bin/rm -rf objs $(EXECUTABLE) libyarpgen.a
debug: $(EXECUTABLE)
debug: OPT=-O0 -g
ubsan: $(EXECUTABLE)
ubsan: CXXFLAGS+=-fsanitize=undefined
gcc: $(EXECUTABLE)
gcc: CXX=g++
gcov: $(EXECUTABLE)
gcov: CXX=g++
gcov: OPT+=-fprofile-arcs -ftest-coverage -g
objs/%.o: src/%.cpp $(HEADERS_SRC)
$(CXX) $(OPT) $(CXXFLAGS) -o $@ -c $<