SubDir TOP ;

SubInclude TOP core ;
SubInclude TOP abnf ;
SubInclude TOP deliver ;
SubInclude TOP doc ;
SubInclude TOP encodings ;
SubInclude TOP collations ;
SubInclude TOP logd ;
SubInclude TOP aox ;
SubInclude TOP server ;
SubInclude TOP db ;
SubInclude TOP recorder ;
SubInclude TOP sasl ;
SubInclude TOP schema ;
SubInclude TOP scripts ;
SubInclude TOP installer ;
SubInclude TOP extractors ;
SubInclude TOP archiveopteryx ;
SubInclude TOP aoximport ;
SubInclude TOP aoxexport ;


if ( $(BUILDDOC) ) {
    SubInclude TOP udoc ;
}

Doc oryxdoc : core database schema encodings imap logd mailbox message sasl
    server smtp tls user pop sieve extractors abnf collations ;

if ( $(BUILDDOC) ) {
    Depends install : doc ;
    Depends all : doc ;
    Depends doc : exe ;
}


rule Prepare
{
    Depends install : $(<) ;
}


actions together Prepare
{
    mkdir -p $(<) ;
}


Prepare $(INSTALLROOT)$(JAILDIR) ;
Prepare $(INSTALLROOT)$(JAILDIR)/var/run ;
Prepare $(INSTALLROOT)$(MESSAGEDIR) ;
Prepare $(INSTALLROOT)$(PIDFILEDIR) ;
Prepare $(INSTALLROOT)$(CONFIGDIR) ;
Prepare $(INSTALLROOT)$(LIBDIR)/contrib ;
if ( $(LOGFILE:D) != "" && $(LOGFILE:D) != "syslog" ) {
    Prepare $(INSTALLROOT)$(LOGFILE:D) ;
}


# if we make JAILDIR, we should chmod it so noone can read it:
MODE on $(INSTALLROOT)$(JAILDIR) = 701 ;
Chmod $(INSTALLROOT)$(JAILDIR) ;

# if we make MESSAGEDIR, we should chmod it similarly. AOXUSER needs to
# be able to write to it, but we can't chown here, because the user may
# not exist yet.
MODE on $(INSTALLROOT)$(MESSAGEDIR) = 700 ;
Chmod $(INSTALLROOT)$(MESSAGEDIR) ;


actions Message {
fmt <<EOM | sed 's/^/  /'
To set up the database and generate a configuration file, run
$(LIBDIR)/installer as root. The new configuration file will be in
$(CONFIGDIR)/archiveopteryx.conf.

$(LIBDIR)/installer -n shows what it would do, without making any
changes. (If you are just upgrading from an older version,
$(BINDIR)/aox upgrade schema may be enough.
$(BINDIR)/aox upgrade schema -n shows what it would do, without making
any changes.)

The logfile is $(LOGFILE) by default and man pages are in $(MANDIR).

If you have any problems, the FAQ is at
http://www.archiveopteryx.org/faq/ and you can always ask
info@aox.org for help.

EOM
}

Message install ;


if $(BUILDDOC) {
    local s u ;
    local exceptions = canonical msgdump munger renderer logdmain tests
    addressparser whip cram subscribe deliver aox recorder cmdsearch
    installer archiveopteryx aoximport aoxexport dbtest ;
    for s in $(sets) {
        if ! $(s) in $(documented-sets) && ! $(s) in $(u) &&
           ! $(s) in $(exceptions)
        {
            u += $(s) ;
        }
    }
    if $(u) {
        echo Built but not documented: $(u) ;
    }
}
