Project

General

Profile

Statistics
| Revision:

root / branches / simulator / projects / libdragonfly / Makefile @ 943

History | View | Annotate | Download (5.49 KB)

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

    
5
COLONYROOT = ../../..
6
CODEROOT = ../..
7

    
8
# Target file name (without extension).
9
TARGET = libdragonfly
10

    
11
############################
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 = include
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

    
72
# Place -I options here
73
CINCS =
74

    
75

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

    
92

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

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

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

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

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

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

    
116
MATH_LIB = -lm
117

    
118
#============================================================================
119

    
120

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

    
136

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

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

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

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

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

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

    
162
dist: all publish
163

    
164
publish:
165
	$(COPY) $(TARGET).a $(CODEROOT)/lib/bin
166
	$(COPY) include/*.h $(CODEROOT)/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