Statistics
| Revision:

root / demos / john / projects / libwireless / lib / Makefile @ 1692

History | View | Annotate | Download (6.09 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)/lib/include/libdragonfly
75
CINCS += -L$(COLONYROOT)/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
#CFLAGS += -g$(DEBUG)
87
CFLAGS += $(CDEFS) $(CINCS)
88
CFLAGS += -O$(OPT)
89
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
90
CFLAGS += -Wall -Wstrict-prototypes
91
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
92
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
93
CFLAGS += $(CSTANDARD)
94

    
95

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

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

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

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

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

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

    
119
MATH_LIB = -lm
120

    
121
#============================================================================
122

    
123

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

    
139

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

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

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

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

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

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

    
165
dist: all publish
166

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

    
171
build: $(OBJ)
172
	$(AR) $(ALL_ASFLAGS) $(TARGET).a $(OBJ)
173

    
174
computer:
175
	gcc *.c -Wall -Wshadow -Wextra -g -I. -c
176
	ar rcs $(TARGET).a $(OBJ)
177

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

    
184
colonet:
185
	g++ -Wall -Wshadow -Wextra *.c -g -I. -c
186
	ar rcs $(COLONET_TARGET).a $(OBJ)
187

    
188
# Eye candy.
189
# AVR Studio 3.x does not check make's exit code but relies on
190
# the following magic strings to be generated by the compile job.
191
begin:
192
	@echo
193
	@echo $(MSG_BEGIN)
194

    
195
end:
196
	@echo $(MSG_END)
197
	@echo
198

    
199
# Compile: create object files from C source files.
200
%.o : %.c
201
	@echo
202
	@echo $(MSG_COMPILING) $<
203
	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
204

    
205

    
206
# Target: clean project.
207
clean: begin clean_list end
208

    
209
clean_list :
210
	@echo
211
	@echo $(MSG_CLEANING)
212
	$(REMOVE) $(TARGET).a
213
	$(REMOVE) $(COLONET_TARGET).a
214
	$(REMOVE) $(OBJ)
215
	$(REMOVE) $(LST)
216
	$(REMOVE) $(SRC:.c=.s)
217
	$(REMOVE) $(SRC:.c=.d)
218
	$(REMOVE) -r docs
219
	$(REMOVEDIR) .dep
220

    
221

    
222

    
223
# Include the dependency files.
224
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
225