RN rnmake  3.0.0
Arch.atmega16.mk
Go to the documentation of this file.
1 ################################################################################
2 #
3 # Arch/Arch.atmega16.mk
4 #
5 ifdef RNMAKE_DOXY
6 /*!
7 \file
8 
9 \brief RoadNarrows Make System architecture makefile.
10 
11 \par Architecture:
12 Atmel ATmega16 Microcontroller.
13 
14 \par Build Host:
15 Cross-Compiler
16 
17 \par Tool-Chain:
18 avr-*
19 
20 \pkgsynopsis
21 RN Make System
22 
23 \pkgfile{Arch/Arch.atmega16.mk}
24 
25 \pkgauthor{Robin Knight,robin.knight@roadnarrows.com}
26 
27 \pkgcopyright{2009-2018,RoadNarrows LLC,http://www.roadnarrows.com}
28 
29 \license{MIT}
30 
31 \EulaBegin
32 \EulaEnd
33 
34 \cond RNMAKE_DOXY
35  */
36 endif
37 #
38 ################################################################################
39 
40 # Prevent mutliple inclusion
41 _ARCH_ATMEGA16_MK = 1
42 
43 # This architecture (required)
44 RNMAKE_ARCH = atmega16
45 RNMAKE_ARCH_FQNAME = atmega16-mcu
46 
47 # Micro-Controller Unit
48 MCU = atmega16
49 
50 # Output format. One of: srec, ihex, binary
51 # Default is ihex. Override in including make file if necessary.
52 FORMAT ?= ihex
53 
54 # Device High Fuse Byte
55 # Override in including make file if necessary.
56 #
57 # Field Bit Description Default
58 # ----- --- ----------- -------
59 # OCDEN 7 Enable OCD 1 (unprogrammed, OCD disabled)
60 # JTAGEN 6 Enable JTAG 0 (programmed, JTAG enabled)
61 # SPIEN 5 Enable SPI Serial Program 0 (programmed, SPI prog. enabled)
62 # and data Downloading
63 # CKOPT 4 Oscillator options 1 (unprogrammed)
64 # EESAVE 3 EEPROM memory is preserved 1 (unprogrammed, EEPROM not preserved)
65 # through the Chip Erase
66 # BOOTSZ1 2 Select Boot Size 0 (programmed)
67 # BOOTSZ0 1 Select Boot Size 0 (programmed)
68 # BOOTRST 0 Select reset vector 1 (unprogrammed)
69 FUSE_HIGH ?= 0x99
70 
71 # Device Low Fuse Byte
72 # Override in including make file if necessary.
73 #
74 # Field Bit Description Default
75 # ----- --- ----------- -------
76 # BODLEVEL 7 Brown-out Detector trigger 1 (unprogrammed)
77 # level
78 # BODEN 6 Brown-out Detector enable 1 (unprogrammed, BOD disabled)
79 # SUT1 5 Select start-up time 1 (unprogrammed)
80 # SUT0 4 Select start-up time 0 (programmed)
81 # CKSEL3 3 Select Clock source 0 (programmed)
82 # CKSEL2 2 Select Clock source 0 (programmed)
83 # CKSEL1 1 Select Clock source 0 (programmed)
84 # CKSEL0 0 Select Clock source 0 (unprogrammed)
85 FUSE_LOW ?= 0xE1
86 
87 
88 #------------------------------------------------------------------------------
89 # Tool Chain
90 #------------------------------------------------------------------------------
91 
92 # Cross compiler tool chain prefix
93 CROSS_COMPILE = avr-
94 
95 # Build Support Commands
96 AR = $(CROSS_COMPILE)ar
97 RANLIB = $(CROSS_COMPILE)ranlib
98 STRIP_LIB = $(CROSS_COMPILE)strip --strip-debug
99 STRIP_EXE = $(CROSS_COMPILE)strip --strip-all
100 OBJCOPY = $(CROSS_COMPILE)objcopy
101 OBJDUMP = $(CROSS_COMPILE)objdump
102 SIZE = $(CROSS_COMPILE)size
103 NM = $(CROSS_COMPILE)nm
104 
105 
106 #------------------------------------------------------------------------------
107 # C Preprocessor Options
108 #------------------------------------------------------------------------------
109 RNMAKE_ARCH_INCDIRS =
110 RNMAKE_ARCH_CPPFLAGS =
111 
112 
113 #------------------------------------------------------------------------------
114 # Assembler and Options
115 #------------------------------------------------------------------------------
116 AS = $(CROSS_COMPILE)as
117 
118 # Atmel device
119 ASFLAGS_MCU = -mmcu=$(MCU)
120 
121 # Debugging format.
122 # -gstabs: Have the assembler create line number information; note that
123 # for use in COFF files, additional information about filenames
124 # and function names needs to be present in the assembler source
125 # files -- see avr-libc docs [FIXME: not yet described there]
126 ASFLAGS_DEBUG = -gstabs
127 
128 # Pass to other subprocesses
129 # -x Use CPP
130 ASFLAGS_PASS = -x assembler-with-cpp
131 
132 # Listing
133 # -Wa,...: tell GCC to pass this to the assembler.
134 # -adlms: create listing
135 CFLAGS_LISTING = -Wa,-adhlns=$(<:.S=.lst)
136 
137 # Assembler flags.
138 # -Wa,...: tell GCC to pass this to the assembler.
139 # -adlms: create listing
140 ARCH_ASFLAGS = $(ASFLAGS_MCU) \
141  $(ASFLAGS_DEBUG) \
142  $(ASFLAGS_PASS) \
143  $(ASFLAGS_LISTING)
144 
145 
146 #------------------------------------------------------------------------------
147 # C Compiler and Options
148 #------------------------------------------------------------------------------
149 CC = $(CROSS_COMPILE)gcc
150 
151 # Atmel device
152 CFLAGS_MCU = -mmcu=$(MCU)
153 
154 # Compiler flags to generate dependency files.
155 # Not needed in rnmake system.
156 # -Wp pass comma-separated options to cpp
157 # -M build dependency rule for object file
158 # -MP add .PHONY to each rule for object file
159 # -MT set output object to next argument
160 # -MF depencency rule output in file in next argument
161 #CFLAGS_GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
162 
163 # Optimization level, can be [0, 1, 2, 3, s].
164 # 0 = turn off optimization. s = optimize for size.
165 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
166 CFLAGS_OPTIMIZE_LEVEL = -O1
167 
168 # Debugging format.
169 # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
170 # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
171 #CFLAGS_DEBUG = -gstabs
172 CFLAGS_DEBUG = -gdwarf-2
173 
174 # Compiler flag to set the C Standard level.
175 # c89 - "ANSI" C
176 # gnu89 - c89 plus GCC extensions
177 # c99 - ISO C99 standard (not yet fully implemented)
178 # gnu99 - c99 plus GCC extensions
179 CFLAGS_CSTANDARD = -std=gnu99
180 
181 # Optimizations
182 # characters are unsigned
183 # bitfields are unsigned
184 # pack structure members with no holes
185 # smallest enum posible
186 CFLAGS_OPTIMIZES = -funsigned-char \
187  -funsigned-bitfields \
188  -fpack-struct \
189  -fshort-enums
190 
191 # Warnings
192 # All normal warnings
193 # Warn on strict prototypes
194 CFLAGS_WARNING = -Wall -Wstrict-prototypes
195 
196 # Listing
197 # -Wa,...: tell GCC to pass this to the assembler.
198 # -adlms: create listing
199 CFLAGS_LISTING = -Wa,-adhlns=$(<:.c=.lst)
200 
201 CFLAGS_CPP_ONLY = -E
202 CFLAGS_DEPS_ONLY = -M
203 
204 RNMAKE_ARCH_CFLAGS = $(CFLAGS_MCU) \
205  $(CFLAGS_DEBUG) \
206  $(CFLAGS_OPTIMIZE_LEVEL) \
207  $(CFLAGS_OPTIMIZES) \
208  $(CFLAGS_WARNING) \
209  $(CFLAGS_LISTING) \
210  $(CFLAGS_CSTANDARD) \
211  $(CFLAGS_GENDEPFLAGS)
212 
213 # Make AS/C/CXX Dependencies Command
214 RNMAKE_MAKEDEPS = $(CC) $(CFLAGS_DEPS_ONLY)
215 
216 
217 #------------------------------------------------------------------------------
218 # C++ Compiler and Options
219 #------------------------------------------------------------------------------
220 CXX = $(CROSS_COMPILE)g++
221 CXXFLAGS_CPP_ONLY = -E
222 CXXFLAGS_DEPS_ONLY = -M
223 
224 RNMAKE_ARCH_CXXFLAGS = $(CFLAGS_DEBUG) \
225  $(CFLAGS_OPTIMIZE_LEVEL) \
226  $(CFLAGS_OPTIMIZES) \
227  $(CFLAGS_WARNING) \
228  $(CFLAGS_OTHER) \
229  $(CFLAGS_CSTANDARD)
230 
231 
232 #------------------------------------------------------------------------------
233 # Linker and Options
234 #------------------------------------------------------------------------------
235 LD_CC = $(CC)
236 LD_CXX = $(CXX)
237 LD = $(LD_CC)
238 
239 # External memory options
240 #
241 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
242 # used for variables (.data/.bss) and heap (malloc()).
243 #ARCH_LDFLAGS_EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
244 #
245 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
246 # only used for heap (malloc()).
247 #ARCH_LDFLAGS_EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
248 
249 ARCH_LDFLAGS_EXTMEMOPTS =
250 
251 # Linker flags.
252 # -Wl,...: tell GCC to pass this to linker.
253 # -Map: create map file
254 # --cref: add cross reference to map file
255 ARCH_LDFLAGS_LD = -Wl,-Map=$(TARGET).map,--cref
256 
257 ARCH_LDFLAGS = $(ARCH_LDFLAGS_LD) \
258  $(ARCH_LDFLAGS_EXTMEMOPTS)
259 ARCH_LD_LIBPATHS =
260 ARCH_LD_LIBS =
261 
262 
263 #------------------------------------------------------------------------------
264 # Static Library Archiver and Options
265 #------------------------------------------------------------------------------
266 STLIB_LD = ${AR} cr
267 STLIB_PREFIX = lib
268 STLIB_SUFFIX = .a
269 
270 
271 #------------------------------------------------------------------------------
272 # Other Useful Flags, Etc.
273 #------------------------------------------------------------------------------
274 # Minimalistic printf version
275 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
276 
277 # Floating point printf version (requires MATH_LIB = -lm below)
278 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
279 
280 PRINTF_LIB =
281 
282 # Minimalistic scanf version
283 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
284 
285 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
286 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
287 
288 SCANF_LIB =
289 
290 MATH_LIB = -lm
291 
292 
293 ifdef RNMAKE_DOXY
294 /*! \endcond RNMAKE_DOXY */
295 endif