Guide

Usage

Tecmake usage is quite simple. Just call "tecmake" in the folder that contains the "config.mak" file. If your configuration file has a different name, then you should call:

tecmake MF=myconf

In Windows, to add any parameter you must first add the platform, i.e. "tecmake rebuild" must be "tecmake vc7 rebuild" even if vc7 is the default platform. Also in Windows to add a definition you must enclose it with quotes, for ex:

tecmake vc7 "MF=myconf"

Parameters

MF=<file>
Name of the user's configuration file. Default name is "config". The extension ".mak" will be added. Must be present in the folder "src". A distribution file name will also be used, "config.dist" as default.
build (default target)
Compiles to the current platform. It is the target executed when no target is passed in the command line. In this order: it creates the required folders, compiles, generates links to exported files, and generates scripts/batches for applications in order to run them without the need to change the current folder.
In UNIX it also generates a script to call the depurator with the application executable as parameter. One can edit the scripts or create "app.env" or "debug.env" files to be loaded by the respective scripts.
<platform>
Compiles to the specified platform. In UNIX it is the system's TEC_UNAME. In Windows it is the compiler's TEC_UNAME - in this case, the use of this parameter is required for other parameters to work.
In UNIX each compilation starts in a different xterm - therefore, to use this option, one needs to be at a X11 client. The windows are viewed with black background and LightBlue letters, with the name of the respective library displayed in the title. In Windows the platforms will be executed one at a time and it does not include the generation of DLLs (for such, use "all-dll").
depend
Builds the list of dependencies among source files (.c and .cpp) and inclusion files (.h). If the gcc compiler is not installed, tecmake will not be able to execute this option, informing this to the user. The list is stored in a file with the name specified in APPNAME or LIBNAME with extension ".dep". It is dependent on the file config.mak - therefore, every time the latter is changed, the former will be updated.
clean-dir
Deletes all generated folders and their contents.
clean-lohs
Deletes all generated Lua object files.
clean-obj
Deletes all object files generated in the given platform.
clean-all-obj
Deletes all object files generated in all platforms.
clean-target
Deletes the library or executable generated in the given platform.
clean-all-target
Deletes the library or executable generated (in all platforms).
clean
Deletes the object files, library or executable generated in the given platform.
clean-all
Deletes everything the makefile generates: the contents of folders obj, lib, inc and lua, temporary files, and files that are not locked by RCS (ir RCS is activated).
rebuild
Deletes all generated files and recompiles only for the given platform.
relink
Deletes generated files except object files and recompiles only for the given platform.

version
Informs the current version of tecmake.

Folder Organization

Concerning the folder structure, all tecmake needs to run is a folder where the source files will be placed. The diagram below illustrates the folder structure used:

Folders include, obj and lib are created automatically, as well as the subfolders related to the platforms. The folder src is the one from which tecmake must be executed (note: this folder does not need to have this name). Folder include will contain the exported inclusion files associated to the variable EXPINC. This folder will contain only links to the files in folder src. Similarly, the folder lua will exist only when the variable EXPLUA is defined and will also only contain links to files in the src folder.

tecmake was designed to have folder src as reference in the hierarchy presented above, that is, the user will have to work with the current file being src, from where s/he can easily access the product's source files.

Compilers Settings

These are the compiler parameters used internally by Tecmake.

GCC

-Wall (always)
-g (DBG)
-O2 (OPT)
-m64 -fPIC (BUILD_64)
-bundle -undefined dynamic_lookup   (for shared code libraries in MacOS X)
-dynamiclib -install_name lib$(TARGETNAME).dylib    (for dynamic libraries in MacOS X when BUILD_DYLIB=Yes)

Open Watcom

-od -w4 -5r -bt=nt -mf -e25 -zq (always)
-d2 (DBG)
-ot (OPT)
-b -c -n -q -p=512 (libraries)
-bm -br (USE_DLL)

Borland

-v -N -x -xp (DBG)
-O2 (OPT)
-tWDMR (USE_DLL) 

Visual C++

-W3 -GX (always)
-O2 -GL -LTCG (OPT)
-Z7 -Od -GZ (DBG)
-ML 
-MLd (DBG)
-MD (USE_DLL)
-MDd (USE_DLL+DBG)
-MT (USE_MT)
-MTd (USE_MT+DBG)

O2 = Maximize Speed
Z7 = C7 Compatible
Gd (default) = cdecl calling convention 
GZ = Run-Time Error Checks
LTCG, GL = Whole Program Optimization
M* = Run-Time Library (options are mutually exclusive)
     (There is no single thread in VC8 or VC9, USE_MT=Yes is always set)
_CRT_SECURE_NO_DEPRECATE is defined for VC8 and VC9.
To enable automatic manifest file generation and embedding in VC8 or VC9 use GEN_MANIFEST=Yes.
To enable C++ additional definitions for RTL functions in VC8 or VC9 use CPP_NARROW_INLINES=Yes.

As a Makefile in POSIX systems

In UNIX/Posix, Tecmake can be distributed together with the source code with no need for an additional installation. Simply copy the file "tecmake.mak" to your source code and rename it to "Makefile".

To build the target simply do "make" on the command line. The Tecmake parameters can be used simply as doing "make clean". But notice that not all parameters are available (see note bellow).

To build several targets, keep the original name and create a new file called "Makefile" with contents similar to the following:

all: target1 target2 target3

target1:
	@$(MAKE) --no-print-directory -f tecmake.mak                       #(to let Tecmake use "config.mak")

target2:
	@$(MAKE) --no-print-directory -f tecmake.mak MF=target2            #(to make Tecmake use "target2.mak")

target3:
	@$(MAKE) --no-print-directory -f tecmake.mak MF=target3            #(to make Tecmake use "target3.mak")

Then you can use your own parameters to build different targets.

As a general rule the following are not supported without instalation: the "*-all" parameters and remote build.

If you are building a library or application that depends on a Tecgraf library like IUP, CD or IM, then define the TECTOOLS_HOME variable inside your "config.mak". It points to the base path where those libraries are installed. It can be a relative path like "../..".

IMPORTANT: This form of Makefile is know NOT to work on the systems: FreeBSD54, AIX43, IRIX6465 and IRIX65. There are unsolved syntax problems on those systems when using the "($shell uname)" command.

Visual C++ Minimum Installation

Here is a small tutorial on how to setup a minimum Windows build system to use Tecmake and Microsoft Visual C++ 2008.

shortpath "C:\Program Files\Microsoft SDKs\Windows\v6.1"
    C:\PROGRA~1\MICROS~2\Windows\v6.1
shortpath "C:\Program Files\Microsoft Visual Studio 9.0\VC"
    C:\PROGRA~1\MICROS~1.0\VC
set TECMAKE_PATH=c:\tecgraf\tecmake
set TECMAKE_HOME=/cygdrive/c/tecgraf/tecmake
set VC9=C:/PROGRA~1/MICROS~1.0/VC
set VC9SDK=C:/PROGRA~1/MICROS~2/Windows/v6.1

The simplest way to use it is to run the "CMD Shell" item in the "Microsoft Windows SDK v6.1" start menu folder. Then at the folder of your project with the "config.mak" file type in the command line:

tecmake vc9

Notice that Visual C++ Express 2008 is not installed, the Windows SDK already includes the necessary command line compilers. But if it is installed will be placed in the same folders of the Windows SDK compilers. On the other hand the Windows SDK does not includes the Visual Studio.

This minimum installation considers that no dependencies are necessary and USE_NODEPEND is set at "config.mak". If you need dependencies then run the Cygwin setup again and mark the "gcc/g++", "sed" and "which" items.

MingW Minimum Installation

Here is a small tutorial on how to setup a minimum Windows build system to use Tecmake and MingW.

set TECMAKE_PATH=c:\tecgraf\tecmake
set TECMAKE_HOME=/cygdrive/c/tecgraf/tecmake
set MINGW3=c:/mingw

Start a command line with "cmd", then at the folder of your project with the "config.mak" file type in the command line:

tecmake mingw3

A very minimum MingW installation can be done without installing Cygwin. Only install MingW and set PATH to its bin folder.