/*
-----BEGIN QCMOD-----
name: zlib
arg: with-zlib-inc=[path],Path to zlib include files
arg: with-zlib-lib=[path],Path to zlib library files
-----END QCMOD-----
*/

//----------------------------------------------------------------------------
// qc_zlib
//----------------------------------------------------------------------------
class qc_zlib : public ConfObj {
public:
    qc_zlib(Conf *c) : ConfObj(c) { }
    QString name() const { return "zlib"; }
    QString shortname() const { return "zlib"; }
    bool    exec()
    {
        QString inc, lib;
        QString s;

        s = conf->getenv("QC_WITH_ZLIB_INC");
        if (!s.isEmpty()) {
            if (!conf->checkHeader(s, "zlib.h"))
                return false;
            inc = s;
        } else {
            if (!conf->findHeader("zlib.h", QStringList(), &s))
                return false;
            inc = s;
        }

        s = conf->getenv("QC_WITH_ZLIB_LIB");
        if (!s.isEmpty()) {
            if (!conf->checkLibrary(s, "z"))
                return false;
            lib = s;
        } else {
            if (!conf->findLibrary("z", &s))
                return false;
            lib = s;
        }

        if (!inc.isEmpty())
            conf->addIncludePath(inc);
        if (!lib.isEmpty())
            conf->addLib(QString("-L") + s);
        conf->addLib("-lz");

        return true;
    }
};
