% Copyright (C) 1994, Digital Equipment Corporation
% All rights reserved.
% See the file COPYRIGHT for a full description.
%
% Last modified on Tue Aug 20 20:58:50 PDT 1996 by najork
%      modified on Mon Jun 19 08:07:53 PDT 1995 by kalsow
%

%
% Please comment out the sections below that you don't want built.
% Note that some of the earlier sections are required when building
% later sections.
%

if equal (OS_TYPE, "WIN32")
  TOUCH = "copy nul >"
else
  TOUCH = "cat /dev/null >"
end

readonly new_m3build = format ("%s%s%s", BIN_USE, SL, "m3build")
readonly new_m3ship  = format ("%s%s%s", BIN_USE, SL, "m3ship")

readonly proc BuildChunk (x) is
  if not stale (x, x)
    % we've already built this chunk
    write ("-- ", x, " done --", CR)
    return
  end

  local goto_chunk = format ("cd ..%s%s", SL, x)

  % let'm know what we're doing
  write (CR, "---------------------- building ", x,
            " ----------------------", CR,CR)
  if equal (OS_TYPE, "WIN32")

    % Build and ship the chunk.  Since there is no command-separator
    % (such as ";" in Unix and "&&" in NT) in Windows95, we write the 
    % commands to a batch file, execute it, and then delete it again
    BATCH_FILE = ".M3BATCH.bat"

    > BATCH_FILE in
      write ("@echo off", CR)
      write ("@", goto_chunk, "> nul:", CR)
      write ("@", new_m3build, CR)
      write ("@", new_m3ship, CR)

      % If you don't want to delete derived objects as soon as they are
      % installed, comment out the following line.
      write ("@echo y | del ", BUILD_DIR, " > nul:", CR)
    end

    exec ("@", BATCH_FILE)
    local sink = unlink_file (BATCH_FILE)

  else % OS_TYPE is POSIX

    % build and ship the chunk
    exec ("@", goto_chunk, ";", new_m3build)
    exec ("@", goto_chunk, ";", new_m3ship)
  
    % If you don't want to delete derived objects as soon as they are
    % installed, comment out the following line.
    exec ("@-", goto_chunk, ";", "rm -rf", BUILD_DIR)

  end

  % remember that we've built this chunk
  exec ("@", TOUCH, x)
end



%--- mtex --- utility -------------------------------------------------
% mtex is a quake function that is used to produce
% both troff man pages and HTML pages from the same source
% requires:
BuildChunk ("mtex")

%--- m3core --- library -------------------------------------------------
% m3core is the minimal base library.  It must be built before any others.
% requires:
BuildChunk ("m3core")

%--- libm3 --- library -------------------------------------------------
% libm3 is the library that most others need.
% requires: m3core
BuildChunk ("libm3")

%--- sil --- demo -------------------------------------------------
% Sil is a simple drawing program that runs on Windows/NT.  It's included
% in the distribution as a sample of native Windows programming in Modula-3.
% requires: libm3
if equal (OS_TYPE, "WIN32")
 BuildChunk ("sil")
end

%--- m3middle --- library -------------------------------------------------
% the Modula-3 compiler's IL definition
% requires: libm3
% BuildChunk ("m3middle")  %-- built as part of the bootstrap process

%--- m3linker --- library -------------------------------------------------
% the Modula-3 prelinker
% requires: m3middle
% BuildChunk ("m3linker")  %-- built as part of the bootstrap process

%--- m3objfile --- library -------------------------------------------------
% the Modula-3 object file writers
% requires: m3middle
% BuildChunk ("m3objfile")  %-- built as part of the bootstrap process

%--- m3front --- library -------------------------------------------------
% the Modula-3 compiler front-end
% requires: m3middle
% BuildChunk ("m3front")  %-- built as part of the bootstrap process

%--- m3back --- library -------------------------------------------------
% the Windows/NT x86 back-end
% requires: m3middle, m3objfile
% BuildChunk ("m3back")  %-- built as part of the bootstrap process

%--- m3staloneback --- utility -----------------------------------------------
% an standalone back-end program like m3cc that uses m3back
% requires: m3back
% BuildChunk ("m3staloneback")  %-- built as part of the bootstrap process

%--- m3 --- utility -------------------------------------------------
% the Modula-3 compiler (main program)
% requires: m3linker, m3front, m3middle, libm3
% BuildChunk ("m3")  %-- built as part of the bootstrap process

%--- m3loader --- utility -------------------------------------------------
% an experimental dynamic loader for Windows/NT
% requires: libm3, m3middle
% if equal (OS_TYPE, "WIN32")
%   BuildChunk ("m3loader")
% end

%--- m3quake --- library --------------------------------------------------
% an experimental callable version of quake
% requires: libm3, m3middle
% BuildChunk ("m3quake")

%--- m3build2 --- utility ------------------------------------------------
% an experimental Modula-3 version of m3build
% requires: libm3, m3quake
% BuildChunk ("m3build2")

%--- cg-burs --- utility -------------------------------------------------
% an experimental Modula-3 back-end that uses BURS
% requires: m3middle
% BuildChunk ("cg-burs")  %-- experimental

%--- coverage --- utility program & library ----------------------------------
% a line-based coverage analyzer/profiler
% requires: libm3
if equal (OS_TYPE, "POSIX")
  BuildChunk ("coverage")
end

%--- pp --- utility -------------------------------------------------
% a Modula-3 pretty-printer
% requires: libm3
if equal (OS_TYPE, "POSIX")
  BuildChunk ("pp")
end

%--- m3bundle --- utility -------------------------------------------------
% a program that captures binary data from files as Modula-3 source,
%   needed to build the formsvbt library
% requires: libm3
BuildChunk ("m3bundle")

%--- m3totex --- utility -------------------------------------------------
% a program that wraps Modula-3 source in enough TeX to make it printable
% requires: libm3, m3bundle
BuildChunk ("m3totex")

%--- set --- library ------------------------------------------------------
% a simple, generic Set interface.
% requires: libm3
BuildChunk ("set")

%--- realgeometry --- library -----------------------------------------------
% a version of the geometry package (Point, Rect, Path, ...)
%   with REAL-valued coordinates
% requires: libm3
BuildChunk ("realgeometry")

%--- parseparams --- library -----------------------------------------------
% a library that helps parse command line arguments.
% requires: libm3
BuildChunk ("parseparams")

%--- slisp --- library -----------------------------------------------
% a library containing a small Lisp interpreter
% requires: libm3
BuildChunk ("slisp")

%--- tempfiles --- library -----------------------------------------------
% a library to build tempfiles
% requires: libm3
BuildChunk ("tempfiles")

%--- tcp --- library -------------------------------------------------
% tcp implements a Modula-3 interface to TCP sockets.  It is used
%   by the Testle window system and network objects.
% requires: libm3
BuildChunk ("tcp")

%--- web --- library -------------------------------------------------
% a library for retrieving documents from the World Wide Web using an
%   http proxy server.
% requires: tcp
BuildChunk ("web")

%--- netobj --- library -------------------------------------------
% the network objects runtime library, needed by most distributed applications
% requires: tcp
BuildChunk ("netobj")

%--- netobjd --- utility -------------------------------------------
% the network objects daemon, needed by all programs using network objects
% requires: netobj
BuildChunk ("netobjd")

%--- m3tk --- library -------------------------------------------
% a (large) Modula-3 abstract syntax tree (AST) toolkit, needed by stubgen
% requires: libm3
BuildChunk ("m3tk")

%--- stubgen --- utility -------------------------------------------
% the network objects stub generator, needed by programs using network objects
% requires: m3tk
BuildChunk ("stubgen")

%--- stable --- library ---------------------------------------------
% A library providing log-based persistent objects
% requires: libm3
BuildChunk ("stable")

%--- stablegen --- utility -------------------------------------------
% a stub generator to make the use of the "stable" library much easier
% requires: m3tk, stable
BuildChunk ("stablegen")

%--- sharedboard --- prototype -------------------------------------------
% a prototype shared whiteboard
% requires: stable, stablegen
% BuildChunk ("sharedboard")

%--- X11R4 --- library -------------------------------------------------
% X11R4 implements a Modula-3 interface to the X library.  It is used
%   by the Testle window system.
% requires: libm3
if PLATFORM_SUPPORTS_X
  BuildChunk ("X11R4")
end

%--- PEX --- library -------------------------------------------------
% PEX implements a Modula-3 interface to the PEX 3D graphics library.
%   It is used by all graphical 3D applications
% requires: X11R4 and a host PEX implementation
if PLATFORM_SUPPORTS_PEX
  BuildChunk ("PEX")
end

%--- opengl --- library -------------------------------------------------
% opengl implements a Modula-3 interface to the OpenGL 3D graphics library.
%   It is used by all graphical 3D applications
% requires: X11R4 and a host OpenGL implementation
if PLATFORM_SUPPORTS_OPENGL
  BuildChunk ("opengl")
end

%--- motif --- library -------------------------------------------------
% motif implements a Modula-3 interface to the X/Motif library.
% requires: X11R4
if PLATFORM_SUPPORTS_MOTIF
  BuildChunk ("motif")
end

%--- tetris --- game -------------------------------------------------
% a Modula-3 version of Tetris
% requires: X11R4
if PLATFORM_SUPPORTS_X
  BuildChunk ("tetris")
end

%--- columns --- game -------------------------------------------------
% a Modula-3 version of the PC game, columns
% requires: X11R4
if PLATFORM_SUPPORTS_X
  BuildChunk ("columns")
end

%--- ui --- library -------------------------------------------------
% ui implements the Trestle window-system toolkit.  It is used
%   by most graphical applications.
% requires: X11R4 and tcp on POSIX; libm3 on WIN32
% Note: The WIN32 version is still VERY buggy
BuildChunk ("ui")

%--- bicycle --- library -------------------------------------------------
% bicycle is a library of playing card images.
% requires: ui
BuildChunk ("bicycle")

%--- solitaire --- game -------------------------------------------------
% a Modula-3 version of SeaHaven towers
% requires: bicycle
BuildChunk ("solitaire")

%--- badbricks --- game -------------------------------------------------
% a Modula-3 game similar to minesweeper, inspired by the crumbling
%     facade of SRC's building.
% requires: ui
BuildChunk ("badbricks")

%--- m3tools --- library -------------------------------------------------
% a simple Modula-3 scanner, needed by m3tohtml and m3browser
% requires: libm3, tcp
BuildChunk ("m3tools")

%--- m3tohtml --- utility -------------------------------------------------
% a program to convert batches of Modula-3 source to interconnected HTML
% requires: libm3, m3tools
BuildChunk ("m3tohtml")

%--- m3browser --- utility -------------------------------------------------
% an HTTP server that provides WWW browsing of the installed Modula-3 system
% requires: libm3, m3tools
BuildChunk ("m3browser")

%--- tcl --- library -------------------------------------------------
% a thin Modula-3 veneer on the TCL library (version 6.2).
% requires: libm3  (TCL is required to build a shared library)
% BuildChunk ("tcl")

%--- dps --- library -------------------------------------------------
% a thin Modula-3 veneer on the display Postscript extensions to X
% requires: X11R4, display PostScript, pswrap
% BuildChunk ("dps")  %-- many sites do not have the X extensions

%--- dpsslides --- utility -------------------------------------------------
% a program to display postscript slides in X
% requires: dps
% BuildChunk ("dpsslides")

%--- vbtkit --- library -------------------------------------------------
% a large collection of useful window widgets, needed by many of the
%   following libraries and programs.
% requires: ui
BuildChunk ("vbtkit")

%--- fours --- game -------------------------------------------------
% a collection of Modula-3 variants of the PC game, tetris.
% requires: vbtkit
BuildChunk ("fours")

%--- showheap --- utility -------------------------------------------------
% a program to graphically display in real-time the state of each heap page.
% requires: vbtkit
if equal (OS_TYPE, "POSIX")
  BuildChunk ("showheap")
end

%--- recordheap --- utility -------------------------------------------------
% a program to capture a "showheap" trace
% requires: 
if equal (OS_TYPE, "POSIX")
  BuildChunk ("recordheap")
end

%--- replayheap --- utility -------------------------------------------------
% a program to graphically display the log captured by "recordheap"
% requires: vbtkit
if equal (OS_TYPE, "POSIX")
  BuildChunk ("replayheap")
end

%--- shownew --- utility -------------------------------------------------
% a program to graphically display in real-time per-type allocations
% requires: vbtkit
if equal (OS_TYPE, "POSIX")
  BuildChunk ("shownew")
end

%--- showthread --- utility -------------------------------------------------
% a program to graphically display in real-time the state of each thread.
% requires: vbtkit
if equal (OS_TYPE, "POSIX")
  BuildChunk ("showthread")
end

%--- images --- library -------------------------------------------------
% support for displaying bitmap images
% requires: vbtkit
BuildChunk ("images")

%--- jvideo --- library -------------------------------------------------
% a low-level interface to the J-video hardware, needed by videovbt
% requires: tcp
BuildChunk ("jvideo")

%--- videovbt --- library -------------------------------------------------
% a window widget that displays live video images
% requires: jvideo, ui
BuildChunk ("videovbt")

%--- formsvbtpixmaps --- library -------------------------------------------
% misc. bitmaps, cursors and stuff used by formsvbt
% requires: libm3, m3bundle
BuildChunk ("formsvbtpixmaps")

%--- formsvbt --- library -------------------------------------------------
% a high-level language based on S-expressions that makes it easy
% to assemble VBTs (windows) using the TeX metaphors of boxes and
% glue.
% requires: vbtkit, videovbt, formsvbtpixmaps, web
BuildChunk ("formsvbt")

%--- formsedit --- utility -------------------------------------------------
% a 1-1/2 view GUI editor for FormsVBT expressions
% requires: formsvbt
BuildChunk ("formsedit")

%--- fisheye --- demo -------------------------------------------------
% a demo of "fisheye" views for graph browsing
% requires: formsvbt
BuildChunk ("fisheye")

%--- calculator --- demo -------------------------------------------------
% a 10-key calculator using FormsVBT
% requires: formsvbt
BuildChunk ("calculator")

%--- cube --- demo -------------------------------------------------
% a rotating cube
% requires: formsvbt
BuildChunk ("cube")

%--- codeview --- library -------------------------------------------
% support for animated views of source code, needed by zeus
% requires: formsvbt
BuildChunk ("codeview")

%--- rehearsecode --- utility -------------------------------------------
% a program to manually test drive source code animations
% requires: codeview
BuildChunk ("rehearsecode")

%--- mg --- library -------------------------------------------
% the low-level animation support
% requires: formsvbt
BuildChunk ("mg")

%--- mgkit --- library -------------------------------------------
% a collection of easier-to-use animation widgets
% requires: m3
BuildChunk ("mgkit")

%--- anim3D --- library -------------------------------------------
% a collection of 3D animation widgets
% requires: parseparams, vbtkit, and one of the following:
%    X11R4 and PEX
%    X11R4 and OpenGL
%    soon: OpenGL and Windows NT
BuildChunk ("anim3D")

%--- synloc --- library -------------------------------------------
% a low-level library used by the Obliq interpreter
% requires: libm3
BuildChunk ("synloc")

%--- synex --- library -------------------------------------------
% a low-level "syntax extension" library used by the Obliq interpreter
% requires: synloc
BuildChunk ("synex")

%--- metasyn --- library -------------------------------------------
% a low-level library used by the Obliq interpreter
% requires: synex
BuildChunk ("metasyn")

%--- obliqrt --- library -------------------------------------------
% the Obliq interpreter's runtime library
% requires: synloc, netobj
BuildChunk ("obliqrt")

%--- obliqlibm3 --- library -------------------------------------------
% the Obliq interpreter's hooks to the libm3 library
% requires: obliqrt, libm3
BuildChunk ("obliqlibm3")

%--- obliqlibui --- library -------------------------------------------
% the Obliq interpreter's hooks to the ui library
% requires: obliqrt, formsvbt
BuildChunk ("obliqlibui")

%--- obliqlibanim --- library -------------------------------------------
% the Obliq interpreter's hooks to the animation libraries
% requires: obliqrt, mgkit
BuildChunk ("obliqlibanim")

%--- obliqparse --- library -------------------------------------------
% the Obliq interpreter's parser
% requires: obliqrt
BuildChunk ("obliqparse")

%--- obliqprint --- library -------------------------------------------
% the Obliq interpreter's value printer
% requires: obliqrt
BuildChunk ("obliqprint")

%--- obliq --- library -------------------------------------------
% the Obliq interpreter
% requires: obliqparse, obliqprint, metasyn
BuildChunk ("obliq")

%--- obliqlib3D --- library -------------------------------------------
% the Obliq interpreter's hooks to the 3D animation libraries
% requires: anim3D, obliqlibanim, obliq
BuildChunk ("obliqlib3D")

%--- obliqbinmin --- utility -------------------------------------------
% the Obliq interpreter with minimal runtime hooks
% requires: obliq
BuildChunk ("obliqbinmin")

%--- obliqbinstd --- utility -------------------------------------------
% the Obliq interpreter with the "standard" runtime hooks
% requires: obliq, obliqlibm3
BuildChunk ("obliqbinstd")

%--- obliqbinui --- utility -------------------------------------------
% the Obliq interpreter with ui support
% requires: obliq, obliqlibm3, obliqlibui
BuildChunk ("obliqbinui")

%--- obliqbinanim --- utility -------------------------------------------
% the Obliq interpreter with full animation support
% requires: obliq, obliqlibm3, obliqlibui, obliqlibanim
BuildChunk ("obliqbinanim")

%--- obliqbin3D --- utility -------------------------------------------
% the Obliq interpreter with full 3D animation support
% requires: obliq, obliqlibm3, obliqlibui, obliqlibanim, obliqlib3D
BuildChunk ("obliqbin3D")

%--- obliqsrvstd --- utility -------------------------------------------
% an Obliq "server" with the standard runtime hooks
% requires: obliq, obliqlibm3
BuildChunk ("obliqsrvstd")

%--- obliqsrvui --- utility -------------------------------------------
% an Obliq "server" with ui support
% requires: obliq, obliqlibm3, obliqlibui
BuildChunk ("obliqsrvui")

%--- m3zume --- utility -------------------------------------------
% the "interesting event" preprocessor needed by zeus
% requires: formsvbt, stubgen
BuildChunk ("m3zume")

%--- zeus --- library -------------------------------------------
% the algorithm animation toolkit
% requires: netobj, codeview, mgkit, m3zume, netobj, stubgen
BuildChunk ("zeus")

%--- mentor --- demo -------------------------------------------------
% a collection of algoritm animations
% requires: zeus, obliqbinanim
BuildChunk ("mentor")

%--- smalldb --- library -------------------------------------------
% an in-memory database library, used by the package tools
% requires: libm3
if equal (OS_TYPE, "POSIX")
  BuildChunk ("smalldb")
end

%
% The "package tools" are a collection of user-level commands
% that enable sharing of software.  They support a simple
% directory-based check-in/check-out model.  They are not
% essential to the Modula-3 distribution, but are quite
% useful for large-scale software development.
%
% The current default is not to build the package tools:
%   pkgobj, pkgtool, pkgsrv, pkgq, pkgfprint.
%

%
%--- pkgobj --- library -------------------------------------------
% the low-level library support for the package tools
% requires: smalldb, netobj
% BuildChunk ("pkgobj")

%--- pkgtool --- utility -------------------------------------------
% the client program(s) to access the package tools
% requires: pkgobj
% BuildChunk ("pkgtool")

%--- pkgsrv --- utility -------------------------------------------
% the server daemon required to use the package tools
% requires: pkgobj
% BuildChunk ("pkgsrv")

%--- pkgq --- utility -------------------------------------------
% the client program(s) needed to manage the package tools
% requires: pkgobj
% BuildChunk ("pkgq")

%--- pkgfprint --- utility -------------------------------------------
% an internal utility program needed by the package tools
% requires: pkgobj
% BuildChunk ("pkgfprint")

%--- siphontools --- utility -------------------------------------------
% the program(s) needed to manage distributed instances of the package tools
% requires: pkgobj
%
% !!! must be built by hand with make
%
%## BuildChunk ("siphontools")



%--- visualobliq --- demo -------------------------------------------
% a prototype of an easy-to-use distributed programming environment
% requires: formsvbt, obliq, obliqlibui, obliqlibm3
BuildChunk ("visualobliq")

%--- voquery --- demo -------------------------------------------
% a simple query program used by vorun
% requires: formsvbt
BuildChunk ("voquery")

%--- vorun --- demo -------------------------------------------
% a safe visual obliq interpreter suitable for embedding in the WWW.
% requires: obliqlibui, obliqlibm3, obliq, voquery, vorun
if equal (OS_TYPE, "POSIX")
  BuildChunk ("vorun")
end

%--- vocgi --- demo -------------------------------------------
% an HTML/cgi gateway, required to embed Visual Obliq code in the WWW.
% requires: vbtkit, filename, obliqlibm3, obliq
BuildChunk ("vocgi")

%--- llscan --- utility -------------------------------------------
% a little mh program used by Postcard
% requires: 
if equal (OS_TYPE, "POSIX")
  BuildChunk ("llscan")
end

%--- postcard --- utility -------------------------------------------
% an integrated mail/news reader
% requires: formsvbt llscan mtex
if equal (OS_TYPE, "POSIX")
  BuildChunk ("postcard")
end

%--- gnuemacs --- library -------------------------------------------------
% a library of useful E-lisp code for Modual-3-mode in gnuemacs,
%   also a program to build Modula-3 tags
% requires: 
if equal (OS_TYPE, "POSIX")
  BuildChunk ("gnuemacs")
end

%--- webvbt --- library -------------------------------------------------
% a library for displaying HTML pages inside a VBT
% requires: formsvbt obliqparse obliqlibm3 obliqlibui obliqlibanim web
BuildChunk ("webvbt")

%--- webscape --- utility -------------------------------------------------
% a web browser with support for interactive content
% requires: webvbt
BuildChunk ("webscape")

%--- deckscape --- utility -------------------------------------------------
% a web browser that uses a new metaphor: "decks" of web pages
% requires: webvbt
BuildChunk ("deckscape")
