detect.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. x11_error=os.system("pkg-config xinerama --modversion > /dev/null ")
  29. if (x11_error):
  30. print("xinerama not found.. x11 disabled.")
  31. return False
  32. return True # X11 enabled
  33. def get_opts():
  34. return [
  35. ('use_llvm','Use llvm compiler','no'),
  36. ('use_sanitizer','Use llvm compiler sanitize address','no'),
  37. ('use_leak_sanitizer','Use llvm compiler sanitize memory leaks','no'),
  38. ('pulseaudio','Detect & Use pulseaudio','yes'),
  39. ('new_wm_api', 'Use experimental window management API','no'),
  40. ('debug_release', 'Add debug symbols to release version','no'),
  41. ]
  42. def get_flags():
  43. return [
  44. ('builtin_zlib', 'no'),
  45. ("openssl", "yes"),
  46. ("theora","no"),
  47. ]
  48. def configure(env):
  49. is64=sys.maxsize > 2**32
  50. if (env["bits"]=="default"):
  51. if (is64):
  52. env["bits"]="64"
  53. else:
  54. env["bits"]="32"
  55. env.Append(CPPPATH=['#platform/x11'])
  56. if (env["use_llvm"]=="yes"):
  57. if 'clang++' not in env['CXX']:
  58. env["CC"]="clang"
  59. env["CXX"]="clang++"
  60. env["LD"]="clang++"
  61. env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
  62. env.extra_suffix=".llvm"
  63. if (env["colored"]=="yes"):
  64. if sys.stdout.isatty():
  65. env.Append(CXXFLAGS=["-fcolor-diagnostics"])
  66. if (env["use_sanitizer"]=="yes"):
  67. env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer'])
  68. env.Append(LINKFLAGS=['-fsanitize=address'])
  69. env.extra_suffix+="s"
  70. if (env["use_leak_sanitizer"]=="yes"):
  71. env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer'])
  72. env.Append(LINKFLAGS=['-fsanitize=address'])
  73. env.extra_suffix+="s"
  74. #if (env["tools"]=="no"):
  75. # #no tools suffix
  76. # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
  77. # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
  78. if (env["target"]=="release"):
  79. if (env["debug_release"]=="yes"):
  80. env.Append(CCFLAGS=['-g2'])
  81. else:
  82. env.Append(CCFLAGS=['-O3','-ffast-math'])
  83. elif (env["target"]=="release_debug"):
  84. env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED'])
  85. elif (env["target"]=="debug"):
  86. env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
  87. env.ParseConfig('pkg-config x11 --cflags --libs')
  88. env.ParseConfig('pkg-config xinerama --cflags --libs')
  89. env.ParseConfig('pkg-config xcursor --cflags --libs')
  90. if (env("openssl"]=="yes"):
  91. env.ParseConfig('pkg-config openssl --cflags --libs')
  92. env.ParseConfig('pkg-config freetype2 --cflags --libs')
  93. env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
  94. env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
  95. env.Append(CPPFLAGS=["-DALSA_ENABLED"])
  96. if (env["pulseaudio"]=="yes"):
  97. if not os.system("pkg-config --exists libpulse-simple"):
  98. print("Enabling PulseAudio")
  99. env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
  100. env.ParseConfig('pkg-config --cflags --libs libpulse-simple')
  101. else:
  102. print("PulseAudio development libraries not found, disabling driver")
  103. env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL'])
  104. env.Append(LIBS=['GL', 'GLU', 'pthread','asound','z']) #TODO detect linux/BSD!
  105. #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
  106. #host compiler is default..
  107. if (is64 and env["bits"]=="32"):
  108. env.Append(CPPFLAGS=['-m32'])
  109. env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu'])
  110. elif (not is64 and env["bits"]=="64"):
  111. env.Append(CPPFLAGS=['-m64'])
  112. env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu'])
  113. import methods
  114. env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  115. env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  116. env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  117. #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
  118. if(env["new_wm_api"]=="yes"):
  119. env.Append(CPPFLAGS=['-DNEW_WM_API'])
  120. env.ParseConfig('pkg-config xinerama --cflags --libs')