-
Notifications
You must be signed in to change notification settings - Fork 4
/
tool_gcc.mak
176 lines (138 loc) · 5.51 KB
/
tool_gcc.mak
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Tool-chain specific items
#===============================================================================
# GNUARM_ROOT and NEXTTOOL_ROOT need to adapt your PC environment
#===============================================================================
# specify GNU-ARM root directory
ifndef GNUARM_ROOT
GNUARM_ROOT = ~/nxtOSEK/gnuarm
#/cygdrive/C/cygwin/GNUARM
endif
# specify NeXTTool root directory
ifndef NEXTTOOL_ROOT
NEXTTOOL_ROOT = /cygdrive/C/cygwin/nexttool
endif
#===============================================================================
$(VERBOSE).SILENT:
TARGET_PREFIX :=arm-elf
MKDIR = mkdir -p
TOUCH = touch
CROSS = $(GNUARM_ROOT)/bin/$(TARGET_PREFIX)-
CC = $(CROSS)gcc
CXX = $(CROSS)g++
AS = $(CROSS)as
AR = $(CROSS)ar
LD = $(CROSS)g++ -nostartfiles
OBJCOPY = $(CROSS)objcopy
BIOSFLASH = biosflash.exe
APPFLASH = appflash.exe
RAMBOOT = ramboot.exe
NEXTTOOL = NeXTTool.exe
OUTPUT_OPTION = -MD -o $@
# GCC optimisation level
ifndef C_OPTIMISATION_FLAGS
C_OPTIMISATION_FLAGS = -Os
endif
# for .c
CFLAGS = -c -ffreestanding -fsigned-char -mcpu=arm7tdmi \
$(C_OPTIMISATION_FLAGS) \
-Winline -Wall -Werror-implicit-function-declaration --param max-inline-insns-single=1000 \
-mthumb -mthumb-interwork -ffunction-sections -fdata-sections \
$(addprefix -iquote ,$(INC_PATH)) -I. $(addprefix -I,$(TOPPERS_INC_PATH)) \
$(addprefix -D,$(ECROBOT_DEF)) $(addprefix -D,$(USER_DEF)) $(addprefix -D,$(TOPPERS_KERNEL)) -std=gnu99 $(USER_C_OPT)
#
## for C++ (.cc and .cpp)
## Note that C++ RTTI is disabled by -fno-rtti option
#
ifdef ECROBOT_CPP_ROOT
# for .cpp
CXX_PATH = $(addprefix -I ,$(ECROBOT_CPP_ROOT)/device) $(addprefix -I ,$(ECROBOT_CPP_ROOT)/util)
else
# for .cc
CXX_PATH = $(addprefix -I ,$(CXX_ROOT)) $(addprefix -I ,$(CXX_ROOT)/boost) $(addprefix -I ,$(CXX_ROOT)/util)
endif
CXXFLAGS = -c -fsigned-char -mcpu=arm7tdmi -fno-exceptions \
$(C_OPTIMISATION_FLAGS) \
-Winline -Wall --param max-inline-insns-single=1000 \
-fno-common -fno-rtti \
-mthumb -mthumb-interwork -ffunction-sections -fdata-sections \
$(CXX_PATH) \
$(addprefix -iquote ,$(INC_PATH)) -I. $(addprefix -I,$(TOPPERS_INC_PATH)) \
$(addprefix -D,$(ECROBOT_DEF)) $(addprefix -D,$(USER_DEF)) $(addprefix -D,$(TOPPERS_KERNEL)) $(USER_CXX_OPT)
#
## for C/C++ (.c, .cc and .cpp)
#
ifdef ECROBOT_CPP_ROOT
# for .cpp
CXX_LIB = $(LIBECROBOT_CPP)
else
# for .cc
CXX_LIB = $(LIBLEJOSOSEK)
endif
# Moved C math lib hook (-lm) to the end of option to make sure to link it. by takashic June 3, 2011
LDFLAGS = -mthumb -mthumb-interwork -Wl,--allow-multiple-definition -Wl,-Map,$(basename $@).map -Wl,--cref -Wl,--gc-sections \
-L$(LIBPREFIX) $(addprefix -L,$(INC_PATH)) \
$(addprefix -L,$(CXX_ROOT)) -L$(O_PATH) -L$(O_PATH)/$(LEJOS_PLATFORM_SOURCES_PATH) $(CXX_LIB) $(LIBECROBOT) \
$(addprefix -l,$(USER_LIB)) -lm
ASFLAGS = -mcpu=arm7tdmi -mthumb-interwork $(addprefix -I,$(TOPPERS_INC_PATH))
LINK_ELF = $(LD) -o $@ -Wl,-T,$(filter-out %.o %.oram %owav %.obmp %ospr, $^) $(filter %.o %.oram %owav %.obmp %ospr,$^) $(EXTRALIBS) $(LDFLAGS)
ifdef O_PATH
%.bin : %.elf
@echo "Generating binary file $@"
$(OBJCOPY) -O binary $< $@
.SECONDEXPANSION:
$(O_PATH)/%.o : %.c $$(@D)/.f
@echo "Compiling $< to $(notdir $@)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(O_PATH)/%.o : %.cc $$(@D)/.f
@echo "Compiling $< to $(notdir $@)"
$(COMPILE.cc) $(OUTPUT_OPTION) $<
$(O_PATH)/%.o : %.cpp $$(@D)/.f
@echo "Compiling $< to $(notdir $@)"
$(COMPILE.cpp) $(OUTPUT_OPTION) $<
$(O_PATH)/%.oram : %.c $$(@D)/.f
@echo "Compiling $< to $(notdir $@)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(O_PATH)/%.oram : %.cc $$(@D)/.f
@echo "Compiling $< to $(notdir $@)"
$(COMPILE.cc) $(OUTPUT_OPTION) $<
$(O_PATH)/%.oram : %.cpp $$(@D)/.f
@echo "Compiling $< to $(notdir $@)"
$(COMPILE.cpp) $(OUTPUT_OPTION) $<
$(O_PATH)/%.oram: %.S $$(@D)/.f
@echo "Assembling $< to $(notdir $@)"
$(COMPILE.S) -o $@ $<
$(O_PATH)/%.o: %.S $$(@D)/.f
@echo "Assembling $< to $(notdir $@)"
$(COMPILE.S) -o $@ $<
$(O_PATH)/%.oram: %.s $$(@D)/.f
@echo "Assembling $< to $(notdir $@)"
$(COMPILE.S) -o $@ $<
$(O_PATH)/%.o: %.s $$(@D)/.f
@echo "Assembling $< to $(notdir $@)"
$(COMPILE.s) -o $@ $<
$(O_PATH)/%.owav : %.wav $$(@D)/.f
@echo "Converting $< to $(notdir $@)"
$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
--redefine-sym _binary_$(subst .,,$(subst /,_,$(basename $<)))_wav_start=$(basename $(notdir $<))_wav_start \
--redefine-sym _binary_$(subst .,,$(subst /,_,$(basename $<)))_wav_end=$(basename $(notdir $<))_wav_end \
--redefine-sym _binary_$(subst .,,$(subst /,_,$(basename $<)))_wav_size=$(basename $(notdir $<))_wav_size \
$< $@
$(O_PATH)/%.obmp : %.bmp $$(@D)/.f
@echo "Converting $< to $(notdir $@)"
$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
--redefine-sym _binary_$(subst .,,$(subst /,_,$(basename $<)))_bmp_start=$(basename $(notdir $<))_bmp_start \
--redefine-sym _binary_$(subst .,,$(subst /,_,$(basename $<)))_bmp_end=$(basename $(notdir $<))_bmp_end \
--redefine-sym _binary_$(subst .,,$(subst /,_,$(basename $<)))_bmp_size=$(basename $(notdir $<))_bmp_size \
$< $@
$(O_PATH)/%.ospr : %.spr $$(@D)/.f
@echo "Converting $< to $(notdir $@)"
$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
--redefine-sym _binary_$(subst .,,$(subst /,_,$(basename $<)))_spr_start=$(basename $(notdir $<))_spr_start \
--redefine-sym _binary_$(subst .,,$(subst /,_,$(basename $<)))_spr_end=$(basename $(notdir $<))_spr_end \
--redefine-sym _binary_$(subst .,,$(subst /,_,$(basename $<)))_spr_size=$(basename $(notdir $<))_spr_size \
$< $@
.PRECIOUS: %/.f
%/.f:
$(MKDIR) $(dir $@)
$(TOUCH) $@
endif