r10374: Add HAVE_* defines (on command-line or in config.h file) for scons +
[kai/samba.git] / source / SConstruct
1 #!/usr/bin/env python
2
3 # This is the experimental scons build script for Samba 4. For a proper 
4 # build use the old build system (configure + make). scons may
5 # eventually replace this system.
6 #
7 # Copyright (C) 2005 Jelmer Vernooij <jelmer@samba.org>
8 # Published under the GNU GPL
9
10 # We don't care about NFS builds...
11
12 opts = Options(None, ARGUMENTS)
13 opts.AddOptions(
14                 BoolOption('developer','enable developer flags', 0),
15                 PathOption('prefix','installation prefix','/usr/local/samba'),
16                 BoolOption('configh','use config.h file', 0)
17 )
18
19 hostenv = Environment(
20                 toolpath=['build/scons','.'],
21                 tools=['default','pidl','proto','et','asn1'],
22                 options=opts,
23                 CPPPATH=['#include','#','#lib'], 
24                 CPPDEFINES={'_SAMBA_BUILD_': None},
25                 )
26
27 hostenv.SetOption('max_drift', 1)
28
29 if hostenv['developer']:
30         hostenv.Append(CCFLAGS='-Wall')
31         hostenv.Append(CCFLAGS='-Wshadow')
32         hostenv.Append(CCFLAGS='-Werror-implicit-function-declaration')
33         hostenv.Append(CCFLAGS='-Wstrict-prototypes')
34         hostenv.Append(CCFLAGS='-Wpointer-arith')
35         hostenv.Append(CCFLAGS='-Wcast-qual')
36         hostenv.Append(CCFLAGS='-Wcast-align')
37         hostenv.Append(CCFLAGS='-Wwrite-strings')
38         hostenv.Append(CCFLAGS='-Wmissing-format-attribute')
39         hostenv.Append(CCFLAGS='-Wformat=2')
40         hostenv.Append(CCFLAGS='-Wno-format-y2k')
41         hostenv.Append(CCFLAGS='-Wno-declaration-after-statement')
42
43 defines = {}
44 Export('defines')
45
46 hostenv.Append(CPPPATH = ['#heimdal_build', '#heimdal/lib/krb5',
47                           '#heimdal/lib/hdb', '#heimdal/lib/gssapi',
48                           '#heimdal/lib/asn1', '#heimdal/lib/des',
49                           '#heimdal/kdc', '#heimdal/lib/roken',
50                           '#heimdal/lib/com_err'])
51
52 Export('hostenv')
53
54 buildenv = hostenv
55
56 Export('buildenv')
57
58 cross_compiling = 0
59
60 if cross_compiling:
61         buildenv = hostenv.Copy()
62         buildenv.BuildDir('build-env','.')
63
64 dynenv = hostenv.Copy()
65
66 paths = { 
67         'BINDIR': 'bin',
68         'SBINDIR': 'sbin',
69         'CONFIGFILE': 'cfg',
70         'LOGFILEBASE': 'lfb',
71         'NCALRPCDIR': 'ncalrpc',
72         'LMHOSTSFILE': 'lmhosts',
73         'LIBDIR': 'libdir',
74         'SHLIBEXT': 'ext',
75         'LOCKDIR': 'lockdir',
76         'PIDDIR': 'piddir',
77         'PRIVATE_DIR': 'private',
78         'SWATDIR': 'swat'
79 }
80
81 Export('paths')
82
83 conf = hostenv.Configure()
84 for h in ['sys/select.h','fcntl.h','sys/fcntl.h','sys/time.h'] + \
85         ['utime.h','grp.h','sys/id.h','limits.h','memory.h'] + \
86         ['compat.h','math.h','sys/param.h','ctype.h','sys/wait.h'] + \
87         ['sys/resource.h','sys/ioctl.h','sys/ipc.h','sys/mode.h'] + \
88         ['sys/mman.h','sys/filio.h','sys/priv.h','sys/shm.h','string.h'] + \
89         ['strings.h','stdlib.h','sys/vfs.h','sys/fs/s5param.h','sys/filsys.h'] + \
90         ['termios.h','termio.h','fnmatch.h','pwd.h','sys/termio.h'] + \
91         ['sys/time.h','sys/statfs.h','sys/statvfs.h','stdarg.h'] + \
92         ['security/pam_modules.h','security/_pam_macros.h','dlfcn.h'] + \
93         ['sys/syslog.h','syslog.h','stdint.h','inttypes.h','locale.h'] + \
94         ['shadow.h','nss.h','nss_common.h','ns_api.h','sys/security.h'] + \
95         ['security/pam_appl.h','sys/capability.h','syscall.h','sys/syscall.h'] + \
96         ['sys/acl.h']:
97         if conf.CheckCHeader(h):
98                 defines['HAVE_' + h.upper().replace('.','_').replace('/','_')] = 1
99
100 for f in ['dlopen','dlsym','dlerror','waitpid','getcwd','strdup'] + \
101         ['strndup','strnlen','strerror','chroot','bzero','memset','strlcpy'] + \
102         ['strlcat','memmove','vsnprintf','snprintf','asprintf','vasprintf'] + \
103         ['setsid','pipe','crypt16','getauthuid','strftime','sigprocmask'] + \
104         ['sigblock','sigaction','innetgr','setnetgrent','getnetgrent'] + \
105         ['endnetgrent','initgroups','setgroups','sysconf','mktime','rename'] + \
106         ['ftruncate','chsize','getpwanam','setlinebuf','srandom','random'] + \
107         ['srand','rand','setenv','usleep','syslog','vsyslog','timegm'] + \
108         ['backtrace','setbuffer','pread','pwrite']:
109         if conf.CheckFunc(f):
110                 defines['HAVE_' + f.upper()] = 1
111
112 conf.Finish()
113
114 [dynenv.Append(CPPDEFINES = {p: '\\"%s\\"' % paths[p]}) for p in paths]
115         
116 dynconfig = dynenv.Object('dynconfig.c')
117 Export('dynconfig')
118
119 proto_files = []
120 Export('proto_files')
121
122 SConscript(
123                 dirs=['lib','torture','rpc_server','cldap_server','libcli',
124                 'nbt_server','client','ldap_server','libnet','nsswitch','web_server',
125                 'smbd','dsdb','heimdal_build','ntptr','kdc','smb_server','ntvfs',
126                 'winbind','scripting','auth'])
127
128 hostenv.CProtoHeader(target='include/proto.h',source=proto_files)
129
130 if hostenv['configh']:
131         def create_config_h(env,target,source):
132                 pass #FIXME
133         hostenv.Command('include/config.h',[],create_config_h)
134         hostenv.Append(CPPDEFINES = {HAVE_CONFIG_H: 1})
135 else:
136         [hostenv.Append(CPPDEFINES = {p: defines[p]}) for p in defines]