| 1 | |
| 2 | AddOption('--force-mingw32', |
| 3 | action='store_true', dest='mingw32', default=False, |
| 4 | help='Cross compile using MinGW for Windows') |
| 5 | |
| 6 | AddOption('--force-mingw64', |
| 7 | action='store_true', dest='mingw64', default=False, |
| 8 | help='Cross compile using MinGW for Windows 64-bit') |
| 9 | |
| 10 | AddOption('--force-32bit', |
| 11 | action='store_true', dest='gcc32', default=False, |
| 12 | help='Always compile using 32-bit compiler flags') |
| 13 | |
| 14 | AddOption('--force-64bit', |
| 15 | action='store_true', dest='gcc64', default=False, |
| 16 | help='Always compile using 64-bit compiler flags') |
| 17 | |
| 18 | AddOption('--build-universal', |
| 19 | action='store_true', dest='universal', default=False, |
| 20 | help='Create Mac 32-bit and 64-bit universal binaries') |
| 21 | |
| 22 | VariantDir('build', 'src') |
| 23 | env = Environment() |
| 24 | |
| 25 | if env['PLATFORM'] == 'win32' or GetOption('mingw32') or GetOption('mingw64'): |
| 26 | env.Append(CPPDEFINES = ['WINVER=0x0501']) |
| 27 | |
| 28 | if GetOption('mingw32'): |
| 29 | env.Tool('crossmingw', toolpath = ['scons-tools']) |
| 30 | |
| 31 | if GetOption('mingw64'): |
| 32 | env.Tool('crossmingw64', toolpath = ['scons-tools']) |
| 33 | |
| 34 | if GetOption('gcc32'): |
| 35 | env.Append(CFLAGS = ['-m32']) |
| 36 | env.Append(CPPFLAGS = ['-m32']) |
| 37 | env.Append(CXXFLAGS = ['-m32']) |
| 38 | env.Append(LINKFLAGS = ['-m32']) |
| 39 | |
| 40 | if GetOption('gcc64'): |
| 41 | env.Append(CFLAGS = ['-m64']) |
| 42 | env.Append(CPPFLAGS = ['-m64']) |
| 43 | env.Append(CXXFLAGS = ['-m64']) |
| 44 | env.Append(LINKFLAGS = ['-m64']) |
| 45 | |
| 46 | env.Append(CFLAGS = ['-Wall', '-Werror', '-O2']) |
| 47 | |
| 48 | conf = Configure(env) |
| 49 | conf.CheckLib('socket') |
| 50 | if conf.CheckFunc('getaddrinfo'): |
| 51 | env.Append(CPPDEFINES = ['HAVE_GETADDRINFO']) |
| 52 | else: |
| 53 | if conf.CheckLibWithHeader('ws2_32', 'ws2tcpip.h','c','getaddrinfo(0,0,0,0);'): |
| 54 | env.Append(CPPDEFINES = ['HAVE_GETADDRINFO']) |
| 55 | else: |
| 56 | if conf.CheckLib('ws2_32'): |
| 57 | # We have windows socket lib without getaddrinfo, disable IPv6 |
| 58 | env.Append(CPPDEFINES = ['DISABLE_IPV6']) |
| 59 | conf.CheckLib('winmm') |
| 60 | env = conf.Finish() |
| 61 | |
| 62 | env.SConscript('build/SConscript', exports='env') |
| 63 | |