summaryrefslogtreecommitdiff
path: root/source4/build/scons/iconv.py
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-09-19 22:01:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:28 -0500
commit069e498da2a03bd253a2fcf2b7ff13f266ab63b4 (patch)
tree640f3f77f4a16577c5deab17c4c9216da51bd179 /source4/build/scons/iconv.py
parent700120068620f32f7affb479dc5986544afed643 (diff)
downloadsamba-069e498da2a03bd253a2fcf2b7ff13f266ab63b4.tar.gz
samba-069e498da2a03bd253a2fcf2b7ff13f266ab63b4.tar.bz2
samba-069e498da2a03bd253a2fcf2b7ff13f266ab63b4.zip
r10330: Add SConscript to more subsystems. Some of the tdb tools build now.
Start on custom Samba scons tools (for handling proto generation, pidl, etc) (This used to be commit 4bffe4435944fffa3f9680b5a2fe63f2bdd98003)
Diffstat (limited to 'source4/build/scons/iconv.py')
-rw-r--r--source4/build/scons/iconv.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/source4/build/scons/iconv.py b/source4/build/scons/iconv.py
new file mode 100644
index 0000000000..ef82dc475d
--- /dev/null
+++ b/source4/build/scons/iconv.py
@@ -0,0 +1,75 @@
+# Based on the M4 macro by Bruno Haible.
+
+def _CheckIconvPath(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(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,[])