views:

872

answers:

1

Hi; I am working on an AVR project and have multiple folders containing my code.

The makefile I am using is the "Standardized AVR Makefile Template" by Pat Deegan. It's capable of compiling every cpp file in every folder correctly and generate the right object (.o) files.

However, the linker fails because it try to find to .o files in the subfolders (the compiler put them in the main folder). This is an example of an error I get :

avr-gcc: subfolder/module.o: No such file or directory make: ***

[GrandCanyon.out] Error 1

Can you help me modifying it so the linker and compiler put and check for the files (.o) in the same folders?

Thank you

you can get the makefile here : http://electrons.psychogenic.com/articles/Makefile.tpl

+2  A: 

The problem is the filter command, which removes the directory and leaves only the file name (link). So instead of defining all the files in a single line and doing:

#  C
CFILES=$(filter %.c, $(PRJSRC))
#  Assembly
ASMFILES=$(filter %.S, $(PRJSRC))

you need to manually define the file list for each type:

CCFILES = sub1/file1.c sub2/file2.c
ASMFILES = sub1/file1.asm sub3/file2.asm
kgiannakakis