File: SConstruct

package info (click to toggle)
unworkable 0.53-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 552 kB
  • sloc: ansic: 6,093; python: 443; yacc: 319; makefile: 6
file content (110 lines) | stat: -rw-r--r-- 4,024 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# scons (http://www.scons.org) build for non-OpenBSD systems
# on OpenBSD, just type 'make'.
# $Id: SConstruct,v 1.17 2008-09-09 05:42:13 niallo Exp $

import sys

SRCS = ['announce.c', 'bencode.c', 'buf.c', 'ctl_server.c', 'main.c', 'network.c', 'parse.y', 'progressmeter.c', \
        'scheduler.c', 'torrent.c', 'trace.c', 'util.c', 'xmalloc.c']
LIBS =  ['event', 'crypto']
LIBPATH = ['/usr/lib', '/usr/local/lib']
CPPPATH = ['/usr/include', '/usr/local/include']
CCFLAGS = ['-Wall', '-Wstrict-prototypes', '-Wmissing-prototypes', '-Wmissing-declarations', '-Wshadow', '-Wpointer-arith', '-Wcast-qual', '-Wsign-compare', '-g', '-ggdb']

# Assume this is Solaris with packages from www.sunfreeware.com
if sys.platform.startswith('sunos'):
	SRCS.append('openbsd-compat/err.c')
	SRCS.append('openbsd-compat/errx.c')
	SRCS.append('openbsd-compat/warn.c')
	SRCS.append('openbsd-compat/warnx.c')
	SRCS.append('openbsd-compat/verr.c')
	SRCS.append('openbsd-compat/verrx.c')
	SRCS.append('openbsd-compat/vwarnx.c')
	SRCS.append('openbsd-compat/vwarn.c')
	CPPPATH.append('/usr/local/ssl/include')
	CPPPATH.append('openbsd-compat/')
	LIBPATH.append('/usr/local/ssl/lib')
	LIBPATH.append('/usr/ucblib')
	LIBS.append('socket')
	LIBS.append('nsl')
	LIBS.append('ucb')
	CCFLAGS.append('-DNO_ERR')

# Assume this is Mac OS X with macports, so stuff is under /opt
elif sys.platform.startswith('darwin'):
	LIBPATH.append('/opt/local/lib')
	CPPPATH.append('/opt/local/include')

# Explicitly make off_t 64bit on Linux
elif sys.platform.startswith('linux'):
	CCFLAGS.append('-D_FILE_OFFSET_BITS=64')

env = Environment(LIBPATH=LIBPATH, CPPPATH=CPPPATH)
conf = Configure(env)

if not conf.CheckType('u_int8_t', '#include <sys/types.h>\n'):
	CCFLAGS.append('-Du_int8_t=unsigned char')

if not conf.CheckType('u_int32_t', '#include <sys/types.h>\n'):
	CCFLAGS.append('-Du_int32_t=unsigned int')

if not conf.CheckType('u_int64_t', '#include <sys/types.h>\n'):
	CCFLAGS.append('-Du_int64_t=unsigned long long')

if not conf.CheckType('int64_t', '#include <sys/types.h>\n'):
	CCFLAGS.append('-Dint64_t=long long')

if not conf.CheckCHeader('openssl/bn.h'):
	print "No openssl/bn.h found.  Do you have the OpenSSL headers correctly installed?"
	Exit(1)

if not conf.CheckCHeader('openssl/dh.h'):
	print "No openssl/dh.h found.  Do you have the OpenSSL headers correctly installed?"
	Exit(1)

if not conf.CheckCHeader('openssl/engine.h'):
	print "No openssl/engine.h found.  Do you have the OpenSSL headers correctly installed?"
	Exit(1)

if not conf.CheckCHeader('sys/queue.h') or not conf.CheckCHeader('sys/tree.h') \
	or not conf.CheckCHeader('sha1.h'):
	print "Missing some headers, using bundled includes"
	CPPPATH.append('openbsd-compat/')

if not conf.CheckFunc('strlcpy'):
	print "No system strlcpy found.  Using bundled version"
	SRCS.append('openbsd-compat/strlcpy.c')
	conf.env.Append(CCFLAGS = '-DNO_STRLCPY')
	CCFLAGS.append('-DNO_STRLCPY')

if not conf.CheckFunc('strlcat'):
	print "No system strlcat found.  Using bundled version"
	SRCS.append('openbsd-compat/strlcat.c')
	CCFLAGS.append('-DNO_STRLCAT')

if not conf.CheckFunc('strtonum'):
	print "No system strtonum found.  Using bundled version"
	SRCS.append('openbsd-compat/strtonum.c')
	CCFLAGS.append('-DNO_STRTONUM')

if not conf.CheckFunc('SHA1Update'):
	print "No system SHA1Update found.  Using bundled version"
	SRCS.append('openbsd-compat/sha1.c')

if not conf.CheckFunc('getaddrinfo') and not sys.platform.startswith('sunos'):
	print "No system getaddrinfo() found.  Using bundled version"
	SRCS.append('openbsd-compat/getaddrinfo.c')
	CCFLAGS.append('-DNO_GETADDRINFO')

if not conf.CheckLib('crypto'):
	print "OpenSSL crypto library not found on your system.  You can get it at http://www.openssl.org"
	Exit(1)

if not conf.CheckLib('event'):
	print "Libevent not found on your system.  You can get it at http://monkey.org/~provos/libevent/"
	Exit(1)


env = conf.Finish()

env.Program('unworkable', SRCS, LIBS=LIBS, LIBPATH=LIBPATH, CPPPATH=CPPPATH, CCFLAGS=CCFLAGS)