Copyright © 2010-2011 Oliver Hamann. Homepage: http://eaglemode.sourceforge.net/
The make system consists of three layers:
The following chapters are describing the maker scripts and unicc in detail.
package example; use strict; use warnings; sub GetDependencies { return ('emCore'); } sub IsEssential { return 0; } sub GetFileHandlingRules { return (); } sub GetExtraBuildOptions { return (); } sub Build { shift; my %options=@_; system( @{$options{'unicc_call'}}, "--math", "--rtti", "--exceptions", "--bin-dir" , "bin", "--lib-dir" , "lib", "--obj-dir" , "obj", "--inc-search-dir", "include", "--link" , "emCore", "--type" , "dynlib", "--name" , "example", "src/example/example.cpp" )==0 or return 0; return 1; }
In addition to the dependencies defined by this function, every project implicitly depends on a special project which is named "defaults".
0 means that the project is not so essential and that the user may want to ignore a failure with building the project.
1 means that the project is so essential, that the overall building shall always be stopped on a failure with building the project.
For most files, the rules from the defaults project are already correct. But other projects can give some additional rules for their individual files.
Each rule is a string of the form:
<op><flag>[<op><flag>[<op><flag>...]]:<pattern>With:
<op> is either a + for setting the flag, or a - for removing the flag.The flag operations of a rule are applied to all files whose file paths match the pattern. Hereby the path is relative to the current directory (the top-level directory), and the path elements are separated by slashes, even on Windows.<flag> is the name of the flag. Possible names are:
clean - The file has to be deleted by the clean command. install - The file has to be installed by the install command. exec - The file is an executable. private - The file must not be released in addition to files which have the clean flag set (developer's private stuff). nobackup - The file must not be backed up in addition to files which have the clean flag set (developer's private stuff). <pattern> is a pattern for matching the file path. It's a Perl regular expression.
If there are contrary rules, the later one counts. The project dependencies are respected.
Be careful when writing the regular expressions. One error could mean that the clean command deletes some or all of the source files. Please study all existing rules before making new ones. Make backups before testing.
shift;Thereby the hashes variable %options contains all the options. Hash index is the option name, hash value is the option value. Following options are defined by default:
my %options=@_;
In addition, there are all the extra options defined through GetExtraBuildOptions from all the projects.
- compiler
- Name of compiler and linker to be used.
- cpus
- Number of CPUs to be used.
- debug
- Whether to produce debug information. Must be "yes" or "no".
- unicc
- Relative path to the unicc directory.
- unicc_call
- Reference to an array which contains the first arguments for calling unicc.pl. It's like:
[ 'perl', catfile($options{'unicc'},'unicc.pl'), '--compiler', $options{'compiler'}, '--cpus', $options{'cpus'}, $options{'debug'} eq 'yes' ? ('--debug') : () ]
- utils
- Relative path to the utils directory.
- projects
- This should not be used by the maker scripts.
- continue
- This should not be used by the maker scripts.
The Build function has to return 1 on success. On failure, it may either return 0 or call the die function.
unicc is written in Perl, and it can be found in: $EM_DIR/makers/unicc
$EM_DIR/makers/unicc/unicc.pl --compiler gnu hello.c --name helloAnd here comes a more complex example:
$EM_DIR/makers/unicc/unicc.pl --compiler wat src/hello.c src/world.c \
--obj-dir obj --lib-search-dir lib --inc-search-dir include \
--bin-dir bin --debug --type wexe --name helloworld
- src-file
- Path name of a source file including the file name ending which must be ".c", ".cpp", ".cc" or ".cxx". On Windows, ".rc" files are also supported. This argument can be given multiple times.
- --compiler name
- Name of the compiler. See the Compilers chapter more below for all possible names. The default is gnu.
- --cpus count
- Number of CPUs to be used. More precisely, it is the maximum number of source files to be compiled in parallel. The default is 1.
- --type type
- Set the type of the output file. Possible types are:
cexe - console executable (this is the default) wexe - windowed executable (different against cexe on Windows only) lib - static library dynlib - dynamic library
- --name name
- Set the name of the output file without ending, and, if it's a library, without the UNIX "lib" in front (Default: "unnamed").
- --obj-dir dir
- Target directory for object files and other temporary files (default: ".").
- --bin-dir dir
- Target directory for the executable (default: "."). Ignored if type is not cexe or wexe.
- --lib-dir dir
- Target directory for the library, if type is lib or dynlib (default: "."). In addition, this option acts like --lib-search-dir.
- --lib-search-dir dir
- A directory where to search for libraries to be linked. This option can be given multiple times.
- --inc-search-dir dir
- A directory where to search for include files. This option can be given multiple times.
- --link name
- Name of a library to be linked. The name must be without file name ending and without the UNIX "lib" in front (e.g. say "X11" instead of "libX11.a"). This argument can be given multiple times. The order may be important (high-level first).
- --math
- Link with the standard math library.
- --rtti
- Enable Run Time Type Information.
- --exceptions
- Enable C++ exceptions.
- --debug
- Create debug information in the output.
- --def name[=value]
- Define a preprocessor variable. This option can be given multiple times.
- bor
- Use the Borland C/C++ compiler on Windows. Please do not use this for compiling Eagle Mode! It has been tested with Borland C++ 5.6.4 (C++BuilderX) and CodeGear C++ 5.9 (C++Builder 2007), but Eagle Mode always crashes right away or it even fails to compile (seems difficult to solve).
- gnu
- Use the GNU C/C++ compiler (gcc). This has been successfully tested with many gcc versions. Minimum should be something like version 3.3. Cygwin and MinGW are also supported.
- int
- Use the Intel C/C++ compiler (icc) on Linux.
Successfully tested with:
* icc 9.1 on Linux, 64-bit
- mic
- Use the Microsoft C/C++ compiler on Windows.
Successfully tested with:
* cl 13.10 (Visual Studio .NET 2003)
* cl 14.00 AMD64 (Platform SDK for Server 2003 R2)
- sun
- Use the Sun C/C++ compiler on Linux.
Successfully tested with:
* Sun Studio 12 RC 1 on Linux, 64-bit
- wat
- Use the Watcom or Open Watcom C/C++ compiler on Windows.
Successfully tested with:
* Watcom 11.0b
* Open Watcom 1.7a