~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kdm/ConfigureChecks.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
macro_optional_find_package(CkConnector)
 
2
macro_bool_to_01(CKCONNECTOR_FOUND HAVE_CKCONNECTOR)
 
3
if(CKCONNECTOR_FOUND)
 
4
  # when building with libck-connector, we also need the low-level D-Bus API
 
5
  find_package(DBus REQUIRED)
 
6
endif(CKCONNECTOR_FOUND)
 
7
 
 
8
macro_log_feature(CKCONNECTOR_FOUND "ck-connector" "The ConsoleKit connector library" "http://freedesktop.org/wiki/Software/ConsoleKit" FALSE "" "Provides ConsoleKit integration in KDM")
 
9
 
 
10
include(CheckCSourceRuns)
 
11
include(CheckStructMember)
 
12
 
 
13
check_struct_member("struct passwd" "pw_expire" "pwd.h" HAVE_STRUCT_PASSWD_PW_EXPIRE)
 
14
check_struct_member("struct utmp" "ut_user" "utmp.h" HAVE_STRUCT_UTMP_UT_USER)
 
15
check_struct_member("struct utmp" "ut_host" "utmp.h" HAVE_STRUCT_UTMP_UT_HOST)
 
16
 
 
17
check_include_files(lastlog.h HAVE_LASTLOG_H)
 
18
check_include_files(termio.h HAVE_TERMIO_H)
 
19
check_include_files(termios.h HAVE_TERMIOS_H)
 
20
check_include_files(sys/sockio.h HAVE_SYS_SOCKIO_H)
 
21
 
 
22
check_symbol_exists(sysinfo "sys/sysinfo.h" HAVE_SYSINFO)
 
23
check_symbol_exists(systeminfo "sys/systeminfo.h" HAVE_SYS_SYSTEMINFO)
 
24
check_symbol_exists(getdomainname   "unistd.h"    HAVE_GETDOMAINNAME)
 
25
 
 
26
check_function_exists(initgroups HAVE_INITGROUPS)
 
27
check_function_exists(mkstemp HAVE_MKSTEMP)
 
28
check_function_exists(getusershell HAVE_GETUSERSHELL)
 
29
 
 
30
check_c_source_runs("
 
31
#include <errno.h>
 
32
#include <unistd.h>
 
33
int main()
 
34
{
 
35
    setlogin(0);
 
36
    return errno == ENOSYS;
 
37
}
 
38
" HAVE_SETLOGIN)
 
39
 
 
40
# for config-kdm.h
 
41
check_function_exists(seteuid HAVE_SETEUID)
 
42
 
 
43
# for environ in config-kdm.h
 
44
check_include_files(crt_externs.h HAVE_CRT_EXTERNS_H)
 
45
check_function_exists(_NSGetEnviron HAVE_NSGETENVIRON)
 
46
 
 
47
find_library(UTIL_LIBRARIES util)
 
48
mark_as_advanced(UTIL_LIBRARIES)
 
49
 
 
50
macro_push_required_vars()
 
51
set(CMAKE_REQUIRED_LIBRARIES ${UTIL_LIBRARIES})
 
52
check_function_exists(setusercontext HAVE_SETUSERCONTEXT)
 
53
check_function_exists(login_getclass HAVE_LOGIN_GETCLASS)
 
54
check_function_exists(auth_timeok HAVE_AUTH_TIMEOK)
 
55
if (PAM_FOUND)
 
56
    set(CMAKE_REQUIRED_LIBRARIES ${PAM_LIBRARIES})
 
57
    check_function_exists(pam_getenvlist HAVE_PAM_GETENVLIST)
 
58
endif (PAM_FOUND)
 
59
macro_pop_required_vars()
 
60
 
 
61
 
 
62
macro(define_library LIB FN)
 
63
    set(varname ${FN}_in_${LIB})
 
64
    string(TOUPPER ${LIB}_LIBRARIES libname)
 
65
    check_library_exists(${LIB} ${FN} "" ${varname})
 
66
    set(${libname})
 
67
    if (${varname})
 
68
        set(${libname} ${LIB})
 
69
    endif (${varname})
 
70
endmacro(define_library)
 
71
 
 
72
define_library(s authenticate)
 
73
define_library(posix4 sched_yield)
 
74
define_library(socket connect)
 
75
define_library(resolv dn_expand)
 
76
 
 
77
# for Solaris
 
78
check_function_exists(gethostbyname have_gethostbyname)
 
79
if (NOT have_gethostbyname)
 
80
    define_library(nsl gethostbyname)
 
81
endif (NOT have_gethostbyname)
 
82
 
 
83
macro_push_required_vars()
 
84
set(CMAKE_REQUIRED_LIBRARIES ${SOCKET_LIBRARIES})
 
85
check_c_source_runs("
 
86
#include <sys/socket.h>
 
87
#include <sys/un.h>
 
88
#include <sys/stat.h>
 
89
#include <sys/types.h>
 
90
#include <string.h>
 
91
#include <unistd.h>
 
92
#include <errno.h>
 
93
int main()
 
94
{
 
95
    int fd, fd2;
 
96
    struct sockaddr_un sa;
 
97
 
 
98
    if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
 
99
        return 2;
 
100
    sa.sun_family = AF_UNIX;
 
101
    strcpy(sa.sun_path, \"testsock\");
 
102
    unlink(sa.sun_path);
 
103
    if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)))
 
104
        return 2;
 
105
    chmod(sa.sun_path, 0);
 
106
    setuid(getuid() + 1000);
 
107
    if ((fd2 = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
 
108
        return 2;
 
109
    connect(fd2, (struct sockaddr *)&sa, sizeof(sa));
 
110
    return errno != EACCES;
 
111
}
 
112
" HONORS_SOCKET_PERMS)
 
113
macro_pop_required_vars()
 
114
 
 
115
# for genkdmconf; this is TODO
 
116
#if (EXISTS /etc/ttys)
 
117
#    set(BSD_INIT 1)
 
118
#    check_function_exists(getttyent HAVE_GETTTYENT)
 
119
#endif (EXISTS /etc/ttys)
 
120
 
 
121
if (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME MATCHES Darwin OR CMAKE_SYSTEM_NAME MATCHES GNU/FreeBSD)
 
122
    set(HAVE_UTMPX)
 
123
    set(HAVE_LASTLOGX)
 
124
else (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME MATCHES Darwin OR CMAKE_SYSTEM_NAME MATCHES GNU/FreeBSD)
 
125
    check_function_exists(getutxent HAVE_UTMPX)
 
126
    check_function_exists(updlastlogx HAVE_LASTLOGX)
 
127
endif (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME MATCHES Darwin OR CMAKE_SYSTEM_NAME MATCHES GNU/FreeBSD)
 
128
set(BSD_UTMP)
 
129
if (NOT HAVE_UTMPX)
 
130
    check_function_exists(getutent have_getutent)
 
131
    if (NOT have_getutent)
 
132
        set(BSD_UTMP 1)
 
133
    endif (NOT have_getutent)
 
134
endif (NOT HAVE_UTMPX)
 
135
check_function_exists(updwtmp HAVE_UPDWTMP)
 
136
 
 
137
check_function_exists(arc4random HAVE_ARC4RANDOM)
 
138
if (NOT HAVE_ARC4RANDOM)
 
139
    # assume that /dev/random is non-blocking if /dev/urandom does not exist
 
140
    if (EXISTS /dev/urandom)
 
141
        set(DEV_RANDOM "\"/dev/urandom\"")
 
142
    else (EXISTS /dev/urandom)
 
143
        if (EXISTS /dev/random)
 
144
            set(DEV_RANDOM "\"/dev/random\"")
 
145
        endif (EXISTS /dev/random)
 
146
    endif (EXISTS /dev/urandom)
 
147
endif (NOT HAVE_ARC4RANDOM)
 
148
 
 
149
option(KDE4_RPCAUTH "Use Sun's secure RPC for Xauth cookies in KDM" OFF)
 
150
if (KDE4_RPCAUTH)
 
151
    find_path(RPC_INCLUDE_DIR rpc/rpc.h)
 
152
    if (RPC_INCLUDE_DIR)
 
153
        set(RPCAUTH_FOUND TRUE)
 
154
    else (RPC_INCLUDE_DIR)
 
155
        message(STATUS "Sun's secure RPC header was not found")
 
156
    endif (RPC_INCLUDE_DIR)
 
157
endif (KDE4_RPCAUTH)
 
158
mark_as_advanced(RPC_INCLUDE_DIR)
 
159
macro_bool_to_01(RPCAUTH_FOUND SECURE_RPC)
 
160
 
 
161
option(KDE4_KRB5AUTH "Use Sun's secure RPC for Xauth cookies in KDM" OFF)
 
162
if (KDE4_KRB5AUTH)
 
163
    find_library(KRB5_LIBRARIES krb5)
 
164
    if (KRB5_LIBRARIES)
 
165
        find_path(KRB5_INCLUDE_DIR krb5/krb5.h)
 
166
        if (KRB5_INCLUDE_DIR)
 
167
            set(KRB5AUTH_FOUND TRUE)
 
168
        else (KRB5_INCLUDE_DIR)
 
169
            message(STATUS "KDE4_KRB5AUTH requires Kerberos5 header files.
 
170
Due to a problem with X includes you probably have to run \"ln -s . krb5\"
 
171
in the directory where the krb5.h include resides to make things actually work.")
 
172
        endif (KRB5_INCLUDE_DIR)
 
173
    endif (KRB5_LIBRARIES)
 
174
    mark_as_advanced(KRB5_INCLUDE_DIR KRB5_LIBRARIES)
 
175
    macro_bool_to_01(KRB5AUTH_FOUND K5AUTH)
 
176
endif (KDE4_KRB5AUTH)
 
177
 
 
178
if (X11_Xdmcp_FOUND)
 
179
    macro_push_required_vars()
 
180
    set(CMAKE_REQUIRED_LIBRARIES ${X11_LIBRARIES})
 
181
    check_function_exists(XdmcpWrap HASXDMAUTH)
 
182
    macro_pop_required_vars()
 
183
endif (X11_Xdmcp_FOUND)
 
184
 
 
185
option(KDE4_KERBEROS4 "Compile KDM with Kerberos v4 support" OFF)
 
186
if (KDE4_KERBEROS4)
 
187
    find_path(KRB4_INCLUDE_DIR krb.h)
 
188
    find_library(KRB4_LIBRARY krb)
 
189
    find_library(DES_LIBRARY des)
 
190
    if (KRB4_INCLUDE_DIR AND KRB4_LIBRARY)
 
191
        set(KERBEROS 1)
 
192
        set(KRB4_LIBRARIES ${KRB4_LIBRARY} ${DES_LIBRARY} ${RESOLV_LIBRARIES})
 
193
    endif (KRB4_INCLUDE_DIR AND KRB4_LIBRARY)
 
194
    option(KDE4_AFS "Compile KDM with AFS support" OFF)
 
195
    if (KDE4_AFS)
 
196
        find_path(AFS_INCLUDE_DIR kafs.h)
 
197
        find_library(AFS_LIBRARY kafs)
 
198
        if (AFS_INCLUDE_DIR AND AFS_LIBRARY)
 
199
            set(AFS 1)
 
200
            set(KRB4_LIBRARIES ${KRB4_LIBRARIES} ${AFS_LIBRARY})
 
201
        endif (AFS_INCLUDE_DIR AND AFS_LIBRARY)
 
202
    endif (KDE4_AFS)
 
203
endif (KDE4_KERBEROS4)
 
204
 
 
205
option(KDE4_XDMCP "Build KDM with XDMCP support" ON)
 
206
if (KDE4_XDMCP AND X11_Xdmcp_FOUND)
 
207
    set(XDMCP 1)
 
208
endif (KDE4_XDMCP AND X11_Xdmcp_FOUND)
 
209
 
 
210
option(KDE4_KDM_XCONSOLE "Build KDM with built-in xconsole" OFF)
 
211
macro_bool_to_01(KDE4_KDM_XCONSOLE WITH_KDM_XCONSOLE)
 
212
 
 
213
macro_push_required_vars()
 
214
set(CMAKE_REQUIRED_LIBRARIES ${NSL_LIBRARIES})
 
215
check_function_exists(getifaddrs HAVE_GETIFADDRS)
 
216
macro_pop_required_vars()
 
217
check_function_exists(getloadavg  HAVE_GETLOADAVG)
 
218
check_function_exists(setproctitle HAVE_SETPROCTITLE)
 
219
check_function_exists(strnlen     HAVE_STRNLEN)
 
220
 
 
221
check_struct_member("struct sockaddr_in" "sin_len" "sys/socket.h;netinet/in.h" HAVE_STRUCT_SOCKADDR_IN_SIN_LEN)
 
222
check_struct_member("struct sockaddr_in6" "sin6_len" "sys/socket.h;netinet/in.h" HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN)
 
223
 
 
224
FOREACH(path /usr/local/bin /usr/bin /bin)
 
225
    if (XBINDIR STREQUAL ${path})
 
226
        set(dont_add_xbin 1)
 
227
    endif (XBINDIR STREQUAL ${path})
 
228
ENDFOREACH(path)
 
229
if (dont_add_xbin)
 
230
    set(KDM_DEF_USER_PATH "/usr/local/bin:/usr/bin:/bin:/usr/games")
 
231
    set(KDM_DEF_SYSTEM_PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
 
232
else (dont_add_xbin)
 
233
    set(KDM_DEF_USER_PATH "/usr/local/bin:/usr/bin:/bin:${XBINDIR}:/usr/games")
 
234
    set(KDM_DEF_SYSTEM_PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${XBINDIR}")
 
235
endif (dont_add_xbin)
 
236
 
 
237
set(KDM_LIBEXEC_STRIP 0)
 
238
if (NOT LIBEXEC_INSTALL_DIR STREQUAL "${BIN_INSTALL_DIR}")
 
239
    STRING(LENGTH "${BIN_INSTALL_DIR}" bidl)
 
240
    STRING(LENGTH "${LIBEXEC_INSTALL_DIR}" lxidl)
 
241
    set(ips "${CMAKE_INSTALL_PREFIX}/")
 
242
    STRING(LENGTH "${ips}" ipsl)
 
243
    set(inip 1)
 
244
    if (bidl LESS ${ipsl} OR lxidl LESS ${ipsl})
 
245
        set(inip)
 
246
    else (bidl LESS ${ipsl} OR lxidl LESS ${ipsl})
 
247
        STRING(SUBSTRING "${BIN_INSTALL_DIR}" 0 ${ipsl} bpr)
 
248
        STRING(SUBSTRING "${LIBEXEC_INSTALL_DIR}" 0 ${ipsl} lpr)
 
249
        if (NOT bpr STREQUAL "${lpr}")
 
250
            set(inip)
 
251
        endif (NOT bpr STREQUAL "${lpr}")
 
252
    endif (bidl LESS ${ipsl} OR lxidl LESS ${ipsl})
 
253
    if (NOT inip)
 
254
        set(KDM_LIBEXEC_STRIP -1)
 
255
        set(KDM_LIBEXEC_SUFFIX "${LIBEXEC_INSTALL_DIR}")
 
256
    else (NOT inip)
 
257
        MATH(EXPR bsfxl "${bidl} - ${ipsl}")
 
258
        STRING(SUBSTRING "${BIN_INSTALL_DIR}" ${ipsl} ${bsfxl} bsfx)
 
259
        STRING(REPLACE "/" ";" bsfxl "${bsfx}")
 
260
        LIST(LENGTH bsfxl KDM_LIBEXEC_STRIP)
 
261
        MATH(EXPR klxsfxl "${lxidl} - ${ipsl}")
 
262
        STRING(SUBSTRING "${LIBEXEC_INSTALL_DIR}" ${ipsl} ${klxsfxl} KDM_LIBEXEC_SUFFIX)
 
263
    endif (NOT inip)
 
264
endif (NOT LIBEXEC_INSTALL_DIR STREQUAL "${BIN_INSTALL_DIR}")
 
265
 
 
266
configure_file(config-kdm.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdm.h)