<!--
  - Authors:
  -   Christian Schulte <schulte@ps.uni-sb.de>
  -
  - Copyright:
  -   Christian Schulte, 1998
  -
  - Last change:
  -   $Date: 1999/12/13 18:31:10 $ by $Author: kornstae $
  -   $Revision: 1.12 $
  -
  - This file is part of Mozart, an implementation
  - of Oz 3
  -    http://www.mozart-oz.org
  -
  - See the file "LICENSE" or
  -    http://www.mozart-oz.org/LICENSE.html
  - for information on usage and redistribution
  - of this file, and for a DISCLAIMER OF ALL
  - WARRANTIES.
  -
  -->

<Chapter id="chapter.deployment" proglang=sh>
  <Title/Application Deployment/


  <Section id="Section.Deployment.Linking">
    <Title/Linking Functors/

    <P>
      Application development can be considerably eased by splitting
      the application in a large number of orthogonal and reusable
      functors. However, deployment of an application gets harder in
      the presence of a large number of functors:
      <List enum>
        <Item>Installing the application requires correct installation
        of a large number of functors.
        <Item>Execution might be slow due to frequent file- or even
        network accesses.
      </List>
    
    <P>
      The commandline tool <Kbd/ozl/ eases deployment by creating a
      new functor that includes imported functors in a prelinked
      fashion: it is possible to collapse a collection of functors into
      a single equivalent one. The model that should be kept in mind,
      is that the newly created functor employs an internal, private
      module manager that executes the toplevel
      application functor together with all included functors.

    <P>
      The linker can be invoked on the input functor <Var/In/ in order
      to create an output functor <Var/Out/ as follows:
      <<<ozl <Var/In/ -o <Var/Out/>>>

    <p>
      For example, from the pickled toplevel functor <file/LMF.ozf/ a
      new functor can be created as follows:
      <<<ozl LMF.ozf -o LMF.oza>>>
      where the pickled functor <file/LMF.ozf/ is created by
      compilation as follows:
      <<<ozc -c LMF.oz -o LMF.ozf>>>

    <p>
      Now the newly created pickled functor <file/LMF.oza/ can be
      installed everywhere, the functors stored in <file/DB.ozf/ and
      <file/Form.ozf/ are included in <file/LMF.oza/.

    <p>
      The linker can be used in verbose mode with the option
      <<--verbose>> (or <<-v>> as abbreviation). In verbose mode the
      linker prints information on which functors are included and which
      functors are imported by the newly created functor. For example,
      <<<ozl -v LMF.ozf -o LMF.oza>>>
      prints something like
<code display proglang=fundamental>
Include:
   /home/schulte/DB.ozf, /home/schulte/Form.ozf,
   /home/schulte/LMF.ozf.
Import:
   x-oz://system/Application.ozf, x-oz://system/System.ozf, 
   x-oz://system/Tk.ozf.
</code>

    <p>
      The linker also supports options that control which functors are
      included, for more information see <ptr.extern to="ozdoc:tools"
      key="chapter.linker">.
 
  </Section>

  <Section id="Section.Deployment.compressed">
    <Title/Compressed Pickled Functors/

    <p>
      Pickles created by the compiler and linker can also take
      advantage of compression. For that matter, both tools support
      the <<--compress>> (or <<-z>> as shortcut) option that must be
      followed by a single digit that defines the compression level to
      be used.

    <p>
      For example, the pickled functor <file/LMF.oza/ can be created
      compressed by
      <<<ozl --compress 9 LMF.ozf -o LMF.oza>>>
      This reduces the used disk space by 50%. 

  </Section>

  <Section id="Section.Deployment.execute">
    <Title/Executing Functors/

    <p>
      This section shows a convenient form to execute functors.

    <p>
      The option <<--exec>> (or <<-x>> as shortcut) can be supplied to
      both compiler and linker. Functors that are created with that
      option can be directly executed. For example, the file <file/lmf.exe/
      created with
      <<<ozl -x LMF.ozf -o lmf.exe>>>
      can be directly executed:
      <<<lmf.exe>>
      The pickled functor <file/lmf.exe/ just features a particular header
      that allows direct execution. It can still be used together with
      the <file/ozengine/ program:
      <<<ozengine lmf.exe>>>

    <p>
      Naturally, the extension <file/.exe/ can be omitted under Unix.
      
  </Section>


</Chapter>

