summaryrefslogtreecommitdiffstats
path: root/c/src/automake/compile.am
blob: 0aee6951aa32a92f59544f5d8dabad23bb3a6bc4 (plain) (blame)
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
125
126
127
128
129
##
## $Id$
##

## -------------------------------------------------------------------------
## NOTE: This file is rather immature and has to be considered to be 
## almost experimental.
##
## Expect frequent changes -- It deserves to be cleaned up :(
## -------------------------------------------------------------------------

## The section below is based on make/compilers/gcc-target-default.cfg
## used in former versions of RTEMS.

## 
## Set up the flags for the toolchains:
##
## We are considering 3 different building schemes here:
## * Using gcc's being able to accept -specs (aka gcc-2.8 building scheme)
## * Using gcc's not being able to accept -specs (aka gcc-2.7.2 building
##   scheme)
## * Using third party toolchains (aka non-gcc building scheme)
##
## Automake conditionals in use:
## RTEMS_USE_GCC     .. if we are using GCC

## NOTES: 
## * The gcc-2.8 building scheme is the nominal building scheme and
##   is actively supported.
## * The non-gcc building scheme requires manually setting up environment 
##   variables and is hardly tested at all

## CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V are the values we
## would want the corresponding macros to be set to.
##
## CFLAGS_OPTIMIZE, CFLAGS_DEBUG are set by the 
## 'VARIANT=<OPTIMIZE|DEBUG>' targets to their _V values.

if RTEMS_USE_GCC
## All the stuff below is specific to gcc

## gcc >= 2.8.x
GCCSPECS = $(GCC_SPECS) $(RTEMS_BSP_SPECS)
else
## fall back to the old style compilers/*.cfg
## CONFIG.CC is supposed to be provided by <BSP>.cfg
include $(CONFIG.CC)
endif # RTEMS_USE_GCC

DEFS = @DEFS@

CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) $(DEFINES)
CFLAGS   = @RTEMS_CFLAGS@
## FIXME: This should be correct, but is not supported, yet
# CXXFLAGS = @RTEMS_CXXFLAGS@ $(XCXXFLAGS)
## Fall back to using RTEMS_CFLAGS for C++
CXXFLAGS = @RTEMS_CFLAGS@ $(XCXXFLAGS)
ASFLAGS  = $(CPU_ASFLAGS) $(CPU_CFLAGS) $(XASFLAGS)

depend:

if RTEMS_USE_GCC
## gcc >= 2.8
RTEMS_RELLDFLAGS = -qnolinkcmds -nostdlib -Wl,-r
define make-rel
	$(LINK) $(RTEMS_RELLDFLAGS) $^
endef
else
## non-gcc
define make-rel
	$(LINK) $(RTEMS_RELLDFLAGS) $^
endef
endif

## -------------------------------------------------------------------------

## translate VARIANT into VARIANT_V
VARIANT = OPTIMIZE

VARIANT_OPTIMIZE_V = OPTIMIZE
VARIANT_DEBUG_V = DEBUG
VARIANT_optimize_V = OPTIMIZE
VARIANT_debug_V = DEBUG

VARIANT_V = $(VARIANT_$(VARIANT)_V)

## Setup the library suffix
LIBSUFFIX_OPTIMIZE_V =
LIBSUFFIX_DEBUG_V = _g
LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V)

LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V)

## These are supposed to be set in make/custom/<bsp>.cfg
CPU_CFLAGS = @CPU_CFLAGS@
CFLAGS_OPTIMIZE_V = @CFLAGS_OPTIMIZE_V@
CFLAGS_DEBUG_V = @CFLAGS_DEBUG_V@
CFLAGS__V = $(CFLAGS_OPTIMIZE_V)

## ------------------------------------------------------------------------
## Setup hard-coded flags
if RTEMS_USE_GCC
## gcc >= gcc-2.8
RTEMS_CFLAGS_OPTIMIZE_V =
RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused

## non-gcc
## We can't guess what flags might be required here.
## Pass the values from the environment if you want to apply them.
endif
RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V)

## -------------------------------------------------------------------------

CC = @CC@ $(GCCSPECS)
CXX = @CXX@ $(GCCSPECS)
CPP = @CPP@ $(GCCSPECS)

LD = @LD@
OBJCOPY = @OBJCOPY@
NM = @NM@
SIZE = @SIZE@
STRIP = @STRIP@

##
AM_CPPFLAGS = $(RTEMS_CPPFLAGS)
AM_CFLAGS =
AM_CXXFLAGS =
AM_CCASFLAGS = $(RTEMS_CPPFLAGS) $(RTEMS_CCASFLAGS)