Project

General

Profile

Statistics
| Revision:

root / branches / autonomous_recharging / code / projects / libwireless / lib / Makefile @ 706

History | View | Annotate | Download (6.25 KB)

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

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

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

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

    
12
CDEFS = 
13

    
14
# MCU name
15
MCU = atmega128
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 = 16000000
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
CDEFS += -DROBOT
71

    
72
# Place -I options here
73
CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
74
CINCS += -L$(COLONYROOT)/code/lib/bin
75

    
76
CBBINCS = -I$(COLONYROOT)/code/projects/libbayboard
77
CBBINCS += -L$(COLONYROOT)/code/projects/libbayboard
78

    
79

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

    
97

    
98
#---------------- Library Options ----------------
99
# Minimalistic printf version
100
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
101

    
102
# Floating point printf version (requires MATH_LIB = -lm below)
103
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
104

    
105
# If this is left blank, then it will use the Standard printf version.
106
PRINTF_LIB = 
107
#PRINTF_LIB = $(PRINTF_LIB_MIN)
108
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
109

    
110
# Minimalistic scanf version
111
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
112

    
113
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
114
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
115

    
116
# If this is left blank, then it will use the Standard scanf version.
117
SCANF_LIB = 
118
#SCANF_LIB = $(SCANF_LIB_MIN)
119
#SCANF_LIB = $(SCANF_LIB_FLOAT)
120

    
121
MATH_LIB = -lm
122

    
123
#============================================================================
124

    
125

    
126
# Define programs and commands.
127
SHELL = sh
128
CC = avr-gcc
129
AR = avr-ar
130
OBJCOPY = avr-objcopy
131
OBJDUMP = avr-objdump
132
SIZE = avr-size
133
NM = avr-nm
134
AVRDUDE = avrdude
135
REMOVE = rm -f
136
REMOVEDIR = rm -rf
137
COPY = cp
138
DOXYGEN = doxygen
139
WINSHELL = cmd
140

    
141

    
142
# Define Messages
143
# English
144
MSG_ERRORS_NONE = Errors: none
145
MSG_BEGIN = -------- begin --------
146
MSG_END = --------  end  --------
147
MSG_COMPILING = Compiling:
148
MSG_CLEANING = Cleaning project:
149

    
150
# Define all object files.
151
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
152
OBJBB = $(SRC:.c=.obb) $(ASRC:.S=.obb) 
153

    
154
# Define all listing files.
155
LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) 
156

    
157
# Compiler flags to generate dependency files.
158
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
159

    
160
# Combine all necessary flags and optional flags.
161
# Add target processor to flags.
162
ALL_CFLAGS = -mmcu=atmega128 -I. $(CFLAGS) $(CINCS) -Wall $(GENDEPFLAGS)
163
ALL_BBCFLAGS = -DBAYBOARD -DROBOT -mmcu=atmega164p -I. $(CFLAGS) $(CBBINCS) -Wall $(GENDEPFLAGS)
164
ALL_ASFLAGS = rcs
165

    
166
# Default target.
167
all: bayboard
168
bayboard: begin buildbayboard end
169

    
170
dist: all publish
171

    
172
publish:
173
	$(COPY) $(TARGET).a $(COLONYROOT)/code/lib/bin
174
	$(COPY) *.c $(COLONYROOT)/code/lib/src/$(TARGET)
175
	$(COPY) *.h $(COLONYROOT)/code/lib/include/$(TARGET)
176

    
177
docs:
178
	$(DOXYGEN)
179
	$(COPY) docs/html/* $(COLONYROOT)/docs/$(TARGET)
180

    
181
build: $(OBJ)
182
	$(AR) $(ALL_ASFLAGS) $(TARGET).a $(OBJ)
183

    
184
buildbayboard: $(OBJBB)
185
	$(AR) $(ALL_ASFLAGS) $(TARGET).a $(OBJBB)
186

    
187
computer:
188
	gcc *.c -Wall -g -I. -c
189
	ar rcs $(TARGET).a $(OBJ)
190

    
191
colonet:
192
	g++ -Wall -Wshadow -Wextra *.c -g -I. -c
193
	ar rcs $(TARGET).a $(OBJ)
194

    
195
# Eye candy.
196
# AVR Studio 3.x does not check make's exit code but relies on
197
# the following magic strings to be generated by the compile job.
198
begin:
199
	@echo
200
	@echo $(MSG_BEGIN)
201

    
202
end:
203
	@echo $(MSG_END)
204
	@echo
205

    
206
# Compile: create object files from C source files.
207
%.o : %.c
208
	@echo
209
	@echo $(MSG_COMPILING) $<
210
	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
211

    
212
%.obb : %.c
213
	@echo
214
	@echo $(MSG_COMPILING) $<
215
	$(CC) -c $(ALL_BBCFLAGS) $< -o $@ 
216

    
217

    
218
# Target: clean project.
219
clean: begin clean_list end
220

    
221
clean_list :
222
	@echo
223
	@echo $(MSG_CLEANING)
224
	$(REMOVE) $(TARGET).a
225
	$(REMOVE) $(OBJ)
226
	$(REMOVE) $(OBJBB)
227
	$(REMOVE) $(LST)
228
	$(REMOVE) $(SRC:.c=.s)
229
	$(REMOVE) $(SRC:.c=.d)
230
	$(REMOVE) -r docs
231
	$(REMOVEDIR) .dep
232

    
233

    
234

    
235
# Include the dependency files.
236
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
237