summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-09-23 16:32:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:48 -0500
commit4be0ae794e4af2354d678fddd7bf1e822ffa9148 (patch)
tree128989d970334e4a896329992e827c4f09b8c035 /source4/lib
parentda46c9252ee887602b3e629065ca87b9ed11466f (diff)
downloadsamba-4be0ae794e4af2354d678fddd7bf1e822ffa9148.tar.gz
samba-4be0ae794e4af2354d678fddd7bf1e822ffa9148.tar.bz2
samba-4be0ae794e4af2354d678fddd7bf1e822ffa9148.zip
r10456: More SCons fixes:
- Add framework for fallback generating code - Move pread / pwrite replacement functions to libreplace - Support pidl builds correctly - Support asn1 builds correctly - Move OS-specific checks to lib/replace/SConscript (This used to be commit fbbfad0a1f7dedbf48e835a864f8285f283d72f3)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/charset/SConscript92
-rw-r--r--source4/lib/registry/SConscript8
-rw-r--r--source4/lib/replace/README2
-rw-r--r--source4/lib/replace/SConscript28
-rw-r--r--source4/lib/replace/config.m41
-rw-r--r--source4/lib/replace/replace.c22
-rw-r--r--source4/lib/socket/SConscript59
7 files changed, 200 insertions, 12 deletions
diff --git a/source4/lib/charset/SConscript b/source4/lib/charset/SConscript
index 53e5db44bb..b3305579e1 100644
--- a/source4/lib/charset/SConscript
+++ b/source4/lib/charset/SConscript
@@ -1,15 +1,91 @@
+#!/usr/bin/env python
+# tastes like -*- python -*-
+
Import('hostenv')
-SConscript('../../build/scons/iconv.py')
-# tastes like -*- python -*-
-#conf = Configure( custom_tests = { 'CheckIconv' : CheckIconv })
-#(have_iconv,iconv) = conf.CheckIconv()
-#conf.Finish()
+def _CheckIconvPath(context,path):
+ # Some systems have iconv in libc, some have it in libiconv (OSF/1 and
+ # those with the standalone portable libiconv installed).
+ context.Message("checking for iconv in " + path + " ... ")
+
+ main = """
+int main()
+{
+ iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);
+ return 0;
+}"""
+
+ have_giconv_iconv = context.TryLink("""
+#include <stdlib.h>
+#include <giconv.h>
+""" + main, '.c')
+ if have_giconv_iconv:
+ context.Result(1)
+ return ("giconv.h", "")
+
+ have_iconv_iconv = context.TryLink("""
+#include <stdlib.h>
+#include <iconv.h>
+""" + main, '.c')
+
+ if have_iconv_iconv:
+ context.Result(1)
+ return ("iconv.h", "")
+
+ #FIXME: Add -lgiconv
+ have_giconv_lib_iconv = context.TryLink("""
+#include <stdlib.h>
+#include <giconv.h>
+""" + main, '.c')
+ if have_giconv_lib_iconv:
+ context.Result(1)
+ return ("giconv.h", "-lgiconv")
+
+ #FIXME: Add -liconv
+ have_iconv_lib_iconv = context.TryLink("""
+#include <stdlib.h>
+#include <iconv.h>
+"""+main,'.c')
+
+ if have_iconv_lib_iconv:
+ context.Result(1)
+ return ("iconv.h", "-liconv")
+
+ return None
+
+def CheckIconv(context):
+ context.Message("checking for iconv ... ")
+
+ look_dirs = ['/usr','/usr/local','/sw']
+
+ for p in look_dirs:
+ _CheckIconvPath(context,p) #FIXME: Handle return value
+
+ if context.TryRun("""
+#include <iconv.h>
+main() {
+ iconv_t cd = iconv_open("ASCII", "UCS-2LE");
+ if (cd == 0 || cd == (iconv_t)-1) return -1;
+ return 0;
+}
+""", '.c'):
+ context.Result(1)
+ return (1,[])
+
+ context.Result(0)
+ return (0,[])
-#if not have_iconv:
-# print "Install iconv for better charset compatibility"
+if hostenv['configure']:
+ conf = hostenv.Configure( custom_tests = { 'CheckIconv' : CheckIconv })
+ (have_iconv,iconv) = conf.CheckIconv()
+ conf.Finish()
-iconv = []
+ if not have_iconv:
+ print "Install iconv for better charset compatibility"
+else:
+ iconv = [] # FIXME
charset = hostenv.StaticLibrary('charset',['iconv.c','charcnv.c',iconv])
Export('charset')
diff --git a/source4/lib/registry/SConscript b/source4/lib/registry/SConscript
index a90557532b..aa2d587260 100644
--- a/source4/lib/registry/SConscript
+++ b/source4/lib/registry/SConscript
@@ -9,4 +9,12 @@ regshell = hostenv.Program('regshell', ['tools/regshell.c',registry,talloc,basic
regpatch = hostenv.Program('regpatch', ['tools/regpatch.c',registry,talloc,basic,popt_common,popt,param])
regdiff = hostenv.Program('regdiff', ['tools/regdiff.c',registry,talloc,basic,popt_common,popt,param])
+hostenv.StaticLibrary('reg_backend_dir.c')
+hostenv.StaticLibrary('reg_backend_gconf.c')
+hostenv.StaticLibrary('reg_backend_ldb.c')
+hostenv.StaticLibrary('reg_backend_nt4', ['reg_backend_nt4.c',hostenv.TdrMarshaller('regf.idl')])
+hostenv.StaticLibrary('reg_backend_rpc.c')
+hostenv.StaticLibrary('reg_backend_w95.c')
+hostenv.StaticLibrary('reg_backend_wine.c')
+
hostenv.Install(paths['BINDIR'], [regtree,regshell,regpatch,regdiff])
diff --git a/source4/lib/replace/README b/source4/lib/replace/README
index 6575112eff..eb3360b74a 100644
--- a/source4/lib/replace/README
+++ b/source4/lib/replace/README
@@ -46,6 +46,8 @@ bzero
strerror
errno
mkstemp (a secure one!)
+pread
+pwrite
Types:
socklen_t
diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript
index 982120e1bf..a2b3a30e10 100644
--- a/source4/lib/replace/SConscript
+++ b/source4/lib/replace/SConscript
@@ -1,11 +1,31 @@
-Import('hostenv')
+#!/usr/bin/env python
+Import('hostenv defines')
if hostenv['configure']:
conf = Configure(hostenv)
- #FIXME: conf.CheckBrokenInetNtoa()
+ for f in ['memset','syslog','setnetgrent','getnetgrent','endnetgrent', \
+ 'mktemp']:
+ if not conf.CheckFunc(f,'c'):
+ print "Required function `%s' not found" % f
+ exit(1)
+
for f in ['strtoull','__strtoull','strtouq','strtoll','__strtoll','strtoq',
- 'seteuid','setresuid','setegid','setresgid']:
- conf.CheckFunc(f,'c')
+ 'seteuid','setresuid','setegid','setresgid','dlsym','dlopen',
+ 'dlerror','dlclose','waitpid','getcwd','strdup','strndup',
+ 'strnlen','strerror','bzero','chroot','strlcpy','strlcat',
+ 'memmove','vsnprintf','asprintf','snprintf','vasprintf',
+ 'innetgr','mktime','rename','ftruncate','chsize','setlinebuf',
+ 'setenv','vsyslog','pread','pwrite']:
+ if conf.CheckFunc(f,'c'):
+ defines['HAVE_' + f.upper()] = 1
+
+ for h in ['dlfcn.h']:
+ if conf.CheckCHeader('dlfcn.h'):
+ defines['HAVE_' + h.upper().replace('.','_').replace('/','_')] = 1
+
+ if not conf.CheckType('socklen_t'):
+ defines['socklen_t'] = 'int'
+
conf.Finish()
hostenv.StaticLibrary('repdir', ['repdir/repdir.c'])
diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4
index ac4db9ed5b..07fbed9d91 100644
--- a/source4/lib/replace/config.m4
+++ b/source4/lib/replace/config.m4
@@ -22,6 +22,7 @@ AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename)
AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup)
+AC_CHECK_FUNCS(pread pwrite)
AC_HAVE_DECL(setresuid, [#include <unistd.h>])
AC_HAVE_DECL(setresgid, [#include <unistd.h>])
AC_HAVE_DECL(errno, [#include <errno.h>])
diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c
index aa79f23fd0..c53b5a5727 100644
--- a/source4/lib/replace/replace.c
+++ b/source4/lib/replace/replace.c
@@ -523,3 +523,25 @@ int rep_mkstemp(char *template)
return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
}
#endif
+
+#ifndef HAVE_PREAD
+static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset)
+{
+ if (lseek(__fd, __offset, SEEK_SET) != __offset) {
+ return -1;
+ }
+ return read(__fd, __buf, __nbytes);
+}
+#endif
+
+#ifndef HAVE_PWRITE
+static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
+{
+ if (lseek(__fd, __offset, SEEK_SET) != __offset) {
+ return -1;
+ }
+ return write(__fd, __buf, __nbytes);
+}
+#endif
+
+
diff --git a/source4/lib/socket/SConscript b/source4/lib/socket/SConscript
index db449592c2..c4e791467a 100644
--- a/source4/lib/socket/SConscript
+++ b/source4/lib/socket/SConscript
@@ -1,5 +1,64 @@
+#!/usr/bin/env python
Import('hostenv')
+
+if hostenv['configure']:
+ conf = hostenv.Configure()
+ conf.CheckCHeader('sys/socket.h')
+ conf.CheckCHeader('sys/sockio.h')
+ conf.CheckCHeader('sys/un.h')
+ #HAVE_SOCK_SIN_LEN
+ conf.TryCompile("""
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+int main(void)
+{
+ struct sockaddr_in sock; sock.sin_len = sizeof(sock);
+ return 0;
+}""", '.c')
+
+ #HAVE_UNIXSOCKET
+ conf.TryCompile("""
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/socket.h>
+#include <sys/un.h>],
+
+int main(void)
+{
+ struct sockaddr_un sunaddr;
+ sunaddr.sun_family = AF_UNIX;
+ return 0;
+}""", '.c')
+
+ # HAVE_IPV6
+ conf.CheckFunc('gethostbyname2')
+
+ # The following test taken from the cvs sources
+ # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
+ # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
+ # libsocket.so which has a bad implementation of gethostbyname (it
+ # only looks in /etc/hosts), so we only look for -lsocket if we need
+ # it.
+
+ connect_libs = []
+
+ if not conf.CheckFunc('connect'):
+ for l in ['nsl_s','nsl','socket','inet']:
+ if conf.CheckLib(l, 'connect'):
+ connect_libs.append(l)
+ break
+
+ # HAVE_WORKING_AF_LOCAL
+ # FIXME: Try compiling build/tests/unixsock.c
+
+
+ conf.Finish()
+
hostenv.StaticLibrary('socket_ipv4.c')
hostenv.StaticLibrary('socket_ipv6.c')
hostenv.StaticLibrary('socket_unix.c')
hostenv.StaticLibrary('socket', ['socket.c','access.c','connect.c'])
+