MyTetra Share
Делитесь знаниями!
Sublime Text 2 + AVRGCC
Время создания: 20.12.2016 18:01
Текстовые метки: gcc, st, st2
Раздел: Computer - Programming

{

"shell": true,

"working_dir": "${project_path:${folder}}",

"selector": "source.c",

"cmd": "avr-gcc -g -Os -std=gnu99 -mmcu=atmega8 -c ${file_base_name}.c && avr-gcc -g -std=gnu99 -mmcu=atmega8 -o ${file_base_name}.elf ${file_base_name}.o && avr-objcopy -j .text -j .data -O ihex ${file_base_name}.elf ${file_base_name}.hex && avr-gcc -std=gnu99 -c -g -Os -Wa,-a,-ad -mmcu=atmega8 ${file_base_name}.c > ${file_base_name}.lst && avr-size -C --common --mcu=atmega8 ${file_base_name}.elf",

"path": "/usr/bin/:/bin"

}


/*

{

"cmd": ["make", "all"],

"working_dir": "${project_path:${folder}}",

"encoding": "cp1251",

"selector": "source.c",

"variants": [

{

"cmd": ["make", "clean"],

"name": "Clean"

},

{

"cmd": ["make", "program"],

"name": "Flush"

}

],

"windows":

{

"path": "C:\\WinAVR\\bin;C:\\WinAVR\\utils\\bin"

},

"linux":

{

"path": "/usr/bin/:/bin"

}

}

*/


Normally to add extra directories to be searched for header files you simply add -I followed by a directory name (preferably relative to the Makefile directory rather than absolute). To help you with the creation of the -I's the template has introduced the concept of EXTRAINCDIRS. So instead of just adding multiple "-I dirname" to CFLAGS you just say "EXTRAINCDIRS=../foo ../bar" or whatever and this tells the C preprocessor to look in foo and bar (relative to "here") for any #include "filename"

EXTRALIBDIRS is not for searching for other .c files though. It is to tell the linker where to search for linkable .a (archived library) and .o (object) files. Your best bet to locate uart.c is to simply edit the SRC= line so that instead of just USART.c you specify something like ../foo/USART.c or whatever the path to it is.

BTW if you have problems understanding all this why bother messing with Makefiles? Why not use a decent IDE such as Studio 6 (which comes with avr-gcc 4.8.1 in AS6.2Beta) and then you just use a file selector to add the files to a "project" and the IDE handles all the complications of creating a Makefile to say where everything is.

I'm saying that if you used:

avr-gcc ... -I./boardinit -I./ADC -I./dataflash -I./TC -I./UART infile.c -o outfile.o

then:

#include "boardinit/boardinitialize.h"
#include "ADC/ADC.h"
#include "dataflash/dataflash.h"
#include "RTC/RTC.h"
#include "USART/USART.h"

could be written as:

#include "boardinitialize.h"
#include "ADC.h"
#include "dataflash.h"
#include "RTC.h"
#include "USART.h"

and that would still work. In fact if you then moved all your UART/ADC/dataflash stuff to N:\avrlib\UART etc. then you could just change:

avr-gcc ... -IN:\avrlib\boardinit -IN:\avrlib\ADC -IN:\avrlib\dataflash -IN:\avrlib\RTC -IN:\avrlib\UART infile.c -o outfile.o

and the source would still build.

IOW you are moving knowledge about your path structure out of your actual source files and into the Makefile.

 
MyTetra Share v.0.53
Яндекс индекс цитирования