Project

General

Profile

Statistics
| Revision:

root / branches / autonomous_recharging / code / projects / libbayboard / Makefile @ 649

History | View | Annotate | Download (5.52 KB)

1
############################
2
### Update this Section ####
3
############################
4

    
5
COLONYROOT = ../../..
6

    
7
# Target file name (without extension).
8
TARGET = libbayboard
9

    
10
############################
11

    
12
CDEFS = 
13

    
14
# MCU name
15
MCU = atmega164p
16

    
17

    
18
# Processor frequency.
19
#     This will define a symbol, F_CPU, in all source code files equal to the 
20
#     processor frequency. You can then use this symbol in your source code to 
21
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
22
#     automatically to create a 32-bit value in your source code.
23
F_CPU = 8000000
24

    
25

    
26
# Output format. (can be srec, ihex, binary)
27
FORMAT = ihex
28

    
29

    
30
# List C source files here. (C dependencies are automatically generated.)
31
SRC = $(wildcard *.c)
32

    
33
# List Assembler source files here.
34
#     Make them always end in a capital .S.  Files ending in a lowercase .s
35
#     will not be considered source files but generated files (assembler
36
#     output from the compiler), and will be deleted upon "make clean"!
37
#     Even though the DOS/Win* filesystem matches both .s and .S the same,
38
#     it will preserve the spelling of the filenames, and gcc itself does
39
#     care about how the name is spelled on its command-line.
40
ASRC = 
41

    
42
# Optimization level, can be [0, 1, 2, 3, s]. 
43
#     0 = turn off optimization. s = optimize for size.
44
#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
45
OPT = s
46

    
47
# Debugging format.
48
#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
49
#     AVR Studio 4.10 requires dwarf-2.
50
#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
51
DEBUG = 
52
# dwarf-2
53

    
54
# List any extra directories to look for include files here.
55
#     Each directory must be seperated by a space.
56
#     Use forward slashes for directory separators.
57
#     For a directory that has spaces, enclose it in quotes.
58
EXTRAINCDIRS = 
59

    
60
# Compiler flag to set the C Standard level.
61
#     c89   = "ANSI" C
62
#     gnu89 = c89 plus GCC extensions
63
#     c99   = ISO C99 standard (not yet fully implemented)
64
#     gnu99 = c99 plus GCC extensions
65
CSTANDARD = -std=gnu99
66

    
67

    
68
# Place -D or -U options here
69
CDEFS += -DF_CPU=$(F_CPU)UL 
70

    
71
# Place -I options here
72
CINCS =
73

    
74

    
75
#---------------- Compiler Options ----------------
76
#  -g*:          generate debugging information
77
#  -O*:          optimization level
78
#  -f...:        tuning, see GCC manual and avr-libc documentation
79
#  -Wall...:     warning level
80
#  -Wa,...:      tell GCC to pass this to the assembler.
81
#    -adhlns...: create assembler listing
82
CFLAGS = -g$(DEBUG)
83
CFLAGS += $(CDEFS) $(CINCS)
84
CFLAGS += -O$(OPT)
85
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
86
CFLAGS += -Wall -Wstrict-prototypes
87
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
88
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
89
CFLAGS += $(CSTANDARD)
90

    
91

    
92
#---------------- Library Options ----------------
93
# Minimalistic printf version
94
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
95

    
96
# Floating point printf version (requires MATH_LIB = -lm below)
97
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
98

    
99
# If this is left blank, then it will use the Standard printf version.
100
PRINTF_LIB = 
101
#PRINTF_LIB = $(PRINTF_LIB_MIN)
102
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
103

    
104
# Minimalistic scanf version
105
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
106

    
107
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
108
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
109

    
110
# If this is left blank, then it will use the Standard scanf version.
111
SCANF_LIB = 
112
#SCANF_LIB = $(SCANF_LIB_MIN)
113
#SCANF_LIB = $(SCANF_LIB_FLOAT)
114

    
115
MATH_LIB = -lm
116

    
117
#============================================================================
118

    
119

    
120
# Define programs and commands.
121
SHELL = sh
122
CC = avr-gcc
123
AR = avr-ar
124
OBJCOPY = avr-objcopy
125
OBJDUMP = avr-objdump
126
SIZE = avr-size
127
NM = avr-nm
128
AVRDUDE = avrdude
129
REMOVE = rm -f
130
REMOVEDIR = rm -rf
131
COPY = cp
132
DOXYGEN = doxygen
133
WINSHELL = cmd
134

    
135

    
136
# Define Messages
137
# English
138
MSG_ERRORS_NONE = Errors: none
139
MSG_BEGIN = -------- begin --------
140
MSG_END = --------  end  --------
141
MSG_COMPILING = Compiling:
142
MSG_CLEANING = Cleaning project:
143

    
144
# Define all object files.
145
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
146

    
147
# Define all listing files.
148
LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) 
149

    
150
# Compiler flags to generate dependency files.
151
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
152

    
153
# Combine all necessary flags and optional flags.
154
# Add target processor to flags.
155
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
156
ALL_ASFLAGS = rcs
157

    
158
# Default target.
159
all: begin build end
160

    
161
dist: all publish
162

    
163
publish:
164
	$(COPY) $(TARGET).a $(COLONYROOT)/code/lib/bin
165
	$(COPY) *.c $(COLONYROOT)/code/lib/src/$(TARGET)
166
	$(COPY) *.h $(COLONYROOT)/code/lib/include/$(TARGET)
167

    
168
docs:
169
	$(DOXYGEN)
170
	$(COPY) docs/html/* $(COLONYROOT)/docs/$(TARGET)
171

    
172

    
173
build: $(OBJ)
174
	$(AR) $(ALL_ASFLAGS) $(TARGET).a $(OBJ)
175

    
176
# Eye candy.
177
# AVR Studio 3.x does not check make's exit code but relies on
178
# the following magic strings to be generated by the compile job.
179
begin:
180
	@echo
181
	@echo $(MSG_BEGIN)
182

    
183
end:
184
	@echo $(MSG_END)
185
	@echo
186

    
187
# Compile: create object files from C source files.
188
%.o : %.c
189
	@echo
190
	@echo $(MSG_COMPILING) $<
191
	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
192

    
193

    
194
# Target: clean project.
195
clean: begin clean_list end
196

    
197
clean_list :
198
	@echo
199
	@echo $(MSG_CLEANING)
200
	$(REMOVE) $(TARGET).a
201
	$(REMOVE) $(OBJ)
202
	$(REMOVE) $(LST)
203
	$(REMOVE) $(SRC:.c=.s)
204
	$(REMOVE) $(SRC:.c=.d)
205
	$(REMOVEDIR) .dep
206

    
207

    
208

    
209
# Include the dependency files.
210
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
211