Generated Makefile

The -genmake option causes a portable makefile to be generated to assist in the C or C++ compilation of all of the generated C or C++ source files. This makefile contains a rule to invoke ASN1C to regenerate the .c and .h files if any of the dependent ASN.1 source files are modified. It also contains rules to compile all of the C or C++ source files. Header file dependencies are generated for all the C or C++ source files.

Two basic types of makefiles are generated:

  1. A GNU compatible makefile. This makefile is compatible with the GNU make utility which is suitable for compiling code on Linux and many UNIX operating systems, and

  2. A Microsoft Visual Studio compatible makefile. This makefile is compatible with the Microsoft Visual Studio nmake utility.

A GNU compatible makefile is produced by default, the Microsoft compatible file is produced when the –w32 command line option is specified in addition to –genmake.

Both of these makefile types rely on definitions in the platform.mk make include file. This file contains parameters specific to different compiler and linker utilities available on different platforms. Typically, all the needs to be done to port to a different platform is to adjust the parameters in this file.

When a makefile is generated, it is assumed that the ASN1C project exists within the ASN1C installation directory tree. The generation logic tries to determine the root directory of the installation by traversing upward from the project directory in an attempt to locate the rtsrc subdirectory which is assumed to be the installation root directory. The makefile variable OSROOTDIR is then set to this value. A similar traversal is done to locate the platform.mk and xmlparser.mk files. These paths are then set in the makefile. If the project directory is located outside of the ASN1C directory tree, the user must set the OSROOTDIR environment variable to point at the ASN1C root directory in order for the makefile generation to be successful. If this is done, it is assumed that the platform.mk and xmlparser.mk files are located in this directory as well. If the compiler is unable to determine the root directory using any of the methods described above, an error will be generated and the user will need to manually edit the makefile to set the required root directory parameters and makefile include file paths.