cd "${SOURCE_DIRECTORY}" &&

# Install c-cient
mkdir -pv /usr/include/imap &&
cp -fv ./c-client/*.h /usr/include/imap/ &&
cp -fv ./c-client/c-client.a /usr/lib/libc-client.a &&

# Install imapd and ipop{2,3}d
cp -fv ./imapd/imapd /usr/sbin/ &&
cp -fv ./ipopd/ipop2d /usr/sbin/ &&
cp -fv ./ipopd/ipop3d /usr/sbin/ &&
cp -fv ./mtest/mtest /usr/bin/ &&

# Install stunnel certificates, if stunnel is requested
if is_depends_enabled $SPELL stunnel; then
    ln -sf "${TRACK_ROOT}/etc/stunnel/stunnel.pem" /etc/ssl/certs/imapd.pem &&
    ln -sf "${TRACK_ROOT}/etc/stunnel/stunnel.pem" /etc/ssl/certs/ipop3d.pem
fi &&

message "${MESSAGE_COLOR}If you get 'unknown AUTHORIZATION state command'" &&
message "then you probably want to edit /etc/xinetd.d/imapd-stunnel" &&
message "and use imap without stunnel encapsulation... ${DEFAULT_COLOR}"
