1 |
# Makefile for AVR function library development and examples |
1 |
# Makefile for AVR function library development and examples |
2 |
# Author: Pascal Stang |
2 |
# Author: Pascal Stang |
3 |
# |
3 |
# |
4 |
# For those who have never heard of makefiles: a makefile is essentially a |
4 |
# For those who have never heard of makefiles: a makefile is essentially a |
5 |
# script for compiling your code. Most C/C++ compilers in the world are |
5 |
# script for compiling your code. Most C/C++ compilers in the world are |
6 |
# command line programs and this is even true of programming environments |
6 |
# command line programs and this is even true of programming environments |
7 |
# which appear to be windows-based (like Microsoft Visual C++). Although |
7 |
# which appear to be windows-based (like Microsoft Visual C++). Although |
8 |
# you could use AVR-GCC directly from the command line and try to remember |
8 |
# you could use AVR-GCC directly from the command line and try to remember |
9 |
# the compiler options each time, using a makefile keeps you free of this |
9 |
# the compiler options each time, using a makefile keeps you free of this |
10 |
# tedious task and automates the process. |
10 |
# tedious task and automates the process. |
11 |
# |
11 |
# |
12 |
# For those just starting with AVR-GCC and not used to using makefiles, |
12 |
# For those just starting with AVR-GCC and not used to using makefiles, |
13 |
# I've added some extra comments above several of the makefile fields which |
13 |
# I've added some extra comments above several of the makefile fields which |
14 |
# you will have to deal with. |
14 |
# you will have to deal with. |
15 |
|
15 |
|
16 |
########### change this lines according to your project ################## |
16 |
########### change this lines according to your project ################## |
17 |
#put the name of the target mcu here (at90s8515, at90s8535, attiny22, atmega603 etc.) |
17 |
#put the name of the target mcu here (at90s8515, at90s8535, attiny22, atmega603 etc.) |
18 |
# MCU = atmega163 |
18 |
# MCU = atmega163 |
19 |
# MCU = atmega161 |
19 |
# MCU = atmega161 |
20 |
MCU = atmega128 |
20 |
MCU = atmega128 |
21 |
|
21 |
|
22 |
#put the name of the target file here (without extension) |
22 |
#put the name of the target file here (without extension) |
23 |
# Your "target" file is your C source file that is at the top level of your code. |
23 |
# Your "target" file is your C source file that is at the top level of your code. |
24 |
# In other words, this is the file which contains your main() function. |
24 |
# In other words, this is the file which contains your main() function. |
25 |
|
25 |
|
26 |
TRG = gpstest |
26 |
TRG = gpstest |
27 |
|
27 |
|
28 |
#put your C sourcefiles here |
28 |
#put your C sourcefiles here |
29 |
# Here you must list any C source files which are used by your target file. |
29 |
# Here you must list any C source files which are used by your target file. |
30 |
# They will be compiled in the order you list them, so it's probably best |
30 |
# They will be compiled in the order you list them, so it's probably best |
31 |
# to list $(TRG).c, your top-level target file, last. |
31 |
# to list $(TRG).c, your top-level target file, last. |
32 |
|
32 |
|
33 |
SRC = $(AVRLIB)/buffer.c $(AVRLIB)/uart2.c $(AVRLIB)/rprintf.c $(AVRLIB)/timer.c $(AVRLIB)/vt100.c $(AVRLIB)/tsip.c $(AVRLIB)/nmea.c $(AVRLIB)/gps.c $(AVRLIB)/lcd_hd44780.c $(TRG).c $(AVRLIB)/utm.c |
33 |
# SRC = $(AVRLIB)/buffer.c $(AVRLIB)/uart2.c $(AVRLIB)/rprintf.c $(AVRLIB)/timer.c $(AVRLIB)/vt100.c $(AVRLIB)/tsip.c $(AVRLIB)/nmea.c $(AVRLIB)/gps.c $(AVRLIB)/lcd_hd44780.c $(AVRLIB)/utm.c $(TRG).c |
- |
|
34 |
SRC = buffer.c uart2.c rprintf.c timer.c vt100.c tsip.c nmea.c gps.c lcd_hd44780.c utm.c $(TRG).c |
34 |
|
35 |
|
35 |
#put additional assembler source file here |
36 |
#put additional assembler source file here |
36 |
# The ASRC line allows you to list files which contain assembly code/routines that |
37 |
# The ASRC line allows you to list files which contain assembly code/routines that |
37 |
# you would like to use from within your C programs. The assembly code must be |
38 |
# you would like to use from within your C programs. The assembly code must be |
38 |
# written in a special way to be usable as a function from your C code. |
39 |
# written in a special way to be usable as a function from your C code. |
39 |
|
40 |
|
40 |
ASRC = |
41 |
ASRC = |
41 |
|
42 |
|
42 |
#additional libraries and object files to link |
43 |
#additional libraries and object files to link |
43 |
# Libraries and object files are collections of functions which have already been |
44 |
# Libraries and object files are collections of functions which have already been |
44 |
# compiled. If you have such files, list them here, and you will be able to use |
45 |
# compiled. If you have such files, list them here, and you will be able to use |
45 |
# use the functions they contain in your target program. |
46 |
# use the functions they contain in your target program. |
46 |
|
47 |
|
47 |
LIB = |
48 |
LIB = |
48 |
|
49 |
|
49 |
#additional includes to compile |
50 |
#additional includes to compile |
50 |
INC = |
51 |
INC = |
51 |
|
52 |
|
52 |
#assembler flags |
53 |
#assembler flags |
53 |
ASFLAGS = -Wa, -gstabs |
54 |
ASFLAGS = -Wa, -gstabs |
54 |
|
55 |
|
55 |
#compiler flags |
56 |
#compiler flags |
56 |
CPFLAGS = -g -Os -Wall -Wstrict-prototypes -I$(AVRLIB) -Wa,-ahlms=$(<:.c=.lst) |
57 |
CPFLAGS = -g -Os -Wall -Wstrict-prototypes -I$(AVRLIB) -Wa,-ahlms=$(<:.c=.lst) |
57 |
|
58 |
|
58 |
#linker flags |
59 |
#linker flags |
59 |
# LDFLAGS = -Wl,-Map=$(TRG).map,--cref |
60 |
# LDFLAGS = -Wl,-Map=$(TRG).map,--cref |
60 |
LDFLAGS = -Wl,-Map=$(TRG).map,--cref -lm |
61 |
LDFLAGS = -Wl,-Map=$(TRG).map,--cref -lm |
61 |
#PRINTF_LIB = -Wl,-u,vfprintf -lprintf_flt |
62 |
#PRINTF_LIB = -Wl,-u,vfprintf -lprintf_flt |
62 |
|
63 |
|
63 |
########### you should not need to change the following line ############# |
64 |
########### you should not need to change the following line ############# |
64 |
include $(AVRLIB)/make/avrproj_make |
65 |
include $(AVRLIB)/make/avrproj_make |
65 |
|
66 |
|
66 |
###### dependecies, add any dependencies you need here ################### |
67 |
###### dependecies, add any dependencies you need here ################### |
67 |
# Dependencies tell the compiler which files in your code depend on which |
68 |
# Dependencies tell the compiler which files in your code depend on which |
68 |
# other files. When you change a piece of code, the dependencies allow |
69 |
# other files. When you change a piece of code, the dependencies allow |
69 |
# the compiler to intelligently figure out which files are affected and |
70 |
# the compiler to intelligently figure out which files are affected and |
70 |
# need to be recompiled. You should only list the dependencies of *.o |
71 |
# need to be recompiled. You should only list the dependencies of *.o |
71 |
# files. For example: uart.o is the compiled output of uart.c and uart.h |
72 |
# files. For example: uart.o is the compiled output of uart.c and uart.h |
72 |
# and therefore, uart.o "depends" on uart.c and uart.h. But the code in |
73 |
# and therefore, uart.o "depends" on uart.c and uart.h. But the code in |
73 |
# uart.c also uses information from global.h, so that file should be listed |
74 |
# uart.c also uses information from global.h, so that file should be listed |
74 |
# in the dependecies too. That way, if you alter global.h, uart.o will be |
75 |
# in the dependecies too. That way, if you alter global.h, uart.o will be |
75 |
# recompiled to take into account the changes. |
76 |
# recompiled to take into account the changes. |
76 |
|
77 |
|
77 |
buffer.o : buffer.c buffer.h |
78 |
buffer.o : buffer.c buffer.h |
78 |
uart.o : uart.c uart.h global.h |
79 |
uart.o : uart.c uart.h global.h |
79 |
uart2.o : uart2.c uart2.h global.h |
80 |
uart2.o : uart2.c uart2.h global.h |
80 |
rprintf.o : rprintf.c rprintf.h |
81 |
rprintf.o : rprintf.c rprintf.h |
81 |
a2d.o : a2d.c a2d.h |
82 |
#a2d.o : a2d.c a2d.h |
82 |
timer.o : timer.c timer.h global.h |
83 |
timer.o : timer.c timer.h global.h |
83 |
pulse.o : pulse.c pulse.h timer.h global.h |
84 |
#pulse.o : pulse.c pulse.h timer.h global.h |
84 |
lcd.o : lcd.c lcd.h lcdconf.h global.h |
85 |
lcd.o : lcd.c lcd.h lcdconf.h global.h |
85 |
i2c.o : i2c.c i2c.h global.h |
86 |
#i2c.o : i2c.c i2c.h global.h |
86 |
spi.o : spi.c spi.h global.h |
87 |
#spi.o : spi.c spi.h global.h |
87 |
swpwm.o : swpwm.c swpwm.h global.h |
88 |
#swpwm.o : swpwm.c swpwm.h global.h |
88 |
servo.o : servo.c servo.h global.h |
89 |
#servo.o : servo.c servo.h global.h |
89 |
swuart.o : swuart.c swuart.h global.h |
90 |
#swuart.o : swuart.c swuart.h global.h |
90 |
tsip.o : tsip.c tsip.h global.h |
91 |
tsip.o : tsip.c tsip.h global.h |
91 |
nmea.o : nmea.c nmea.h global.h |
92 |
nmea.o : nmea.c nmea.h global.h |
92 |
vt100.o : vt100.c vt100.h global.h |
93 |
vt100.o : vt100.c vt100.h global.h |
93 |
gps.o : gps.c gps.h global.h |
94 |
gps.o : gps.c gps.h global.h |
94 |
lcd_hd44780.o : lcd_hd44780.c lcd_hd44780.h global.h |
95 |
lcd_hd44780.o : lcd_hd44780.c lcd_hd44780.h global.h |
95 |
utm.o : utm.c utm.h |
96 |
utm.o : utm.c utm.h |
96 |
$(TRG).o : $(TRG).c global.h |
97 |
$(TRG).o : $(TRG).c global.h |