Makefile Generator

Macro Language (MGML) syntax and commands

Toolbar

Macro Language (MGML)

Toolbar

Makefile Generator does not have Toolbar buttons.

Macro Language (MGML)

Macro Directives

Macros for Conditional Expressions

File Macros

Name Modifiers

Macro Directives

Macro directives appear in the line in which "#$" are the first two non-white characters. They are used for iteration purposes throughout the project files and dependencies. Lines between consecutive iteration directives are repeated for each iterated file. Within project file iteration and within group file iteration, another dependency iteration is possible.

#$EndFor

Ends the appropriate #$For* block.

#$ForAll( conditional_expression [, switch] )

Used for iteration in all files that belong to the project and meet the set requirements. For each file which meets the requirements, the lines between this directive and the #$EndFor directive are repeated. The switch parameter may have the following values:

-s expands files in alphabetical order (default).

-s- expands files in the order in which they appear in the project file.

#$ForAllDependencies( conditional_expression [,switch] )

Performs iteration through all project files included in the active project file. This loop is used nestled in the loop body of a different type, and is applied to the active file of an external loop iteration. The body of this loop must contain the %FileName macro and cannot contain nestled loops. This loop must also end with the #$EndFor directive.
The switch parameter may have the following values:

-s expands files in alphabetical order (default).

-s- expands files in the order in which they have been included.

#$ForAllInGroup( groups, conditional_expression [,switch] [,switch] )

Used for iteration in all files that belong to logical groups groups (as they are defined in the Logical view) and meet the set requirements in conditional_expression parameter. For every such file the lines between this directive and the #$EndFor directive are repeated.
The meanings and rules for parameter use:

groups: The name of one or more logical groups as it appears in Logical view. If several logical groups are listed, they are separated by space characters. Names containing space characters must be surrounded by quotation marks.
For example: "grp 1" grp2 grp3
A group can be a subgroup. You must write the full "subgroup path" using "\".
For example: "grp 1\subgrp 1\subsubgrp 1"

switch:possible values:

-r recursive iteration. In this case, iteration will be performed through all files of the given or more groups and through all files of all subgroups.

-r- Iteration is not applied to subgroups - there is no recursion. (default).

-s expands files in alphabetical order (default).

-s- expands files in the order in which they have been added to the group.

#$SetCommentEndString( text )

Sets the string that will be used as the end of the generated comment in the output-file. Default: (""). Strings containing blank space must be quoted.

#$SetCommentStartString( text )

Sets the string that will be used as the start of the generated comment in the output-file. Default: "#". Strings containing a blank space must be quoted.

#$SetDirSeparator( text )

Sets the string which will be used as a separator of the folder in the file names (paths) which you get by expanding macros. Backslash ( \ ) is the default character.

#$SetGeneratorMode( mode )

This command enables you to influence generator behavior, where mode is the name of the type of the make utility you are using.
Possible values for the mode parameter are: borland, microsoft, polytron, gnu (values are not case-sensitive). Default behavior suits the GNU make utility. If your utility is not supported, and you feel it needs support, please contact our support (all necessary information is available at the beginning of the manual).

#$SetOutputTo( filename )

After this, output will be redirected to the file named filename. File names containing a blank space must be quoted.

Old directives are still supported: #$for_all, #$for_all_dependencies, #$for_all_in_group, #$for_all_in_groups, #$set_comment_strart_string, #$set_comment_end_string, #$set_dir_separator, #$set_generator_mode, #$set_output_to and #$end_for.

Macros for Conditional Expressions

Conditional expressions are used in macro directives to determine the files to be iterated. The operators allowed are OR, AND, and NOT, with AND and NOT having priority over OR. Use "()" to build complex expressions

You can use the following macros:

ALL "TRUE" for all files

ASM_SOURCE "TRUE" if the file has a Assembler source file type

C_SOURCE "TRUE" if the file has a C source file type

EXTENSION( "string" ) "TRUE" if the file has a string extension. Dot is not a part of the extension specifying string.

HEADER "TRUE" if the file has header extension

LIB_HEADER "TRUE" if the file has a header extension and is included using brackets ("<" and ">").

TEXT "TRUE" if the file has a text extension

File Macros

Macros in MGML are used to obtain information (a name or a part of a name, Makefile options) about the project file or files in which iteration is executed. Macros are expanded in "free text" form. They start with a "%" character ("%%" is always expanded as "%"). Unrecognized constructs are simply not expanded.

%<  %>  

These macros enable you to work with names of files and folders which contain spaces. During macro expansion, they are turned into quotation marks (") if the text they adjoin contains spaces. Application is illustrated by the template and makefiles excerpts following this table.

%[  %] 

These macros enable you to work with directories which contain relative parts 

Example for Project root C:\Projects\ProjE320\Source\

--- template:
%[%ProjectRootDir..\Headers%]
---
--- makefile:
C:\Projects\ProjE320\Headers
---

%AppendLine 

This macro expands multiple lines from the template file into one line in the makefile file.

Examples which illustrate the use:

--- template:
Files %AppendLine
#$ ForAll( ASM_SOURCE OR C_SOURCE )
$(OBJDIR)\%FileName( NAME ).OBJ %AppendLine
#$ EndFor
---
--- makefile:
Files $(OBJDIR)\dnc.OBJ $(OBJDIR)\events.OBJ $(OBJDIR)\HrdwInit.OBJ
---

%AppendString ( string_one, string_two )

This macro does not expand the string_one in the last line of the iteration. Strings should be written without being enclosed in quotation marks. If a particular parameter is to contain one or more comma characters ( , ), they must be assigned with "%," (non-inclusive of quotation marks). A line containing the #$EndFor macro directive must directly follow the line containing this macro.

%AsmToolsDir

Returns active “Assembler tools directory” configured in "Options > Assembler..." dialog. 

%CompToolsDir

Returns active “Compiler tools directory” configured in "Options > Compiler..." dialog. 

%FileName( Name_Modifiers )

%FileName is always the name of the currently iterated file. When dependencies are iterated, %FileName is the file name of the header files %FileName – path relative to the Project Root, or the full path if not in Project Root

%FileOptions 

Makefile options for iterated file name.

%HeaderDirs

Returns project header directories for Project and Referential root.

%MakeToolsDir

Returns "Make Tools Directory", configured in "Options > Makefile Generator..." dialog. 

%ProjectRootDir

Returns Project Root Directory path.

%Project( Name_Modifiers )

Returns Project file name.

%Registry( Key )

Returns value of key.

%IfNotFull( String )

Returns String if currently iterated name is not  full name, else empty string.

Example which illustrate the use of the %< and %> macro:

--- template:
#$ ForAll( C_SOURCE )
%<$(OBJDIR)\%FileName( NAME ).OBJ%>: %<%FileName()%> \
#$ ForAllDependencies( ALL )
%<%FileName( ALL )%> %AppendString(\)
#$ EndFor
$(CC) %FileOptions %<%FileName()%> -o %<%FileName( NAME ).OBJ%>
#$ EndFor
---
--- makefile:
$(OBJDIR)\sftwinit.OBJ: control\sftwinit.c \
headers\dnc.h
$(CC) control\sftwinit.c -o sftwinit.OBJ
$(OBJDIR)\axis_b1.OBJ: "Real Time\axis_b1.c" \
headers\axis_b1.h \
headers\axistype.h
$(CC) "Real Time\axis_b1.c" -o axis_b1.OBJ
---

Old macros are still supported:%s, %file_name, %file_options, %comp_tools_dir, %append_line, %registry, %if_not_full, %make_tools_dir, %asm_tools_dir, %append_string and %header_dirs.

Name Modifiers

In file name expansion macros, the following modifiers can be used to mark which name components will enter the resulting string.

For example: %FileName( DIR NAME EXT ) will copy the folder containing the file, file name and file extension to the resulting file.

DISK Disk part of file name.

DIR Folder part of file name.

NAME Name part of file name.

EXT Extension part of file name.

SHORT If the file is in Project Root tree, name relative to Project Root, else the full file name.