// DIE's signature file

init("compiler", "ldc");

function getLDCVersion() {
    var sResult = "";
    var nSection = ELF.getSectionNumber(".comment");
    if (nSection != -1) {
        var nSectionOffset = ELF.getSectionFileOffset(nSection);
        var nSectionSize = ELF.getSectionFileSize(nSection);
        var nOffset = ELF.findString(nSectionOffset, nSectionSize, "ldc version ");
        if (nOffset != -1) {
            sResult = ELF.getString(nOffset + 12, 20);
        }
    }

    return sResult;
}

function detect(bShowType, bShowVersion, bShowOptions) {
    if (ELF.isLibraryPresent("libphobos2-ldc-shared.so.98") || ELF.isLibraryPresent("libdruntime-ldc-shared.so.98")) {
        bDetected = 1;
    }

    var sLDCVersion = getLDCVersion();
    if (sLDCVersion != "") {
        bDetected = 1;
        sVersion = sLDCVersion;
    }

    _setLang("D", bDetected);
    return result(bShowType, bShowVersion, bShowOptions);
}