root / trunk / code / projects / libdragonfly / Makefile @ 1985
History | View | Annotate | Download (5.48 KB)
1 | 8 | bcoltin | ############################ |
---|---|---|---|
2 | ### Update this Section #### |
||
3 | ############################ |
||
4 | |||
5 | COLONYROOT = ../../.. |
||
6 | |||
7 | # Target file name (without extension). |
||
8 | TARGET = libdragonfly |
||
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 | |||
71 | # Place -I options here |
||
72 | |||
73 | |||
74 | #---------------- Compiler Options ---------------- |
||
75 | # -g*: generate debugging information |
||
76 | # -O*: optimization level |
||
77 | # -f...: tuning, see GCC manual and avr-libc documentation |
||
78 | # -Wall...: warning level |
||
79 | # -Wa,...: tell GCC to pass this to the assembler. |
||
80 | # -adhlns...: create assembler listing |
||
81 | CFLAGS = -g$(DEBUG) |
||
82 | CFLAGS += $(CDEFS) $(CINCS) |
||
83 | CFLAGS += -O$(OPT) |
||
84 | CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums |
||
85 | CFLAGS += -Wall -Wstrict-prototypes |
||
86 | CFLAGS += -Wa,-adhlns=$(<:.c=.lst) |
||
87 | CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
||
88 | CFLAGS += $(CSTANDARD) |
||
89 | |||
90 | |||
91 | #---------------- Library Options ---------------- |
||
92 | # Minimalistic printf version |
||
93 | PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min |
||
94 | |||
95 | # Floating point printf version (requires MATH_LIB = -lm below) |
||
96 | PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt |
||
97 | |||
98 | # If this is left blank, then it will use the Standard printf version. |
||
99 | PRINTF_LIB = |
||
100 | #PRINTF_LIB = $(PRINTF_LIB_MIN) |
||
101 | #PRINTF_LIB = $(PRINTF_LIB_FLOAT) |
||
102 | |||
103 | # Minimalistic scanf version |
||
104 | SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min |
||
105 | |||
106 | # Floating point + %[ scanf version (requires MATH_LIB = -lm below) |
||
107 | SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt |
||
108 | |||
109 | # If this is left blank, then it will use the Standard scanf version. |
||
110 | SCANF_LIB = |
||
111 | #SCANF_LIB = $(SCANF_LIB_MIN) |
||
112 | #SCANF_LIB = $(SCANF_LIB_FLOAT) |
||
113 | |||
114 | MATH_LIB = -lm |
||
115 | |||
116 | #============================================================================ |
||
117 | |||
118 | |||
119 | # Define programs and commands. |
||
120 | SHELL = sh |
||
121 | CC = avr-gcc |
||
122 | AR = avr-ar |
||
123 | OBJCOPY = avr-objcopy |
||
124 | OBJDUMP = avr-objdump |
||
125 | SIZE = avr-size |
||
126 | NM = avr-nm |
||
127 | AVRDUDE = avrdude |
||
128 | REMOVE = rm -f |
||
129 | REMOVEDIR = rm -rf |
||
130 | COPY = cp |
||
131 | DOXYGEN = doxygen |
||
132 | WINSHELL = cmd |
||
133 | |||
134 | |||
135 | # Define Messages |
||
136 | # English |
||
137 | MSG_ERRORS_NONE = Errors: none |
||
138 | MSG_BEGIN = -------- begin -------- |
||
139 | MSG_END = -------- end -------- |
||
140 | MSG_COMPILING = Compiling: |
||
141 | MSG_CLEANING = Cleaning project: |
||
142 | |||
143 | # Define all object files. |
||
144 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
||
145 | |||
146 | # Define all listing files. |
||
147 | LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) |
||
148 | |||
149 | # Compiler flags to generate dependency files. |
||
150 | GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d |
||
151 | |||
152 | # Combine all necessary flags and optional flags. |
||
153 | # Add target processor to flags. |
||
154 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) |
||
155 | ALL_ASFLAGS = rcs |
||
156 | |||
157 | # Default target. |
||
158 | all: begin build end |
||
159 | |||
160 | dist: all publish |
||
161 | |||
162 | publish: |
||
163 | $(COPY) $(TARGET).a $(COLONYROOT)/code/lib/bin |
||
164 | $(COPY) *.h $(COLONYROOT)/code/lib/include/$(TARGET) |
||
165 | |||
166 | 1144 | deffi | .PHONY: docs |
167 | 8 | bcoltin | docs: |
168 | $(DOXYGEN) |
||
169 | $(COPY) docs/html/* $(COLONYROOT)/docs/$(TARGET) |
||
170 | |||
171 | |||
172 | build: $(OBJ) |
||
173 | $(AR) $(ALL_ASFLAGS) $(TARGET).a $(OBJ) |
||
174 | |||
175 | # Eye candy. |
||
176 | # AVR Studio 3.x does not check make's exit code but relies on |
||
177 | # the following magic strings to be generated by the compile job. |
||
178 | begin: |
||
179 | @echo |
||
180 | @echo $(MSG_BEGIN) |
||
181 | |||
182 | end: |
||
183 | @echo $(MSG_END) |
||
184 | @echo |
||
185 | |||
186 | # Compile: create object files from C source files. |
||
187 | %.o : %.c |
||
188 | @echo |
||
189 | @echo $(MSG_COMPILING) $< |
||
190 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
||
191 | |||
192 | |||
193 | # Target: clean project. |
||
194 | clean: begin clean_list end |
||
195 | |||
196 | clean_list : |
||
197 | @echo |
||
198 | @echo $(MSG_CLEANING) |
||
199 | $(REMOVE) $(TARGET).a |
||
200 | $(REMOVE) $(OBJ) |
||
201 | $(REMOVE) $(LST) |
||
202 | $(REMOVE) $(SRC:.c=.s) |
||
203 | $(REMOVE) $(SRC:.c=.d) |
||
204 | $(REMOVEDIR) .dep |
||
205 | |||
206 | |||
207 | |||
208 | # Include the dependency files. |
||
209 | -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) |