detect.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import os
  2. import sys
  3. def is_active():
  4. return True
  5. def get_name():
  6. return "X11"
  7. def can_build():
  8. if (os.name!="posix"):
  9. return False
  10. if sys.platform == "darwin":
  11. return False # no x11 on mac for now
  12. errorval=os.system("pkg-config --version > /dev/null")
  13. if (errorval):
  14. print("pkg-config not found.. x11 disabled.")
  15. return False
  16. x11_error=os.system("pkg-config x11 --modversion > /dev/null ")
  17. if (x11_error):
  18. print("X11 not found.. x11 disabled.")
  19. return False
  20. ssl_error=os.system("pkg-config openssl --modversion > /dev/null ")
  21. if (ssl_error):
  22. print("OpenSSL not found.. x11 disabled.")
  23. return False
  24. x11_error=os.system("pkg-config xcursor --modversion > /dev/null ")
  25. if (x11_error):
  26. print("xcursor not found.. x11 disabled.")
  27. return False
  28. return True # X11 enabled
  29. def get_opts():
  30. return [
  31. ('use_llvm','Use llvm compiler','no'),
  32. ('use_sanitizer','Use llvm compiler sanitize address','no'),
  33. ]
  34. def get_flags():
  35. return [
  36. ('builtin_zlib', 'no'),
  37. ("openssl", "yes"),
  38. ("theora","no"),
  39. ]
  40. def configure(env):
  41. is64=sys.maxsize > 2**32
  42. if (env["bits"]=="default"):
  43. if (is64):
  44. env["bits"]="64"
  45. else:
  46. env["bits"]="32"
  47. env.Append(CPPPATH=['#platform/x11'])
  48. if (env["use_llvm"]=="yes"):
  49. env["CC"]="clang"
  50. env["CXX"]="clang++"
  51. env["LD"]="clang++"
  52. if (env["use_sanitizer"]=="yes"):
  53. env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer'])
  54. env.Append(LINKFLAGS=['-fsanitize=address'])
  55. env.extra_suffix=".llvms"
  56. else:
  57. env.extra_suffix=".llvm"
  58. if (env["colored"]=="yes"):
  59. if sys.stdout.isatty():
  60. env.Append(CXXFLAGS=["-fcolor-diagnostics"])
  61. #if (env["tools"]=="no"):
  62. # #no tools suffix
  63. # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
  64. # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
  65. if (env["target"]=="release"):
  66. env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer'])
  67. elif (env["target"]=="release_debug"):
  68. env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED'])
  69. elif (env["target"]=="debug"):
  70. env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
  71. env.ParseConfig('pkg-config x11 --cflags --libs')
  72. env.ParseConfig('pkg-config xcursor --cflags --libs')
  73. env.ParseConfig('pkg-config openssl --cflags --libs')
  74. env.ParseConfig('pkg-config freetype2 --cflags --libs')
  75. env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
  76. env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
  77. env.Append(CPPFLAGS=["-DALSA_ENABLED"])
  78. if not os.system("pkg-config --exists libpulse-simple"):
  79. print("Enabling PulseAudio")
  80. env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
  81. env.ParseConfig('pkg-config --cflags --libs libpulse-simple')
  82. else:
  83. print("PulseAudio development libraries not found, disabling driver")
  84. env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL'])
  85. env.Append(LIBS=['GL', 'GLU', 'pthread','asound','z']) #TODO detect linux/BSD!
  86. #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
  87. #host compiler is default..
  88. if (is64 and env["bits"]=="32"):
  89. env.Append(CPPFLAGS=['-m32'])
  90. env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu'])
  91. elif (not is64 and env["bits"]=="64"):
  92. env.Append(CPPFLAGS=['-m64'])
  93. env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu'])
  94. if (env["CXX"]=="clang++"):
  95. env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
  96. env["CC"]="clang"
  97. env["LD"]="clang++"
  98. import methods
  99. env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  100. env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  101. env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  102. #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )