Project

General

Profile

Statistics
| Revision:

root / branches / wireless / code / projects / libwireless / Makefile @ 1617

History | View | Annotate | Download (6.24 KB)

1
############################
2
### Update this Section ####
3
############################
4
COLONYROOT = ../../..
5

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

    
10
############################
11
# don't touch this unless you know what you're doing.
12

    
13
CDEFS = 
14

    
15
# MCU name
16
MCU = atmega128
17

    
18

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

    
26

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

    
30

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

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

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

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

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

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

    
68

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

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

    
77

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

    
96

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

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

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

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

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

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

    
120
MATH_LIB = -lm
121

    
122
#============================================================================
123

    
124

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

    
140

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

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

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

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

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

    
163
# Default target.
164
all: begin build end
165

    
166
dist: all publish
167

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

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

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

    
179
computer:
180
	gcc *.c -Wall -Wshadow -Wextra -g -I. -c
181
	ar rcs $(TARGET).a $(OBJ)
182

    
183
# we should fine a better way to do this.....
184
bayboard:
185
	avr-gcc *.c -DBAYBOARD -mmcu=atmega164p -I. -DF_CPU=8000000UL -DROBOT -I../../../../code/lib/include/libbayboard \
186
			-L../../../../code/lib/bin/bayboard -Wall -Wshadow -Wextra -std=gnu99 -MD -MP -MF -c
187
	avr-ar rcs $(TARGET).a $(OBJ)
188

    
189
colonet:
190
	g++ -Wall -Wshadow -Wextra *.c -g -I. -c
191
	ar rcs $(COLONET_TARGET).a $(OBJ)
192

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

    
200
end:
201
	@echo $(MSG_END)
202
	@echo
203

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

    
210

    
211
# Target: clean project.
212
clean: begin clean_list end
213

    
214
clean_list :
215
	@echo
216
	@echo $(MSG_CLEANING)
217
	$(REMOVE) $(TARGET).a
218
	$(REMOVE) $(COLONET_TARGET).a
219
	$(REMOVE) $(OBJ)
220
	$(REMOVE) $(LST)
221
	$(REMOVE) $(SRC:.c=.s)
222
	$(REMOVE) $(SRC:.c=.d)
223
	$(REMOVE) -r docs
224
	$(REMOVEDIR) .dep
225

    
226

    
227

    
228
# Include the dependency files.
229
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
230