Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 125 lines (103 sloc) 3.89 KB
#!/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', 'bpowers@cs.umass.edu')
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()
You can’t perform that action at this time.