r23801: The FSF has moved around a lot. This fixes their Mass Ave address.
[nivanova/samba-autobuild/.git] / source3 / python / setup.py
1 # -*- mode: python -*-
2 #
3 # Unix SMB/CIFS implementation.
4 # Module packaging setup for Samba python extensions
5 #
6 # Copyright (C) Tim Potter, 2002-2003
7 # Copyright (C) Martin Pool, 2002
8 #
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 3 of the License, or
12 # (at your option) any later version.
13 #   
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.
18 #   
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #
22
23 from distutils.core import setup
24 from distutils.extension import Extension
25
26 import sys, string, os
27
28 # The Makefile passes in environment variable $PYTHON_OBJ as being the
29 # list of Samba objects.  This kind of goes against the distutils.cmd
30 # method of adding setup commands and will also confuse people who are
31 # familiar with the python Distutils module.
32
33 samba_objs = os.environ.get("PYTHON_OBJS", "")
34
35 samba_cflags = os.environ.get("PYTHON_CFLAGS", "")
36
37 samba_srcdir = os.environ.get("SRCDIR", "")
38
39 compiler = os.environ.get("CC", "")
40
41 # These variables are filled in by configure
42
43 samba_libs = os.environ.get("LIBS", "")
44
45 obj_list = string.split(samba_objs)
46
47 # Unfortunately the samba_libs variable contains both shared libraries
48 # and linker flags.  The python distutils doesn't like this so we have
49 # to split $samba_libs into a flags component and a library component.
50
51 libraries = []
52 library_dirs = []
53
54 next_is_path = 0
55 next_is_flag = 0
56
57 for lib in string.split(samba_libs):
58     if next_is_path != 0:
59         library_dirs.append(lib);
60         next_is_path = 0;
61     elif next_is_flag != 0:
62         next_is_flag = 0;
63     elif lib == "-Wl,-rpath":
64         next_is_path = 1;
65     elif lib[0:2] == ("-l"):
66         libraries.append(lib[2:])
67     elif lib[0:8] == ("-pthread"):
68         pass # Skip linker flags
69     elif lib[0:4] == ("-pie"):
70         pass # Skip linker flags
71     elif lib[0:2] == "-L":
72         library_dirs.append(lib[2:])
73     elif lib[0:2] in ("-W","-s"):
74         pass # Skip linker flags
75     elif lib[0:2] == "-z":
76         next_is_flag = 1 # Skip linker flags
77     else:
78         print "Unknown entry '%s' in $LIBS variable passed to setup.py" % lib
79         sys.exit(1)
80
81 flags_list = string.split(samba_cflags)
82
83 # Invoke distutils.setup
84
85 setup(
86
87     # Overview information
88     
89     name = "Samba Python Extensions",
90     version = "0.1",
91     author = "Tim Potter",
92     author_email = "tpot@samba.org",
93     license = "GPL",
94
95     # Get the "samba" directory of Python source.  At the moment this
96     # just contains the __init__ file that makes it work as a
97     # subpackage.  This is needed even though everything else is an
98     # extension module.
99     package_dir = {"samba": os.path.join(samba_srcdir, "python", "samba")},
100     packages = ["samba"],
101     
102     # Module list
103     ext_package = "samba", 
104     ext_modules = [
105
106     # SPOOLSS pipe module
107
108     Extension(name = "spoolss",
109               sources = [samba_srcdir + "python/py_spoolss.c",
110                          samba_srcdir + "python/py_common.c",
111                          samba_srcdir + "python/py_conv.c",
112                          samba_srcdir + "python/py_ntsec.c",
113                          samba_srcdir + "python/py_spoolss_common.c",
114                          samba_srcdir + "python/py_spoolss_forms.c",
115                          samba_srcdir + "python/py_spoolss_forms_conv.c",
116                          samba_srcdir + "python/py_spoolss_drivers.c",
117                          samba_srcdir + "python/py_spoolss_drivers_conv.c",
118                          samba_srcdir + "python/py_spoolss_printers.c",
119                          samba_srcdir + "python/py_spoolss_printers_conv.c",
120                          samba_srcdir + "python/py_spoolss_printerdata.c",
121                          samba_srcdir + "python/py_spoolss_ports.c",
122                          samba_srcdir + "python/py_spoolss_ports_conv.c",
123                          samba_srcdir + "python/py_spoolss_jobs.c",
124                          samba_srcdir + "python/py_spoolss_jobs_conv.c",
125                          ],
126               libraries = libraries,
127               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
128               extra_compile_args = flags_list,
129               extra_objects = obj_list),
130
131     # LSA pipe module
132
133     Extension(name = "lsa",
134               sources = [samba_srcdir + "python/py_lsa.c",
135                          samba_srcdir + "python/py_common.c",
136                          samba_srcdir + "python/py_ntsec.c"],
137               libraries = libraries,
138               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
139               extra_compile_args = flags_list,
140               extra_objects = obj_list),
141
142     # SAMR pipe module
143
144     Extension(name = "samr",
145               sources = [samba_srcdir + "python/py_samr.c",
146                          samba_srcdir + "python/py_conv.c",
147                          samba_srcdir + "python/py_samr_conv.c",
148                          samba_srcdir + "python/py_common.c"],
149               libraries = libraries,
150               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
151               extra_compile_args = flags_list,
152               extra_objects = obj_list),
153
154     # winbind client module
155
156     Extension(name = "winbind",
157               sources = [samba_srcdir + "python/py_winbind.c",
158                          samba_srcdir + "python/py_winbind_conv.c",
159                          samba_srcdir + "python/py_conv.c",
160                          samba_srcdir + "python/py_common.c"],
161               libraries = libraries,
162               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
163               extra_compile_args = flags_list,
164               extra_objects = obj_list),
165
166     # WINREG pipe module
167
168     Extension(name = "winreg",
169               sources = [samba_srcdir + "python/py_winreg.c",
170                          samba_srcdir + "python/py_common.c"],
171               libraries = libraries,
172               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
173               extra_compile_args = flags_list,
174               extra_objects = obj_list),
175
176     # SRVSVC pipe module
177
178     Extension(name = "srvsvc",
179               sources = [samba_srcdir + "python/py_srvsvc.c",
180                          samba_srcdir + "python/py_conv.c",
181                          samba_srcdir + "python/py_srvsvc_conv.c",
182                          samba_srcdir + "python/py_common.c"],
183               libraries = libraries,
184               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
185               extra_compile_args = flags_list,
186               extra_objects = obj_list),
187
188     # tdb module
189
190     Extension(name = "tdb",
191               sources = [samba_srcdir + "python/py_tdb.c"],
192               libraries = libraries,
193               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
194               extra_compile_args = flags_list,
195               extra_objects = obj_list),
196
197     # libsmb module
198
199     Extension(name = "smb",
200               sources = [samba_srcdir + "python/py_smb.c",
201                          samba_srcdir + "python/py_common.c",
202                          samba_srcdir + "python/py_ntsec.c"],
203               libraries = libraries,
204               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
205               extra_compile_args = flags_list,
206               extra_objects = obj_list),
207
208     # tdbpack/unpack extensions.  Does not actually link to any Samba
209     # code, although it implements a compatible data format.
210     
211     Extension(name = "tdbpack",
212               sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")],
213               extra_compile_args = ["-I."])
214     ],
215 )