forked from plasma-umass/Mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·124 lines (103 loc) · 3.89 KB
/
configure
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python
#-*- mode: python; -*-
from platform import system
from support.config import ConfigBuilder, slurp, exe_available
from os import environ, curdir, listdir
from os.path import abspath
from sys import argv, platform
NAME = 'mesh'
VERSION = '0.1.0'
c = ConfigBuilder()
c.append('version', VERSION)
c.config('version', VERSION)
c.config('canonical-name', NAME)
c.config('package-bugreport', '[email protected]')
if c.debug_build:
c.append('cflags', '-g')
c.append('ldflags', '-g')
if c.optimize_build:
c.append('cflags', '-DNDEBUG')
c.append('cflags', '-O3 -flto')
c.append('ldflags', '-O3 -flto')
c.append('cflags', '-pthread -D_FORTIFY_SOURCE=2')
else:
c.append('cflags', '-O0')
if c.gcov_build:
c.append('cflags', '--coverage')
c.append('ldflags', '--coverage')
if c.clangcov_build:
c.append('cflags', '-fprofile-instr-generate')
c.append('cflags', '-fcoverage-mapping')
c.append('ldflags', '-fprofile-instr-generate')
c.append('ldflags', '-fcoverage-mapping')
c.prefer('cc', 'clang')
c.prefer('cxx', 'clang++')
c.prefer('ar', 'llvm-ar')
c.prefer('ranlib', 'llvm-ranlib')
c.append('ldflags', '-fuse-ld=lld')
modern_cpu = True
if system() == 'Linux':
# we need to check if the CPU is recent enough to use popcnt and
# AVX instructions
cpuinfo = slurp('/proc/cpuinfo').splitlines()
flags = [l for l in cpuinfo if l.startswith('flags')][0]
modern_cpu = 'popcnt' in flags and 'avx' in flags
if modern_cpu:
c.append('cflags', '-march=westmere')
c.append('ldflags', '-march=westmere')
c.append('cflags', '-mavx')
c.append('cflags', '-fPIC')
c.append('cflags', '-pipe')
c.append('cflags', '-fno-builtin-malloc')
c.append('cflags', '-fno-omit-frame-pointer')
c.append('cflags', '-ffunction-sections')
c.append('cflags', '-fdata-sections')
c.append('cflags', '-Werror=implicit-function-declaration')
c.append('cflags', '-Werror=implicit-int')
c.append('cflags', '-Werror=pointer-sign')
c.append('cflags', '-Werror=pointer-arith')
if platform != 'darwin':
c.append('cflags', '-D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700')
c.append('cflags', '-Wundef')
c.append('cflags', '-Wall -Wextra -pedantic')
# c.append('cflags', '-Wno-gnu-statement-expression')
c.append('cflags', '-Wno-unused-parameter')
c.append('cflags', '-Wno-unused-variable')
# c.append('cflags', '-Wno-c99-extensions')
c.append('cxxflags', '-Woverloaded-virtual')
c.append('cflags', '-Werror=return-type')
c.append('cflags', '-Wtype-limits')
c.append('cflags', '-Wempty-body')
c.append('cxxflags', '-Wno-ctor-dtor-privacy')
c.append('cxxflags', '-Winvalid-offsetof')
c.append('cflags', '-Wvariadic-macros')
c.append('cflags', '-Wcast-align')
c.append('cflags', '-Isrc/vendor/googletest/googletest/include')
c.append('cflags', '-Isrc/vendor/googletest/googletest')
c.append('cflags', '-Isrc/vendor/Heap-Layers')
c.append('cflags', '-fvisibility=hidden')
c.append('ldflags', '-fvisibility=hidden')
if platform != 'darwin':
c.append('ldflags', '-Wl,--no-as-needed')
c.append('ldflags', '-Wl,--no-add-needed')
c.append('ldflags', '-Wl,--sort-common')
c.append('ldflags', '-Wl,--gc-sections')
c.append('ldflags', '-Wl,--hash-style=both')
c.append('ldflags', '-Wl,--no-undefined')
c.append('ldflags', '-Wl,-Bsymbolic-functions')
c.append('ldflags', '-Wl,-z,now,-z,relro')
c.append('ldflags', '-ftls-model=initial-exec')
c.append('ldflags', '-static-libstdc++ -static-libgcc')
c.append('ldflags', '-lrt')
c.append('libs', '-lm -lpthread')
c.append('libs', '-ldl')
c.append('cxxflags', '-std=c++14 -I src')
c.append('cxxflags', '$(CFLAGS)')
# for development work, clang has much, much nicer error messages
# c.prefer('cc', 'clang')
# c.prefer('cxx', 'clang++')
# c.prefer('ar', 'llvm-ar')
# c.prefer('ranlib', 'llvm-ranlib')
if not 'cc' in c.env or c.env['cc'] != 'clang':
c.append('cflags', '-Wa,--noexecstack')
c.generate()