summaryrefslogtreecommitdiff
path: root/makefiles/Makefile.gcc
blob: 5f2bd4d3787bade2bd03612fe45c810911c04b22 (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
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
# GCC specific toolchain setup
# We assume that we're using a standard GCC/binutils environment

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 for various attributes
CFLAGS := $(CFLAGS) -D_ALIGNED="__attribute__((aligned))"

# Extensions for coverage target
ifeq ($(MAKECMDGOALS),coverage)
  COVCFLAGS ?= -fprofile-arcs -ftest-coverage
  COVCXXFLAGS ?= -fprofile-arcs -ftest-coverage
  COVLDFLAGS ?= -lgcov

  CFLAGS := $(CFLAGS) $(COVCFLAGS)
  CXXFLAGS := $(CXXFLAGS) $(COVCXXFLAGS)
  LDFLAGS := $(LDFLAGS) $(COVLDFLAGS)
endif

# Extensions for profile target
ifeq ($(MAKECMDGOALS),profile)
  PROFCFLAGS ?= -pg
  PROFCXXFLAGS ?= -pg
  PROFLDFLAGS ?= -pg

  CFLAGS := $(CFLAGS) $(PROFCFLAGS)
  CXXFLAGS := $(CXXFLAGS) $(PROFCXXFLAGS)
  LDFLAGS := $(LDFLAGS) $(PROFLDFLAGS)
endif

# RISC OS module extensions
ifeq ($(COMPONENT_TYPE),riscos-module)
  ifneq ($(HOST),arm-unknown-riscos)
    $(error Attempting to build a RISC OS module for a non-RISC OS target)
  endif

  CFLAGS := $(CFLAGS) -mmodule
  CXXFLAGS := $(CXXFLAGS) -mmodule
  LDFLAGS := $(LDFLAGS) -mmodule
endif

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

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

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

# Determine if the compiler supports simultaneous build & dep.
ccvsn := $(shell $(CC) -dumpversion)
# ccvsn = x.y.z
GCCVER := $(word 1,$(subst ., ,$(ccvsn)))
# GCCVER = x

# If the major version (x, above) is not 2, then assume build & dep.
# This will break if using a version of GCC < 2, but that's unlikely.
ifneq ($(GCCVER),2)
  CC_CAN_BUILD_AND_DEP ?= yes
endif