r8538: honour CC in python build.
[Samba.git] / source / python / setup.py
blobbfc743603bdb5a5eb59b12bb4f14159c70895b5c
1 # -*- mode: python -*-
3 # Unix SMB/CIFS implementation.
4 # Module packaging setup for Samba python extensions
6 # Copyright (C) Tim Potter, 2002-2003
7 # Copyright (C) Martin Pool, 2002
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 from distutils.core import setup
25 from distutils.extension import Extension
27 import sys, string, os
29 # The Makefile passes in environment variable $PYTHON_OBJ as being the
30 # list of Samba objects. This kind of goes against the distutils.cmd
31 # method of adding setup commands and will also confuse people who are
32 # familiar with the python Distutils module.
34 samba_objs = os.environ.get("PYTHON_OBJS", "")
36 samba_cflags = os.environ.get("PYTHON_CFLAGS", "")
38 samba_srcdir = os.environ.get("SRCDIR", "")
40 compiler = os.environ.get("CC", "")
42 # These variables are filled in by configure
44 samba_libs = os.environ.get("LIBS", "")
46 obj_list = string.split(samba_objs)
48 # Unfortunately the samba_libs variable contains both shared libraries
49 # and linker flags. The python distutils doesn't like this so we have
50 # to split $samba_libs into a flags component and a library component.
52 libraries = []
53 library_dirs = []
55 for lib in string.split(samba_libs):
56 if lib[0:2] == "-l":
57 libraries.append(lib[2:])
58 continue
59 if lib[0:2] == "-L":
60 library_dirs.append(lib[2:])
61 continue
62 if lib[0:2] == "-W":
63 # Skip linker flags
64 continue
65 print "Unknown entry '%s' in $LIBS variable passed to setup.py" % lib
66 sys.exit(1)
68 flags_list = string.split(samba_cflags)
70 # Invoke distutils.setup
72 setup(
74 # Overview information
76 name = "Samba Python Extensions",
77 version = "0.1",
78 author = "Tim Potter",
79 author_email = "tpot@samba.org",
80 license = "GPL",
82 # Get the "samba" directory of Python source. At the moment this
83 # just contains the __init__ file that makes it work as a
84 # subpackage. This is needed even though everything else is an
85 # extension module.
86 package_dir = {"samba": os.path.join(samba_srcdir, "python", "samba")},
87 packages = ["samba"],
89 # Module list
90 ext_package = "samba",
91 ext_modules = [
93 # SPOOLSS pipe module
95 Extension(name = "spoolss",
96 sources = [samba_srcdir + "python/py_spoolss.c",
97 samba_srcdir + "python/py_common.c",
98 samba_srcdir + "python/py_conv.c",
99 samba_srcdir + "python/py_ntsec.c",
100 samba_srcdir + "python/py_spoolss_common.c",
101 samba_srcdir + "python/py_spoolss_forms.c",
102 samba_srcdir + "python/py_spoolss_forms_conv.c",
103 samba_srcdir + "python/py_spoolss_drivers.c",
104 samba_srcdir + "python/py_spoolss_drivers_conv.c",
105 samba_srcdir + "python/py_spoolss_printers.c",
106 samba_srcdir + "python/py_spoolss_printers_conv.c",
107 samba_srcdir + "python/py_spoolss_printerdata.c",
108 samba_srcdir + "python/py_spoolss_ports.c",
109 samba_srcdir + "python/py_spoolss_ports_conv.c",
110 samba_srcdir + "python/py_spoolss_jobs.c",
111 samba_srcdir + "python/py_spoolss_jobs_conv.c",
113 libraries = libraries,
114 library_dirs = ["/usr/kerberos/lib"] + library_dirs,
115 extra_compile_args = flags_list,
116 extra_objects = obj_list),
118 # LSA pipe module
120 Extension(name = "lsa",
121 sources = [samba_srcdir + "python/py_lsa.c",
122 samba_srcdir + "python/py_common.c",
123 samba_srcdir + "python/py_ntsec.c"],
124 libraries = libraries,
125 library_dirs = ["/usr/kerberos/lib"] + library_dirs,
126 extra_compile_args = flags_list,
127 extra_objects = obj_list),
129 # SAMR pipe module
131 Extension(name = "samr",
132 sources = [samba_srcdir + "python/py_samr.c",
133 samba_srcdir + "python/py_conv.c",
134 samba_srcdir + "python/py_samr_conv.c",
135 samba_srcdir + "python/py_common.c"],
136 libraries = libraries,
137 library_dirs = ["/usr/kerberos/lib"] + library_dirs,
138 extra_compile_args = flags_list,
139 extra_objects = obj_list),
141 # winbind client module
143 Extension(name = "winbind",
144 sources = [samba_srcdir + "python/py_winbind.c",
145 samba_srcdir + "python/py_winbind_conv.c",
146 samba_srcdir + "python/py_conv.c",
147 samba_srcdir + "python/py_common.c"],
148 libraries = libraries,
149 library_dirs = ["/usr/kerberos/lib"] + library_dirs,
150 extra_compile_args = flags_list,
151 extra_objects = obj_list),
153 # WINREG pipe module
155 Extension(name = "winreg",
156 sources = [samba_srcdir + "python/py_winreg.c",
157 samba_srcdir + "python/py_common.c"],
158 libraries = libraries,
159 library_dirs = ["/usr/kerberos/lib"] + library_dirs,
160 extra_compile_args = flags_list,
161 extra_objects = obj_list),
163 # SRVSVC pipe module
165 Extension(name = "srvsvc",
166 sources = [samba_srcdir + "python/py_srvsvc.c",
167 samba_srcdir + "python/py_conv.c",
168 samba_srcdir + "python/py_srvsvc_conv.c",
169 samba_srcdir + "python/py_common.c"],
170 libraries = libraries,
171 library_dirs = ["/usr/kerberos/lib"] + library_dirs,
172 extra_compile_args = flags_list,
173 extra_objects = obj_list),
175 # tdb module
177 Extension(name = "tdb",
178 sources = [samba_srcdir + "python/py_tdb.c"],
179 libraries = libraries,
180 library_dirs = ["/usr/kerberos/lib"] + library_dirs,
181 extra_compile_args = flags_list,
182 extra_objects = obj_list),
184 # libsmb module
186 Extension(name = "smb",
187 sources = [samba_srcdir + "python/py_smb.c",
188 samba_srcdir + "python/py_common.c",
189 samba_srcdir + "python/py_ntsec.c"],
190 libraries = libraries,
191 library_dirs = ["/usr/kerberos/lib"] + library_dirs,
192 extra_compile_args = flags_list,
193 extra_objects = obj_list),
195 # tdbpack/unpack extensions. Does not actually link to any Samba
196 # code, although it implements a compatible data format.
198 Extension(name = "tdbpack",
199 sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")],
200 extra_compile_args = ["-I."])