TAG = value
TMAKE can also do tag expansion using $$:
ALLFILES = Project files: $$HEADERS $$SOURCES
Normally you assign to a tag, but you can also add to a tag, subtract
from a tag or replace parts of the tag.
A = abc
X = xyz
A += def # A = abc def
X *= xyz # X = xyz
B = $$A # B = abc def
B -= abc # B = def
X /= s/y/Y/ # X = xYz
The *= operation adds the value if the tag does not already contain it.
The /= operation performs regular expression substitution.
You can also set tags from the command line when running the tmake program. For instance, if you want to generate a makefile with debug information:
tmake hello.pro "CONFIG+=debug"
Use the unix: or win32: qualifier if you want a platform-specific tag:
SOURCES = common.cpp # common for all platforms
unix:SOURCES += unix.cpp # additional sources for UNIX
win32:SOURCES += win32.cpp # additional sources for Windows
unix:LIBS += -lm # on UNIX we need the math lib
You may even define your own project tags to be used by custom templates.
A project tag is stored in %project, which is an associative
Perl array. Access it like this: $project{"tag"}. For
example, after reading "hello.pro", $project{"SOURCES"}
contains "hello.cpp main.cpp".
Example:
CLEAN_FILES = core *~
| debug | Compile with debug options enabled. | ||
| dll | Create a DLL/shared object target (app.t only). | ||
| opengl | This is an application which requires the OpenGL library. | ||
| qt | This is a Qt application. Tells tmake to add rules for moc files and link with the Qt library. | ||
| release | Compile with optimization enabled. This option is ignored if "debug" is specified. | ||
| staticlib | UNIX/lib.t only: Create only a static library, no shared library. | ||
| warn_on | The compiler should emit more warnings than normally. This option is ignored if "warn_off" is specified. | ||
| warn_off | The compiler should emit no warnings or as few as possible. | ||
| windows | Windows only: The application requires Windows header files and the Windows libraries. | ||
| x11 | X11 only: The application requires X header files and the libX11 library. |
DESTDIR = ../../libYou must create this directory before running make.
INCLUDEPATH. The ';' or ':'
separators have been replaced by ' ' (single space). This makes it
easier to split. qtapp.t and other templates expand
INCPATH to set -I options for the C++ compiler.
Example:
INCLUDEPATH = c:\msdev\include;d:\stl\includeUse ';' as the directory separator.
Example:
unix:LIBS = -lXext -lm win32:LIBS = ole32.lib
Example:
MOC_DIR = tmpYou must create this directory before running make.
See also: OBJECTS_DIR.
SOURCES by the StdInit() function.
The extension of each source file has been replaced by .o (UNIX) or .obj
(Win32).Example:
SOURCES = a.x b.yThen
OBJECTS become "a.o b.o" on UNIX and "a.obj b.obj" on
Win32.
Example:
OBJECTS_DIR = tmpYou must create this directory before running make.
See also: MOC_DIR.
$moc_aware is true. OBJMOC contains the name of
all intermediate moc object files.Example:
HEADERS = demo.h SOURCES = demo.cpp main.cppIf demo.h and main.cpp define classes that use signals and slots (i.e. the
Q_OBJECT "keyword" is found in these two
files), OBJMOC becomes:OBJMOC = moc_demo.objSee also: SRCMOC.
CONFIG contains "qt". SRCMOC contains the name of
all intermediate moc files.Example:
HEADERS = demo.h SOURCES = demo.cpp main.cppIf demo.h and main.cpp define classes that use signals and slots (i.e. the
Q_OBJECT "keyword" is found in these two
files), SRCMOC becomes:SRCMOC = moc_demo.cpp main.mocSee also: OBJMOC.
Example:
#$ AddIncludePath('$QTDIR/include;/local/include');
Example:
#$ BuildMocObj($project{"OBJMOC"},$project{"SRCMOC"});
Output:moc_hello.o: moc_hello.cpp \ hello.h \ ...
Example:
#$ BuildMocSrc($project{"HEADERS"});
#$ BuildMocSrc($project{"SOURCES"});
Output:moc_hello.cpp: hello.h $(MOC) hello.h -o moc_hello.cpp
Example:
#$ BuildObj($project{"OBJECTS"},$project{"SOURCES"});
Output:hello.o: hello.cpp \ hello.h \ ... main.o: main.cpp \ hello.h \ ...
CONFIG tag contains the given string.
Example:
#$ if ( Config("release") { }
Example:
#$ Config("debug") && DisableOutput();
Anything here is skipped if CONFIG contains "debug".
#$ Config("debug") && EnableOutput();
$text = $project{$tag}.
Example:
VERSION = #$ &expand("VERSION");
Output:VERSION = 1.1
Example:
clear:
#$ ExpandGlue("OBJECTS","-del","\n\t-del ","");
Output (Windows NT):
clear:
-del hello.obj
-del main.obj
ExpandGlue($tag,""," \\\n\t\t","").Example:
OBJECTS = #$ ExpandList("OBJECTS");
Output:OBJECTS = hello.o \ main.o
Example:
#$ IncludeTemplate("qtapp");
Example:
# Generated at #$ Now()Output:
# Generated at 12:58, 1996/11/19
Examples:
# Get a project variable:
$s = Project("TEMPLATE"); -> $s = "TEMPLATE"
# Set a project variable:
Project("TEMPLATE = lib"); -> TEMPLATE = lib
Project("CONFIG =";) -> CONFIG empty
# Append to a project variable:
Project("CONFIG = qt"); -> CONFIG = qt
Project("CONFIG += debug"); -> CONFIG = qt debug
# Append to a project variable if it does not contain the value already:
Project("CONFIG = qt release"); -> CONFIG = qt release
Project("CONFIG *= qt"); -> CONFIG = qt release
Project("CONFIG *= opengl"); -> CONFIG = qt release opengl
# Subtract from a project variable:
Project("THINGS = abc xyz"); -> THINGS = abc xyz
Project("THINGS -= abc"); -> THINGS = xyz
# Search/replace on a project variable:
Project("CONFIG = tq opengl"); -> CONFIG = tq opengl
Project("CONFIG /= s/tq/qt/"); -> CONFIG = qt opengl
# The operations can be performed on several project variables at a time.
Project("TEMPLATE = app", "CONFIG *= opengl", "THINGS += klm");
%project array.
This function creates some new project tags:
OBJECTS
- Object files corresponding to
SOURCES.
SRCMOC - moc source files.
OBJMOC - moc object files.
CONFIG contains "qt"
Important: Use single quotes around the string, otherwise perl will expand any $tags it finds.
Example:
Substitute('Project name: $$PROJECT, uses template $$TEMPLATE');