SRM(1)

NAME
srm - SR makefile generator

SYNOPSIS
srm [ options ] file.sr ... [ other files and libraries ]

DESCRIPTION

Srm generates a makefile (for use with make(1)) that builds an SR program from the given sr source files (.sr files), other files (.c, .o files), libraries (-llib), and archives (.a files).

Srm produces a makefile that uses sr(1) and srl(1) to compile, link, and execute the program described by the files and libraries listed on the command line. The generated makefile provides the following services:

make compile
    compiles without linking

make link
    links after a ``make compile'' (really the same thing as just ``make'')

make run
    executes the program (runtime arguments may be specified with the -R option)

make ls
    produces a list of the source files (e.g., ``pr `make ls`'')

make clean
    removes all artifacts of compilation except for the executable

make cleanx
    removes all artifacts of compilation including the executable (additional files may be specified for removal with the -Z option)

make make
    re-makes the makefile as per the original instructions (useful if the resource import graph changes and the makefile needs to reflect the new dependencies)

The default makefile name is Makefile, and thus the command ``make'' executes it. The makefile name can be changed using the -f option. As a safety feature, srm refuses to overwrite an existing file that it did not create.

The default executable name is a.out. This can be changed using the -o option.

Srm attempts to determine the main resource (for linking purposes) by analyzing the source files and selecting the first resource it finds that is imported by the least number of resources. If some other resource is to be the main resource, it should be specified with the -m option.

Srm takes a number of option flags, which are specified in arguments beginning with a hyphen. The following options are recognized:

-f mfile
    Name the makefile mfile instead of Makefile. A file name of ``-'' directs the makefile to standard output.

-I dir
    Use dir/Interfaces as the Interfaces directory instead of ./Interfaces.

-o ofile
    Use ofile for executable output instead of a.out.

-c compiler
    Use compiler instead of the default compiler.

-m res
    Use the specified resource as the main resource. The default is the first resource found that is imported by the fewest number of resources.

-v  Display interesting information while building the makefile.

-w  Output wide makefile lines instead of limiting to 78 columns.

-C opts
    Include opts in the list of options passed to the compiler sr(1).

-L opts
    Include opts in the list of options passed to the linker srl(1).

-R args
    Include args in the list of arguments passed to the executable by ``make run''.

-Z files
    Include files in the list of files removed by ``make cleanx''.

EXAMPLES

srm *.sr
    no options, all .sr files in current directory

srm -m main -o x a.sr b.sr
    the main resource and executable name are specified

srm -C "-q -O" a.sr b.sr
    flags are passed to sr(1)

srm a.sr b.sr c.o -ll r.c -lm
    objects, libraries and C sources listed are passed on to srl(1) to be linked in with the sr program.

ENVIRONMENT

SRMOPTS
    The environment variable SRMOPTS may contain srm options to be processed ahead of explicit options.

SR_PATH
    Srm searches for resources and object files by looking first in the current directory, then in the Interfaces directory, and finally in the SR library. (Items found somewhere other than the current directory are included in the makefile as srl arguments but not as dependencies.) If SR_PATH is set, any directories named there are checked ahead of the standard search sequence. Directories in SR_PATH are separated by colons (:).

FILES
Makefile    generated makefile
file.sr    SR source file
a.out    executable program
Interfaces/component.o    object file
Interfaces/resource.spec    export information

SEE ALSO
sr(1), srl(1), make(1)

DIAGNOSTICS
Srm uses the sr compiler to obtain dependency information. In addition to the syntax errors detected by the compiler, srm detects missing resource/global specifications and duplicate spec/body definitions. Warnings are issued if a resource or global has no body or a resource that is not the main resource is not imported by any other resource.

CAVEATS

Omitting srm's initial s can have disastrous results.

Srm doesn't escape shell meta-characters in the makefile.

If the main resource is imported by others, the -m option will probably be required to produce a correct makefile.