Copyright © 2001-2005
2005
OpenSBE is a software building framework based on Autoconf, GNU Make, Perl, and sh. OpenSBE provides a build environment that is platform, language, and compiler independent. The driving idea behind OpenSBE development initiative is to provide a higher level of abstraction for Autoconf and Make and relieve the burden of manual maintenance for complex projects.
Table of Contents
List of Tables
List of Examples
OpenSBE is a universal software building framework based on Autoconf, GNU Make, Perl, and sh. The framework provides a build environment that is platform, language, and compiler independent. OpenSBE simplifies creation of makefiles without sacrificing flexibility, yet introduces a minimum of new concepts into the existing build process.
OpenSBE integrates seamlessly into various stages of the standard Autoconf/Make build process. The basic idea of OpenSBE is to provide a higher level of abstraction for Autoconf and Make by defining appropriate macros, variables, and targets.
At the heart of OpenSBE is the use of recursion instead of manual maintenance. Traditional use of Autoconf requires the project directory structure to be traced in file configure.ac. The responsibility to keep the trace current is developer's.
OpenSBE uses recursion instead. In every directory (subdirectory) of the project, starting from the root project directory, the developer creates a dir.ac file that lists the subdirectories and files that must be included in the build. OpenSBE recursively processes the dir.ac hierarchy and builds the directory trace automatically.
The same method is used to distribute Autoconf macros throughout the project directory structure: every project module (subdirectory on any level) contains an autoconf included file with macros specific to that module. (Macros specific to a module still affect the whole project.)
The net effect of the definitions hierarchy is simplification of project build system maintenance.
OpenSBE is not a black box; rather, it is a framework that specifies interfaces for plugging in arbitrary subsystems such as programming language compilers, documentation publishing tools, middleware, and so on. Currently, OpenSBE includes out-of-box support for C/C++ and CORBA builds.
OpenSBE uses Autoconf as the foundation. The important components of OpenSBE are:
Note that while OpenSBE creates an additional layer of abstraction over Autoconf and Make, it still requires good command of both Autoconf and Make.
Table of Contents
OpenSBE is currently hosted at SourceForge, and is available as both Tarball package and CVS source.
Website. http://sourceforge.net/projects/osbe/
CVS Repository. cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/osbe co OpenSBE
OpenSBE is intended as a platform-independent build system that requires no platform changes in Autoconf and Make files. For example, the CXX subsystem equally well supports GCC and Microsoft Visual C++ compilers, so the Autoconf/Make process will run smoothly on both Unix and Windows™ operating systems.
OpenSBE requires the following software to run:
The following matrix identifies operating environments that OpenSBE has been tested with.
Table 2.1. Test Suits Legend
Test name | Description |
Sample 01 | Example of a multitarget C++ project. |
Sample 02 | Example of a C++ CORBA-aware client/server project. |
Test 01 | Test of a multitarget C++ project. |
Test 02 | Test of a very deeply nested multitarget C++ project using an external library. |
Test 03 | Test 02 converted to use def files approach. |
Table 2.2. OpenSBE OS/Compiler Support
Sample 01 | Sample 02 | Test 01 | Test 02 | |
Linux SuSE 8.2 | g++ 3.3 | g++ 3.3, ORBacus, TAO | g++ 3.3 | g++ 3.3 |
Linux RedHat 3 ES | g++ 3.2.3 | g++ 3.2.3, ORBacus | g++ 3.2.3 | g++ 3.2.3 |
Fedora Core 2 | g++ 3.3.3 | NOT TESTED | g++ 3.3.3 | g++ 3.3.3 |
Debian 2.2 | g++ 2.95.3 | NOT TESTED | g++ 2.95.3 | g++ 2.95.3 |
Mandrake Linux 10.0 ProSuite | g++ 3.4.1 | NOT TESTED | g++ 3.4.1 | g++ 3.4.1 |
Linux SuSE 8 ES AMD 64 bit Opteron | g++ 3.2.2 | NOT TESTED | g++ 3.2.2 | g++ 3.2.2 |
Linux Debian 3.0 Alpha ev67 | g++ 2.95.5 | NOT TESTED | g++ 2.95.5 | g++ 2.95.5 |
HP True64 UNIX 5.1B Alpha ev67 | cxx 6.5-040 | NOT TESTED | cxx 6.5-040 | cxx 6.5-040 |
FreeBSD 4.8 | g++ 2.95.5 | NOT TESTED | g++ 2.95.5 | g++ 2.95.5 |
FreeBSD 3.4 | g++ 2.95.4 | NOT TESTED | g++ 2.95.4 | g++ 2.95.4 |
NetBSD 1.6.1 | g++ 2.95.4 | NOT TESTED | g++ 2.95.4 | g++ 2.95.4 |
Sun Solaris 9 x86 | g++ 3.3.2, Sun Forte 5.5 | NOT TESTED | g++ 3.3.2, Sun Forte 5.5 | g++ 3.3.2, Sun Forte 5.5 |
Sun Solaris 9 UltraSPARC II | g++ 3.3.2, Sun Forte 5.5 | NOT TESTED | g++ 3.3.2, Sun Forte 5.5 | g++ 3.3.2, Sun Forte 5.5 |
MacOS X 10.2 Server | g++ 3.3 | NOT TESTED | g++ 3.3 | g++ 3.3 |
HP-UX 11.11 PA RISC 8700 | aCC B3910B A.03.57 | NOT TESTED | aCC B3910B A.03.57 | aCC B3910B A.03.57 |
Cygwin 2.340.2.5 | MSVC 6.0, g++ 3.2 | MSVC 6.0, ORBacus, TAO | MSVC 6.0, g++ 3.2 | MSVC 6.0, g++ 3.2 |
Once you obtain the OpenSBE source from CVS, you can create a tarball package similar to that available from the project's official website.
Here is the complete procedure to package OpenSBE.
Issue cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/osbe co OpenSBE
Change to the root directory of OpenSBE source (cd OpenSBE.)
Issue autoconf to create the configure script.
Issue ./configure to obtain the make files.
Issue make dist to create a tar/gz package. Make creates the package in the current directory, with filename following the format OpenSBE-<version number>.tar.gz.
Issue cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/osbe co OpenSBE
Change to the root directory of OpenSBE source (cd OpenSBE.)
Issue autoconf to create the configure script.
Issue ./configure to obtain the make files.
Issue make dist-install to install OpenSBE. This command creates an installation script containing the distribution tarball and runs the script. Note that you must also add the OpenSBE/bin directory (usually, as /usr/local/share/OpenSBE/bin) directory to environment variable PATH.
Gunzip/untar the tarball (e.g. tar -xzf OpenSBE-1.0.2.tar.gz.)
Change to the root directory of OpenSBE source (e.g. cd OpenSBE-1.0.2.)
Issue ./configure to obtain the make files. By default, configure uses /usr/local/share as the default installation prefix. You can change the prefix either by passing a '--prefix' option to configure (as in ./configure --prefix=/tmp) or by passing a 'prefix' option to make install on the next stage (as in make install prefix=/tmp).
Issue make install to install OpenSBE. Note that you must also add the OpenSBE/bin (usually, under /usr/local/share/) directory to environment variable PATH.
This manual uses a number of simple terms.
The deepest directory containing all project files. Otherwise referred to as <PROJECT>.
A set of M4 macros and make rules defined in AC-files and rule templates. The developer must enable features to access the macros and rules. There are two feature categories, user-level (intended for use by developers) and internal (enabled by other features, required mainly for OpenSBE code reuse).
A set of features intended for a specific development tool, such as CORBA, Java or C++.
A compiler compatibility layer (CCL) is a file containing definitions of certain variables and functions. The naming conventions for variables and functions create an interface which makes CCL files pluggable into OpenSBE for the purpose of extending the set of supported C++ compilers. In order to add support for a compiler, you must design a CCL file and place it at a specific point of the OpenSBE files hierarchy. If you do, please send the CCL to the OpenSBE development team, so we could include it in the future OpenSBE releases.
An ORB compatibility layer (OCL) is a file containing definitions of certain variables and functions. The naming conventions for variables and functions create and interface which makes OCL files pluggable into OpenSBE for the purpose of extending the set of supported Corba ORBs. In order to add support for an ORB, you must design an OCL file and place it at a specific point of the OpenSBE files hierarchy. If you do, please send the OCL file to the OpenSBE development team, so we could include it in the future OpenSBE releases.
Table of Contents
This chapter describes how to manage a projects using OpenSBE. We define a simple project to illustrate the basic principles of working with OpenSBE, and then increase complexity step-by-step to introduce the remaining capabilities of the framework.
![]() | Tip |
---|---|
When you encounter a link to an OpenSBE project tree, click it to open the tree in a new window. The trees are expandable and expose sample source code along with the descriptions of the files. |
We view a project managed with OpenSBE as a tree of directories and files that need to be configured plus some common definitions that regulate the build process in general. The common definitions go into the configure.ac file at the top level (under the topmost project directory <PROJECT>), while configuration instructions related to concrete directories go into dir.ac files under the directories that need to be configured. Although dir.ac files are intended for instructions specific to concreted project modules, remember that all instructions in these files are interpreted as project-wise because they get included into the top-level configure.ac. In practice, you may choose to use configure.ac for important instructions that only affect specific subdirectories.
Distributed maintenance of definitions and instructions keeps configure.ac and dir.ac concise and clear, and we manage to keep configuration code near the files that it configures.
Since OpenSBE is a wrapper around Autoconf, you must introduce slight changes into the Autoconf patterns, as follows:
dir.ac is used to configure files and subdirectories. On each level of the project directories, starting from the topmost project directory, a dir.ac file specifies files and subdirectories that need to be configured. Additionally, dir.ac may contain commands to execute shell statements and set variables.
dir.ac contained directly under the <PROJECT> directory is linked up with configure.ac through an m4_include([dir.ac]) macro invocation. In turn, dir.ac includes all the required files and subdirectories.
The macros used in dir.ac are OSBE_CONFIG_FILE, OSBE_CONFIG_SUBDIR, and OSBE_CONFIG_COMMANDS.
OSBE_CONFIG_FILE. OSBE_CONFIG_FILE([file_name]) is similar (but not equivalent) to Autoconf macro AC_CONFIG_FILES. Here are the differences:
OSBE_CONFIG_SUBDIR. OSBE_CONFIG_SUBDIR([subdir_name]) includes, through an m4_include statement, the dir.ac file located under the specified subdirectory and modifies the macro OSBE_CURRENT_DIR, so it becomes possible for OSBE_CONFIG_FILE to determine the full pathname of a file being configured.
OSBE_CONFIG_COMMANDS. OSBE_CONFIG_COMMANDS([commands], [init-commands]) accepts shell commands to execute at the end of config.status as the first parameter and shell commands to initialize config.status variables from configure variables as the second parameter. The difference from Autoconf's AC_CONFIG_COMMANDS is that the commands are executed in the build directory corresponding to the source directory containing the AC-file that invokes OSBE_CONFIG_COMMANDS. Here is a (not too realistic) example of a dir.ac file:
OSBE_CONFIG_FILE([SimpleServerTest.sh]) chmod_options=777 OSBE_CONFIG_COMMANDS([chmod $chmod_options SimpleServerTest.sh], [chmod_options=$chmod_options])
File configure.ac, traditionally placed directly under the topmost project directory, is the Autoconf's configure.ac. In OpenSBE, configure.ac contains housekeeping code, directives that enable OpenSBE's features and include libraries required for building your project, and may also contain the usual Autoconf directives. However, with OpenSBE, configure.ac does not specify the directories and files to include in the build; this one is the function of dir.ac.
In general, configure.ac will consist of the following items:
macro AC_INIT([configure.ac]) starts configure.ac;
macro OSBE_OUTPUT ends configure.ac;
macro m4_include([OpenSBE.ac]) includes OpenSBE-specific macros and must appear before any OSBE_ macros;
macro OSBE_ENABLE_FEATURE enables an OpenSBE feature and brings in macros, make rules, and variables associated with the feature. There are currently eight features available:
CXX/CXX. Defines a set of Make variables common to all C++ features, as well as M4 macros for plugging external C++ libraries into a project. See Section 5.3.1, “CXX/CXX Feature” for details.
CXX/Ex. Defines entities required to build C++ executables.
CXX/So. Defines entities required to build a C++ shared library.
CXX/Ar. Defines entities required to build a C++ static library.
CXX/Inl. Defines entities required to build a C++ inline library.
CXX/Def. Defines entities required to use libraries dependencies approach based on def files. See Section 4.8, “Easier way to use dependencies” for details.
CXX/Corba. Provide s CORBA mapping support for a C++ project. See Section 5.3.7, “CXX/Corba Feature” for details.
CXX/XML/XSD. Provides XSD mapping support for a C++ project. See Section 5.3.8, “CXX/XML/XSD Feature” for details.
Documentation/Doxygen. Extends the project with Make targets for building Doxygen documentation from the source code.
macro m4_include([dir.ac]) links in the dir.ac file.
An example of a subsystem-specific macro is OSBE_CXX_USE_LIB that makes C and C++ libraries available for use in your project. See Section 5.3.1.1, “OSBE_CXX_USE_LIB Macro” for details.
An OpenSBE Makefile.in includes rulesets specific to a project and defines build dependencies like the traditional Makefiles do. Every OpenSBE subsystem predefines a number of variables that support building relevant code.
In general, there is a Makefile.in in every project directory with source code; it contains build rules specific to that directory's files and subdirectories. Makefile.in is a template; after being processed by OpenSBE and Automake, it translates into a specific Makefile in the build directory.
To use OpenSBE functionality, every Makefile.in must include ruleset Common.pre.rules at the beginning as follows:
include Common.pre.rules
See Chapter 5, OpenSBE Reference for specific Makefile.in structures. Read on through the next chapter for examples.
Consider a simple C++ project that has two parts: a shared library (HelloLib) and the application using the library (HelloApp.)
By OpenSBE conventions, the topmost project directory (<PROJECT>) will initially contain top-level files controlling the build procedures (configure.ac, dir.ac, Makefile.in) plus the src subdirectory containing all source code files along with lower-level files dir.ac and Makefile.in.
This project tree reflects the structure and content of our simple project as it may exist in a revision control repository.
Start with analyzing the contents of configure.ac. As you see, besides the standard m4_include and AC_INIT/OSBE_OUTPUT macros, configure.ac contains two instances of OSBE_ENABLE_FEATURE. These are required to include two features of the CXX subsystem, namely CXX/Ex and CXX/So. CXX/Ex is required for building C++ executables, in this case the HelloApp executable; CXX/So is required for building shared libraries, in this case the HelloLib library. Enabling these features makes available the variables and rules that OpenSBE needs to correctly generate Makefiles and a suitable configure script.
Top-level dir.ac, through the use of macros OSBE_CONFIG_FILE and OSBE_CONFIG_SUBDIR, instructs OpenSBE to configure a Makefile and also include dir.ac from the directory src.
Top-level Makefile template, Makefile.in, is minimal: it includes two required rule files (see Section 5.1.1.1, “Direntry.post.rules” and Section 5.1.2, “Common.pre.rules”) and indicates that Make must change to directory src/ and run through the standard routine. Makefile.in uses OpenSBE variable target_directory_list to list project directories which Make must scan.
On to directory src/. src/ contains two subdirectories with actual source code, HelloLib/ and HelloApp/. We need, again, to configure these two directories as we did for src/.
Refer to files src/dir.ac and src/Makefile.in. src/dir.ac is very similar to the top-level dir.ac: it configures a Makefile and also includes respective dir.ac from HelloLib and HelloApp. src/Makefile.in, aside from listing both subdirectories in the value of target_directory_list, also indicates the dependency between the two in the standard Make fashion. According to this declaration, HelloApp depends on HelloLib. This dependency will be reflected in the instantiated Makefiles.
Next in the line, is the directory HelloLib. Pretty straightforward, two C++ modules and a primitive dir.ac that only configures a Makefile. The different part is in src/HelloLib/Makefile.in; it contains inclusion directives for various rule files. First comes the already familiar Common.pre.rules. Since we are building C++ code, we need to include CXX.pre.rules. CXX.pre.rules does not exist during the development stage, so you cannot reference it by a simple name, as in case of Common.pre.rules. Instead, CXX.pre.rules is instantiated by configure; because of this, Makefile.in uses a generalized pathname (a pathname containing variable part) to include this rule file.
Variables sources define, respectively, names of the source C++ modules and the base name of the compiled shared object. We are instructing the system to compile source files Hello1.cpp and Hello2.cpp into a shared library with base name HelloLib. Variable includes lists include directories, relative to <PROJECT>.
Finally, src/HelloLib/Makefile.in includes another generated rule file by its generalized name, So.post.rules. To build a static library, include Ar.post.rules instead.
Now look into src/HelloApp/. Again, source code files, dir.ac and Makefile.in. Using this approach, you can build project hierarchies of any complexity, and you will always have minimal maintenance hassle under every given subdirectory. src/HelloApp/Makefile.in is a good example of a Makefile template intended for building C++ executables. In structure, the file is similar to src/HelloLib/Makefile.in. It includes rule files Common.pre.rules and CXX.pre.rules, and also rule file Ex.post.rules, which instructs the system to build an executable. Ex.post.rules relies on the values of variables sources and target that identify the source code files and the base name of the executable to build.
What about the HelloLib.so.pre.rules business? This one is a rule file generated specifically for HelloLib when HelloLib gets built. You must include HelloLib's pre-rules in order to build HelloApp; in particular, it enables you to include HelloLib's headers as if they were on the search path (see, for example, the source for src/HelloApp/HelloWorld.cpp.) Since pre-rules file is generated automatically, your only worry is to include the file by its generalized name derived from OpenSBE's project tree conventions (more on this later.)
Read through the next section to learn about basic build steps and OpenSBE's policy on project deliverables.
Assuming we have a sample project tree from the previous section, how do we proceed with preparing the project for distribution and building it on a target system? Instructions below refer to our simple C++ project, but you are free to try them on the C++ sample project included in the OpenSBE distribution.
For OpenSBE, preparing a project tree for building is known as bootstrapping. When you bootstrap a project, OpenSBE generates all the files required to build the project and also creates the configure script under the <PROJECT> directory. This process eliminates all dependencies on Autoconf and OpenSBE and, therefore, prepares the project for redistribution. You can package <PROJECT> for redistribution immediately after bootstrapping.
To bootstrap a project:
Change to directory <PROJECT>.
Issue osbe; this creates the supporting hierarchy under <PROJECT>/OpenSBE/ and <PROJECT>/configure.
In this state, the project is ready for building on any system that Autotools support.
To build a bootstrapped project:
Change to directory <PROJECT>.
Create a build directory: issue mkdir build or the equivalent for your operating system.
Change to build directory and issue ../configure. This prepares the project for building on the current system. Aside from the standard Autoconf diagnostics, configure will generate rule files under <PROJECT>/build/OpenSBE/ and Makefiles and rule files under <PROJECT>/build/src/.
![]() | Note |
---|---|
When you run configure without options for the first time, you may be prompted for various paths and settings. For more information on this behaviour, refer to Section 4.6, “OpenSBE-Generated configure Scripts”. |
Still in <PROJECT>/build/, issue make all to build the project. This command will make Make traverse subdirectories of <PROJECT>/build/ according to containment and dependencies order. Assuming that HelloApp from our simple project depends on HelloLib, Make will interpret <PROJECT>/build/src/HelloLib/Makefile first, producing intermediated object files (<PROJECT>/build/src/HelloLib/Hello1.o, <PROJECT>/build/src/HelloLib/Hello2.o), target files (<PROJECT>/build/src/HelloLib/libHelloLib.so, <PROJECT>/build/lib/libHelloLib.so) and the rule file <PROJECT>/build/config/src/HelloLib/HelloLib.so.pre.rules. (It is important that the pre-rules file generated for the library contitutes the single linking channel: when included into a Makefile for an executable or another library, it provides all Make rules required for compiler to find library headers and for linker to find library binary or binaries.) After this, Make will run for HelloApp, producing intermediate object files (<PROJECT>/build/src/HelloApp/HelloWorld.o, <PROJECT>/build/src/HelloApp/HelloUniverse.o) and executable target files <PROJECT>/build/src/HelloApp/HelloApp and <PROJECT>/build/bin/HelloApp.
To complete acquaintance with creating multitarget projects, please refer to <PREFIX>/share/OpenSBE/samples/Sample_01, where PREFIX is the OpenSBE installation directory.
Policy on Deliverables. OpenSBE separates source code from intermediate object files and project deliverables, such as the executables in the last example. Instead of creating everything in the project source directories, it replicates the project directory structure under a build directory and builds there. The above instructions invoke configure and make all directory <PROJECT>build/ for this reason exactly. You should prefer this approach over building directly in <PROJECT/>. Here is the filesystem tree of our simple C++ project after bootstrapping and building minus some operation-related files such as Autoconf-related files, Makefiles, and configuration files.
The main intent of the conventional Autoconf-generated configure scripts is to compute variables and instantiate template files (usually Makefiles and header files) by substituting variable values instead of @VARNAME@ entries in templates. configure computes variable values by performing target system tests or, alternatively, by obtaining them from the execution environment.
OpenSBE provides two more ways of defining variable values: through user interaction and through configuration files. Every OpenSBE feature brings in a number of variables; some of the variables are read-only and some are adjustable by end user. OpenSBE computes the default variable values and the user running configure has an opportunity to edit or confirm each of the values.
The order of the default variable values search is this:
OpenSBE-generated configure scripts have two operation modes: the interactive mode, when configure tries to resolve paths and settings by prompting for user input, and the non-interactive mode, when configure tries to deduce all required settings on its own. When configure runs successfully, it creates a configuration file containing values for all required settings; you can reuse the file to rerun configure in non-interactive mode. By default, configure saves the settings in current.config. The following OpenSBE-specific command-line options are available for configure.
--enable-no-questions={yes|no}. Runs configure in non-interactive mode. If configure is unable to figure out at least one parameter, it will terminate with an error. The default is --enable-no-questions=no.
--with-config-file={config file name|no}. Instructs configure to look for default values in the file specified. If you don't specify a file, configure will look for file default.config in the current directory. If you specify --with-config-file=no, configure will ignore the configuration file when search for default values. If you do specify a file and the file is not found, configure will behave the same as if --with-config-file=no were specified.
--enable-guess-location={yes|no}. Instructs configure to guess location of third-party software components required by the application being configured. The default is --enable-guess-location=yes. Usually, configure guesses root directories of libraries used in compilation by matching file hierarchies and file contents under library roots, which can vary from release to release, as well as can differ when debug version is built. The only disadvantage of this option being enabled is that the configure script execution time increases, and the increase can be quite significant when directories /usr and /opt where the search is performed by default contain deep hierarchies or mount points to remote filesystems. To change the default search directory list, update the value of variable LOCATION_GUESS_PATH by setting it in configure.ac as a project developer or/and exporting it outside configure script as an end user.
export LOCATION_GUESS_PATH="~/mylibs" && ./configure
You can disable the search for root directories as the most time-consuming task, but still let configure guess the structures of libraries. To do this, set LOCATION_GUESS_PATH to an empty string.
Let's complicate our simple C++ project by making use of Xerces library (Xerces.) To include an external library into our project, we need to modify some of the project files. Refer to this modified project tree.
First, we introduced the macro OSBE_CXX_USE_LIB into <PROJECT>/configure.ac. You can learn the details of using the macro in Section 5.3.1.1, “OSBE_CXX_USE_LIB Macro”.
Second, we modified the file <PROJECT/src/HelloApp/Makefile.in> to make Xerces visible to application HelloApp during the build. To that end, we included the rule file Xerces.pre.rules by its generalized name.
The last thing to do was include a relevant Xerces header in HelloWorld.cpp.
To sum up, we used OSBE_CXX_USE_LIB to inform OpenSBE that we are going to need Xerces-related rule files and variables, then linked the Xerces rule file into an appropriate Makefile template. This allowed us to use Xerces code in our project without worrying about linking and compilation issues.
Note that libraries are linked to targets in the order in which they appear in a Makefile. So when library "A" links library "B", Makefile.in should look like this:
# Makefile.in ... include $(osbe_builddir)/config/CXX/A.pre.rules include $(osbe_builddir)/config/CXX/B.pre.rules ...
For another example of OSBE_CXX_USE_LIB usage refer to <PREFIX>/share/OpenSBE/tests/Test_02, where PREFIX is the OpenSBE installation directory.
There is an easier way to rule libraries dependencies, especially convinient for inter-project libraries usage. This section describes def files format and usage. You also can refer to <PREFIX>/share/OpenSBE/tests/Test_03, where PREFIX is the OpenSBE installation directory. In effect this is Test_02 converted to use def files technology.
Def file is a library definiton file. Its name is a library identificator (refer to the first parameter of OSBE_CXX_USE_LIB macro). It must provide information about library itself and the libraries it uses. Therefore it consists of two virtual parts: library description and dependencies description. In fact it is a shell script and there are no strict rules of order or format of data provided.
Library description is a set of shell variables providing arguments to OSBE_CXX_USE_LIB macro.
Variable | Macro parameter | Short description |
name | $2 | Verbose library name. |
include | $3 | Optional. List of include relative directories. |
lib | $4 | Optional. List of relative library directories. |
so_files | $5 | Optional. List of shared libraries. |
ar_files | $6 | Optional. List of static libraries. |
hint | $8 | Optional. Library root directory search hint. |
find_options | $9 | Optional. Find options callback function name. |
find_acknowledge | $10 | Optional. Find acknowledge function name. |
ld_flags | $11 | Optional. Extra ld flags. |
root | $12 | Optional. Default root directory value. |
As far as def file is a shell script you can provide find function bodies right in place.
Example 4.8.1. OpenSSL.def
name="OpenSSL library" include=include lib=lib so_files="ssl crypto"
The above code is nearly equivalent to the following macro
Example 4.8.2. configure.ac
OSBE_CXX_USE_LIB([OpenSSL], [OpenSSL library], [include], [lib], [ssl crypto], [], [External/OpenSSL.pre.rules])
The second part of def file is a set of osbe_cxx_dep functions calls. The only argument it takes is a library identificator of dependable library
For example, alternative def file for OpenSSL library can look like this
Example 4.8.3. Crypto.def
name="Crypto library" include=include lib=lib so_files=crypto
Example 4.8.3. OpenSSL.def
name="OpenSSL library" include=include lib=lib so_files=ssl osbe_cxx_dep Crypto
Similarly use can write def files for your in-project libraries
Example 4.8.4. WebLayer.def
name="Common Web Communication Layer (secure/insecure)" so_files=CommonWebLayer osbe_cxx_dep OpenSSL osbe_cxx_dep AnotherInProjectLibrary osbe_cxx_dep YetAnotherOne
OSBE project libraries cannot be both shared and static (and both so_files and ar_files cannot be used for in-project libraries). Therefore this def file describes shared in-project library with library id equal to WebLayer and target CommonWebLayer. It requires OpenSSL and (via OpenSSL) Crypto, two in-project libraries are also required. To allow OSBE to use that def file you must use OSBE_CXX_USE_DEF macro in your dir.ac file.
Provided with this information OSBE allows you not to fill most of Makefile.in you need for your library. For example, the following Makefile.in
Example 4.8.5. Makefile.in
@weblayer_deps@ sources := WebLayer1.cpp WebLayer2.cpp @weblayer_post@
will be expanded to
Example 4.8.6. Makefile
include Common.pre.rules include $(osbe_builddir)/config/CXX/CXX.pre.rules include $(osbe_builddir)/config/CXX/External/OpenSSL.pre.rules include $(top_builddir)/config/some/path/to/AnotherInProjectLibrary.so.pre.rules include $(top_builddir)/config/some/path/to/YetAnotherOne.inl.pre.rules libname := WebLayer target := CommonWebLayer sources := WebLayer1.cpp WebLayer2.cpp include $(osbe_builddir)/config/CXX/So.post.rules
Note: paths to in-project libraries and their types are determined by OSBE automatically. You just need to inform OSBE about them with OSBE_CXX_USE_DEF macro. By default def files for external libraries are searched in <PROJECT>/defs/ and /usr/share/OpenSBE/defs/ directories. Alternatively you can use OSBE_DEFS environment variable or cxx.def.path variable in default.config. Anyway you can edit this value during configuration process.
Similarly you can attach CORBA, XSDTree and XSDParser.
Example 4.8.7. CorbaXSD.def
name="Corba and XSD library" so_files=CorbaXSDMix osbe_cxx_feature_dep CORBA osbe_cxx_feature_dep XSDTree
Example 4.8.8. Makefile.in
@corbaxsd_deps@ sources := CorbaXSD1.cpp corba_skeleton_idls := CorbaXSD2.idl xsd_files := CorbaXSD3.xsd @corbaxsd_post@
The result is
Example 4.8.9. Makefile
include Common.pre.rules include $(osbe_builddir)/config/CXX/CXX.pre.rules include $(osbe_builddir)/config/CXX/Corba.pre.rules include $(osbe_builddir)/config/CXX/XML/XSD.pre.rules libname := CorbaXSD target := CorbaXSDMix sources := CorbaXSD1.cpp corba_skeleton_idls := CorbaXSD2.idl xsd_files := CorbaXSD3.xsd include $(osbe_builddir)/config/CXX/XML/XSDTree.post.rules include $(osbe_builddir)/config/CXX/Corba.post.rules include $(osbe_builddir)/config/CXX/So.post.rules
Of course, such dependancy way can be used for executable files also. Just skip the first part of the file and list dependencies. But you are still forced to mention target in your Makefile.in because no information about it is stored in the def file
This approach allows you to use your project libraries in other projects easily as well. Just specify that something requires WebLayer and dependencies of WebLayer (OpenSSL, Crypto, AnotherInProjectLibrary, YetAnotherOne and even their dependencies) will be resolved automatically composing correct list of include and library directories and files.
Note that it is not "completely another way" to solve dependency problems but just an extention of the previous. For example you can combine both of the approaches. Test_03 has executable named EX11 using direct dependency scheme in completely converted test.
In this section, we transform our simple C++ application into a C++/CORBA application. Refer to this C++ CORBA application reduced tree.
The first change is in configure.ac, to support building CORBA applications, you must enable the CXX/Corba feature. To that end, we added the macro OSBE_ENABLE_FEATURE([CXX/Corba]) into configure.ac.
The new files introduced for their CORBA-related functionality are <PROJECT>/src/HelloLib/HelloLib.idl, <PROJECT>/src/HelloApp/HelloServer.idl, <PROJECT>/src/HelloApp/HelloServerImpl.hpp, and <PROJECT>/src/HelloApp/HelloServerImpl.cpp.
Note how <PROJECT>/src/HelloLib/Hello1.hpp include a CORBA stub that does not even exist during development using angle brackets in the #include directive. This is possible because HelloLib's Makefile.in defines variable corba_includes to point to a correct build-time directory (src). See corba_includes for more information on this variable. In a similar fashion, <PROJECT>/src/HelloApp/HelloServer.idl can reference HelloLib/HelloLib.idl (corba_idl_includes); and <PROJECT>/src/HelloApp/HelloServerImpl.hpp can reference HelloLib/HelloLib.hpp because HelloApp/Makefile.in includes the rule file $(top_builddir)/config/src/HelloLib/HelloLib.so.pre.rules. Another instance of corba_includes, this time in HelloApp/Makefile.in, allows <PROJECT>/src/HelloApp/HelloServerImpl.hpp to include a skeleton header, HelloApp/HelloServer_s.hpp.
If you look into <PROJECT>/src/HelloLib/Makefile.in and <PROJECT>/src/HelloApp/Makefile.in, you can see that we added the necessary CORBA-specific pre- and post-rules files references. We also identified CORBA stub and skeleton files by defining variables specific to CXX/CORBA feature: corba_stub_idls and corba_skeleton_idls. One last thing to do was add the implementation module HelloServerImpl.cpp to the list of sources in HelloApp's Makefile.in.
To complete acquaintance with creating C++/CORBA projects, please refer to <PREFIX>/share/OpenSBE/samples/Sample_02, where PREFIX is the OpenSBE installation directory. Use Section 5.3.7, “CXX/Corba Feature” as the reference.
This section will tell how to add support of XSD mapping to the application.
There are two ways a specific xsd file can be translated into C++ code: DOM and SAX. While the first loads xml file into the memory as a composition of objects, the second notifies you about the elements during the parse process. OSBE allows you to use both of them in your projects.
Firstly change confiure.ac file enabling CXX/XML/XSD feature. Addition of macro OSVE_ENABLE_FEATURE([CXX/XML/XSD]) makes it.
Then for every Makefile you're using for xsd translation you must choose one of two ways of translation. If you want to use DOM style you will need to include $(osbe_builddir)/config/CXX/XML/XSDTree.post.rules file in your Makefile. If SAX style is more preferred please include $(osbe_builddir)/config/CXX/XML/XSDTree.post.rules file.
Files to be processed are required to be mentioned in xsd_files variable in your Makefile. The source files to be compiled will be automatically added to sources variable, there is no need to mention them explicitly.
If you need to use the path to the generated C++ header files you may need to use xsd_includes variable.
OpenSBE's subsystem Documentation/Doxygen support generation of reference code documentation during the builds. Refer to this doxygenated version of our simple C++ project.
We enabled the Documentation/Doxygen feature in configure.ac, created a separate directory for Doxygen configuration files, <PROJECT>/doc/, and modified the top-level dir.ac to include the documentation directory into the project.
You can issue doxygen -g ./Doxyfile.in command to instantiate a Doxygen configuration file, then edit the file to introduce @top_srcdir@ variable which is up to configure to define.
For a more practical example of using Documentation/Doxygen, see the samples that come with OpenSBE.
Table of Contents
This references encompasses OpenSBE subsystems, features, rule files, macros, and variables.
Some rule files become available as a result of enabling features, others are generic and are available at all times. This section deals with rule files that are readily available.
This rule files serves for running Make on subdirectories. Rules defined in this file rely on variable target_directory_list that specifies, through a space-separated list, the directories for which OpenSBE must run additional instances of Make.
The script will change directory and pass parameters and goals to Make in all recursive calls.
Such behaviour is useful when the project build is based on a number of make files distributed throughout subdirectories.
This rule serves for running Make on concrete make files. Rules defined in this file rely on variable target_makefile_list that specifies, through a space-separated list, the make files for which OpenSBE must run additional instances of Make.
The script will pass parameters and goals to Make in all such calls.
Such behaviour is useful when the project build is based on a number of make files located in the same directory.
This rule file serves for running shell commands to test whether the system built is functioning properly. Specify the commands by defining the variable check_commands prior to including the rule file. When Make runs with goal 'check', it runs commands from check_commands.
Before running these commands, the rule file updates and exports environment variables LD_LIBRARY_PATH and PATH, so executables and libraries built from a project are available to check commands. Any libraries introduced through macro OSBE_CXX_USE_LIB and CXX/Corba feature become available as well.
Example 5.4. Makefile.in
include Common.pre.rules define check_commands echo ""; echo "Running The System test ..."; \ ServerApp -self-check; \ if test "$$?" -eq "0"; then \ echo "Test Succeeded"; \ else \ echo "Test Failed"; \ fi; \ echo "" endef include $(osbe_builddir)/config/Check.post.rules
![]() | Note |
---|---|
If you need to use character '$' (dollar sign) in the check script, prepend it another '$'. This requirement has nothing to do with OpenSBE; but stems from the fact that Make defines a variable name as a word beginning with character '$'. |
![]() | Note |
---|---|
Character '\' (backslash) at the end of a line is required in cases where the line and the next one must belong to the same shell command in order to make sense. |
You can specify two groups of commands related to the installation goal of the project. The two rule files intended for this are Install.pre.rules and Install.post.rules. By initializing variable install_commands, you specify the shell commands that actually install the system built. The variable must appear after the Install.pre.rules inclusion directive and before the Install.post.rules inclusion directive. When Make is invoked with goal 'install', the commands from install_commands are executed.
The file Install.pre.rules defines two groups of variables.
Variables specifying various destination paths: prefix, exec_prefix, bindir, sbindir, libdir, libexecdir, includedir, oldincludedir, infodir, mandir, localstatedir, sharedstatedir, sysconfdir, datadir. For descriptions, please refer to Autoconf documentation.
Variables containing commands for installing different types of files.
INSTALL. Contains a generic installation command, "install-sh -c". install-sh is a BSD-style installation script shipped with OpenSBE.
INSTALL_PROGRAM, INSTALL_SCRIPT. Contain commands for installing programs and scripts. Contain the same command as the INSTALL variable.
INSTALL_DATA. Contains commands for installing data files. Contains the INSTALL command with option "-m 644" appended.
INSTALL_DIR. Contains commands for installing a directory. Parameters:
source-dir - Specifies the directory with content to install.
dest-dir - Specifies the location which the source files should be copied to. Source file paths existing in the source directory are preserved when the files are copied to the destination directory.
name-patterns - An space-separated list of name patterns to be considered for installation. This parameter is optional. By default, pattern '*' is used, which means all files and links are copied.
extra-find-options - A list of additional find options used for grabbing files to be copied to the destination directory. For the list of options available, refer to find's manual. This parameter is optional. By default, the options specification is "-true", which means no filtering applies.
Example 5.5. Makefile.in
include Common.pre.rules include $(osbe_builddir)/config/Install.pre.rules define install_commands echo ""; echo "Installing The System ..." $(INSTALL_DIR) $(top_srcdir)/src $(destdir)$(includedir) '*.hpp *.idl' \ -not -name Test.hpp && \ $(INSTALL_DIR) $(top_builddir)/lib $(destdir)$(libdir) && \ $(INSTALL_DIR) $(top_builddir)/bin $(destdir)$(bindir); \ \ if test "$$?" -eq "0"; then \ echo "Installation completed successfully"; \ else \ echo "Installation failed"; \ fi echo "" endef include $(osbe_builddir)/config/Install.post.rules
For better usability Ar.post.rules, Ex.post.rules, Inl.post.rules, So.post.rules, Corba.post.rules, XSDTree.so.post.rules and XSDParser.post.rules export the following variables:
Variable | Description |
cxx_type | Either ar, ex, inl or so, depending on the post.rules file used. |
cxx_target | Target binary file name, or list of target binary file names (primary and secondary template instantiations sequently for So.post.rules). |
corba_sources | List of cpp files generated because of corba_stub_idls and corba_skeleton_idls variables. |
corba_headers | List of headers generated because of corba_stub_idls and corba_skeleton_idls variables. |
xml_xsd_sources | List of cpp files generated because of xsd_files variable. |
xml_xsd_headers | List of header files generated because of xsd_files variable. |
OpenSBE will automatically produce this rule file in every directory that contains files instantiated from templates through the OSBE_CONFIG_FILE macro. Common.pre.rules contains ready definitions of the following variables.
srcdir. Path of the appropriate source directory relative to the current build directory.
top_builddir. Path of the top build directory relative to the current build directory.
top_srcdir. Path of the top source directory relative to the current build directory.
osbe_srcdir. Path of the top OpenSBE source directory relative to the current build directory. This directory contains templates of rule files and files required for updating OpenSBE-specific targets.
osbe_builddir. Path of the top OpenSBE build directory relative to the current build directory. This directory contains rule files instantiated by configure script.
Common.pre.rules also includes a file defining some common variables and targets required by OpenSBE rule files.
Let's assume we have the following Makefile.
Makefile
chapters := chapter1.txt chapter2.txt chapter3.txt .PHONY: all all: book.txt book.txt: $(chapters) cat $(chapters) >$@
Let's assume we have all of the chapters for the book. And let's create the book.
First Makefile execution
% make cat chapter1.txt chapter2.txt chapter3.txt >book.txt %
Hah. Maybe chapter3.txt is excess? Let's remove it from chapters and run make again.
Second Makefile execution
% make make: Nothing to be done for `all'. %
Why hasn't book.txt been reassembled? It's correct. Neither chapter1.rxt nor chapter2.txt is newer than book.txt. The rules say it should not be reassembled. Well then. Let's remove it manually and rerun make.
Third Makefile execution
% rm book.txt % make cat chapter1.txt chapter2.txt >book.txt %
It's been reassembled. Well. But maybe we will return chapter3.txt back? Let's edit chapters and run make again.
Forth Makefile execution
% make make: Nothing to be done for `all'. %
It's definitly lack of rules. make is not as smart as required to solve those problems. That's what Command Depend feature is created for.
For those rules you want Command Depend stores the command has been executed literally. And while running make the next time it checks whether this command changed or not and it is able to run a new command not only when prerequisite files have been changed but the command itself changed.
It means that Command Depend notes the differences between lists of two and three chapters and reexecutes assembly command in the second and forth Makefile execution.
To enable this feature you must include OSBE_ENABLE_FEATURE([CmdDep]) in your configure.ac file. To apply Command Depend functionality for the specific rule use must use osbe_command_depend_target and osbe_command_depend functions
Let's use modified Makefile
Makefile with Command Depend
include Common.pre.rules chapters := chapter1.txt chapter2.txt chapter3.txt .PHONY: all all: book.txt $(call osbe_command_depend_target,book.txt): $(chapters) $(call osbe_command_depend,'cat $(chapters) >$@')
Let's try if it works
Usage of Makefile with Command Depend
% make cat chapter1.txt chapter2.txt chapter3.txt >book.txt % make % # Let's remove chapter3.txt from chapters here. % make cat chapter1.txt chapter2.txt >book.txt % # Let's add chapter3.txt back. % make cat chapter1.txt chapter2.txt chapter3.txt >book.txt %
You can set command_dependences variable to off if you don't want to use this functionality in the specific Makefile
The following features take advantage of usage of Command Depend feature:
Let's assume we want to modify the previous Makefile to make it work independently of presence of OSBE_ENABLE_FEATURE([CmdDep]) in our configure.ac file. We should use a list of supplied autoconf substitutes in order to make translation of Makefile.in into Makefile for both of our cases.
Makefile.in with Command Depend's substitutes
include Common.pre.rules chapters := chapter1.txt chapter2.txt chapter3.txt .PHONY: all all: book.txt @CD_TB@book.txt@CD_TE@: $(chapters) @CD_CB@ @CD_LB@ -@echo "Chapters: " $(chapters) @CD_LE@ @CD_LB@ @cat @(chapters) >$@ @CD_LE@ @CD_CE@
Note: that each line with a command starts with tab character.
Substitute | Value when using Command Depend | Value when not using Command Depend | Description |
@CD_ON@ | on | empty | Flag. Useful in if constructions. |
@CD_TB@ | $(call osbe_command_depend_target, | empty | Targets' Beginning. It should be added right before your targets. |
@CD_TE@ | ) | empty | Targets' End. It should be added right after your targets. |
@CD_CB@ | $(call osbe_command_depend,\ | @mkdir -p $(@D) | Command's Beginning. It is the first line of your commands. |
@CD_CE@ | ) | empty | Command's End. It is the last line of your commands. |
@CD_LB@ | ' | empty | Line's Beginning. It is the first token in every command. |
@CD_LE@ | '\ | empty | Line's End. It is the last token in every command. |
For details of usage you can look into CXX.mk.in file, for example
CXX/CXX does not define any Make targets of its own; however, it defines a set of common variables required by Make targets provided by other CXX/* features.
Defines M4 macro OSBE_CXX_USE_LIB. In configure.ac, an instance of the macro refers to an external C++ library. After defining OSBE_CXX_USE_LIB, the developer can reference the headers of this specific library in project source files as well as link the library to project's build targets.
Other CXX/* features automatically enable CXX/CXX so there is generally no need to enable it explicitly.
This macro is instantiated in configure.ac and references an external C++ library. Instantiating the macro enables the developer to references the library headers in project source files as well as link it to targets of a project.
During generation of the configure script, M4 expands this macro into code, which on the configuration stage generates a Make rule file. Including this file into the project's Makefile responsible for producing executables or libraries adds Make rules required for compiler to find library headers and for linker to find the library binaries.
When run in the interactive mode, configure prompts the user to confirm or edit the library root directory, include and library directory paths, shared and static library filenames.
The macro has the following parameters:
Parameter | Description |
$1 | Project-wide unique library identifier. Used to generate keys for configuration file and produce related environment variable names. This document refers to the unique library identifier as <libid> or <LIBID>. |
$2 | Verbose library name. Used at the project configuration stage in prompts regarding this library. |
$3 | Optional parameter. Space-separated list of include directory paths relative to the library's root directory. This list with library root prepended will be offered for confirmation or editing if a) variable "external.lib.<libid>.cxx.include" is not defined in the configuration file; and b) environment variable <LIBID>_CXX_INCLUDE is not set. After the list of include paths is settled, with or without user interaction, it is instantiated in library rule file as a list of -I C preprocessor options passed to a compiler. |
$4 | Optional. Space-separated list of library directory paths relative to the library's root directory. This list with library root prepended will be offered for confirmation or editing if a) variable "external.lib.<libid>.cxx.lib" is not defined in the configuration file; and b) environment variable <LIBID>_CXX_LIB is not set. After the list of library paths is settled, with or without user interaction, it is instantiated in library rule file as a list of -L options passed to a linker. |
$5 | Optional. Space-separated list of filenames of shared libraries. This list will be offered for confirmation or editing if a) variable "external.lib.<libid>.cxx.so_files" is not defined in the configuration file b) environment variable <LIBID>_CXX_SO_FILES is not set. After the list of filenames list is settled, with or without user interaction, it is instantiated in library rule file as a list of -l options passed to a linker. |
$6 | Optional. Space-separated list of filenames of static libraries. This list will be offered for confirmation or editing if a) variable "external.lib.<libid>.cxx.ar_files" is not defined in the configuration file b) environment variable <LIBID>_CXX_AR_FILES is not set. After the list of filenames is settled, with or without user interaction, it is instantiated in library rule file as a list of -l options passed to linker. |
$7 | Name of the produced rule file relative to $(osbe_builddir)/config/CXX/ path. |
The next three parameters relate to OpenSBE "location guessing" functionality. By providing these parameters, you can get configure script to search for library root directory. Using these location guessing parameters of OSBE_CXX_USE_LIB, you can specify quite complex search criteria, from matching filesystem entries to matching content of library files. | |
$8 | Optional. Library root directory search hint. A list of relative paths that should be present under the library root directory. If omitted, no search will be performed. |
$9 | Optional. Name of a callback function that, being provided with a search hint (one of the hints from $8), will print to standard output additional find-style search options (man find for specific syntax). |
$10 | Optional. Name of a callback function which acknowledges the search hints passed as the parameter by performing additional content analysis. If the acknowledgement callback function recognizes a path as a search hint, it will print 1 to the standard output, 0 otherwise. If $10 is omitted, file matches will be acknowledged automatically. |
$11 | Optional. Extra ld flags. They are passed as is to the linker command line. |
$12 | Optional. Default root value for the library. This value could be overriden by the search procedure or by default.config. |
CXX_ID. Compiler identifier used to uniquely name supported compilers. The identifier must map into a CCL files present under directory <PREFIX>/share/OpenSBE/config/CXX/Defaults/. The default value search order for this variable is:
CXX. The command for running the C++ compiler (path to g++ compiler in case of GCC). The default value search order for this variable is:
CXX_FLAGS. C++ options. Usually, flags for optimization and warning levels, debug information generation. The default value search order for this variable is:
CPP_FLAGS. C preprocessor flags, usually containing search options for header files. The default value search order for this variable is:
OBJ_EXT. Extension for object files (".o" for g++ and many other compilers). The default value search order for this variable is:
LD_SO. The command for running a shared library linker. The default value search order for this variable is:
LD_EX. The command for running an executable linker. The default value search order for this variable is:
LD_FLAGS. Options passed to the linker used in building of executables and shared libraries. The default value search order for this variable is:
LIBS. Linker options specifying the libraries to link with when building executables and shared libraries (for example, -lstlport_gcc -lg++.) The default value search order for this variable is:
AR. The command for running a static library linker. The default value search order for this variable is:
AR_FLAGS. Options passed to the static library linker. The default value search order for this variable is:
CXX_DEP. Path to the dependency files generator shipped with OpenSBE. The value of this variable is not adjustable ("$(osbe_srcdir)/bin/cxxdep.pl").
DEP_EXT. Extension for dependency files. The value of this variable is not adjustable (".d").
DEP_FLAGS. Options passed to dependency files generator. The value of this variable is empty and not adjustable.
AR_TARGET_TEMPLATE. Static library file names template. Character % (per cent sign) in the template is replaced with a library name. For example, on UNIX the template is "lib%.a". The default value search order for this variable is:
EX_TARGET_TEMPLATE. Executable file names template. Character % (per cent sign) in the template is replaced with an application name. For example, on Windows the template may be "%.exe". The default value search order for this variable is:
SO_PRIMARY_TARGET_TEMPLATE. Shared library file names template. Character % (per cent sign) in the template is replaced with a library name. For example, the pattern may be "%.so" on UNIX and "%.dll" on Windows. The default value search order for this variable is:
SO_SECONDARY_TARGET_TEMPLATE. Shared library additional file names template. Character % (per cent sign) in the template is replaced with a library name. This variable serves exclusively to support MSVC compiler which requires an import library to link a shared library. The value of this variable for MSVC is "%.lib". The default value search order for this variable is:
Here is a minimal Makefile intended only for building a C++ executable:
include Common.pre.rules
include $(osbe_builddir)/config/CXX/CXX.pre.rules
sources := <space-separated list of source files>
target := <name of the executable to produce>
include $(osbe_builddir)/config/CXX/Ex.post.rules
![]() | Includes the usual Common.pre.rules (see Section 5.1.2, “Common.pre.rules”.) |
![]() | Includes the rule file CXX.pre.rules containing variable definitions required for building any C++ target. |
![]() | Initializes the variable sources with a list of C++ source files. For now, the only expected source file extension is ".cpp". |
![]() | Initializes the variable target with a C++ executable target name. The final file name is produced by instantiating the EX_TARGET_TEMPLATE using target's value as the parameter. The result generally depends on the compiler and the operating system used. |
![]() | Includes the file Ex.post.rules defining targets 'all', 'clean', and 'cleanall' required for building the executable, cleaning intermediate and build files, respectively. Rules from Ex.post.rules use the values of variables sources and target. |
Here is a minimal Makefile intended only for building a C++ library:
include Common.pre.rules include $(osbe_builddir)/config/CXX/CXX.pre.rules sources := <space-separated list of source files>target := <name of the library>
includes := <space-separated list of include directories>
include $(osbe_builddir)/config/CXX/So.post.rules or include $(osbe_builddir)/config/CXX/Ar.post.rules
Enable this feature if you intend to build shared libraries from a C++ project.
Enable this feature if you intend to build static libraries from a C++ project.
Enable this feature if you intend to build inline libraries from a C++ project. Inline libraries are just sets of header files therefore sources is not applicable for them.
Enable this feature if you intend to use library dependency approache based on def files. See Section 4.8, “Easier way to use dependencies” for details.
This feature comes into play when you need to compile CORBA IDL files into stubs and skeletons and link the results into an executable or a library.
CXX/Corba does not define any Make targets for building libraries or executables. Besides the usual targets 'clean' and 'cleanall', this Feature only defines the target producing CORBA stub and/or skeleton files from CORBA IDL files.
Usually, this feature is used in conjunction with CXX/Ex, CXX/So, or CXX/Ar.
CXX/Corba computes variables using script files, one per supported CORBA ORB. These files are known as ORB Compatibility Layers (OCL). <PROJECT>/share/OpenSBE/config/CXX/OrbDefaults is the home directory of OCL files.
The set of variables computed in OCL scripts serves as the interface for plugging in support for arbitrary CORBA ORBs.
CXX_CORBA_ORB_ID. Identifies the C++ CORBA ORB to use in the project by its OCL base name (e.g. "ORBacus".) OCL files reside in directory <PREFIX>/share/OpenSBE/config/CXX/OrbDefaults/. The default value search order for this variable is:
CXX_CORBA_IDL. Specifies the command for running C++ CORBA IDL compiler. The default value search order for this variable is:
CXX_CORBA_CPPFLAGS. CORBA-specific C preprocessor flags. The value of CXX_CORBA_CPPFLAGS is appended to the value of CPP_FLAGS when Corba.pre.rules is included. The default value search order for this variable is:
CXX_CORBA_CXXFLAGS. CORBA-specific C++ flags. The value of CXX_CORBA_CXXFLAGS is appended to the value of CXX_FLAGS when Corba.pre.rules is included. The default value search order for this variable is:
CXX_CORBA_LDFLAGS. CORBA-specific C++ linker flags. The value of CXX_CORBA_LDFLAGS is appended to the value of LD_FLAGS when Corba.pre.rules is included. The default value search order for this variable is:
CXX_CORBA_LIBS. CORBA-specific C++ libraries. The value of CXX_CORBA_LIBS is prepended to the value of LIBS when Corba.pre.rules is included. The default value search order for this variable is:
CXX_CORBA_SKELSUFFIX. CORBA skeleton files suffix. The default value search order for this variable is:
CXX_CORBA_STUBSUFFIX. CORBA stub files suffix. The default value search order for this variable is:
CXX_CORBA_IDLPPFLAGS. C++ CORBA IDL preprocessor flags. The default value search order for this variable is:
CXX_CORBA_EXTRA_IDLFLAGS. Additional C++ CORBA IDL flags. The value of this variable is appended to the value of CXX_CORBA_IDLFLAGS. The default value search order for this variable is:
CXX_CORBA_IDLFLAGS. C++ CORBA IDL flags. This variable has no default value and is computed by the OCL script specified in CXX_CORBA_ORB_ID. The script converts the values of variable like CXX_CORBA_SKELSUFFIX and CXX_CORBA_STUBSUFFIX into IDL compiler options and combines them with CXX_CORBA_EXTRA_IDLFLAGS to produce the value of CXX_CORBA_IDLFLAGS.
CXX_CORBA_ORB_PRE_RULES. A CORBA ORB may require injection of additional ORB-specific rules into the Corba.pre.rules files produced by configure. OCL variable CXX_CORBA_ORB_PRE_RULES contains rules that appear at the end of Corba.pre.rules. CXX_CORBA_ORB_PRE_RULES accomodates multiline values.
CXX_CORBA_ORB_POST_RULES. A CORBA ORB may require injection of additional ORB-specific rules into the Corba.post.rules files produced by configure. OCL variable CXX_CORBA_ORB_POST_RULES contains rules that appear at the end of Corba.post.rules. CXX_CORBA_ORB_POST_RULES accomodates multiline values.
Here is a minimal Makefile intended for building a C++ CORBA client executable.
include Common.pre.rules include $(osbe_builddir)/config/CXX/CXX.pre.rulesinclude $(osbe_builddir)/config/CXX/Corba.pre.rules sources := <space-separated list of source files> target := <name of the executable>
corba_stub_idls := <space-separated list of CORBA IDL files>
include $(osbe_builddir)/config/CXX/Corba.post.rules include $(osbe_builddir)/config/CXX/Ex.post.rules
Another minimal Makefile, intended for building a C++ CORBA server:
include Common.pre.rules include $(osbe_builddir)/config/CXX/CXX.pre.rules include $(osbe_builddir)/config/CXX/Corba.pre.rules sources := <space-separated list of source files> target := <name of the executable> corba_stub_idls := <space-separated list of CORBA IDL files>corba_skeleton_idls := <space-separated list of CORBA IDL files> include $(osbe_builddir)/config/CXX/Corba.post.rules include $(osbe_builddir)/config/CXX/Ex.post.rules
![]() | Initializes variable corba_skeleton_idls with a list of CORBA IDL files. This will implicitly append CORBA skeleton source files to variable sources. |
In both cases, when rules generated from CXX/Corba.post.rules have caused IDL files to be compiled into C++ stubs and skeletons, implicitly appending names of the stubs and skeletons to variable sources causes CXX/Ex.post.rules to compile them along with other C++ files and link corresponding object files into the target.
There are two more CORBA-specific variables for parametrizing CXX/Corba.post.rules: corba_idl_includes and corba_includes.
corba_idl_includes. Specifies, through a space-separated list, the directories where the IDL compiler must look for included files when compiling library IDL files or IDL files of a target that uses the library. Technically, library post rules convert corba_idl_includes into IDL preprocessor's -I options. For instance, the value "dir1 dir2" translates into -I$(top_srcdir)/dir1 -I$(top_srcdir)/dir2.
corba_includes. Specifies, through a space-separated list, the directories where the C++ compiler must look for stub and skeleton header files when compiling library source files or source files of a target using the library. Technically, library post rules convert corba_includes into C++ preprocessor's -I options. For instance, the value "dir1 dir2" translates into -I$(top_builddir)/dir1 -I$(top_builddir)/dir2.
TO BE DONE
Makefiles describing several directories or makefiles to build (i.e. containing includes of Makentry.post.rules and Direntry.post.rules) often need to contain dependencies between their entries. For example, if a target of a subdirectory A is a library and a target of a subdirectory B is an executable using library A, library A should be built before executable B will be started to build. It means 'B : A' dependency should be present in the Makefile
Manual writing of dependencies is arduous and error-prone. One may forget to include a dependence and build sometimes will fail. Also an older unrebuilt version of static library may be linked, for example.
Alternatively, OpenSBE build system may make all the hard work. If you use CXX/Def feature widely OpenSBE has all of the information about dependencies of libraries and executables and thereby it knows a build order of the targets. The only thing OpenSBE may not know is a correspondence between target and the makefile it need to use to build that target. By default it assumes that for some/paticular/path/to/Target.def corresponding Makefile is some/paricular/path/to/Makefile. It is not correct if several make files are present in the same directory (having a target for each one and being aggregated by one or more make files which include Makentry.post.rules). Such correspondence should be defined by using the second argument of OSBE_CXX_DEF macro. The following two examples are nearly equivalent but the second provides additional information about correspondence between .def and .mk files.
Example 5.3.9.1. dir.ac
OSBE_CONFIG_FILE([Makefile]) OSBE_CXX_DEF([Math]) OSBE_CONFIG_FILE([Math.mk]) OSBE_CXX_DEF([AdvancedMath]) OSBE_CONFIG_FILE([AdvancedMath.mk])
Example 5.3.9.2. dir.ac
OSBE_CONFIG_FILE([Makefile]) OSBE_CXX_DEF([Math], [Math.mk]) OSBE_CXX_DEF([AdvancedMath], [AdvancedMath.mk])
The example assumes that Makefile describes Math.mk and AdvancedMath.mk as its entries.
With all of the information above it is known which makefile (with full path) or directory (with full path) depends on others. It is obvious that if some/path/to/some/Makefile depends on some/path/to/another/Makefile that the dependence "some : another" is required in the makefile describing subdirectories of some/path/to directory.
Thereby for each directory (called some/directory in the table) there are four types of dependences derived from .def files relations.
Dependence | Behaviour |
Subdirectory Dependent dependes on subdirectory Dependence | For any makefile of directory some/directory including Direntry.post.rules that contains both Dependent and Dependence entries in target_directory_list variable a rule 'Dependent : Dependence' is added. |
Makefile Dependent.mk dependes on makefile Dependence.mk | For any makefile of directory some/directory including Makentry.post.rules that contains both Dependent.mk and Dependence.mk entries in target_makefile_list variable a rule 'Dependent.mk : Dependence.mk' is added. |
Subdirectory Dependent dependes on makefile Dependence.mk | Warning message is issued. No automatic dependence rule is generated. |
Makefile Dependent.mk dependes on subdirectory Dependence | Warning message is issued. No automatic dependence rule is generated. |
If you need any makefile not to include automatically generated dependences add autodependencies := off definition in that makefile.
As the name suggests, Documentation/Doxygen feature is intended for building Doxygen documentation. The feature defines targets 'docs' and 'cleanall' targets, where 'docs' produces Doxygen output and 'cleanall' removes the output.
The only variable this feature computes is DOXYGEN_PATH.
DOXYGEN_PATH. Contains the command for running Doxygen. The default value search order for this variable is:
Here is a minimal Makefile intended only for building Doxygen documentation:
include Common.pre.rules
include $(osbe_builddir)/config/Documentation/Doxygen.pre.rules
doxygen_config := Doxyfile
doxygen_output := Doxydir
include $(osbe_builddir)/config/Documentation/Doxygen.post.rules
![]() | Includes the usual Common.pre.rules (see Section 5.1.2, “Common.pre.rules”.) |
![]() | Includes Doxygen.pre.rules instantiating Make DOXYGEN_PATH variable used for running Doxygen. |
![]() | Initializes variable doxygen_config with a configuration file name to be passed to doxygen command. Refer to Doxygen documentation for information on the structure and content of Doxygen configuration files. |
![]() | Initializes variable doxygen_output with an output directory name. Target 'cleanall' uses this variable to cleanup the output directory. The output directory is expected to be the same as in the Doxygen configuration file referenced in variable doxygen_config. |
![]() | Includes the file Doxygen.post.rules that contains definitions for targets 'docs' and 'cleanall' parametrized using the above variables. |
OSBE_CURRENT_DIR. OpenSBE encourages the developer to disperse configuration macros across multiple dir.ac files, placing them into the very directories containing the files to be configured. However, ruring bootstrapping, AC-files (including configure.ac) all merge into a single configure script. That is why, when referencing other files from a dir.ac, you need to prefix the filename with macro OSBE_CURRENT_DIR, which osbe will replace a directory name relative to the <PROJECT> directory.
OSBE_SUBST_VIA_FILE. Traditionally, Autoconf's own macro AC_SUBST has been used for substituting variables in templates. However, AC_SUBST does not support multiline variable values. OpenSBE introduces macro OSBE_SUBST_VIA_FILE that has identical semantics, but no such limitations. OSBE_SUBST_VIA_FILE is implemented on top of AC_SUBST_FILE, hence the name.
Here is an example of using OSBE_SUBST_VIA_FILE:
SOME_FEATURE_PRE_RULES=\ "export A := X export B := Y" OSBE_SUBST_VIA_FILE(SOME_FEATURE_PRE_RULES)
echo. If the echo command accepts option -e, resolves to echo -e; otherwise, resolves to echo. This is a configuration-time variable, you can use it in AC-files.
LN_S. This is, in fact, Autoconf's configuration-time variable. OpenSBE additionally defines a corresponding Make variable. Under Cygwin, the variable resolves to command cp_lns.sh shipped with OpenSBE. This command will copy the link target instead of creating a Windows LNK file as Cygwin's native ln -s does.
readline. Contains a command to read a line from standard input. Prompts with a string passed as the first parameter. This is a configuration-time variable.
These functions may be useful for OpenSBE contributors and feature developers. They are included into configure automatically.
Name | Description | Parameters | STDOUT output |
osbe_prefix_words | Prepends the specified prefix to every word in a space-separated word list. |
| Space-separated list of prefixed words. |
osbe_suffix_words | Appends the specified suffix to every words in a space-separated word list. |
| Space-separated list of suffixed words. |
osbe_wrap_words | Adds the specified prefix and suffix to words in a space-separated word list. |
| Space-separated list of wrapped words. |
Name | Description | Parameters | STDOUT output | ||||
osbe_ask_for_option | Prompts the user to choose an option from a list options. If configure is running in non-interactive mode, the function returns the default value. Always writes the return value into the file current.config. Here is an example of creating a call to osbe_ask_for_option. option_ids="OPT1 OPT2 OPT3" option_name_OPT1="First Option" option_name_OPT2="Second Option" option_name_OPT3="Third Option" osbe_ask_for_option "Please select an option" \ "Option selected" \ "$option_ids" \ "option_name_" \ option_id \ "my.option.id" \ "OPT2" (1) First Option (OPT1) * (2) Second Option (OPT2) (3) Third Option (OPT3) Please select an option [3] : configure: Option selected : Third Option |
| None. | ||||
osbe_ask_for_pe_string | Prompts the user to confirm or edit a string. To confirm, the user must press either Y or Return key; to edit, the user must press E. Empty strings are allowed. If configure is running in non-interactive mode, the function returns the default value. Always writes the return value into the file current.config. Here is an example of using osbe_ask_for_pe_string. directory_path="~/Projects/OldOne" osbe_ask_for_pe_string "Please enter directory path if exists" \ "directory root path" \ directory_path \ "my.directory" \ "1" Please enter directory path if exists (~/Projects/OldOne) [Y/e]: e > ~/Projects/NewOne configure: C++ compiler : ~/Projects/NewOne |
| None. | ||||
osbe_ask_for_ne_string | Prompts the user to confirm or edit a string. To confirm, the user must press either Y or Return key; to edit, the user must press E. Empty strings are not allowed. If configure is running in non-interactive mode, the function returns the default value. If the default value is empty, configure will report an error when running in non-interactive mode. Always writes the return value into the file current.config. Here is an example of using osbe_ask_for_ne_string. directory_path="~/Projects/OldOne" osbe_ask_for_ne_string "Please enter directory path if exists" \ "directory root path" \ directory_path \ "my.directory" \ "1" Please enter directory path if exists (~/Projects/OldOne) [Y/e]: e > ~/Projects/NewOne configure: C++ compiler : ~/Projects/NewOne |
| None. | ||||
osbe_ask_for_confirmation | Prompts the user to confirm or edit a set of options. To confirm, the user must press either Y or Return key; to edit, the user must press E. If configure is running in non-interactive mode, the functions returns character 'y'. Here is an example of using osbe_ask_for_confirmation. option1="a" option2="b" options = "My Options:\n Option1 : $option1\n Option2 : $option2" osbe_ask_for_confirmation "Please confirm or edit options listed above" \ "$options" \ options_confirmation My Options: Option1 : a Option2 : b Please confirm or edit options listed above [Y/e]: |
| None. | ||||
osbe_add_option | Function osbe_add_option allows to determine default set of values for every variable for subsequent call to function osbe_ask_for_option. |
| None. | ||||
osbe_ask_for_options | Function osbe_ask_for_options shows values previously determined by function osbe_add_option and prompts the user to confirm the whole set of options or or edit any of them. To confirm, the user must press either Y or Return key; to be asked for editing every of them, the user must press E. If configure is running in non-interactive mode, the functions returns character 'y'. Here is an example of using osbe_add_option and osbe_ask_for_option. base_port=10000 osbe_add_option secure_port `expr $base_port + 1` "server.ports.secure" \ "Secure port number" "" "1" osbe_add_option insecure_port `expr $base_port + 2` "server.ports.insecure" \ "Insecure port number" "" "1" osbe_add_option control_port `expr $base_port + 3` "server.ports.control" \ "Optional control port number" osbe_ask_for_options "Port numbers" Port numbers: Secure port number: 10001 Insecure port number: 10002 Optional control port number: 10003 Please confirm or edit options listed above [Y/e]: |
| None. |
Name | Description | Parameters |
osbe_config_mech_write_nl | Writes an empty line into current.config. | None. |
osbe_config_mech_write_comment | Writes a comment line into current.config. |
|
osbe_config_mech_write_value | Writes a "key = value" pair into current.config. |
|
osbe_config_mech_read_value | If configure is running not without the --with-config-file=no option, the configuration file exists and the key/value pair for the key passed as the first parameter exists, assigns the value found to the variable passed by the name as the second parameter. Otherwise, does not modify the variable. |
|
osbe_set_pe_string | Initializes a variable using a value from the configuration file, if the value is found. Allows empty values. Always writes the resulting value into current.config. |
|
osbe_set_ne_string | Initializes a variable using a value from the configuration file, if the value is found. If the resulting value is empty, aborts execution of configure with an error message. Otherwise, writes the resulting value into current.config. |
|
Name | Description | Parameters | STDOUT output |
osbe_guess_location | Searches for location of the specified relative paths. Returns a list of longest common paths. Here is an example of using osbe_guess_location. search_opt_func() { $echo "-type f -o -type l" } search_acknowledge_func() { signature=`cat "$1"|grep "// My File Unique Signature"` if test -z "$signature"; then $echo "0" else $echo "1" fi } possible_locations=\ `osbe_guess_location "my unique source files" \ "/home/me/projects" \ "file.hpp file.cpp" \ "$search_opt_func" \ "$search_acknowledge_func"` ~/projects/Project1/file.hpp ~/projects/Project1/file.cpp ~/projects/Project2/file.hpp ~/projects/Project2/file.cpp ~/projects/Project3/file.hpp ~/projects/Project4/file.cpposbe_guess_location will return the string "/home/me/projects/Project1 /home/me/projects/Project2". |
| Space-separated list of paths; each of the paths is the longest possible common path for hints found. |
osbe_guess_each_location | Searches for locations of the specified relative paths. Composes the list of the shortest lists of paths, such that for each of the supplied relative paths there is one immediate parent in the resulting list. May ask user to choose one of the list of the lists if they are some. Here is an example of using osbe_guess_each_location. search_opt_func() { $echo "-type f -o -type l" } search_acknowledge_func() { signature=`cat "$1"|grep "// My File Unique Signature"` if test -z "$signature"; then $echo "0" else $echo "1" fi } osbe_guess_each_location "/home/me/projects" \ "file.hpp file.cpp" \ "my unique source files" \ possible_locations \ "$search_opt_func" \ "$search_acknowledge_func" ~/projects/Project1/file.hpp ~/projects/Project1/file.cpp ~/projects/Project2/file.hpp ~/projects/Project3/file.cpp ~/projects/Project4/file.hpp ~/projects/Project4/file.cpposbe_guess_each_location will ask user to choose from "/home/me/projects/Project1", "/home/me/projects/Project4" and optionally user-supplied directory. |
| None |
Name | Description | Parameters | STDOUT output |
osbe_var_undefined | Determines whether a variable is undefined. |
| 1 if the variable is undefined; 0 otherwise. |
osbe_rel2abs | Converts a relative path into its absolute equivalent. |
| An absolute file path. |
GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software-to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items-whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.