Документ взят из кэша поисковой машины. Адрес оригинального документа : http://acat02.sinp.msu.ru/presentations/huhlaev/Metamake.doc
Дата изменения: Mon Jul 15 15:15:36 2002
Дата индексирования: Mon Oct 1 20:18:23 2012
Кодировка:

Metamake - Tools for Personal Project Making in Network Heterogeneous
Environment.


Eugene Huhlaev

Keldysh Institute of Applied Mathematics

Russian Academy of Sciences

huh@keldysh.ru


Abstract

Considered is preparation of personal projects in heterogeneous
network environment with automatic job distribution between target hosts.
The main problems posed by project portability are: file location,
automatic generation of make-file, source code portability. Proposed
technology allows locating files in transparent network file system and
writing portable Imake-files using CPP-macroses incapsulated architecture-
dependent features of compilation and linking. This technology is intended
for automatic preparation of simple personal computational projects and
does not require complicated constructions.
The technology is implemented by "metamake" program. Like ordinary
make, metamake keeps platform-dependent files (object, executables,
libraries) for repeated usage. To use the metamake, one must define basic
project directories (task directory, target root, object directory etc)
and prepare two simple files: task-file that contains common project
settings (selected compilers, common system libraries etc) and architecture-
independent Imake-file which includes project description along with
compiler and linker directives. In most cases, as long as mere generation
of user's executables and libraries is required, Imake-file will only
include the source file list and several simple CPP-macroses.
Environment

. Network geterogeneous environment consists of hosts with different
architecture


. Transparent network file system with direct access and homogeneous naming
(TFS)


. Automatic job distribution between hosts with different architecture


Problem formulation


. Automatic project making (preparation of executables and libraries) from
source files according to target host architecture


. Keeping of platform-dependent intermediate (object, archive libraries)
and target (executables, shared libraries) files for repeated using by
make program


. Simple personal computational project consisting of only several
executables and shared libraries


Project portability problems

1. Displacement of project files (source, intermediate, target) within TFS


2. Portability of makefile according to file displacement, compiler
options, common system libraries, system utilities


3. Program files portability
Basic project directories

1. Task directory - project definition and default project root (is
defined by user)


2. Source files directory - arbitrary displacement in TFS (by user)


3. Target root - common for all platforms (is defined by user)


4. Target platform denotation - platform discriminant (is defined by
metamake automaticly)


5. Target platform directory - under target root with platform
discriminant (is defined by metamake automaticly). It is intended for
executables, libraries and other platform-dependent files. If user
wants he may to create subdirectories under target platform directory
(bin, lib etc).


6. Object directory - under target platform directory - is intended for
generated makefile and object files. It is current directory for make
running.


[pic]

Using metamake

4. metamake options - set basic project directories and project definition
files (task-file, imake-file)


5. Task-file - common project settings


6. Portable Imake-file - project composition and compilation-linking
directives


7. Run metamake - automatic generation and running makefile(s) that
prepares target file(s) according to target platform


8. Target file(s) running


Installation and mastering of metamake

9. To install metamake is necessary:


- to have imake

- to edit host definition file with definition of several symbolic
denotation


10. To master metamake is quite enough:


- to learn several symbolic denotations

- to learn several simple metamake directives


Project definition files

7. Task-file + Imake-file


8. Make-language with CPP-directives (including conditional compilation)
in style of imake


9. Reserved make-variables (basic project settings by user)


10. Predefined make-variables (from metamake options)


11. Predefined constant CPP-macroses (properties of target platform and
selected compilers - are setting in the time of metamake installation).
Macro platformArch is defined for target platform. For example macro
hpuxArch is defined for HP-UX. This macro may be used in directive #if
taking into account non-portable platform features.


12. Metamake directives - CPP-macroses with parameters (are intended to
prepare target files)

Using Imake program

It is impossible to direct using CPP to generate makefile, because:

13. Make's comments (#...) confict with CPP directives


14. CPP merges many-string macroses into single string, while every
makefile string begins with new line


15. CPP replaces "tab" symbol => "space" symbol, while "tab" is the most
main symbol of makefile

Metamake uses imake to run CPP only. All task definition files should be
written in style of imake
Metamake options

metamake [+Ttask-directory] [+Rtarget_root]

[Oobject_directory] [+t taskfile]

[+f imakefile] [+s makefile] [-Dname[=value]]

[-Idir] [make_parameters]

Here

+Ttask_directory defines task directory (full path available as $(TASKDIR))


+Rtarget_root defines target root (full path available as $(PLATFROOT))


+Oobject_directory defines path relative to target directory to displace
object files (full path available as $(OBJDIR))

+t taskfile defines task-file name

+f imakefile defines imake-file name

+s makefile defines generated makefile name, transferred to make program


-Dname[=value] and -Idir are transferred to imake program for processing of
task-file and imake-file


Make-parameters are transferred to make program


Predefined make-variables $(TASKDIR), $(PLATFROOT), $(OBJDIR) are available
within task-file and imake-file. Platform discriminant (as $(PLATF)),
target directory (as $(PLATFDIR)) are available as well.
Task-file - common project settings

16. Set of reserved make-variables

FC, CC, LD, MAKE - selected compilers, loader, make

F_OPTS, C_OPTS, LD_OPTS - common options of compilers and loader

LIB_OPTS, INC_OPTS - search options for system libraries and including
files

USER_LIB_OPTS, USER_INC_OPTS - search options for user's libraries and
including files

17. Symbolic denotations for allowed values of reserved make-variables:
$(FORT77), ($FORT90), $(CC_POSIX), $(CC_ANSI), $(CC_GNU), .

18. Definition of user's CPP-macroses and make-variables


Portable Imake-file - project composition

and compilation-linking directives

11. Definition of source file lists


12. Definition of archive and shared libraries


13. Using predefined and reserved CPP-macroses and make-variables


14. Metamake compilation-linking directives - portability is provided by
metamake


15. Arbitrary hand-made target rules - portability is provided at user's
risk
Basic metamake directives

Compilation-linking directives are portable CPP-macroses.

To prepare executables by Fortran:


FC_CreateProgram(target, dep, srcdir, srclist, libes)

To prepare archive library by Fortran:


FC_CreateArchLib(target, dep, srcdir, srclist)

To prepare shared library by Fortran:


FC_CreateShLib(target, dep, srcdir, srclist)

Here:

target - full path of executable or library file (makefile target)
dep - additional dependent list (besides source files)
srcdir - root directory of source files
srclist - make-variable name with source file list relative to srcdir
libes - list of system and user libraries (-l options)

By C: FC => CC; by C++: FC => CXX

Metamake directives besides compilation-linking rule generate rule with
target "depend::" for automatic creating dependents from h-files by means
of "makedepend" utility
[pic]

Task-file example

# ------ compilers
FC=$(FORT77)
# ------- common compiler options
F_OPTS=$(F_LOCOPT)
# system includes and libraries
INC_OPTS=$(OpenGL_INC)
LIB_OPTS=$(OpenGL)
# -- User's definitions --
SRCDIR=$(TASKDIR)/src
INCDIR=$(TASKDIR)/include
LIBDIR=$(PLATFDIR)/lib
BINDIR=$(PLATFDIR)/bin
USER_LIB_OPTS=-L$(LIBDIR)
USER_INC_OPTS=-I$(INCDIR)
# -------- task definition for HPUX ---------
#ifdef hpuxArch
TARGET_CPU=1.1
F_OPTS=+O2
#endif
Imake-file example

USER_ARCH=$(LIBDIR)/libarch.a
USER_SHLIB=$(LIBDIR)/libshared.$(SHL)
EXE=$(BINDIR)/progtst
LIBES=-larch -lshared
SRCS=tst.f
SRCSHLIBS=shlib/sh1.f shlib/sh2.f
SRCARCHS=arch/s1.f arch/s2.f
all:: $(LIBDIR) $(BINDIR) $(USER_SHLIB) $(EXE)
$(EXE)
$(LIBDIR):
mkdirhier $(LIBDIR)
$(BINDIR):
mkdirhier $(BINDIR)
# ----- Creation of progtst -----
FC_CreateProgram($(EXE),$(USER_ARCH),$(SRCDIR),

SRCS,$(LIBES))
# ----- Creation of shared library -----
FC_CreateShLib($(USER_SHLIB),NullParameter,

$(SRCDIR),SRCSHLIBS)
# ------ Creation of archive library -----
FC_CreateArchLib($(USER_ARCH),NullParameter,

$(SRCDIR),SRCARCHS)


-----------------------










.

obj

obj

linux.

hpux.

$(OBJDIR):

$(PLATFDIR):

$(PLATFROOT):

Platform-dependent directories tree

within TFS










.

.