Tuesday, March 4, 2008

makefiles and source for irsensor example


Here are the files for the irsensor example:

irsensor.zip

This zip file contains irsensor.c, global.h, and makefile.


If you download the file, unzip it in your sixcode directory, and type "make" in the directory with the new files, it should compile the irsensor example.


The makefile contains comments that should help describe what it is, how it works, but the most important things are:
  • the target line: TRG = irsensor.
    • To compile a program of your own devising, you should change this to the name of your c file.
  • the source line: SRC = $(AVRLIB)/buffer.c $(AVRLIB)/uart.c $(AVRLIB)/rprintf.c $(AVRLIB)/timer.c $(AVRLIB)/a2d.c $(AVRLIB)/vt100.c $(TRG).c
    • you should make sure that this includes all of the modules that you use in your main program. For instance, if you use a2d functions, $(AVRLIB)/a2d.c should be on this source line.  
    • notice the $(TRG).c at the end of the line. This is what includes the main program you have written, defined in TRG above.
  • any source file you include needs to be described at the bottom of the makefile as well, under the rules to compile.  
    • For the a2d functions, you see that "a2d.o" has its own line at the bottom of the makefile: "a2d.o: a2d.c a2d.h".  
    • This specifies dependencies. This line says that a2d.o (the object file) depends on a2d.c (the source code) and a2d.h (the header) in order to compile.

No comments: