ICMAKE Part 2

In part 1, Brokken and Kubat explained where the ideas for icmake came from, the basics of the program and where you can get a copy. In Part 2 we cover the grammar of icmake source files. The final part of this article will appear next month and will show examples of the use of icmake.
4.2. Constants, types and variables

Constants may be used in the makefile to indicate a number or a string. Int constants are denoted by numeric characters; e.g., 13 is an int constant. A second way to denote an int constant is by enclosing a character in single quotes. The numeric value of the constant is then the ascii number of the character, e.g., the constant `A' has the value 65. The character between quotes may not be `escaped', such as `\n'. Only single characters are allowed in this notation of integer constants.

String constants are denoted by text between double quote marks, e.g., “a string” is a piece of text.

Icmake recognizes four types: int, string, list and void. The types serve the following purposes:

  • int: The type `int' is used to represent numerical 16-bit signed values.

  • string: The type `string' is used to represent strings, like the strings used in C.

  • list: The type `list' is used for variables and return values of functions consisting of lists of strings. There are no list-constants. Instead, lists always have to be built run-time.

  • void: The type `void' is used only with functions, to indicate that these functions do not return values.

The types int, string and list are also used for defining variables and arguments. Icmake allows global variables and local variables. The declaration of a variable or an argument must state the type of the variable; a counter variable would be an int, while a variable containing the names of all files having extension `.c' would be a list.

Some of the built-in functions of icmake (see the section about icmake's functions) return a value of one of the types int, string or list. The returned value may be assigned to a variable of the same type or may be passed to another function.

Similarly to built-in functions, user-defined functions are assumed to return a value which is either int, string or list. The int type is the default. Functions may be defined as not returning a value. Such functions have the `void' returntype.

The definition of variables follows a C-like syntax. Arguments are defined as in ansi-C. An illustration of the use of types is found in the following listing. Note the use of the constants 55 and “main.c” (a string constant).

string myfun (int x, string y, list z)  // a
user-defined function
{       // of type string, having 3
      int       // parameters
          counter,      // local variables: 2 ints, i;    // 1 string
          and 1 list
      string
          name;
      list
          cfiles;
      counter = 55;     // counter is set to 55 name = "main.c";  //
      name is set to string main.c return (name);    // a string is
      returned to the
  }     // caller
4.3. Strings and escape sequences

Strings in makefiles are used to represent both filenames and displayed text. Icmake allows a number of special formatting sequences in strings to facilitate the display of text. These sequences are called, in analogy to the C programming language, escape sequences. Icmake recognizes the following escape sequences: Escape sequence Action

\a      alert (bell)
\b      backspace character
\f      formfeed character
\n      newline
\r      carriage return character
                tab
\v      vertical tab
\-other-        literal -other-, e.g., \\

Escape sequences in strings are identified by a backslash character \ followed by a character which identifies the escape sequence. Like C, Icmake allows string-concatenation. Long strings, extending over several lines of text, can be built by separating string constants by white-space characters (blanks, tabs, newlines).

4.4. The code of a makefile

This section discusses the user-defined functions which may appear in a makefile and also defines other syntactical constructs.

4.4.1. Flow control statements

Icmake recognizes six control statements:

  • if statements, including if-else

  • while statements

  • for statements

  • return statements

  • break statements

  • exit statements

The exit() statement, though a function in C, is part of the icmake language. The exit statement may be given an expression yielding an int. If an int expression follows, its value is returned as an int to the operating system. Otherwise, the returned value is undefined. The other flow control statements are analogous to the corresponding ones in the C programming language.

______________________

Webcast
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers

Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.

Learn More

Sponsored by AMD

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState