<commit_before># Copyright (c) 2012 Turbulenz Limited.
# Released under "Modified BSD License".  See COPYING for full text.

############################################################
#
# Linux
#
############################################################

CLANG_VERSION ?= 3.6

#
# CCACHE
#
CCACHE:=$(shell test -n "`which ccache 2&>/dev/null`"; if [ $$? -eq 0 ] ; then echo "ccache" ; fi)

#
# DISTCC
#
ifeq (1,$(ENABLE_DISTCC))
DISTCC:=$(shell test -n "`which distcc 2&>/dev/null`"; if [ $$? -eq 0 ] ; then echo "distcc" ; fi)
endif

#
# RPATH the executable dir?
ifneq (1,$(DISABLE_EXECUTABLE_RPATH))
  _rpath_flags := -Wl,-rpath,'$$$$ORIGIN'
endif

#
# CXX / CMM
#

ifeq (clang,$(COMPILER))
  CXXCOMPILER:=$(shell \
    which clang++ || which clang++-$(CLANG_VERSION) || echo -n \
  )
  ifeq ($(CXXCOMPILER),)
    $(error Cannot find clang++)
  endif
else
  CXXCOMPILER:=g++
endif

CXX := $(CCACHE) $(DISTCC) $(CXXCOMPILER)
CC := $(CXX) -x c

#
# CXX / CMM FLAGS
#

_cxxflags_warnings := \
  -Wall -Wsign-compare -Wunused-parameter \
  -Wno-pragmas -Wno-unknown-pragmas -Wno-trigraphs

# -Wconversion

CFLAGSPRE := \
    -fmessage-length=0 -pipe \
    $(_cxxflags_warnings) \
    -fPIC \
    -ftree-vectorize -msse3 -mssse3

ifeq (clang,$(COMPILER))
  CFLAGSPRE += -Qunused-arguments -Wno-deprecated-register
endif

CFLAGSPOST := -c

# SYMBOLS

ifeq (1,$(C_SYMBOLS))
  CFLAGSPRE += -g
  DLLFLAGSPOST += -g -rdynamic
  LDFLAGSPOST += -g -rdynamic
endif

ifeq (1,$(C_OPTIMIZE))
  CFLAGSPRE += -O3 -DNDEBUG -ftree-vectorize

else
  CFLAGSPRE += -O0 -D_DEBUG -DDEBUG
  # ifneq (clang,$(COMPILER))
  #   CFLAGSPRE += -falign-functions=4
  # endif
endif

ifeq (1clang,$(C_RUNTIME_CHECKS)$(COMPILER))
  _RT_FLAGS := -fsanitize=address
    # -fsanitize=thread

    # non-trivial to make work ...
    # requires -frtti:
    # -fsanitize=undefined
    # link error:
    # -fsanitize=dataflow
    # unsupported:
    # -fsanitize=safe-stack
    # -fsanitize=cfi
    # issues at startup
    # _RT_FLAGS := -fsanitize=memory
    # CFLAGSPOST += -fPIE
    # DLLFLAGSPOST += -Wl,-pie
    # LDFLAGSPOST += -Wl,-pie

  CFLAGSPOST += $(_RT_FLAGS) -fPIE
  DLLFLAGSPOST += $(_RT_FLAGS) -Wl,-pie
  LDFLAGSPOST += $(_RT_FLAGS) -Wl,-pie
endif

CXXFLAGSPRE := \
  $(CFLAGSPRE) -Wno-overloaded-virtual -std=c++11 -Wno-reorder \
  -DXP_LINUX=1 -DXP_UNIX=1 -DMOZILLA_STRICT_API
CXXFLAGSPOST := $(CFLAGSPOST) -fexceptions -fpermissive

PCHFLAGS := -x c++-header

#
# LIBS
#

AR := ar
ARFLAGSPRE := cr
arout :=
ARFLAGSPOST :=

libprefix := lib
libsuffix := .a

#
# DLLS
#

DLL := $(CXX)
DLLFLAGSPRE += -shared
DLLFLAGSPOST += $(_rpath_flags)


DLLFLAGS_LIBDIR := -L
DLLFLAGS_LIB := -l

dllprefix := lib
dllsuffix := .so

#
# APPS
#

LDFLAGS_LIBDIR := -L
LDFLAGS_LIB := -l

LD := $(CXX)
LDFLAGSPRE +=
LDFLAGSPOST += -lpthread $(_rpath_flags)


############################################################


# g++ \
#  -shared \
#  -Wl,-soname,turbulenz.so.0.13.0 \
#  <objects> \
#  -Wl,--rpath /usr/local/lib/turbulenz \
#  -L/usr/local/lib/turbulenz -L../../external/v8/lib/linux64 -L../../external/bullet/lib/linux64 -L../../external/zlib/lib/linux64 -L../../external/png/lib/linux64 \
#  -lv8 -lGL -lopenal -lvorbis -lvorbisfile -lpng -ljpeg -lbulletmultithreaded -lbulletdynamics -lbulletcollision -lbulletmath -ltbb `pkg-config --libs-only-l gtkglext-1.0` \
#  -o turbulenz.so.0.13.0<commit_msg>linux lto and sanitize tidy up<commit_after># Copyright (c) 2012 Turbulenz Limited.
# Released under "Modified BSD License".  See COPYING for full text.

############################################################
#
# Linux
#
############################################################

CLANG_VERSION ?= 3.6

#
# CCACHE
#
CCACHE:=$(shell test -n "`which ccache 2&>/dev/null`"; if [ $$? -eq 0 ] ; then echo "ccache" ; fi)

#
# DISTCC
#
ifeq (1,$(ENABLE_DISTCC))
DISTCC:=$(shell test -n "`which distcc 2&>/dev/null`"; if [ $$? -eq 0 ] ; then echo "distcc" ; fi)
endif

#
# RPATH the executable dir?
ifneq (1,$(DISABLE_EXECUTABLE_RPATH))
  _rpath_flags := -Wl,-rpath,'$$$$ORIGIN'
endif

#
# CXX / CMM
#

ifeq (clang,$(COMPILER))
  CXXCOMPILER:=$(shell \
    which clang++ || which clang++-$(CLANG_VERSION) || echo -n \
  )
  ifeq ($(CXXCOMPILER),)
    $(error Cannot find clang++)
  endif
else
  CXXCOMPILER:=g++
endif

CXX := $(CCACHE) $(DISTCC) $(CXXCOMPILER)
CC := $(CXX) -x c

#
# CXX / CMM FLAGS
#

_cxxflags_warnings := \
  -Wall -Wsign-compare -Wunused-parameter \
  -Wno-pragmas -Wno-unknown-pragmas -Wno-trigraphs

# -Wconversion

CFLAGSPRE := \
    -fmessage-length=0 -pipe \
    $(_cxxflags_warnings) \
    -fPIC \
    -ftree-vectorize -msse3 -mssse3

ifeq (clang,$(COMPILER))
  CFLAGSPRE += -Qunused-arguments -Wno-deprecated-register
endif

CFLAGSPOST := -c

# SYMBOLS

ifeq (1,$(C_SYMBOLS))
  CFLAGSPRE += -g
  DLLFLAGSPOST += -g -rdynamic
  LDFLAGSPOST += -g -rdynamic
endif

ifeq (1,$(C_OPTIMIZE))
  CFLAGSPRE += -O3 -DNDEBUG -ftree-vectorize

else
  CFLAGSPRE += -O0 -D_DEBUG -DDEBUG
  # ifneq (clang,$(COMPILER))
  #   CFLAGSPRE += -falign-functions=4
  # endif
endif

ifeq (1,$(LD_OPTIMIZE))
  # TODO: seems not to work as of clang 3.6, Ubuntu 14.04
  #
  #	Apparently, LLVMgold plugin is required got the linker

  # CFLAGSPRE += -flto
  # LDFLAGSPOST += -O3 -flto -fuse-ld=gold
endif

ifeq (1clang,$(C_RUNTIME_CHECKS)$(COMPILER))
  _RT_FLAGS := -fsanitize=address
    # -fsanitize=thread

    # non-trivial to make work ...
    # requires -frtti:
    # -fsanitize=undefined
    # link error:
    # -fsanitize=dataflow
    # unsupported:
    # -fsanitize=safe-stack
    # -fsanitize=cfi
    # issues at startup
    # _RT_FLAGS := -fsanitize=memory
    # CFLAGSPOST += -fPIE
    # DLLFLAGSPOST += -Wl,-pie
    # LDFLAGSPOST += -Wl,-pie
endif

CXXFLAGSPRE := \
  $(CFLAGSPRE) -Wno-overloaded-virtual -std=c++11 -Wno-reorder \
  -DXP_LINUX=1 -DXP_UNIX=1 -DMOZILLA_STRICT_API
CXXFLAGSPOST := $(CFLAGSPOST) -fexceptions -fpermissive $(_RT_FLAGS)

PCHFLAGS := -x c++-header

#
# LIBS
#

AR := ar
ARFLAGSPRE := cr
arout :=
ARFLAGSPOST :=

libprefix := lib
libsuffix := .a

#
# DLLS
#

DLL := $(CXX)
DLLFLAGSPRE += -shared
DLLFLAGSPOST += $(_rpath_flags) $(_RT_FLAGS)


DLLFLAGS_LIBDIR := -L
DLLFLAGS_LIB := -l

dllprefix := lib
dllsuffix := .so

#
# APPS
#

LDFLAGS_LIBDIR := -L
LDFLAGS_LIB := -l

LD := $(CXX)
LDFLAGSPRE +=
LDFLAGSPOST += -lpthread $(_rpath_flags) $(_RT_FLAGS)

############################################################


# g++ \
#  -shared \
#  -Wl,-soname,turbulenz.so.0.13.0 \
#  <objects> \
#  -Wl,--rpath /usr/local/lib/turbulenz \
#  -L/usr/local/lib/turbulenz -L../../external/v8/lib/linux64 -L../../external/bullet/lib/linux64 -L../../external/zlib/lib/linux64 -L../../external/png/lib/linux64 \
#  -lv8 -lGL -lopenal -lvorbis -lvorbisfile -lpng -ljpeg -lbulletmultithreaded -lbulletdynamics -lbulletcollision -lbulletmath -ltbb `pkg-config --libs-only-l gtkglext-1.0` \
#  -o turbulenz.so.0.13.0
{'fraction_non_alphanumeric': 0.21561822125813448, 'fraction_numerical': 0.014172089660159074, 'mean_word_length': 3.3661616161616164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1630648', 'n_tokens_mistral': 2941, 'n_tokens_neox': 2837, 'n_words': 554}