FUNCTION_MACRO change broke the Python modules.
[samba.git] / source / 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
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 2 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, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #
23
24 from distutils.core import setup
25 from distutils.extension import Extension
26
27 import sys, string, os
28
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.
33
34 samba_objs = os.environ.get("PYTHON_OBJS", "")
35
36 samba_cflags = os.environ.get("PYTHON_CFLAGS", "")
37
38 samba_srcdir = os.environ.get("SRCDIR", "")
39
40 # These variables are filled in by configure
41
42 samba_libs = os.environ.get("LIBS", "")
43
44 # Convert libs and objs from space separated strings to lists of strings
45 # for distutils to digest.  Split "-l" prefix off library list.
46
47 obj_list = string.split(samba_objs)
48
49 lib_list = []
50
51 for lib in string.split(samba_libs):
52     lib_list.append(string.replace(lib, "-l", ""))
53
54 flags_list = string.split(samba_cflags)
55
56 # Invoke distutils.setup
57
58 setup(
59
60     # Overview information
61     
62     name = "Samba Python Extensions",
63     version = "0.1",
64     author = "Tim Potter",
65     author_email = "tpot@samba.org",
66     license = "GPL",
67
68     # Get the "samba" directory of Python source.  At the moment this
69     # just contains the __init__ file that makes it work as a
70     # subpackage.  This is needed even though everything else is an
71     # extension module.
72     package_dir = {"samba": os.path.join(samba_srcdir, "python", "samba")},
73     packages = ["samba"],
74     
75     # Module list
76     ext_package = "samba", 
77     ext_modules = [
78
79     # SPOOLSS pipe module
80
81     Extension(name = "spoolss",
82               sources = [samba_srcdir + "python/py_spoolss.c",
83                          samba_srcdir + "python/py_common.c",
84                          samba_srcdir + "python/py_conv.c",
85                          samba_srcdir + "python/py_ntsec.c",
86                          samba_srcdir + "python/py_spoolss_forms.c",
87                          samba_srcdir + "python/py_spoolss_forms_conv.c",
88                          samba_srcdir + "python/py_spoolss_drivers.c",
89                          samba_srcdir + "python/py_spoolss_drivers_conv.c",
90                          samba_srcdir + "python/py_spoolss_printers.c",
91                          samba_srcdir + "python/py_spoolss_printers_conv.c",
92                          samba_srcdir + "python/py_spoolss_printerdata.c",
93                          samba_srcdir + "python/py_spoolss_ports.c",
94                          samba_srcdir + "python/py_spoolss_ports_conv.c",
95                          samba_srcdir + "python/py_spoolss_jobs.c",
96                          samba_srcdir + "python/py_spoolss_jobs_conv.c",
97                          ],
98               libraries = lib_list,
99               library_dirs = ["/usr/kerberos/lib"],
100               extra_compile_args = flags_list,
101               extra_objects = obj_list),
102
103     # LSA pipe module
104
105     Extension(name = "lsa",
106               sources = [samba_srcdir + "python/py_lsa.c",
107                          samba_srcdir + "python/py_common.c",
108                          samba_srcdir + "python/py_ntsec.c"],
109               libraries = lib_list,
110               library_dirs = ["/usr/kerberos/lib"],
111               extra_compile_args = flags_list,
112               extra_objects = obj_list),
113
114     # SAMR pipe module
115
116     Extension(name = "samr",
117               sources = [samba_srcdir + "python/py_samr.c",
118                          samba_srcdir + "python/py_samr_conv.c",
119                          samba_srcdir + "python/py_common.c"],
120               libraries = lib_list,
121               library_dirs = ["/usr/kerberos/lib"],
122               extra_compile_args = flags_list,
123               extra_objects = obj_list),
124
125     # winbind client module
126
127     Extension(name = "winbind",
128               sources = [samba_srcdir + "python/py_winbind.c",
129                          samba_srcdir + "python/py_winbind_conv.c",
130                          samba_srcdir + "python/py_conv.c",
131                          samba_srcdir + "python/py_common.c"],
132               libraries = lib_list,
133               library_dirs = ["/usr/kerberos/lib"],
134               extra_compile_args = flags_list,
135               extra_objects = obj_list),
136
137     # WINREG pipe module
138
139     Extension(name = "winreg",
140               sources = [samba_srcdir + "python/py_winreg.c",
141                          samba_srcdir + "python/py_common.c"],
142               libraries = lib_list,
143               library_dirs = ["/usr/kerberos/lib"],
144               extra_compile_args = flags_list,
145               extra_objects = obj_list),
146
147     # tdb module
148
149     Extension(name = "tdb",
150               sources = [samba_srcdir + "python/py_tdb.c"],
151               libraries = lib_list,
152               library_dirs = ["/usr/kerberos/lib"],
153               extra_compile_args = flags_list,
154               extra_objects = obj_list),
155
156     # libsmb module
157
158     Extension(name = "smb",
159               sources = [samba_srcdir + "python/py_smb.c",
160                          samba_srcdir + "python/py_common.c",
161                          samba_srcdir + "python/py_ntsec.c"],
162               libraries = lib_list,
163               library_dirs = ["/usr/kerberos/lib"],
164               extra_compile_args = flags_list,
165               extra_objects = obj_list),
166
167     # Moving to merge all individual extensions in to one big
168     # extension.  This is to avoid the fact that each extension is 3MB
169     # in size due to the lack of proper depedency management in Samba.
170
171     Extension(name = "samba",
172               sources = [samba_srcdir + "python/py_samba.c",
173                          samba_srcdir + "python/py_common.c"],
174               libraries = lib_list,
175               library_dirs = ["/usr/kerberos/lib"],
176               extra_compile_args = flags_list,
177               extra_objects = obj_list),
178
179     # tdbpack/unpack extensions.  Does not actually link to any Samba
180     # code, although it implements a compatible data format.
181     Extension(name = "tdbpack",
182               sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")],
183               extra_compile_args = ["-I include"])
184     ],
185 )