summaryrefslogtreecommitdiff
path: root/src/sql/configure.pri
blob: 05794582e9eacf18d6915b026d7b0c39e56c7890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# custom tests

defineReplace(filterLibraryPath) {
    str = $${1}
    for (l, QMAKE_DEFAULT_LIBDIRS): \
        str -= "-L$$l"

    return($$str)
}

defineTest(qtConfLibrary_psqlConfig) {
    pg_config = $$config.input.psql_config
    isEmpty(pg_config): \
        pg_config = $$qtConfFindInPath("pg_config")
    !win32:!isEmpty(pg_config) {
        qtRunLoggedCommand("$$pg_config --libdir", libdir)|return(false)
        qtRunLoggedCommand("$$pg_config --includedir", includedir)|return(false)
        libdir -= $$QMAKE_DEFAULT_LIBDIRS
        libs =
        !isEmpty(libdir): libs += "-L$$libdir"
        libs += "-lpq"
        $${1}.libs = "$$val_escape(libs)"
        includedir -= $$QMAKE_DEFAULT_INCDIRS
        $${1}.includedir = "$$val_escape(includedir)"
        export($${1}.libs)
        export($${1}.includedir)
        return(true)
    }
    qtLog("pg_config not found.")
    return(false)
}

defineTest(qtConfLibrary_psqlEnv) {
    # Respect PSQL_LIBS if set
    PSQL_LIBS = $$getenv(PSQL_LIBS)
    !isEmpty(PSQL_LIBS) {
        $${1}.libs = $$PSQL_LIBS
        export($${1}.libs)
    }
    return(true)
}

defineTest(qtConfLibrary_mysqlConfig) {
    mysql_config = $$config.input.mysql_config
    isEmpty(mysql_config): \
        mysql_config = $$qtConfFindInPath("mysql_config")
    !isEmpty(mysql_config) {
        qtRunLoggedCommand("$$mysql_config --version", version)|return(false)
        version = $$split(version, '.')
        version = $$first(version)
        isEmpty(version)|lessThan(version, 4): return(false)]

        # query is either --libs or --libs_r
        query = $$eval($${1}.query)
        qtRunLoggedCommand("$$mysql_config $$query", libs)|return(false)
        qtRunLoggedCommand("$$mysql_config --include", includedir)|return(false)
        eval(libs = $$libs)
        libs = $$filterLibraryPath($$libs)
        # -rdynamic should not be returned by mysql_config, but is on RHEL 6.6
        libs -= -rdynamic
        equals($${1}.cleanlibs, true) {
            for(l, libs) {
                # Drop all options besides the -L one and the -lmysqlclient one
                # so we don't unnecessarily link to libs like OpenSSL
                contains(l, "^(-L|-lmysqlclient).*"): cleanlibs += $$l
            }
            libs = $$cleanlibs
        }
        $${1}.libs = "$$val_escape(libs)"
        eval(rawincludedir = $$includedir)
        rawincludedir ~= s/^-I//g
        includedir =
        for (id, rawincludedir): \
            includedir += $$clean_path($$id)
        includedir -= $$QMAKE_DEFAULT_INCDIRS
        $${1}.includedir = "$$val_escape(includedir)"
        export($${1}.libs)
        export($${1}.includedir)
        return(true)
    }
    qtLog("mysql_config not found.")
    return(false)
}

defineTest(qtConfLibrary_sybaseEnv) {
    libs =
    sybase = $$getenv(SYBASE)
    !isEmpty(sybase): \
        libs += "-L$${sybase}/lib"
    libs += $$getenv(SYBASE_LIBS)
    !isEmpty(libs) {
        $${1}.libs = "$$val_escape(libs)"
        export($${1}.libs)
    }
    return(true)
}