Simple Makefile generator for AVR-GCC
Copyright � 2003, 2004 J�rg Wunsch
This simple Makefile generator is meant as an aid to quicklycustomize the WinAVR Makefile template, producing a file calledMakefile in the current directory as result.
The application consists of a (scrollable) text editor widget, anda menu bar.
The File menu has only two entries:
-
Save writes the contents of the text editor widget to afile called Makefile. Should any file by that namealready exist, it will be renamed. Under Unix, a tilde will beappended to the old name, all other platforms append a .baksuffix.
-
Save As opens a filename selection dialog, and allowsthe user to select a file to save to. After selecting the filename, it behaves identical to Save.
-
Open opens a filename selection dialog, requesting anexisting file to be opened by the user. This file will be loadedinto the editor buffer, and the Makefile menu will beupdated accordingly.
-
Exit will quit the application. No checks whatsoeverare done to ensure the user has saved his editing work before.
The Makefile menu allows customization of the generatedMakefile. Note that the various menu items described below will onlybe present if the corresponding feature is present in the parsedtemplate or input file. This menu is divided into three areas:
-
Code generation options
- The entry Main file name opens a popup window that asksfor the basic name of thisproject. This will become the base name for all major output files(ELF file, MCU output file, several auxiliary files). By default, itwill also serve as the name of the primary C source file, with a.c suffix appended. The popup will be closed by pressing
in the entry field.
- The entries MCU type, Output format,Optimization level,and C standard level select possible values out of apredefined list. When selecting one of these options, therespective Makefile macro will be modified accordingly, and thewidget will be adjusted so the new values can be seenimmediately.
- The entry printf() options works similar, only it doesnot modify a Makefile macro of its own but edits the PRINTF_LIBmacro instead. Note that setting this away fromnone/standard will cause the generated application toalways include the code for vfprintf() (which is huge),regardless of whether the application actually uses any memberof the printf() family. See the avr-libc documentation for themeaning of the different options.
- Likewise, changing the scanf() options changes themacro SCANF_LIB, in the same manner. Note that thescanf() format %[ (string match out of a set ofcharacters) will only be present in the floating point versionsince it requires a lot of code, as well as usingmalloc() (which is otherwise only required for thefloating point version).
- The entry C/C++ source file(s) opens a popup that asksfor a list of C (or C++) source files. C source files get thesuffix .c (lower-case letter c), C++ source files geteither of .C (capital c), .cxx, or .cc.Multiple file names shall be seperated by spaces. A checkboxindicates whether the primary C source file name derived fromthe Main file name setting should be included or not.The popup will be closed by pressing
in the entryfield.
- The entry Assembler source file(s) works similarexcept there are no default assembler sources to be included.Note that assembler source files get the suffix .S(capital letter s) which means they are being pre-processed bythe C preprocessor, so #include etc. will work. Alower-case letter .s suffix is considered to be atemporary compiler output file, and should not be used here.
- Using External RAM options, several possible variantsto use external RAM can be selected. This is internally handledby editing the EXTMEMOPTS macro which eventually gets added tothe LDFLAGS during linking. The options are to either useexternal RAM for both, variables (i. e. sections .data and .bss)as well as for the heap (dynamic memory for malloc()),or to leave variables in internal memory and use the externalRAM only for the heap. In both cases, the stack will alwaysremain in internal memory; this is the fastest way, and someAVR MCUs have hardware bugs so they would not work when thestack is located in external RAM. It can be selected whetherthe external RAM should start at the lowest possible memorylocation (right behind the internal RAM), or at a differentmemory address. Several common memory sizes can be chosen from.Obviously, these options are only accessible for MCU types thatdo have an external memory interface.
- The entry Debug format selects one out of the followingoptions:
-
ELF/stabs ELF object files with stabs debugginginformation are currently the native way to debug under Unixand/or GDB. This includes any GDB frontend, like Insight orDDD.
-
AVR-COFF Selecting this format will internally alsogenerate an ELF/stabs file, but change the Makefile tosubsequently convert the ELF file into a COFF file that adheresto the originally Atmel AVR COFF file format specification.This file format is understood by AVR Studio up to 3.x, andVMLAB up to 3.9.
-
AVR-ext-COFF The conversion from internal ELF toCOFF will be tuned to produce a file according to the laterAVR "extended" COFF specification by Atmel, understood by AVRStudio 4.07 and above, and VMLAB 3.10 and above.
-
ELF/DWARF-2 Create an ELF standard object file withDWARF-2 debug information. This is the proposed standard debugformat for ELF. It is currently Beta, the GNU tools are slowlychanging towards that standard (though it is not yet knownwhether AVR-GDB will already fully understand the format yet),and Atmel has released a beta ELF/DWARF-2 parser for their AVRStudio.
-
AVRdude options
- The entry Programmer allows the selection ofthe programming hardware (parallel port "dongle", or seriallyconnected hardware).
- The entry Port selects the serial or parallelport AVRdude is going to talk across. This menu item mightbe missing on some operating systems where no default portsare known.
-
Miscellaneous
- By default, the editor widget is read-only, and can only bemodified by the menu entries mentioned above. By checking theEnable Editing of Makefile checkbox, this restriction can be lifted,and the widget can be used as a simple standard text editor forthe generated Makefile. Note that the menu operations mentionedabove are not guaranteed to work on arbitrary input texts sincethey search for certain patterns in order to implement theirfunctionality, so manual editing should always be used as a laststep before eventually saving the generated Makefile.