############################################################################# # Makefile for building hello # Generated by tmake at 10:11, 1998/07/07 # Project: hello # Template: app ############################################################################# ####### Compiler, tools and options CC = g++ CFLAGS = -Wall -W -O2 -fno-strength-reduce INCPATH = -I$(QTDIR)/include LINK = g++ LFLAGS = LIBS = -L$(QTDIR)/lib -lqt -L/usr/X11R6/lib -lX11 MOC = moc ####### Files HEADERS = hello.h SOURCES = hello.cpp \ main.cpp OBJECTS = hello.o \ main.o SRCMOC = moc_hello.cpp OBJMOC = moc_hello.o TARGET = hello ####### Implicit rules .SUFFIXES: .cpp .cxx .cc .C .c .cpp.o: $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< .cxx.o: $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< .cc.o: $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< .C.o: $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< .c.o: $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< ####### Build rules all: $(TARGET) $(TARGET): $(OBJECTS) $(OBJMOC) $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) moc: $(SRCMOC) tmake: tmake hello.pro clean: -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(TARGET) -rm -f *~ core ####### Compile hello.o: hello.cpp \ hello.h main.o: main.cpp \ hello.h moc_hello.o: moc_hello.cpp \ hello.h moc_hello.cpp: hello.h $(MOC) hello.h -o moc_hello.cpptmake-1.8/doc/m-win32-msvc.html 100444 773 773 3234 7175526477 14767 0 ustar aavit aavit
############################################################################# # Makefile for building hello # Generated by tmake at 20:40, 1998/02/27 # Project: hello # Template: app ############################################################################# ####### Compiler, tools and options CC = cl CFLAGS = -nologo -W3 -O2 INCPATH = -I"$(QTDIR)\include" LINK = link LFLAGS = /NOLOGO /SUBSYSTEM:windows LIBS = $(QTDIR)\lib\qt.lib user32.lib gdi32.lib comdlg32.lib wsock32.lib MOC = moc ####### Files HEADERS = hello.h SOURCES = hello.cpp \ main.cpp OBJECTS = hello.obj \ main.obj SRCMOC = moc_hello.cpp OBJMOC = moc_hello.obj TARGET = hello.exe ####### Implicit rules .SUFFIXES: .cpp .cxx .cc .c .cpp.obj: $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< .cxx.obj: $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< .cc.obj: $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< .c.obj: $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< ####### Build rules all: $(TARGET) $(TARGET): $(OBJECTS) $(OBJMOC) $(LINK) $(LFLAGS) /OUT:$(TARGET) @<< $(OBJECTS) $(OBJMOC) $(LIBS) << moc: $(SRCMOC) tmake: Makefile Makefile: hello.pro tmake hello.pro -o Makefile clean: -del hello.obj -del main.obj -del moc_hello.cpp -del moc_hello.obj -del $(TARGET) ####### Compile hello.obj: hello.cpp \ hello.h main.obj: main.cpp \ hello.h moc_hello.obj: moc_hello.cpp \ hello.h moc_hello.cpp: hello.h $(MOC) hello.h -o moc_hello.cpptmake-1.8/doc/tmake.html 100444 773 773 51303 7175526477 13746 0 ustar aavit aavit
Our main motivation for developing tmake was that we spent far too much time maintaining makefiles for Qt, our cross-platform GUI toolkit. Qt supports around 15 flavors of Unix, Microsoft Windows, and around 15 different C++ compilers. We looked at GNU autoconf, but it was Unix-specific and not flexible enough in our opinion. Our makefile system also had to deal with Qt meta object compiler (moc) issues. The moc program extracts meta information from C++ files and generates a C++ file with data tables etc. It takes extra work to add makefile rules for the moc and wanted to automate this task.
tmake is written in Perl and requires that you have installed perl version 5 or newer. Basic use of tmake requires no perl knowledge, but if you know perl you can extend tmake and write your own makefile templates.
Windows users: The tmake distribution for Win32 includes tmake.exe (built by the perl2exe utility) and you do not need to download and install perl unless you want to modify the tmake source code or run other perl scripts. You can download perl for Win32 (Windows NT and 95) from www.activestate.com
tmake is free software and you may use, copy, modify and distribute tmake and its documentation for any purpose and without any fee. See the LICENSE file for details.
Feedback is highly appreciated. Contact the author, Haavard Nord (hanord@trolltech.com), if you have ideas, patches etc. for tmake.
Unix Bourne shell:
TMAKEPATH=/local/tmake/lib/linux-g++ PATH=$PATH:/local/tmake/bin export TMAKEPATH PATHUnix C shell:
setenv TMAKEPATH /local/tmake/lib/linux-g++ setenv PATH $PATH:/local/tmake/binMicrosoft Windows:
set TMAKEPATH=c:\tmake\lib\win32-msvc set PATH=%PATH%;c:\tmake\bin
The template directory name has the form platform-compiler and contains a platform configuration file (tmake.conf) and tmake template files.
Supported platforms: AIX, Data General, FreeBSD, HPUX, SGI Irix, Linux, NetBSD, OpenBSD, OSF1/DEC, SCO, Solaris, SunOS, Ultrix, Unixware and Win32.
You can find your platform-compiler combination in the tmake/lib.
Unix users: tmake requires that perl is in /usr/bin. If your version of perl is elsewehere, either change the first line of tmake or make a small shell script which invokes tmake with the correct perl.
HEADERS = hello.h SOURCES = hello.cpp main.cpp TARGET = helloThen run tmake to create a Makefile:
tmake hello.pro -o MakefileAnd finally:
makeThis builds the hello program. Remember to set the
TMAKEPATH
environment variable before you run tmake.
See Makefile for Linux/g++.
See Makefile for Win32/msvc
(Microsoft Visual C++).
TMAKEPATH
environment variable tells tmake where to find
these files:
app.t | Creates a makefile for building applications. | ||
lib.t | Creates a makefile for building libraries. | ||
subdirs.t | Creates a makefile for building targets in subdirectories. | ||
tmake.conf | This configuration file contains compiler options and lists tools and libraries. |
The hello.pro project file above does not have a TEMPLATE
or
a CONFIG
variable. The default template is app (the .t
extension is optional) and the default configuration is qt warn_on
release.
This project file produces exactly the same result as the hello.pro
above:
TEMPLATE = app CONFIG = qt warn_on release HEADERS = hello.h SOURCES = hello.cpp main.cpp TARGET = hello
The CONFIG
variable is recognized by both the app.t and lib.t
templates and specifies what compiler options to use and which extra
libraries to link in.
These options control the compilation flags:
release | Compile with optimization enabled, ignored if "debug" is specified. | ||
debug | Compile with debug options enabled. | ||
warn_on | The compiler should emit more warnings than normally, ignored if "warn_off" is specified. | ||
warn_off | The compiler should emit no warnings or as few as possible. |
These options defines the application/library type:
qt | The target is a Qt application/library and requires Qt header files/library. | ||
opengl | The target requires the OpenGL (or Mesa) headers/libraries. | ||
thread | The target is a multi-threaded application or library. | ||
x11 | The target is a X11 application or library. | ||
windows | The target is a Win32 window application (app.t only). | ||
console | The target is a Win32 console application (app.t only). | ||
dll | The target is a shared object/DLL. | ||
staticlib | The target is a static library (lib.t only). |
As an example, if the hello application uses both Qt and OpenGL and you
want to compile it for debugging, your CONFIG
line should
read:
CONFIG = qt opengl debug
The most common tmake options and project variables are described here. See the tmake reference manual for details.
HEADERS | Header files. | ||
SOURCES | Source files. | ||
TARGET | Name of executable (adds .exe if on Windows). | ||
DESTDIR | Where to put the target. | ||
DEFINES | Tell compiler to define C preprocessor macros (-D option). | ||
INCLUDEPATH | Sets the include file search path for the compiler (-I option). | ||
DEPENDPATH | Sets the dependency search path for tmake. | ||
DEF_FILE | Win32 only: Link with a .def file. | ||
RC_FILE | Win32 only: Use a .rc file (compile to temporary .res). | ||
RES_FILE | Win32 only: Link with a .res file. |
The lib.t template supports the same project variables as app.t, but also
VERSION
. VERSION
is the version number of the
target library, e.g. 1.40. The version is important for shared libraries.
The SUBDIRS
variable contains the name of all subdirectories to
be processed.
vcapp.t | Creates an application project file (Microsoft Visual C++ 5.0 only). | ||
vclib.t | Creates a library project file (Microsoft Visual C++ 5.0 only). |
Run tmake to create a hello.dsp file (use -t to override the default template):
tmake -t vcapp -o hello.dsp hello.pro
HEADERS = gui.h xml.h url.hIf you cannot fit everything on one line, use '\' to split it up:
HEADERS = gui.h \ xml.h \ url.h
Project variables contains lists of items (such as header files, compiler options etc.) and use whitespace to separate the items. This means that tmake cannot deal with items containing whitespace. The INCLUDEPATH variable is an exception. If INCLUDEPATH contains one or more semicolons (;), tmake uses the semicolon to separate the include directories, hence you can have include directories containing whitespace (this is quite common on Windows).
Here is an example:
INCLUDEPATH = C:\Program Files\DBLib\Include;C:\qt\include
tmake supports project variable expension. Use $$ to expand any project variable:
ALLFILES = $$HEADERS $$SOURCES
Most often you assign some value to a project variable, but you can also add to, remove from or replace parts of a project variable.
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 = xYzThe *= operation adds the value if the variable does not already contain it. The /= operation performs regular expression substitution.
You can also set variables from the command line when running the tmake program. For instance, if you want to generate a makefile with debug information:
tmake "CONFIG+=debug" hello.pro
Use the unix: or win32: (conditional) qualifier if you want a platform-specific variable:
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 libIf none of the platforms match, tmake looks for the variable in CONFIG variable:
debug:SOURCES += dbgstuff.cpp # additional source for debuggingFinally, you can set platform and compiler-dependent variables:
linux-g++:TMAKE_CFLAGS = -fno-rtti
You may define your own project variables to be used by custom templates. A
project variable is stored in %project
, which is an associative
Perl array. Access it like this: $project{"var"}
or via the
function Project("var")
. For example, after reading
"hello.pro", $project{"SOURCES"}
contains "hello.cpp
main.cpp".
tmake [options] project files or project settingsOptions:
-e expr Evaluate the Perl expression. Ignores the template file. -nodepend Don't generate dependency information. -o file Write output to file instead of stdout. -t file Specify a template file. -unix Force tmake into Unix mode. -v Verbose/debugging on. -win32 Force tmake into Win32 mode.The -t option overrides any
TEMPLATE
variable in the project file.
The default project file extension is ".pro". The default template file extension is ".t". If you do not specify these extension tmake will automatically add them for you.
Example of basic use:
tmake hello -o Makefile
Example of how to create a makefile with debugging information:
tmake hello "CONFIG+=debug" -o Makefile
Exmaple of how to specify a TMAKEPATH:
tmake "TMAKEPATH=/local/tmake/lib/hpux-g++" hello.pro -o MakefileExample of how to evaluate a perl expression (print names of headers and source files):
tmake hello -e 'Expand("HEADERS","SOURCES")'Note that project settings on the command line must come after the project file, otherwise they will be overridden by the settings in the project file.
progen -n hello -o hello.proIf no .cpp or .h files are specified on the command line, progen searches for .cpp and .h (except moc_*.cpp) in the current directory and below.
Usage:
progen [options] [C/C++ header files and source files]Options:
-lower Lower-case letters in filenames (useful on Windows).
-n name Specify a project name (TARGET
).
-o file Write output to file instead of stdout.
-t file Specify a template file.
solaris-cc:TMAKE_CC = /opt/bin/CC_5.0 solaris-cc:TMAKE_CFLAGS = -pts unix:TMAKE_LIBS = -lXext win32:INCLUDEPATH = c:\myinclude win32-borland:DEFINES = NO_BOOLYou can prefix a project variable with unix: or win32: to make it specific for either Unix or Windows. You can also prefix a variable with platform-compiler
HEADERS
, SOURCES
etc.
All variables and values are stored in a global associative Perl hash
array called project
. For example,
$project{"SOURCES"}
contains "hello.cpp main.cpp"
after processing hello.pro.
When both the tmake.conf and the project files have been
read, tmake starts reading the template file line by line and
executes any Perl code it finds in the template.
#$
until newline is
evaluated as perl code. The perl code is substituted
with the contents of the $text
variable.
#${
until
#$}
.
#!
until newline is stripped.
Example:
#! This is a comment which will be removed. This text will appear in the output. #$ $text = "The header file(s) are: " . $project{"HEADERS"}; # This text also appears in the output. #${ $a = 12; $b = 13; $text = $a * $b; #$} That's all.Output:
This text will appear in the output. The header file(s) are: hello.h # This text also appears in the output. 156 That's all.
Parser template:
#! #! parser.t: This is a custom template for building a parser #! #$ IncludeTemplate("app.t"); ####### Lex/yacc programs and options LEX = flex YACC = #$ $text = ($is_unix ? "yacc -d" : "byacc -d"); ####### Lex/yacc files LEXIN = #$ Expand("LEXINPUT"); LEXOUT = lex.yy.c YACCIN = #$ Expand("YACCINPUT"); YACCOUT = y.tab.c YACCHDR = y.tab.h PARSER = #$ Expand("PARSER"); ####### Process lex/yacc files $(LEXOUT): $(LEXIN) $(LEX) $(LEXIN) $(PARSER): $(YACCIN) $(LEXOUT) $(YACC) $(YACCIN) #$ $text = ($is_unix ? "-rm -f " : "-del ") . '$(PARSER)'; #$ $text = ($is_unix ? "-mv " : "-ren ") . '$(YACCOUT) $(PARSER)';The parser template adds some extra rules to the application template in order to build the lex and yacc portions of the project. This template is portable across Unix and Windows since it generates different commands depending on the
$is_unix
variable.
To learn more about the Expand() function and other Perl functions which tmake provides, consult the reference manual.
Example project file:
TEMPLATE = parser.t CONFIG = console release LEXINPUT = lexer.l YACCINPUT = grammar.y PARSER = parser.cpp SOURCES = $$PARSER \ node.cpp \ asmgen.cpp TARGET = parserHere we use macro expansion
$$PARSER
to avoid writing parser.cpp
two places.
Template wc.t:
#! Template that count number of C++ lines. The number of C++ code lines for #$ $text=$project_name; #${ $files = $project{"HEADERS"} . " " . $project{"SOURCES"}; $text = `wc -l $files`; #$}Run it:
tmake -t wc helloOutput:
The number of C++ code lines for hello.pro 25 hello.h 98 hello.cpp 38 main.cpp 161 totalThis will only work if the wc program is installed on your system. tmake-1.8/doc/tmake_ref.html 100444 773 773 32037 7175526477 14605 0 ustar aavit aavit
Example:
CLEAN_FILES = core *~
These options control the compilation flags:
release | Compile with optimization enabled, ignored if "debug" is specified. | ||
debug | Compile with debug options enabled. | ||
warn_on | The compiler should emit more warnings than normally, ignored if "warn_off" is specified. | ||
warn_off | The compiler should emit no warnings or as few as possible. |
These options defines the application/library type:
qt | The target is a Qt application/library and requires Qt header files/library. | ||
opengl | The target requires the OpenGL (or Mesa) headers/libraries. | ||
x11 | The target is a X11 application (app.t only). | ||
windows | The target is a Win32 window application (app.t only). | ||
console | The target is a Win32 console application (app.t only). | ||
dll | The target is a shared object/DLL (app.t only). | ||
staticlib | The target is a static library (lib.t only). | ||
thread | The target is a multi-threaded application/library. |
DESTDIR = ../../libYou must create this directory before running make.
DISTFILES = CHANGES README
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 ';' or space 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
variable 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{$var}
.
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($var,""," \\\n\t\t","")
.Example:
OBJECTS = #$ ExpandList("OBJECTS");Output:
OBJECTS = hello.o \ main.o
Example:
#$ IncludeTemplate("mytemplate");
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 variables:
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 $vars it finds.
Example:
Substitute('Project name: $$PROJECT, uses template $$TEMPLATE');tmake-1.8/example/ 40775 773 773 0 7365566423 12526 5 ustar aavit aavit tmake-1.8/example/hello.cpp 100444 773 773 4614 7175526477 14437 0 ustar aavit aavit /**************************************************************************** ** $Id: hello.cpp,v 1.6 1999/08/24 13:08:11 hanord Exp $ ** ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. ** ** This file is part of an example program for Qt. This example ** program may be used, distributed and modified without limitation. ** *****************************************************************************/ #include "hello.h" #include