## Example: Translating the File HelloWorld.c

### Purpose

You translate and link the sys/src/SAPDB/HelloWorld.c file to an executable program usr/pgm/hello (or usr\pgm\hello.exe on Microsoft Windows).

### Prerequisites

· You have created the sys/src/SAPDB/HelloWorld.c file.

· You have created the sys/src/SAPDB/HelloWorld.h include file.

### Process Flow

...

1. Start the MAKE operation (VMAKE version fast):

imf.pl hello.lnk

2. VMAKE determines the files that are required:

¡ VMAKE recognizes the sys/desc/hello.lnk description file as the description of an executable program from its file extension .lnk. The description only contains the :SAPDB/HelloWorld.c file; the colon stands for the directory with the module files sys/src.

¡ VMAKE recognizes the sys/src/SAPDB/HelloWorld.c module file as a module files that has to be translated with the C compiler from its file extension .c. The include files that are required by this module file are listed in the sys/desc/SAPDB.com description file:
HelloWorld.c inc=:SAPDB/HelloWorld.h
This row can contain additional options for the compiler.

¡ The include file sys/src/SAPDB/HelloWorld.h does not require any further files. Otherwise, these dependencies would also have to be entered in SAPDB.com.

3. VMAKE updates the files that are required:

¡ Include files:
HelloWorld.h, HelloWorld.c fast, hello.lnk fast
VMAKE copies these from the development area to a corresponding subdirectory sys/wrk/incl, in this case sys/wrk/inl/SAPDB/HelloWorld.h. File names should therefore be specified in #include statements relative to sys/wrk/incl.

¡ C sources:
HelloWorld.h, HelloWorld.c fast, hello.lnk fast
These are translated into object files using the C compiler. Object files can be created in two versions (VMAKE versions): fast (with optimization) or slow (with assertions and trace output). In this case, the file created is written to sys/wrk/fast/obj/SAPDB/HelloWorld.o. On Microsoft Windows, object files receive the file extension .o. The source file in the sys/wrk/fast/tmp directory is coped for translation. All of the intermediate results (this is particularly relevant for PASCAL sources) are created in this directory, and can be checked there in the event of an error.

¡ Executable programs:
HelloWorld.h, HelloWorld.c fast, hello.lnk fast
These are linked and copied to usr/pgm. On UNIX, usr/pgm/hello.f is created and a link to it is entered in the file system, under usr/pgm/hello. On Microsoft Windows, the usr\pgm\hello.exe.f is created and copied to usr\pgm\hello.exe.

4. Display the VMAKE logs hello.lnk.p0 (copy of the screen output) and hello.lnk.x0 (list of all relevant time stamps as well as the executed actions):

imf.pl hello.lnk

#### Variants

· Forced translation: Creates the specified target as a new target. A new link is created to an executable program.

imf.pl -u hello.lnk

hello.lnk fast

· Option –U: Recreates the specified target and all of the necessary module files.

imf.pl -U hello.lnk

HelloWorld.c fast
hello.lnk fast

· Option -U-I: Recreates the specified target, all of the necessary modules, and all of the required include files.

imf.pl -U -I hello.lnk

HelloWorld.h
HelloWorld.c fast
hello.lnk fast

· Option -e: You instruct VMAKE to create targets with debug information (see Activating the Debug Mode).

imf.pl -U -e hello.lnk

HelloWorld.c fast debug
hello.lnk fast debug

usr/pgm/hello can then be started in the debugger. The source files are copied to sys/wrk/fast/debug after the translation process. This is particularly important for PASCAL module files, since these can only be debugged using the generated C file, and not in the source code itself.

5. Display the new targets to be generated:

imf.pl -u -n hello.lnk

6. Display the module and description files that are used:

imf.pl -m hello.lnk

7. Display the module and description files that are used and their dependencies:

imf.pl -C hello.lnk