detect.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. ('pulseaudio','Detect & Use pulseaudio','yes'),
  34. ]
  35. def get_flags():
  36. return [
  37. ('builtin_zlib', 'no'),
  38. ("openssl", "yes"),
  39. ("theora","no"),
  40. ]
  41. def configure(env):
  42. is64=sys.maxsize > 2**32
  43. if (env["bits"]=="default"):
  44. if (is64):
  45. env["bits"]="64"
  46. else:
  47. env["bits"]="32"
  48. env.Append(CPPPATH=['#platform/x11'])
  49. if (env["use_llvm"]=="yes"):
  50. env["CC"]="clang"
  51. env["CXX"]="clang++"
  52. env["LD"]="clang++"
  53. if (env["use_sanitizer"]=="yes"):
  54. env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer'])
  55. env.Append(LINKFLAGS=['-fsanitize=address'])
  56. env.extra_suffix=".llvms"
  57. else:
  58. env.extra_suffix=".llvm"
  59. #if (env["tools"]=="no"):
  60. # #no tools suffix
  61. # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
  62. # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
  63. if (env["target"]=="release"):
  64. env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer'])
  65. elif (env["target"]=="release_debug"):
  66. env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED'])
  67. elif (env["target"]=="debug"):
  68. env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
  69. env.ParseConfig('pkg-config x11 --cflags --libs')
  70. env.ParseConfig('pkg-config xcursor --cflags --libs')
  71. env.ParseConfig('pkg-config openssl --cflags --libs')
  72. env.ParseConfig('pkg-config freetype2 --cflags --libs')
  73. env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
  74. env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
  75. env.Append(CPPFLAGS=["-DALSA_ENABLED"])
  76. if (env["pulseaudio"]=="yes"):
  77. if not os.system("pkg-config --exists libpulse-simple"):
  78. print("Enabling PulseAudio")
  79. env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
  80. env.ParseConfig('pkg-config --cflags --libs libpulse-simple')
  81. else:
  82. print("PulseAudio development libraries not found, disabling driver")
  83. env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES1_ENABLED','-DGLES_OVER_GL'])
  84. env.Append(LIBS=['GL', 'GLU', 'pthread','asound','z']) #TODO detect linux/BSD!
  85. #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
  86. #host compiler is default..
  87. if (is64 and env["bits"]=="32"):
  88. env.Append(CPPFLAGS=['-m32'])
  89. env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu'])
  90. elif (not is64 and env["bits"]=="64"):
  91. env.Append(CPPFLAGS=['-m64'])
  92. env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu'])
  93. if (env["CXX"]=="clang++"):
  94. env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
  95. env["CC"]="clang"
  96. env["LD"]="clang++"
  97. import methods
  98. env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  99. env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  100. env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  101. #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )