mdev: Maple DEVelopment tool
This file presents the Perl script
mdev. This script is designed to help
the development of Maple packages
by providing a programming environment and a few tools, such as
a simple preprocessor and a makefile.
With mdev, it is not necessary to know
how the Maple packages work.
Just enter the Maple functions and
variables of your package. mdev
creates the file that implements the package and takes care
of the Maple archives (including the
variable libname, provided that you have
the standard Maple initialization file
.mapleinit in your home directory. If not,
then create such an empty file).
Note: in order to make mdev work, you
must follow a few conventions that are
described further in this file.
Get and install the script
The source file of the script
mdev can be found
here. Copy this
file, add the symbolic link mdev into some
directory that is in your $PATH. In the
source file, edit the variable $COPYRIGHT.
Programming environment
The script mdev assumes that you have
somewhere in your file system a directory named
maple
.
Within this directory, a programming environment for the
package MyPack is created by
invoking the command mdev -t MyPack.
This command creates the following directories and files.
- MyPack/src: this is where the
.mpl source files should go;
- MyPack/src/TODO: empty file,
the things that remain to be done are listed here;
- MyPack/src/todo: empty directory,
this is where files that need to be worked further should go;
- MyPack/src/trash: empty directory,
this is where you put your trash files;
- MyPack/src/description.mpl: this
.mpl file should contain the
description of the package; it is included in the file that
implements the package;
- MyPack/src/macros.mi: this file contains
a few default Maple's preprocessor macros;
it is included in the file that implements the package;
- MyPack/src/license: empty file, this
is where the license text should go; this text is commented and
included in the file that implements the package; this may be
a symbolic link to
MyPack/LPGL-license;
- MyPack/src/lastversion: file containing
the version numbers. The major version number is to be set manually,
while the minor version number is automatic;
- MyPack/doc: this is where the
.mws documentation files should go;
- MyPack/doc/makedoc.mpl: this file
maps the help topics to the .mws
files and it is used to build the maple.hdb
file;
- MyPack/old: this directory contains the
backups;
- MyPack/release: this directory contains
the Maple archive and it is added to
the variable libname;
- MyPack/test: this is where you do
your tests;
- MyPack/function-header.mpl: this
file gives a prototype of header for writing the
Maple code;
- MyPack/LGPL-license: text of the
GNU LGPL licence.
This programming environment has been designed such that it
is convenient to work with and that the code is clearly
organized.
Writing the source code
The code processed by mdev
must be enclosed in a block.
A block starts by the tag #<<<
and ends by the tag #>>>
; both tags must be put at
the beginning of a line. Anything outside a block is
ignored. mdev knows a few
keywords, which are described below. All keywords
start by the special symbol @ and
must be put in a comment, since
they are not part of the Maple
syntax, and within a block.
Function
The source code of a function is to be put into a block.
The name of the function is determined to be the first name
that is assigned to a procedure, and that is not in a comment.
The scope of a function within the package is, by default,
local. The keyword
@scope allows to set the
scope of the function.
- @scope=local: the function is declared
local within the package;
- @scope=export: the function is declared
export within the package;
- @scope=global: the function is declared
global within the package;
- @scope=extern: the function is not
part of the package, but it is available as a global function.
The keyword @load specifies that the
corresponding function is used for the initialization of the
package.
The keyword @noinclude instructs the
script not to include the function in the package.
Variable
The variables can also be scoped. The following instructions
only declare the variables;
initialization can be done by @rawinclude.
- @sharevar=MyVar: the variable
MyVar is
declared local within the package;
- @globalvar=MyVar: the variable
MyVar is
declared global within the package.
Miscellaneous
Other keywords are listed below.
- @exit: the script will not process
till the end of the file;
- @rawinclude: the block is put at
the end of the file that implements the
package; this instruction
is mainly used to initialize variables;
- @macro: should be used with
@rawinclude; put the block at the
beginning of the file that implements the
package.
Script invokations
The script mdev supports the following
invokations.
- mdev
[-h
| --help]: display a help on
mdev;
- mdev -b | --backup
: backup the source directory;
- mdev -d | --debug
[AnotherPack]: create the file that implements the package in
debug mode (all members are exported) and update the library
associated to the package AnotherPack, or
the library of the current package if not specified;
- mdev -D | --documentation
[AnotherPack]: update the library
maple.hdb that is associated to the package
AnotherPack, or
the library of the current package if not specified;
- mdev -l | --library
: recreate the Maple library of
the current package; this feature is present because
Maple libraries may crash sometimes;
- mdev -m | --make
[AnotherPack]: create the file that implements the package
and update the library
associated to the package AnotherPack, or
the library of the current package if not specified;
- mdev -t | --template
MyPack: create the programming
environment for the package called MyPack;
- mdev -v | --version
: read read the version number of the current project.
Note: the possibility of updating libraries
of other packages is interesting for preparing a software
distribution that gathers several packages.
Example
The example below shows the sequence of instructions for
writing a simple package.
> pwd
$HOME/maple # must be in the maple directory
> mdev -t MyPack # create the programming environment
> cd MyPack/src
> xemacs myfunction.mpl # edit the function 'myfunction'
> mdev -m # create the package and update the archive
> maple
|\^/| Maple 8 (DEC ALPHA UNIX)
._|\| |/|_. Copyright (c) 2002 by Waterloo Maple Inc.
\ MAPLE / All rights reserved. Maple is a registered trademark of
<____ ____> Waterloo Maple Inc.
| Type ? for help.
> with(MyPack);
[myfunction]
LM, Created: 05/31/03 - Last update: 10/14/03