Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: makefiles Up: System generation Previous: makedefs

Subsections



makedefs adjuncts

Per-sourcefile makedefs definitions.

Description

The app, imp, ftn and tst makefiles (§10.6) look for and, if found, include an adjunct makedefs (p[*]) file which may contain definitions (or, in principle, rules) which apply to a particular source code directory. The adjunct files are architecture-specific and are primarily intended to control compiler options on a per-sourcefile basis.

The adjunct files reside in $INSTARCH (see §1.2) and have names of the following form

                           Form                       Examples
            ---------------------------------   ---------------------
   imp      <package>[-<module>].defs           aips.defs
                                                aips-Tables.defs
   tst      <package>[-<module>]-test.defs      aips-Tables-test.defs
   ftn      <package>-fortran[-<module>].defs   aips-fortran.defs
   app      <package>_<app>.defs                aips_gtable.defs

As a simple example of the use of a makedefs adjunct, the applications makefile uses a variable called BIN as a hook to allow conditional compilation of an application. If BIN is set to blank in an adjunct file for a particular architecture then compilation of that particular application will be skipped during a recursive system build.

The following adjunct makedefs decreases the optimization level for TSMCube.cc for the GNU C++ compiler running under OSF/1. The file, $(AIPSCODE)/install/alpha_gnu/aips-Tables.defs, is included by the implement makefile, and it illustrates the general scheme:

   # Switch off optimization for TSMCube.
 
   LVL  := $(C++OPTLVL)
   LVL0 := -O0
 
   TSMCube := 0
 
   C++OPTLVL = $(LVL$($*))

Although this is a non-trivial construct the general form should be easy to follow. The operative part is the last line in which C++OPTLVL, a recursively expanded makedefs variable which determines the C++ optimization level, is evaluated as a ``computed'' variable within the pattern rule which compiles TSMCube.o from TSMCube.cc:

1.
Within the pattern rule, $* is an ``automatic'' variable which evaluates to the stem with which the pattern rule matches, in this case TSMCube. After the first round of translation C++OPTLVL would be set to $(LVL$(TSMCube)).

2.
$(TSMCube) is evaluated in the second round of translation after which C++OPTLVL would become $(LVL0).

3.
The required result, C++OPTLVL = -O0, is achieved after the third round of translation.

For any other source file in the $(AIPSCODE)/aips/implement/Tables/ directory, say Table.cc, the sequence would be as follows:

1.
After the first round of translation C++OPTLVL would be set to $(LVL$(Table)).
2.
In the second round of translation $(Table) is undefined and evaluates to an empty string whence C++OPTLVL would become $(LVL).
3.
After the third round of translation C++OPTLVL is set to its original value by virtue of the simply expanded variable assignment of LVL at the start of the adjunct makedefs.

The default case relied on Table being undefined as a makefile variable. This is a safe assumption since makefile variable names are case-sensitive and while AIPS++ source file names contain a mixture of upper- and lower-case characters, the makedefs and makefile variables in AIPS++ are all upper-case.

The makedefs variables which specify debug or optimization flags for the various compilers are

C++DBGLVL
...C++ debug flags
C++OPTLVL
...C++ optimization flags
CDBGLVL
...C debug flags
COPTLVL
...C optimization flags
FCDBGLVL
...FORTRAN debug flags
FCOPTLVL
...FORTRAN optimization flags

These variables are not used directly in the makefiles but are instead used as components in the definition of variables which contain all of the compiler flags. An imporant prerequisite for this system is that these variables, namely C++DBG, C++OPT, CDBG, COPT, FCDBG, and FCOPT, be recursively expanded. This also applies for the programmer compilation option variables C++FLAGS, CFLAGS, and FCFLAGS.

See also

The GNU make manual.
The GNU manual page for gmake.
AIPS++ variable names (§1.2).
gmake (p[*]), GNU make.
makedefs (p[*]), AIPS++ makefile definitions.
makefiles (p[*]), GNU makefiles used to rebuild AIPS++.


next up previous contents index
Next: makefiles Up: System generation Previous: makedefs   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15