# Creating Packages with install.rb/setup.rb

## install.rb -- the Single Package Installer

install.rb can handle one set of ruby scripts, ruby extentions, commands, and data file. Call them a "package". install.rb requires that the archive is structured like this:

>     package-top/
>         install.rb
>         lib/
>             ruby scripts
>         ext/
>             ruby extentions
>         bin/
>             commands
>         data/
>             data files

Each file/directories acts as below:

`install.rb`

  The installer core. This file is included in this archive. Just copy it to the archive.

`lib/, bin/, data/`

  These directories includes data files which are to be installed. This directory tree is mirrored to the target directory, from `lib/` to `RUBYLIB/`, from `bin/` to `BINDIR/`, from `ext/` to `RUBYLIB/ARCH/` ....

  Use `lib/` for ruby scripts, `bin/` for commands, `share/` for any other data files.

`ext/`

  `ext/` includes ruby extentions. If you want to install `RUBYLIB/ARCH/someext.so`, create a directory `ext/someext/` and put source files into it.

  [WARNING] All extention source directories MUST include the file "MANIFEST". install.rb will complies directries only if the directries contains MANIFEST.

## setup.rb -- the Multiple Package Installer

setup.rb can handle an archive which includes multiple packages. "package" means a set of install.rb's archive.

setup.rb requires this type of structure:

>     package-top/
>         setup.rb
>         packages/
>             tmail/        (tmail package)
>     	    lib/
>     	    ext/
>     	    bin/
>     	    data/
>             raccrt/       (raccrt package)
>                 :
>             strscan/      (strscan package)
>                 :
>             amstd/        (amstd package)
>                 :

## Hooking Tasks

You can hook any tasks, such as "config" "setup". For example, you want to make some files in `lib/tmail/` when setup. Then create file `lib/tmail/pre-setup.rb` and put this:

>     # pre-setup.rb

>     # process grammer file
>     system "racc #{srcdir_root + '/src/mp.y'} -o mailp.rb"

>     # require all ruby scripts in this directory from _loadlib.rb.
>     list = Dir.glob(curr_srcdir + '/*.rb').collect {|n| File.basename(n) }
>     File.open( '_loadlib.rb', 'w' ) {|f|
>       f.puts list.collect {|n| "require 'tmail/" + n + "'" }
>     }
>     File.open( '../tmail.rb', 'w' ) {|f|
>       f.puts "require 'tmail/_loadlib'"
>     }

This file is evaluated on task "setup" in the directory, before processing any other thing. Acceptable hook file name is:

>     {pre,post}-{config,setup,install,clean}.rb

[NOTE] You can also put hook files in the top directory of archive and/or the type-root directory (`bin/`, `lib/`,...).

## srcdir/objdir support

install.rb/setup.rb supports srcdir/objdir. In other words, you can compile everything out of the source directory.

If you write hooks, you should supports srcdir/objdir system. When you read source code, read it from srcdir. When you write anything, write it to the current directory. There's also some APIs to help your work. see Hook Script APIs Reference Manual

## metaconfig

You can add new config entries by writing file "metaconfig". metaconfigs must be placed in the package-root directory.

Here is a simple example of metaconfig.

>     add_path_config 'libc', '/lib/libc.so', 'path to the C standard library'
>     add_bool_config 'win32', false, 'compile with Win32 support'

This script defined new config option --libc and --win32.

In `metaconfig`, you can use some APIs described in metaconfig API Reference Manual

## License

GNU Lesser General Public License (LGPL) version 2. For details, see file "LGPL".

NOTE: You CAN distribute your program under the any licenses you like. LGPL does NOT force you to make your programs LGPL if the installer is LGPLed one.

## Installation Manual

You can freely copy/edit and/or distribute my usage.{txt,html} documents which included in this archive. I do not claim any rights to them. Removing my copyright is also OK.