Initialize a S-PLUS Chapter and Create a Makefile for User Code

DESCRIPTION:

Initializes a directory for use with S-PLUS, and, optionally, creates or updates a makefile to go with user-contributed C, C++, Fortran, Ratfor, or S-PLUS code and SGML help files. The generated makefile contains rules for compiling code for subsequent dynamic linking with S-PLUS. This makefile is portable across most UNIX platforms on which S-PLUS is supported. It is appropriate for creating a new library section or a new chapter.

USAGE:

Splus CHAPTER [-m] [-d dir] [-type Windows|DOS|Unix] [-u] 
      files.{cfro} files.cc|cxx|C|cpp|q|sgml

OPTIONAL ARGUMENTS:

-m
suppresses creation or update of the makefile. By default, a makefile is created for any C, C++, Fortran, Ratfor, S-PLUS, or SGML help files detected in the current directory. If you run CHAPTER in a new directory, no makefile is created.
-d
create a new S-PLUS chapter in directory dir, making the directory if necessary.
-type
create the S-PLUS mapping file appropriate for the specified platform type, Unix or Windows. (DOS is an accepted synonym for Windows.) If type is omitted, CHAPTER creates the mapping file for the current operating system. Use type=Windows to create the most portable chapters; this option creates a mapping file ___nonfi that uses the more restrictive Windows naming conventions to determine which objects are name-mapped.
-u
create the directories __init and __prev used by the undo function.
files
names of source, object or help files. The suffixes c, f, r and o refer to C, Fortran, Ratfor, and object code, respectively. The suffixes cc, cxx, C, and cpp are for C++ files, the suffix q is for S-PLUS files, and the suffix sgml is for SGML help files.

SIDE EFFECTS:

A makefile is written in the current directory. Nothing is compiled. Use Splus make to compile a target.

DETAILS:

The primary purpose of the CHAPTER utility is to set up the S-PLUS chapter. If the chapter contains source code, you can also use the CHAPTER utility to create a makefile. This file contains targets and rules, meaningful to the make program, to do several things which relate to integration of new code into S-PLUS. Such code will be generated from source code according to the S-PLUS compile rules of the target platform (the platform on which make is run), regardless of the platform on which CHAPTER prepared the makefile. When running make on a makefile created with CHAPTER, you must have the environment variable SHOME set correctly. Calling make as an argument to your usual S-PLUS script, as in Splus make, ensures that SHOME is set correctly. You will typically have to change very little before using the makefile to compile and integrate the code. If a makefile or Makefile already exists, CHAPTER will create a backup copy named [mM]akefile.before before modifying the file.

To create a CHAPTER, type

$ Splus CHAPTER

from a shell. This creates an S chapter in your current directory.

The CHAPTER command creates a subdirectory .Data to hold S objects and generates a makefile including rules to dump and restore the chapter, and optionally to compile subroutines to be linked with S.

To make an archival record of your data, run the S function

dumpChapter()

This generates a file called DUMP_FILES which contains the names of all the files you need to archive the chapter. Now, you can create an archive by using a shell tool. For example,

tar cf myChapter.tar 'cat DUMP_FILES'

To regenerate a chapter on another machine, type

$ Splus CHAPTER

which creates a data directory for chapter. Then, boot the chapter contents:

$ Splus make boot

If you have C,C++, or Fortran code shipped with the chapter, type

$ Splus make S.so

to create a shared object S.so that is automatically linked when the new chapter is attached.

SEE ALSO:

, , .

EXAMPLES:

$ mkdir myfuns 
$ cd myfuns 
$ cat > hello.c 
# include <stdio.h> 
void 
hello(char** name) 
{ 
     fprintf(stderr, "Hello, %s!", *name); 
} 
$ Splus CHAPTER hello.c 
$ Splus make 
$ Splus 
> .C("hello", "John Doe")