-> Note: this file is a template used by the Perl script 'get_contents'. -> get_contents reads this file and the CONTENTS files in each -> subdirectory then creates the new_developer.html file by -> populating the "Where does your code belong" section. -> Albert Danial Jan 2 2002 Octave-Forge Developer's Notes
GNU Octave Repository

Home |  Summary |  Forums |  Bugs |  Support |  Patches |  Lists |  Tasks |  Docs |  Surveys |  News |  CVS |  Files

Contributing Code to the Gnu Octave Repository

Requirements

To contribute your .m files, C++, C, or Fortran code to the Octave Repository you need to The first two requirements are easy but may take a few days. If you don't already have one, request a SourceForge (SF) account here. To become a developer on octave-forge (octave-forge is the CVS project name of the Gnu Octave Repository) simply email a request to one of the octave-forge administrators: cgijobs@users.sf.net, joolean@users.sf.net, or pkienzle@users.sf.net. Include a bit of information about the code you plan to submit. Finally, if your computer runs linux or FreeBSD, chances are good that both ssh and CVS are already installed on your system. If they aren't, you will need to find prebuilt packages for them or download their source codes and build them.

Create a SF home directory

If you've never submitted code to a SourceForge project before, create your home directory by logging onto the octave-forge account with ssh:

   $ ssh -l sflogin  cvs.octave.sourceforge.net
   Password:  your SF password
Although SF will only show you a message-of-the-day screen then log you out, this process has the useful side effect of creating a home directory for you if one doesn't already exist. Some CVS commands will fail if you do not have a home directory on SF.

Download the latest octave-forge distribution

CVS expects the code you plan to submit to reside in a directory within the existing octave-forge directory structure. You will therefore need to download a copy of the latest octave-forge distribution to work in. Change directories to a place you want to put the code, then issue the CVS checkout (abreviated as 'co') command:
   $ cd working_directory
   $ export CVS_RSH=ssh
   $ cvs -d:ext:sflogin@cvs.sourceforge.net:/cvsroot/octave co octave-forge

Where does your code belong?

Put your file(s) in a subdirectory under the octave-forge/ directory. Here are some guidelines to help you decide where your code belongs:

Add a copyright notice

Each file in octave-forge must contain a copyright notice. If you wish to release your code under the GNU GPL , insert the following text at the top of your file:

## Copyright (C) year   Your Name   <your@preferred.email>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Here are other popular open source licenses: Consult opensource.org. for a comprehensive list of Open Source licenses.

Package structure

package/NOINSTALL
don't install this package; the user can rename or delete this file if they want the package installed anyway.
package/*.m
m-files for the package; these will be installed in site/mfiles/octave-forge/package
package/data/*
datafiles to be installed with the mfiles. You can accesses them from your m-files with x = file_in_load_path("a").
package/Makefile
Makefile with a default target to build anything that needs building, an optional "install" target in case you need to install something other than m-files, oct-files, data files or octave binaries, and a "clean" target to remove everything that has been built. See below for details.
package/configure.add, package/Makeconf.add
Additional configuration-time commands to run in order to find all the components that your package requires. You can look for anything you want in configure.add and note what you need in Makeconf.add. The definitions in Makeconf.add will be available when you include ../../Makeconf in your Makefile. See main/symbolic for an example.
package/*.oct
oct-files built by Makefile. These will be installed all together in site-oct-files/octave-forge. You may assume that HAVE_OCTAVE_20 is defined for 2.0.x series mkoctfile, and HAVE_OCTAVE_21 is defined for 2.1.x series mkoctfile.
package/bin/*
executable files built by Makefile. These will be installed in Octave's EXEC_PATH, so they will be available from Octave but not from the shell. You have two options regarding this directory. The better one would be to make sure that the directory exists before you try building the binary. The other option is to have a hidden bin/.keepdir so that CVS won't delete it for you automatically.

Adding a Makefile

If your package has something other than m-files you will need a Makefile in your directory. This could be as short as three lines:
include ../../Makeconf
all: f1.oct
clean: ; -$(RM) *.o core octave-core *.oct *~

If you define multiple DEFUN_DLD's in a file, you may need to use symbolic links in order for Octave to find them:

include ../../Makeconf

# extra functions defined in fn.oct
fn_LINKS=fn2.oct fn3.oct

# all compiled functions
PROGS=fn.oct $(fn_LINKS) gn.oct

all: $(PROGS)

$(PROGS): Makefile

$(fn_LINKS):
	-$(RM) $@
	$(LN_S) fn.oct $@

clean: ; -$(RM) *.o core octave-core *.oct *~

The "include ../../Makeconf" line above includes all of the definitions that were created during configuration. This includes things like MKOCTFILE, as well as implicit rules for compiling oct-files. See Makeconf.base for a list of predefined variables and rules. Sometimes you will see "sinclude ../../Makeconf". This is for packages which can be compiled independently of Octave-forge. If Octave-forge is configured, then the variable OCTAVE_FORGE will be defined.

Even more complicated makefiles are sometimes necessary, particularly when the package depends on external libraries. See main/symbolic/Makefile for an example. The external libraries must be found during configure so main/symbolic/configure.add provides detection rules. The results are posted in main/symbolic/Makeconf.add, and will be available during make.

Please try to keep compatibility with older versions of Octave. The main configure script tests for features that have changed since octave-2.1.36. The tests are done in such a way that conditions are only defined if you are using an older version of octave. That way if the tests are not performed and the conditions are not defined, support defaults to the newer version of octave. The following conditions are defined in configure.base:

HAVE_SLLIST_H
subsref changed from using SLList to using std::list. To support older versions of octave, use:

#ifdef HAVE_SLLIST_H
#define LIST SLList
#define LISTSIZE length
#define SUBSREF_STRREF
#else
#include <list>
#define LIST std::list
#define LISTSIZE size
#define SUBSREF_STRREF &
#endif
...
  octave_value subsref (const std::string SUBSREF_STRREF type,
                        const LIST<octave_value_list>& idx) {
	...
  }
  octave_value_list subsref (const std::string SUBSREF_STRREF type,
                             const LIST<octave_value_list>& idx,
                             int nargout) {
        ...

     if (idx.LISTSIZE () > 1)
        ...
  }
NEED_OCTAVE_QUIT
signal handling changed from longjump to C++ exceptions. To support older versions of octave, use:

#ifdef NEED_OCTAVE_QUIT
#define OCTAVE_QUIT do {} while (0)
#define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
#define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
#define octave_throw_bad_alloc() \
   do { jump_to_top_level(); panic_impossible(); } while (0)
#else
#include <octave/quit.h>
#endif
USE_OCTAVE_NAN
octave_NaN and octave_Inf constants were converted to functions. To support older versions of octave, use:

#ifdef USE_OCTAVE_NAN
#define lo_ieee_nan_value() octave_NaN
#define lo_ieee_inf_value() octave_Inf
#endif

m-file support across multiple versions is tricky. Sometimes try/catch will help, but for syntax changes you will need some sort of preprocessor, such as awk or sed.

Submit your code!

You are now ready to upload your code to the Gnu Octave Repository. Do this with two CVS commands--one to add a new entry for your file in the octave-forge catalog, and a second command to actually upload the file:
   $ cvs add files
   $ cvs commit files
After hitting the carriage return at the end of the commit command, CVS will open your default editor so that you can enter comments about the commit. The first time you commit a file the comment might be something as simple as `Initial commit into CVS.' However, for all subsequent commits please add meaningful comments that explain why changes were made to the file since all comments will appear in the changelog. Try to gather related changes into one commit command.

Aside: the default editor can be defined like so:

   $ export EDITOR=vim

If you are uploading an entire package, then put your directory into the octave-forge tree and do the following:

   $ cd octave-forge/main
   $ cvs add package
   $ cvs commit package
   $ cd package
   $ cvs add *
   $ cvs commit *
You may find it easier to use the import command, especially if your package contains subdirectories. In this case, you should not put your directory into the octave-forge tree. Instead, change to the root of your package tree and enter the following:
   $ cd package
   $ cvs -d:ext:sflogin@cvs.octave.sourceforge.net:/cvsroot/octave import -m "package name" octave-forge/main/package sflogin start
You can then fetch the new package from octave-forge as follows:
   $ cd octave-forge
   $ cvs -q update -d

From time to time, you will need to synchronize with CVS:

   $ cd octave-forge
   $ cvs -q update -d
Each file will be listed with one of the following codes:

Learn more about CVS

The few CVS commands shown here just scratch the surface of this powerful versioning package. If you become an active contributor you will benefit from learning more CVS commands and understanding how CVS works. The CVS Book is a great place to begin your exploration.

Join the developers' mailing list

Finally, consider joining the octave-forge developer's mailing list. It is very low traffic. It is used to announce pending releases of octave-forge and discuss issues related to working with octave-forge. Discussion of the functions in octave-forge mostly occurs on the primary octave mailing lists.

Hosted by
SourceForge.net Logo