Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / libwireless / lib / Makefile @ 17

History | View | Annotate | Download (5.65 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

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

    
94

    
95
#---------------- Library Options ----------------
96
# Minimalistic printf version
97
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
98

    
99
# Floating point printf version (requires MATH_LIB = -lm below)
100
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
101

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

    
107
# Minimalistic scanf version
108
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
109

    
110
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
111
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
112

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

    
118
MATH_LIB = -lm
119

    
120
#============================================================================
121

    
122

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

    
138

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

    
147
# Define all object files.
148
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
149

    
150
# Define all listing files.
151
LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) 
152

    
153
# Compiler flags to generate dependency files.
154
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
155

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

    
161
# Default target.
162
all: begin build end
163

    
164
dist: all publish
165

    
166
publish:
167
	$(COPY) $(TARGET).a $(COLONYROOT)/code/lib/bin
168
	$(COPY) *.c $(COLONYROOT)/code/lib/src/$(TARGET)
169
	$(COPY) *.h $(COLONYROOT)/code/lib/include/$(TARGET)
170

    
171
docs:
172
	$(DOXYGEN)
173
	$(COPY) docs/html/* $(COLONYROOT)/docs/$(TARGET)
174

    
175

    
176
build: $(OBJ)
177
	$(AR) $(ALL_ASFLAGS) $(TARGET).a $(OBJ)
178

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

    
186
end:
187
	@echo $(MSG_END)
188
	@echo
189

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

    
196

    
197
# Target: clean project.
198
clean: begin clean_list end
199

    
200
clean_list :
201
	@echo
202
	@echo $(MSG_CLEANING)
203
	$(REMOVE) $(TARGET).a
204
	$(REMOVE) $(OBJ)
205
	$(REMOVE) $(LST)
206
	$(REMOVE) $(SRC:.c=.s)
207
	$(REMOVE) $(SRC:.c=.d)
208
	$(REMOVE) -r docs
209
	$(REMOVEDIR) .dep
210

    
211

    
212

    
213
# Include the dependency files.
214
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
215