summaryrefslogtreecommitdiff
path: root/makefiles/Makefile.clang
blob: 2a11a5bbca761b7a6b1e715d8c8945dc1a91b1f6 (plain)
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
# Clang-specific toolchain setup
# We assume that we're using a standard GCC/binutils environment, as well
# as clang being mostly GCC-compatible on the command line

CCDEF := -D
CCOPT := -O2
CCNOOPT := -O0
CCDBG := -g
CCINC := -I
CCLIB := -L
CCAS := -xassembler-with-cpp
CCSHR := -fPIC

CXXDEF := -D
CXXOPT := -O2
CXXNOOPT := -O0
CXXDBG := -g
CXXINC := -I
CXXLIB := -L
CXXSHR := -fPIC

LDDBG := -g
# Reevaluation is required here
LDSHR = -shared -Wl,-soname,$(SONAME)

ARFLG := cru

# Definitions of various attributes
CFLAGS := $(CFLAGS) -D_ALIGNED="__attribute__((aligned))"

# Extensions for sanitize target
ifeq ($(MAKECMDGOALS),sanitize)
  SANCFLAGS ?= -fsanitize=address -fsanitize=undefined -fno-sanitize-recover
  SANCXXFLAGS ?= -fsanitize=address -fsanitize=undefined -fno-sanitize-recover
  SANLDFLAGS ?= -fsanitize=address -fsanitize=undefined -fno-sanitize-recover

  CFLAGS := $(CFLAGS) $(SANCFLAGS)
  CXXFLAGS := $(CXXFLAGS) $(SANCXXFLAGS)
  LDFLAGS := $(LDFLAGS) $(SANLDFLAGS)
endif

###############################################################################
# Mac OS X Universal Binaries
###############################################################################

ifeq ($(findstring darwin,$(HOST)),darwin)
	ifneq ($(UNIVERSAL),)
		UNIVERSAL_FLAGS := $(foreach arch,$(UNIVERSAL),-arch $(arch) )
		
		CFLAGS := $(CFLAGS) $(UNIVERSAL_FLAGS)
		LDFLAGS := $(LDFLAGS) $(UNIVERSAL_FLAGS)
		CXXFLAGS := $(CXXFLAGS) $(UNIVERSAL_FLAGS)
		ARFLAGS := $(ARFLAGS) -s 
	endif
endif

###############################################################################
# Other settings
###############################################################################

CC_CAN_BUILD_AND_DEP ?= yes