A.3. Example for the pkgconf file

#-----------------------------------------------------------------------------
kind declarations: # partially evaluated by pkgm 1.0
#-----------------------------------------------------------------------------

 #----------------------------------------------------------------------------
 case "^i[345]86-.*-win32-.*$":
  compilation target kind "program" default prefix "" default suffix ".exe";
  compilation target kind "library" default prefix "" default suffix ".lib";
  derived kind "depfile" default extension "dep";
  derived kind "code_object_file" default extension "obj";

 #----------------------------------------------------------------------------
 default:

  #---------------------------------------------------------------------------
  # generic declarations
  compilation target kind "program" default prefix "" default suffix "";
  compilation target kind "library" default prefix "lib" default suffix ".a";
  dummy target kind "dummy_target"  default prefix "" default suffix "";
  program file kind "program_file"  default prefix "" default suffix ""
    default location "";
  document file kind "document_file"  default prefix "" default suffix ""
    default location "";
  data file kind "data_file"  default prefix "" default suffix ""
    default location "";
  file kind "file"  default prefix "" default suffix ""
    default location "";
  data file kind "project_description"  default prefix "" default suffix ""
    default location "";
  data file kind "package_description"  default prefix "" default suffix ""
    default location "";
  data file kind "package_dependencies"  default prefix "" default suffix ""
    default location "";
  data file kind "package_tags"  default prefix "" default suffix ""
    default location "";
  derived kind "depfile" default extension "dep";
  derived kind "code_object_file" default extension "o";
  virtual kind "add_define";
  virtual kind "add_include";
  virtual kind "add_libpath";
  virtual kind "add_library";

  #---------------------------------------------------------------------------
  # declarations for JAVA
  program source kind "java_source" default extension "java" 
    default location "java" preserve path document source;
  derived kind "java_object_file" default extension "class" 
    preserve path object;
  #derived kind "java_archive_file" default extension "zip";
  compilation target kind "java_archive_file" default extension "zip";
  compilation target kind "java_start_script" default prefix "run_" 
    default extension "";
  derived kind "java_html_file" default extension "html" 
    default location "html";
  virtual kind "java_package_name";

  #---------------------------------------------------------------------------
  # declarations for Modula-3
  program source kind "m3_interface" default extension "i3" 
    default location "src" document source;
  program source kind "m3_implementation" default extension "m3" 
    default location "src" document source;
  program source kind "m3_generic_interface" default extension "ig" 
    default location "src" document source;
  program source kind "m3_generic_implementation" default extension "mg" 
    default location "src" document source;
  compound kind "m3_module" is
    "m3_interface" and "m3_implementation";
  compound kind "m3_generic_module" is
    "m3_generic_interface" and "m3_generic_implementation";

  #---------------------------------------------------------------------------
  # declarations for script files
  program source kind "perl_source" default extension "pl" 
    default location "src" document source;
  program source kind "python_source" default extension "py" 
    default location "src" document source;
  program source kind "shell_script" default extension "sh" 
    default location "src" document source;

  #---------------------------------------------------------------------------
  # declarations for C
  program source kind "c_source" default extension "c" default location "src";
  program source kind "c_header" default extension "h" default location "inc";
  generic source kind "c_generic_header" default extension "gh" 
    default location "inc";
  generic source kind "c_generic_source" default extension "gc"
    default location "src";
  generic instance kind "c_generic_source_instance" default location "";
  generic instance kind "c_generic_header_instance" default location "";
  compound kind "c_module" is "c_header" and "c_source";
  compound kind "c_generic_module" is
    "c_generic_header" and "c_generic_source";
  compound kind "c_generic_module_instance" is
    "c_generic_header_instance" and "c_generic_source_instance";
  virtual kind "c_header_ext";
  virtual kind "c_source_ext";
  virtual kind "c_generic_header_ext";
  virtual kind "c_generic_source_ext";

  #---------------------------------------------------------------------------
  # declarations for C++
  program source kind "cc_source" default extension "cc" 
    default location "src";
  program source kind "cc_header" default extension "hh"
    default location "inc";
  generic source kind "cc_generic_header" default extension "ghh"
    default location "inc";
  generic source kind "cc_generic_source" default extension "gcc"
    default location "src";
  generic source kind "cc_template" default extension "thh" 
    default location "inc";
  generic instance kind "cc_generic_source_instance" default location "";
  generic instance kind "cc_generic_header_instance" default location "";
  compound kind "cc_module" is "cc_header" and "cc_source";
  compound kind "cc_generic_module" is
    "cc_generic_header" and "cc_generic_source";
  compound kind "cc_generic_module_instance" is
    "cc_generic_header_instance" and "cc_generic_source_instance";
  virtual kind "cc_header_ext";
  virtual kind "cc_source_ext";
  virtual kind "cc_generic_header_ext";
  virtual kind "cc_generic_source_ext";

  #---------------------------------------------------------------------------
  # code generator kinds
  program source kind "lex_c_source" default extension "l"
    default location "src";
  program source kind "lex_cc_source" default extension "l"
    default location "src";
  derived kind "c_lex_generated" default extension "c" default location "";
  derived kind "cc_lex_generated" default extension "cc" default location "";

  program source kind "yacc_c_source" default extension "y"
    default location "src";
  program source kind "yacc_cc_source" default extension "y"
    default location "src";
  derived kind "c_yacc_generated" default extension "c" default location "";
  derived kind "cc_yacc_generated" default extension "cc" default location "";

  #---------------------------------------------------------------------------
  # GNU configure kinds
  program source kind "autoconf_c_header" default suffix ".h.in" 
    default location "./";
  derived kind "c_autoconfigured_header" default suffix ".h"
    default location "";

  #---------------------------------------------------------------------------
  # documentation kinds
  document source kind "tex_source" default extension "tex" 
    default location "doc";
  document source kind "latex_source" default extension "tex" 
    default location "doc";
  document source kind "texinfo_source" default extension "texi" 
    default location "doc";
  document source kind "sgml_source" default extension "sgml" 
    default location "doc";
  document source kind "html_source" default extension "html" 
    default location "doc";
  document source kind "man_page" default extension "man" 
    default location "doc";
  document source kind "doc_source" default extension "doc" 
    default location "doc";
  document target kind "ps_file" default extension "ps";
  document target kind "dvi_file" default extension "dvi";
  document target kind "html_file" default extension "html";
  document target kind "ascii_file" default extension "txt";

end;

#-----------------------------------------------------------------------------
derivation declarations: # partially evaluated by pkgm 1.0
#-----------------------------------------------------------------------------
  # Each derivation may be declared to be of a special type.
  # Predefined types are compile, link, archive, makedepend, instantiate,
  # format, index, convert, translate, hook

 default:

  #---------------------------------------------------------------------------
  # generic derivations
  "archivation" : archive is "code_object_file"* --> "library";
  #"linkage"     : link is "code_object_file"*, "library"* --> "program";

  #---------------------------------------------------------------------------
  # derivations for JAVA
  "java_archivation" : archive is "java_object_file"* --> "java_archive_file";
  "java_compilation" : compile is "java_source" --> "java_object_file";
  "java_linkage"     : link    is "java_object_file"* --> "java_start_script";
  "java_format"      : format  is "java_source"* --> "java_html_file";

  #---------------------------------------------------------------------------
  # derivations for C
  "c_compilation" : compile is "c_source" --> "code_object_file";
  "c_gi_compilation" : compile is 
    "c_generic_source_instance" --> "code_object_file";
  "c_linkage"     : link is "code_object_file"*, "library"* --> "program";
  "c_archivation" : archive is "code_object_file"* --> "library";
  "c_makedepend"  : makedepend is "c_source" --> "depfile";
  "c_inst_makedepend"  : makedepend is 
    "c_generic_source_instance" --> "depfile";
  "c_instantiate_header" : instantiate is 
    "c_generic_header" --> "c_generic_header_instance";
  "c_instantiate_source" : instantiate is 
    "c_generic_source" --> "c_generic_source_instance";

  #---------------------------------------------------------------------------
  # derivations for C++
  "cc_compilation" : compile is "cc_source" --> "code_object_file";
  "cc_gi_compilation" : compile is 
    "cc_generic_source_instance" --> "code_object_file";
  "cc_linkage"     : link is "code_object_file"*, "library"* --> "program";
  "cc_archivation" : archive is "code_object_file"* --> "library";
  "cc_makedepend"  : makedepend is "cc_source" --> "depfile";
  "cc_inst_makedepend"  : makedepend is 
    "cc_generic_source_instance" --> "depfile";
  "cc_instantiate_header" : instantiate is 
    "cc_generic_header" --> "cc_generic_header_instance";
  "cc_instantiate_source" : instantiate is 
    "cc_generic_source" --> "cc_generic_source_instance";

  #---------------------------------------------------------------------------
  # code generator derivations
  "lex_c_generation" : generate is
        "lex_c_source" --> "c_lex_generated";
  "lex_cc_generation" : generate is
        "lex_cc_source" --> "cc_lex_generated";
  "c_lex_generated_compilation" : compile is
        "c_lex_generated" --> "code_object_file";
  "cc_lex_generated_compilation" : compile is 
        "cc_lex_generated" --> "code_object_file";
  "c_lex_generated_makedepend" : makedepend is
        "c_lex_generated" --> "depfile";
  "cc_lex_generated_makedepend" : makedepend is
        "cc_lex_generated" --> "depfile";

  "yacc_c_generation" : generate is "yacc_c_source" --> "c_yacc_generated";
  "yacc_cc_generation" : generate is "yacc_cc_source" --> "cc_yacc_generated";
  "c_yacc_generated_compilation" : compile is
        "c_yacc_generated" --> "code_object_file";
  "cc_yacc_generated_compilation" : compile is
        "cc_yacc_generated" --> "code_object_file";
  "c_yacc_generated_makedepend" : makedepend is
        "c_yacc_generated" --> "depfile";
  "cc_yacc_generated_makedepend" : makedepend is
        "cc_yacc_generated" --> "depfile";
  
  #---------------------------------------------------------------------------
  # GNU configure derivations
  "autoconf_c_generation" : generate is 
     "autoconf_c_header" --> "c_autoconfigured_header";

  #---------------------------------------------------------------------------
  # document derivations
  "latex_format"     : format is "latex_source" --> "dvi_file";
  "dvi_format"       : format is "dvi_file"     --> "ps_file";
  "sgml_html_format" : format is "sgml_source"  --> "html_file";
  #"man_page_format"  : format is "man_page"     --> "ascii_file";

end;

#-----------------------------------------------------------------------------
action declarations:
#-----------------------------------------------------------------------------

#-------------------------------------------------------------------------
# imported variables: 
#   --- file extensions from PkgDesc ---   
#   PKG_Ext_c_header      -- current extension for c_header
#   PKG_Ext_c_source      -- current extension for c_sources
#   PKG_Ext_cc_header     -- current extension for cc_header
#   PKG_Ext_cc_source     -- current extension for cc_sources
#   PKG_Ext_asm_source    -- current extension for asm_sources
#
#   --- add declarations from PkgDesc ---
#   PKG_Decls_add_define  -- contents of all add_define() decls
#   PKG_Decls_add_include -- contents of all add_include() decls
#   PKG_Decls_add_libpath -- contents of all add_libpath() decls 
#   PKG_Decls_add_library -- contents of all add_library() decls
#
#   --- values computed by pkgm (building) ---   
#   PKG_DerivedDir        -- name of the directory for all derived files
#   PKG_ImportRoots       -- root dirs of all imported packages
#   PKG_Root              -- root dir of current package
#   PKG_ActSource         -- current source file
#   PKG_ActDerived        -- current derived file
#   PKG_ActDerivedBase    -- current derived file name without pre- and suffix
#   PKG_ObjectBases       -- all object files without extension
#   PKG_Objects           -- all object files with extension
#   PKG_LibDirs           -- all library paths to search
#   PKG_Libs              -- all libs to link with
#   PKG_Libraries         -- complete paths for all imported libraries
#   PKG_KindPrefix        -- first element of a kind name
#                            (usually a short notation for the language)
#   
#   --- substitution list from PkgDesc declaration ---
#   PKG_ActSubs           -- substitutions for current instantiation
#   
#   --- values computed by pkgm (shipping) ---   
#   PKG_ActFile           -- current file to be shipped
#   PKG_ActDest           -- current shipping destination path
#   PKG_KindPrefix        -- first element of a kind name
#                            (usually a short notation for the language)
#   
#   --- values from the initialization file compactrc ---
#   PKG_BinDir            -- where binaries are to be installed
#   PKG_LocalBinDir       -- where binaries are to be installed locally
#   PKG_ProjectBinDir     -- where binaries are to be installed on a 
#                            project-wide scale
#   PKG_GlobalBinDir      -- where binaries are to be installed globally
#   PKG_DocDir            -- where documentation is to be installed
#   PKG_LocalDocDir       -- where documentation is to be installed locally
#   PKG_ProjectDocDir     -- where documentation is to be installed on a 
#                            project-wide scale
#   PKG_GlobalDocDir      -- where documentation is to be installed
#                            globally
#
#   --- values computed by poolm (pool administration) ---   
#   POOL_Path               -- the root of the package pool
#   POOL_PackageName        -- the name of the current package
#   POOL_PackageVersion     -- the version of the current pool/package set
#   POOL_PackageVersionDir  -- the same version as pathname
#   POOL_TPC_Path           -- TPC as pathname (derived files directory)
#   POOL_PackagePath        -- the path pool/package/version_dir
#   POOL_PackageDerivedPath -- the path pool/package/version_dir/tpc_path
#   POOL_PackageVersions    -- list of all versions of pool/package
#
# derived variables:
#   DEFINES, PKGINCS, INCDIRS, INCLUDES, SOURCE, LDFLAGS, 
#   OBJECTS, LIBDIRS, LIBS, LIB, SUBS,
#   PGMNAME, LIBNAME
#-------------------------------------------------------------------------

  #---------------------------------------------------------------------------
  case "^i[345]86-.*-.*-gcc-.*$", "^i[345]86-.*-.*-gcc$":

    #------------------------------------------------------------------------
    # file prefixes and suffixes
    let file_suffix_dep = ".dep";
    let file_suffix_obj = ".o";
    let file_prefix_lib = "lib";
    let file_suffix_lib = ".a";
    let file_suffix_bin = "";

  #---------------------------------------------------------------------------
  case "^i[345]86-.*-win32-.*$":

    #------------------------------------------------------------------------
    # file prefixes and suffixes
    let file_suffix_dep = ".dep";
    let file_suffix_obj = ".obj";
    let file_prefix_lib = "";
    let file_suffix_lib = ".lib";
    let file_suffix_bin = ".exe";

  #---------------------------------------------------------------------------
  case "^i[345]86-.*-win32-.*$":

    let SYSLIBS = split(env("lib"), ";");
    # env("LIB")

  case "^i[345]86-.*-.*-gcc-.*$", "^i[345]86-.*-.*-gcc$":

    let SYSLIBS = ("/usr/lib");

  #---------------------------------------------------------------------------
  case "^.*$":

    #------------------------------------------------------------------------
    # definitions for building and shipping
    let SOURCE   = {PKG_ActSource};
    let DEFINES  = {PKG_Decls_add_define};
    let INC1     = addsuffix(concat(({PKG_Root}), {PKG_ImportRoots}), 
                     concat("/", {PKG_DerivedDir}));
    let INC2     = addsuffix(concat(({PKG_Root}), {PKG_ImportRoots}), "/inc");
    #let INC12    = concat({INC1}, {INC2});
    let INC12    = combine({INC1}, {INC2}, "1");
    let INCDIRS  = concat({INC12}, {PKG_Decls_add_include});
    let INCLUDES = addprefix({INCDIRS}, "-I");

    let OBJECTS  = {PKG_Objects};

    let LIBNAME  = concat({file_prefix_lib}, 
                          concat({PKG_ActDerivedBase}, {file_suffix_lib}));
    let PGMNAME  = {PKG_ActDerived};

    let LIBS     = addprefix(concat({PKG_Libs},  
                                    {PKG_Decls_add_library}), "-l");
    let LIBDIRS  = addprefix(
             concat(
               concat({PKG_LibDirs}, {PKG_Decls_add_libpath}),
                       {SYSLIBS}),
                     "-L");
    let ALLLIBS  = addsuffix(
                     addprefix(
                       concat({PKG_Libs}, {PKG_Decls_add_library}),
                       {file_prefix_lib}),
                     {file_suffix_lib});
    let ALLLIBDIRS = concat(
               concat({PKG_LibDirs}, {PKG_Decls_add_libpath}),
               {SYSLIBS});
    let LIBRARIES = locate({ALLLIBDIRS}, {ALLLIBS});
    let DEPFILE  = {PKG_ActDerived};
    let SUBS     = {PKG_ActSubs};

  #---------------------------------------------------------------------------
  case "^.*-jdk.*$", "^.*-jikes.*$":
    let DEFAULT_CLASS_PATH = "/usr/local/java/lib/classes.zip:.:";
    let ADD_INCL_LIST = addsuffix({PKG_Decls_add_include}, ":");
    let ADD_INCL_PATH = subst(concat("", {ADD_INCL_LIST}), " ", "");
    let PKGJAVA = concat({PKG_Root}, "/java:");
    let PKGLOCALDERIVED = concat({PKG_Root}, concat("/", {PKG_DerivedDir}));
    let PKGLOCALNAME = basename({PKG_Root});
    let PKGPOOLNAMES = basename(dirname({PKG_ImportRoots}));

    # The following computes the classpath with a zip-file for the
    # current package
    let PKGROOTS = concat(({PKG_Root}), {PKG_ImportRoots});
    let PKGNAMES = concat(({PKGLOCALNAME}), {PKGPOOLNAMES});
    let PKGDERIVEDDIRS = addsuffix({PKGROOTS}, concat("/", 
                           concat({PKG_DerivedDir}, "/")));
    let PKGCLASSARCHIVES = combine({PKGDERIVEDDIRS},
                             addsuffix({PKGNAMES}, ".zip:"), "1");
    let PKGCLASSARCHIVESSTR = concat({PKGJAVA}, {PKGCLASSARCHIVES});
    let JAVA_PKG_CLASS_PATH = subst({PKGCLASSARCHIVESSTR}, " ", "");
    let JAVA_CLASS_PATH = concat({DEFAULT_CLASS_PATH}, 
                           concat({ADD_INCL_PATH}, {JAVA_PKG_CLASS_PATH}));

    # Now the classpath is computed with zip-files only for the
    # imported packages
    let PKGIMPDERIVEDDIRS = addsuffix({PKG_ImportRoots}, concat("/", 
                             concat({PKG_DerivedDir}, "/")));
    let PKGIMPCLASSARCHIVES = combine({PKGIMPDERIVEDDIRS},
                                addsuffix({PKGPOOLNAMES}, ".zip:"), "1");
    let PKGIMPCLASSARCHIVESSTR = concat("", {PKGIMPCLASSARCHIVES});
    let JAVA_PKG_IMP_CLASS_PATH = subst({PKGIMPCLASSARCHIVESSTR}, " ", "");
    let JAVA_CLASS_PATH2 = concat({DEFAULT_CLASS_PATH}, 
                             concat({ADD_INCL_PATH},
                               concat(
                                 concat({PKGLOCALDERIVED}, ":"),
                                        {JAVA_PKG_IMP_CLASS_PATH})));
    #let JAVA_MAIN = subst({PKG_ActDerivedBase}, ".", "");
    let JAVA_MAIN = {PKG_ActDerivedBase};
    let SOURCES = addprefix(addsuffix(noext({PKG_ObjectBases}),
                                      ".java"), 
                            "../../java/");
    #let ADD_SOURCE = store("JAVA_SOURCES",
    #                       concat((val("JAVA_SOURCES")), ({SOURCE})));
    #let GET_SOURCES = val("JAVA_SOURCES");
    let ADD_SOURCE = store("JAVA_SOURCES",
                           concat((val("JAVA_SOURCES")), ({SOURCE})));
    let GET_SOURCES = val("JAVA_SOURCES");
    let JAVA_PACKAGE_PATH = subst({PKG_Decls_java_package_name}, ".", "/");
    let REAL_DERIVED_HTML_BASE = concat({PKG_Decls_java_package_name},
                                   concat(".", 
                                     subst({PKG_ActDerived}, 
                                           "../../html/", "")));
    let REAL_DERIVED_HTML = concat("../../html/", {REAL_DERIVED_HTML_BASE});

  #---------------------------------------------------------------------------
  case "^i[345]86-.*-.*-gcc.*$":

    #------------------------------------------------------------------------
    # make-specific value definitions
    make_comment_start     = "# ";
    make_include_directive = "-include {NAME}";
    make_phony_directive   = ".PHONY:  {NAME}";
    make_shell_declaration = "SHELL = /bin/sh";

    #------------------------------------------------------------------------
    # special external command declarations
    # cmd_remove_file = "rm -f";
    # cmd_remove_dir  = "rmdir";
    # cmd_remove_recursive = "rm -rf";
    # cmd_shell = "/bin/sh";

  #---------------------------------------------------------------------------
  case "^i[345]86-.*-win32-.*$":

    #------------------------------------------------------------------------
    # make-specific value definitions
    make_comment_start     = "# ";
    make_include_directive = "-include {NAME}";
    make_phony_directive   = ".PHONY:  {NAME}";
    make_shell_declaration = "";

    #------------------------------------------------------------------------
    # special external command declarations
    # cmd_remove_file = "del";
    # cmd_remove_dir  = "rd";
    # cmd_remove_recursive = "rd /s";
    # cmd_shell = "/bin/sh";

  #---------------------------------------------------------------------------
  case "^i[345]86-.*-.*-gcc-.*$", "^i[345]86-.*-.*-gcc$":

    #------------------------------------------------------------------------
    # poolm actions
    pool_remove = "rm -rf {POOL_PackagePath}";
    pool_status = "du -k  {POOL_PackagePath}";

  #---------------------------------------------------------------------------
  case "^i[345]86-.*-win32-.*$":

    #------------------------------------------------------------------------
    # poolm actions
    pool_remove = "rd /s {POOL_PackagePath}";
    pool_status = "du -k  {POOL_PackagePath}";

  #---------------------------------------------------------------------------
  case "^.*$":

    #------------------------------------------------------------------------
    # generic instantiation actions
    gen_instantiate_source : instantiate =
      "instgen {PKG_ActSource} {PKG_ActDerived} {SUBS}";
    c_instantiate_header : instantiate =
      "instgen {PKG_ActSource} {PKG_ActDerived} {SUBS}";
    c_instantiate_source : instantiate =
      "instgen {PKG_ActSource} {PKG_ActDerived} {SUBS}";
    cc_instantiate_header : instantiate =
      "instgen {PKG_ActSource} {PKG_ActDerived} {SUBS}";
    cc_instantiate_source : instantiate =
      "instgen {PKG_ActSource} {PKG_ActDerived} {SUBS}";

    #------------------------------------------------------------------------
    # generic document formatting
    latex_format     : format = "latex {PKG_ActSource}";
    sgml_html_format : format = "sgmlfmt -f html {PKG_ActSource}";
    dvi_format       : format = "dvips -o {PKG_ActDerived} {PKG_ActSource}";
    man_page_format  : format = "nroff -man {PKG_ActSource} > {PKG_ActDerived}";

    #------------------------------------------------------------------------
    # generic code generation
    lex_generation : generate =
      "lex -o{PKG_ActDerived} {PKG_ActSource}";
    yacc_generation : generate =
      "yacc {PKG_ActSource} && mv y.tab.c {PKG_ActDerived}";

    #------------------------------------------------------------------------
    # GNU configure 
    autoconf_generation : generate = 
      "../../configure --includedir ../../inc";

    #------------------------------------------------------------------------
    # generic build (dummy targets)
    gen_build : generate = "date > {PKG_ActDerived}";

  #---------------------------------------------------------------------------
  case "^.*-freebsd[0-9]*-.*$":

    #------------------------------------------------------------------------
    # installation actions
    install_dir  = "mkdir -p {PKG_ActDest} && chown 0775 {PKG_ActDest}";
    install_file = "install -c -m 0664 {PKG_ActFile} {PKG_ActDest}";
    install_lib  = "install -c -m 0664 {PKG_ActFile} {PKG_ActDest}";
    install_bin  = "install -c -s -m 0775 {PKG_ActFile} {PKG_ActDest}";

    # list of dummy hooks
    #pre_build  : hook = "@echo pre-build-hook";
    #post_build : hook = "@echo post-build-hook";
    #pre_instantiation  : hook = "@echo pre-instantiation-hook";
    #post_instantiation : hook = "@echo post-instantiation-hook";
    #pre_generation  : hook = "@echo pre-generation-hook";
    #post_generation : hook = "@echo post-generation-hook";
    #pre_archivation  : hook = "@echo pre-archivation-hook";
    #post_archivation : hook = "@echo post-archivation-hook";
    #pre_compilation  : hook = "@echo pre-compilation-hook";
    #post_compilation : hook = "@echo post-compilation-hook";
    #pre_format  : hook = "@echo pre-format-hook";
    #post_format : hook = "@echo post-format-hook";

  #---------------------------------------------------------------------------
  case "^.*-linux-.*$":

    #------------------------------------------------------------------------
    # installation actions
    install_dir  = "mkdir -p {PKG_ActDest} && chown 0775 {PKG_ActDest}";
    install_file = "install -c -m 0664 {PKG_ActFile} {PKG_ActDest}";
    install_lib  = "install -c -m 0664 {PKG_ActFile} {PKG_ActDest}";
    install_bin  = "install -c -s -m 0775 {PKG_ActFile} {PKG_ActDest}";

  #---------------------------------------------------------------------------
  case "^.*-win32-.*$":

    let ActFileWin32 = subst({PKG_ActFile}, "/", "\");
    let ActDestWin32 = subst({PKG_ActDest}, "/", "\");
    let CP = "installfile -v -s";

    #------------------------------------------------------------------------
    # installation actions
    install_dir  = "mkdir -p {PKG_ActDest} && chown 0775 {PKG_ActDest}";
    # seems to me like mkdir -p and chown needs MKS toolkit...
    install_file = "{CP} {ActFileWin32} {ActDestWin32}";
    install_lib  = "{CP} {ActFileWin32} {ActDestWin32}";
    install_bin  = "{CP} {ActFileWin32} {ActDestWin32}";
    # what about file permissions on win32?

  #---------------------------------------------------------------------------
  case "^.*-freebsd[0-9]*-.*":

    #------------------------------------------------------------------------
    # make-specific action definitions
    make                   = "make";
    gnumake                = "gmake";

  #---------------------------------------------------------------------------
  case "^.*-linux-.*":

    #------------------------------------------------------------------------
    # make-specific action definitions
    make                   = "make";
    gnumake                = "make";

  #---------------------------------------------------------------------------
  case "^.*-win32-.*":

    #------------------------------------------------------------------------
    # make-specific action definitions
    make                   = "gmake";
    gnumake                = "gmake";

  #---------------------------------------------------------------------------
  case "^i[345]86-freebsd[0-9]*-aout-gcc$":

    let CFLAGS   = "-pipe";
    let LDFLAGS  = "";
    
  #---------------------------------------------------------------------------
  case "^i[345]86-freebsd[0-9]*-aout-gcc-debug$":

    let CFLAGS   = "-g -pipe -O0";
    let LDFLAGS  = "-g";
    
  #---------------------------------------------------------------------------
  case "^i[345]86-freebsd[0-9]*-aout-gcc-optimize$":

    let CFLAGS   = "-pipe -O2";
    let LDFLAGS  = "";
    
  #---------------------------------------------------------------------------
  case "^i[345]86-freebsd[0-9]*-aout-gcc-debug,optimize$":

    let CFLAGS   = "-g -pipe -O";
    let LDFLAGS  = "-g";
    
  #---------------------------------------------------------------------------
  # Note: recent ELF-based Linux gcc does not take -belf ld option to
  #   produce ELF output.

  #---------------------------------------------------------------------------
  case "^i386-linux-elf-gcc$":

    let CFLAGS   = "-pipe";
    let LDFLAGS  = "";

  case "^i[45]86-linux-elf-gcc$":

    let CFLAGS   = "-m486 -pipe";
    let LDFLAGS  = "";

  #---------------------------------------------------------------------------
  case "^i386-linux-elf-gcc-debug$":

    let CFLAGS   = "-g -O0 -pipe";
    let LDFLAGS  = "-g";

  case "^i[45]86-linux-elf-gcc-debug$":

    let CFLAGS   = "-g -O0 -m486 -pipe";
    let LDFLAGS  = "-g";

  #---------------------------------------------------------------------------
  case "^i386-linux-elf-gcc-optimize$":

    let CFLAGS   = "-O2 -pipe";
    let LDFLAGS  = "";

  case "^i[45]86-linux-elf-gcc-optimize$":

    let CFLAGS   = "-O2 -pipe";
    let LDFLAGS  = "";

  #---------------------------------------------------------------------------
  case "^i386-linux-elf-gcc-debug,optimize$":

    let CFLAGS   = "-g -O -pipe";
    let LDFLAGS  = "-g";

  case "^i[45]86-linux-elf-gcc-debug,optimize$":

    let CFLAGS   = "-g -O -m486 -pipe";
    let LDFLAGS  = "-g";

  #---------------------------------------------------------------------------
  case "^.*-win32-cl$":

    let CFLAGS   = "-nologo -GB -MT";
    let LDFLAGS  = "-nologo -MT";
    let ARFLAGS  = "/machine:ix86 /subsystem:windows";

  #---------------------------------------------------------------------------
  case "^i[345]86-.*-gcc.*$":

    #------------------------------------------------------------------------
    # C-specific actions
    c_compilation        : compile = 
      "gcc -c {CFLAGS} {DEFINES} {INCLUDES} {SOURCE}";
    c_linkage            : link = 
      "gcc {LDFLAGS} -o {PGMNAME} {OBJECTS} {LIBDIRS} {LIBS}";
    c_archivation        : archive = 
      "ar -cru {LIBNAME} {OBJECTS} ; ranlib {LIBNAME}";
    c_makedepend         : makedepend = 
      "gcc -M -MG {DEFINES} {INCLUDES} {SOURCE} > {DEPFILE}";

    #------------------------------------------------------------------------
    # C++-specific actions
    cc_compilation        : compile = 
      "g++ -c {CFLAGS} {DEFINES} {INCLUDES} {SOURCE}";
    cc_linkage            : link =
      "gcc {LDFLAGS} -o {PGMNAME} {OBJECTS} {LIBDIRS} {LIBS}";
    cc_archivation        : archive =
      "ar -cru {LIBNAME} {OBJECTS} ; ranlib {LIBNAME}";
    cc_makedepend         : makedepend =
      "g++ -M -MG {DEFINES} {INCLUDES} {SOURCE} > {DEPFILE}";

  #---------------------------------------------------------------------------
  case "^.*-win32-cl.*$":

    let IncludesWin32 = subst({INCLUDES}, "/", "\");
    let LibDirsWin32 = subst({LIBDIRS}, "/", "\");
    let LibsWin32 = subst({LIBS}, "/", "\");
    let LibrariesWin32 = subst({LIBRARIES}, "/", "\");

    #------------------------------------------------------------------------
    # C-specific actions
    c_compilation        : compile = 
      "cl -c {CFLAGS} {DEFINES} {IncludesWin32} {SOURCE}";
    c_linkage            : link = 
      #"echo SYSLIBS = {SYSLIBS} && echo ALLLIBDIRS = {ALLLIBDIRS} && echo LIBRARIES = {LIBRARIES}";
      "cl {LDFLAGS} -Fe{PGMNAME} {OBJECTS} {LibrariesWin32}";
      # FIXME: library lists won't work
    c_archivation        : archive = 
      "lib {ARFLAGS} /out:{LIBNAME} {OBJECTS}";
    c_makedepend         : makedepend = 
      "gcc -M -MG {DEFINES} {IncludesWin32} {SOURCE} > {DEPFILE}";
      # what about other predefined symbols?

    #------------------------------------------------------------------------
    # C++-specific actions
    cc_compilation        : compile = 
      "cl -c {CFLAGS} {DEFINES} {IncludesWin32} -Tp {SOURCE}";
    cc_linkage            : link =
      "cl {LDFLAGS} -Fe{PGMNAME} {OBJECTS} {LibrariesWin32}";
      # FIXME: library lists won't work
    cc_archivation        : archive =
      "lib {ARFLAGS} /out:{LIBNAME} {OBJECTS}";
    cc_makedepend         : makedepend =
      "g++ -M -MG -D_M_IX86=400 {DEFINES} {IncludesWin32} {SOURCE} > {DEPFILE}";
      # what about other predefined symbols?

  #---------------------------------------------------------------------------
  # JAVA specific actions

  case ".*-jdk[^\\-]*$", ".*-jdk[^\\-]*-dir:.*$",
       ".*-jikes[^\\-]*$", ".*-jikes[^\\-]*-dir:.*$":
    let JAVAC_DEBUGFLAGS = "";
    let JAVAC_VERBOSE = "";

    java_linkage     : link =
      #"jar 0cvf {PKG_ActDerived}.zip {PKG_Objects} && 
      "@echo archiving class files in {JAVA_MAIN}.zip: &&
       jar 0cf {JAVA_MAIN}.zip {PKG_Objects} && 
       echo creating run script {PKG_ActDerived} &&
       echo (cd {PKGLOCALDERIVED}&&java -classpath {JAVA_CLASS_PATH2}
            {JAVA_MAIN} \$\*) > {PKG_ActDerived} && 
       chmod 755 {PKG_ActDerived}";

  case ".*-jdk.*-debug$", ".*-jdk[^\\-]*-debug,dir:.*$",
       ".*-jikes.*-debug$", ".*-jikes[^\\-]*-debug,dir:.*$":
    let JAVAC_DEBUGFLAGS = "-g";
    let JDB_SCRIPT = subst({PKG_ActDerived}, "run_", "debug_");
    let JAVAC_VERBOSE = "";
    
    java_linkage     : link =
      #"jar 0cvf {PKG_ActDerived}.zip {PKG_Objects} && 
      "@echo archiving class files in {JAVA_MAIN}.zip: &&
       jar 0cf {JAVA_MAIN}.zip {PKG_Objects} && 
       echo creating run script {PKG_ActDerived} &&
       echo (cd {PKGLOCALDERIVED}&&java -classpath {JAVA_CLASS_PATH2}
            {JAVA_MAIN} \$\*) > {PKG_ActDerived} && 
       chmod 755 {PKG_ActDerived} &&
       echo (cd {PKGLOCALDERIVED}&&jdb -classpath {JAVA_CLASS_PATH2}
            {JAVA_MAIN} \$\*) > {JDB_SCRIPT} && 
       chmod 755 {JDB_SCRIPT}";

  case "^i[345]86-.*-jdk.*$":
    let JAVAC = "javac";

  case "^i[345]86-.*-jikes.*$":
    let JAVAC = "jikes";

  case "^i[345]86-.*-jdk.*$", "^i[345]86-.*-jikes.*$":
    
    # We use a trick here to achieve somewhat decent compilation times:
    # Rather than compiling each source directly, we assemble all filenames
    # of outdated JAVA sources in the file .outdated-sources. We then use
    # the post_compilation hook to actually compile
    # all outdated sources. To make this work, we use the special
    # file contents replacement syntax $< fn > now supported by System.m3
    # 
    pre_build : hook = "@rm -f .outdated-sources && touch .outdated-sources";

    pre_compilation : hook = "@echo looking for outdated sources:"; 
    #pre_compilation : hook = "@echo `{PKGIMPDERIVEDDIRS}' `{PKGIMPCLASSARCHIVES}' `{PKGIMPCLASSARCHIVESSTR}' `{JAVA_PKG_IMP_CLASS_PATH}' `{JAVA_CLASS_PATH2}'";

    post_compilation : hook = 
      "@echo compiling all outdated sources: && 
       echo '  {JAVAC} {JAVAC_DEBUGFLAGS} {JAVAC_VERBOSE} -classpath' {JAVA_CLASS_PATH2} &&
       cat .outdated-sources &&
       {JAVAC} {JAVAC_VERBOSE} -d . {JAVAC_DEBUGFLAGS} -classpath {JAVA_CLASS_PATH2} 
       $< .outdated-sources > && rm -f .outdated-sources";

    java_compilation : compile =
      "@echo '  new source' --> compile {SOURCE} && 
        echo '    '{SOURCE} >> .outdated-sources";
      # The following line could be used to compile directly, but this
      # is very inefficient because of the poor performance of the
      # JAVA compiler
      # "{JAVAC} {JAVAC_VERBOSE} -d . -depend {JAVAC_DEBUGFLAGS} -classpath {JAVA_CLASS_PATH2} {SOURCE} ";

    java_archivation : archive =
      "@echo archiving class files in {PKG_ActDerived}: &&
       jar 0cf {PKG_ActDerived} {PKG_Objects} ";

    # I still haven't found out about how to compute the dependencies
    # of a JAVA source file. If the JAVA compiler source was available
    # to me, it should be easy to add an option to perform this task...
    java_makedepend  : makedepend =
      "@echo java makedepend {SOURCE} {DEPFILE} not yet available";

    java_format : format = 
      "@echo '  considering '{SOURCE} as document source &&
        ln -sf {REAL_DERIVED_HTML_BASE} {PKG_ActDerived} &&
        echo {SOURCE} >> .document-sources";

    pre_format  : hook =
      "rm -f .document-sources";

    post_format : hook = 
      "@echo generating package documentation in html: &&
       echo '  javadoc -classpath' {JAVA_CLASS_PATH} 
       {PKG_Decls_java_package_name} &&
       javadoc -classpath {JAVA_CLASS_PATH} -d ../../html -author -version
       {PKG_Decls_java_package_name}";
      # $< .document-sources >";
      # We cannot use the last line, because javadoc from jdk 1.1.5
      # considers every file whose name contains a `.' as a package
      # name, which is especially true for every file in ../../java/...

    pkg_realclean : hook =
      "/bin/sh -c 'rm -rf * ../../html/*.html'";
end.