detect.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. #
  2. # tested on | Windows native | Linux cross-compilation
  3. # ------------------------+-------------------+---------------------------
  4. # MSVS C++ 2010 Express | WORKS | n/a
  5. # Mingw-w64 | WORKS | WORKS
  6. # Mingw-w32 | WORKS | WORKS
  7. # MinGW | WORKS | untested
  8. #
  9. #####
  10. # Notes about MSVS C++ :
  11. #
  12. # - MSVC2010-Express compiles to 32bits only.
  13. #
  14. #####
  15. # Notes about Mingw-w64 and Mingw-w32 under Windows :
  16. #
  17. # - both can be installed using the official installer :
  18. # http://mingw-w64.sourceforge.net/download.php#mingw-builds
  19. #
  20. # - if you want to compile both 32bits and 64bits, don't forget to
  21. # run the installer twice to install them both.
  22. #
  23. # - install them into a path that does not contain spaces
  24. # ( example : "C:/Mingw-w32", "C:/Mingw-w64" )
  25. #
  26. # - if you want to compile faster using the "-j" option, don't forget
  27. # to install the appropriate version of the Pywin32 python extension
  28. # available from : http://sourceforge.net/projects/pywin32/files/
  29. #
  30. # - before running scons, you must add into the environment path
  31. # the path to the "/bin" directory of the Mingw version you want
  32. # to use :
  33. #
  34. # set PATH=C:/Mingw-w32/bin;%PATH%
  35. #
  36. # - then, scons should be able to detect gcc.
  37. # - Mingw-w32 only compiles 32bits.
  38. # - Mingw-w64 only compiles 64bits.
  39. #
  40. # - it is possible to add them both at the same time into the PATH env,
  41. # if you also define the MINGW32_PREFIX and MINGW64_PREFIX environment
  42. # variables.
  43. # For instance, you could store that set of commands into a .bat script
  44. # that you would run just before scons :
  45. #
  46. # set PATH=C:\mingw-w32\bin;%PATH%
  47. # set PATH=C:\mingw-w64\bin;%PATH%
  48. # set MINGW32_PREFIX=C:\mingw-w32\bin\
  49. # set MINGW64_PREFIX=C:\mingw-w64\bin\
  50. #
  51. #####
  52. # Notes about Mingw, Mingw-w64 and Mingw-w32 under Linux :
  53. #
  54. # - default toolchain prefixes are :
  55. # "i586-mingw32msvc-" for MinGW
  56. # "i686-w64-mingw32-" for Mingw-w32
  57. # "x86_64-w64-mingw32-" for Mingw-w64
  58. #
  59. # - if both MinGW and Mingw-w32 are installed on your system
  60. # Mingw-w32 should take the priority over MinGW.
  61. #
  62. # - it is possible to manually override prefixes by defining
  63. # the MINGW32_PREFIX and MINGW64_PREFIX environment variables.
  64. #
  65. #####
  66. # Notes about Mingw under Windows :
  67. #
  68. # - this is the MinGW version from http://mingw.org/
  69. # - install it into a path that does not contain spaces
  70. # ( example : "C:/MinGW" )
  71. # - several DirectX headers might be missing. You can copy them into
  72. # the C:/MinGW/include" directory from this page :
  73. # https://code.google.com/p/mingw-lib/source/browse/trunk/working/avcodec_to_widget_5/directx_include/
  74. # - before running scons, add the path to the "/bin" directory :
  75. # set PATH=C:/MinGW/bin;%PATH%
  76. # - scons should be able to detect gcc.
  77. #
  78. #####
  79. # TODO :
  80. #
  81. # - finish to cleanup this script to remove all the remains of previous hacks and workarounds
  82. # - make it work with the Windows7 SDK that is supposed to enable 64bits compilation for MSVC2010-Express
  83. # - confirm it works well with other Visual Studio versions.
  84. # - update the wiki about the pywin32 extension required for the "-j" option under Windows.
  85. # - update the wiki to document MINGW32_PREFIX and MINGW64_PREFIX
  86. #
  87. import os
  88. import sys
  89. import methods
  90. def is_active():
  91. return True
  92. def get_name():
  93. return "Windows"
  94. if (os.getenv("MINGW32_PREFIX")):
  95. mingw32=os.getenv("MINGW32_PREFIX")
  96. mingw = mingw32
  97. if (os.getenv("MINGW64_PREFIX")):
  98. mingw64=os.getenv("MINGW64_PREFIX")
  99. return [
  100. ('mingw_prefix','Mingw Prefix',mingw32),
  101. ('mingw_prefix_64','Mingw Prefix 64 bits',mingw64),
  102. ]
  103. def get_flags():
  104. return [
  105. ('glew','yes'),
  106. ('openssl','builtin'), #use builtin openssl
  107. ]
  108. def build_res_file( target, source, env ):
  109. cmdbase = ""
  110. if (env["bits"] == "32"):
  111. cmdbase = env['mingw_prefix']
  112. else:
  113. cmdbase = env['mingw_prefix_64']
  114. CPPPATH = env['CPPPATH']
  115. cmdbase = cmdbase + 'windres --include-dir . '
  116. import subprocess
  117. for x in range(len(source)):
  118. cmd = cmdbase + '-i ' + str(source[x]) + ' -o ' + str(target[x])
  119. try:
  120. out = subprocess.Popen(cmd,shell = True,stderr = subprocess.PIPE).communicate()
  121. if len(out[1]):
  122. return 1
  123. except:
  124. return 1
  125. return 0
  126. def configure(env):
  127. env.Append(CPPPATH=['#platform/windows'])
  128. env['is_mingw']=False
  129. if (os.name=="nt" and os.getenv("VSINSTALLDIR")!=None):
  130. #build using visual studio
  131. env['ENV']['TMP'] = os.environ['TMP']
  132. env.Append(CPPPATH=['#platform/windows/include'])
  133. env.Append(LIBPATH=['#platform/windows/lib'])
  134. if (env["target"]=="release"):
  135. env.Append(CCFLAGS=['/O2'])
  136. env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
  137. env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
  138. elif (env["target"]=="release_debug"):
  139. env.Append(CCFLAGS=['/O2','/DDEBUG_ENABLED'])
  140. env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
  141. elif (env["target"]=="debug_release"):
  142. env.Append(CCFLAGS=['/Z7','/Od'])
  143. env.Append(LINKFLAGS=['/DEBUG'])
  144. env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
  145. env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
  146. elif (env["target"]=="debug"):
  147. env.Append(CCFLAGS=['/Z7','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/Od'])
  148. env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
  149. env.Append(LINKFLAGS=['/DEBUG'])
  150. env.Append(CCFLAGS=['/MT','/Gd','/GR','/nologo'])
  151. env.Append(CXXFLAGS=['/TP'])
  152. env.Append(CPPFLAGS=['/DMSVC', '/GR', ])
  153. env.Append(CCFLAGS=['/I'+os.getenv("WindowsSdkDir")+"/Include"])
  154. env.Append(CCFLAGS=['/DWINDOWS_ENABLED'])
  155. env.Append(CCFLAGS=['/DRTAUDIO_ENABLED'])
  156. env.Append(CCFLAGS=['/DWIN32'])
  157. env.Append(CCFLAGS=['/DTYPED_METHOD_BIND'])
  158. env.Append(CCFLAGS=['/DGLES2_ENABLED'])
  159. LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shlwapi', 'wsock32','Ws2_32', 'shell32','advapi32','dinput8','dxguid']
  160. env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS])
  161. env.Append(LIBPATH=[os.getenv("WindowsSdkDir")+"/Lib"])
  162. if (os.getenv("DXSDK_DIR")):
  163. DIRECTX_PATH=os.getenv("DXSDK_DIR")
  164. else:
  165. DIRECTX_PATH="C:/Program Files/Microsoft DirectX SDK (March 2009)"
  166. if (os.getenv("VCINSTALLDIR")):
  167. VC_PATH=os.getenv("VCINSTALLDIR")
  168. else:
  169. VC_PATH=""
  170. env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")])
  171. env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")])
  172. env.Append(CCFLAGS=["/I"+DIRECTX_PATH+"/Include"])
  173. env.Append(LIBPATH=[DIRECTX_PATH+"/Lib/x86"])
  174. env['ENV'] = os.environ;
  175. # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code
  176. compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV'])
  177. # Note: this detection/override code from here onward should be here instead of in SConstruct because it's platform and compiler specific (MSVC/Windows)
  178. if(env["bits"] != "default"):
  179. print "Error: bits argument is disabled for MSVC"
  180. print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)"
  181. +" that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler"
  182. +" will be executed and inform you.")
  183. sys.exit()
  184. # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt
  185. # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with)
  186. env["bits"]="32"
  187. env["x86_opt_vc"]=True
  188. print "Detected MSVC compiler: "+compiler_version_str
  189. # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm
  190. if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"):
  191. env["bits"]="64"
  192. env["x86_opt_vc"]=False
  193. print "Compiled program architecture will be a 64 bit executable (forcing bits=64)."
  194. elif (compiler_version_str=="x86" or compiler_version_str == "amd64_x86"):
  195. print "Compiled program architecture will be a 32 bit executable. (forcing bits=32)."
  196. else:
  197. print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup."
  198. if env["bits"]=="64":
  199. env.Append(CCFLAGS=['/D_WIN64'])
  200. # Incremental linking fix
  201. env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program']
  202. env['BUILDERS']['Program'] = methods.precious_program
  203. else:
  204. # Workaround for MinGW. See:
  205. # http://www.scons.org/wiki/LongCmdLinesOnWin32
  206. env.use_windows_spawn_fix()
  207. #build using mingw
  208. if (os.name=="nt"):
  209. env['ENV']['TMP'] = os.environ['TMP'] #way to go scons, you can be so stupid sometimes
  210. else:
  211. env["PROGSUFFIX"]=env["PROGSUFFIX"]+".exe" # for linux cross-compilation
  212. mingw_prefix=""
  213. def can_build():
  214. if (os.name == "nt"):
  215. # building natively on windows!
  216. if (os.getenv("VSINSTALLDIR")):
  217. return True
  218. else:
  219. print("\nMSVC not detected, attempting Mingw.")
  220. mingw32 = ""
  221. mingw64 = ""
  222. if (os.getenv("MINGW32_PREFIX")):
  223. mingw32 = os.getenv("MINGW32_PREFIX")
  224. if (os.getenv("MINGW64_PREFIX")):
  225. mingw64 = os.getenv("MINGW64_PREFIX")
  226. test = "gcc --version > NUL 2>&1"
  227. if os.system(test) != 0 and os.system(mingw32 + test) != 0 and os.system(mingw64 + test) != 0:
  228. print("- could not detect gcc.")
  229. print("Please, make sure a path to a Mingw /bin directory is accessible into the environment PATH.\n")
  230. return False
  231. else:
  232. print("- gcc detected.")
  233. return True
  234. if (os.name == "posix"):
  235. mingw = "i586-mingw32msvc-"
  236. mingw64 = "x86_64-w64-mingw32-"
  237. mingw32 = "i686-w64-mingw32-"
  238. if (os.getenv("MINGW32_PREFIX")):
  239. mingw32 = os.getenv("MINGW32_PREFIX")
  240. mingw = mingw32
  241. if (os.getenv("MINGW64_PREFIX")):
  242. mingw64 = os.getenv("MINGW64_PREFIX")
  243. test = "gcc --version &>/dev/null"
  244. if (os.system(mingw + test) == 0 or os.system(mingw64 + test) == 0 or os.system(mingw32 + test) == 0):
  245. return True
  246. return False
  247. def get_opts():
  248. mingw = ""
  249. mingw32 = ""
  250. mingw64 = ""
  251. if (os.name == "posix"):
  252. mingw = "i586-mingw32msvc-"
  253. mingw32 = "i686-w64-mingw32-"
  254. mingw64 = "x86_64-w64-mingw32-"
  255. if os.system(mingw32 + "gcc --version &>/dev/null") != 0:
  256. mingw32 = mingw
  257. if (os.getenv("MINGW32_PREFIX")):
  258. mingw32 = os.getenv("MINGW32_PREFIX")
  259. mingw = mingw32
  260. if (os.getenv("MINGW64_PREFIX")):
  261. mingw64 = os.getenv("MINGW64_PREFIX")
  262. return [
  263. ('mingw_prefix', 'Mingw Prefix', mingw32),
  264. ('mingw_prefix_64', 'Mingw Prefix 64 bits', mingw64),
  265. ]
  266. def get_flags():
  267. return [
  268. ]
  269. def build_res_file(target, source, env):
  270. cmdbase = ""
  271. if (env["bits"] == "32"):
  272. cmdbase = env['mingw_prefix']
  273. else:
  274. cmdbase = env['mingw_prefix_64']
  275. CPPPATH = env['CPPPATH']
  276. cmdbase = cmdbase + 'windres --include-dir . '
  277. import subprocess
  278. for x in range(len(source)):
  279. cmd = cmdbase + '-i ' + str(source[x]) + ' -o ' + str(target[x])
  280. try:
  281. out = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE).communicate()
  282. if len(out[1]):
  283. return 1
  284. except:
  285. return 1
  286. return 0
  287. def configure(env):
  288. env.Append(CPPPATH=['#platform/windows'])
  289. # Targeted Windows version: Vista (and later)
  290. winver = "0x0600" # Windows Vista is the minimum target for windows builds
  291. env['is_mingw'] = False
  292. if (os.name == "nt" and os.getenv("VSINSTALLDIR") != None):
  293. # build using visual studio
  294. env['ENV']['TMP'] = os.environ['TMP']
  295. env.Append(CPPPATH=['#platform/windows/include'])
  296. env.Append(LIBPATH=['#platform/windows/lib'])
  297. env.Append(CCFLAGS=['/DWINVER=%s' % winver, '/D_WIN32_WINNT=%s' % winver])
  298. if (env["target"] == "release"):
  299. env.Append(CCFLAGS=['/O2'])
  300. env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
  301. env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
  302. elif (env["target"] == "release_debug"):
  303. env.Append(CCFLAGS=['/O2', '/DDEBUG_ENABLED'])
  304. env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
  305. elif (env["target"] == "debug_release"):
  306. env.Append(CCFLAGS=['/Z7', '/Od'])
  307. env.Append(LINKFLAGS=['/DEBUG'])
  308. env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
  309. env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
  310. elif (env["target"] == "debug"):
  311. env.Append(CCFLAGS=['/Z7', '/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED', '/DD3D_DEBUG_INFO', '/Od'])
  312. env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
  313. env.Append(LINKFLAGS=['/DEBUG'])
  314. env.Append(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo'])
  315. env.Append(CXXFLAGS=['/TP'])
  316. env.Append(CPPFLAGS=['/DMSVC', '/GR', ])
  317. env.Append(CCFLAGS=['/I' + os.getenv("WindowsSdkDir") + "/Include"])
  318. env.Append(CCFLAGS=['/DWINDOWS_ENABLED'])
  319. env.Append(CCFLAGS=['/DRTAUDIO_ENABLED'])
  320. env.Append(CCFLAGS=['/DWIN32'])
  321. env.Append(CCFLAGS=['/DTYPED_METHOD_BIND'])
  322. env.Append(CCFLAGS=['/DGLES2_ENABLED'])
  323. LIBS = ['winmm', 'opengl32', 'dsound', 'kernel32', 'ole32', 'oleaut32', 'user32', 'gdi32', 'IPHLPAPI', 'Shlwapi', 'wsock32', 'ws2_32', 'shell32', 'advapi32', 'dinput8', 'dxguid']
  324. env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS])
  325. env.Append(LIBPATH=[os.getenv("WindowsSdkDir") + "/Lib"])
  326. if (os.getenv("DXSDK_DIR")):
  327. DIRECTX_PATH = os.getenv("DXSDK_DIR")
  328. else:
  329. DIRECTX_PATH = "C:/Program Files/Microsoft DirectX SDK (March 2009)"
  330. if (os.getenv("VCINSTALLDIR")):
  331. VC_PATH = os.getenv("VCINSTALLDIR")
  332. else:
  333. VC_PATH = ""
  334. env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")])
  335. env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")])
  336. env.Append(CCFLAGS=["/I" + DIRECTX_PATH + "/Include"])
  337. env.Append(LIBPATH=[DIRECTX_PATH + "/Lib/x86"])
  338. env['ENV'] = os.environ
  339. # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code
  340. compiler_version_str = detect_visual_c_compiler_version(env['ENV'])
  341. # Note: this detection/override code from here onward should be here instead of in SConstruct because it's platform and compiler specific (MSVC/Windows)
  342. if(env["bits"] != "default"):
  343. print "Error: bits argument is disabled for MSVC"
  344. print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)"
  345. + " that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler"
  346. + " will be executed and inform you.")
  347. sys.exit()
  348. # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt
  349. # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with)
  350. env["bits"] = "32"
  351. env["x86_libtheora_opt_vc"] = True
  352. print "Detected MSVC compiler: " + compiler_version_str
  353. # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm
  354. if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"):
  355. env["bits"] = "64"
  356. env["x86_libtheora_opt_vc"] = False
  357. print "Compiled program architecture will be a 64 bit executable (forcing bits=64)."
  358. elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"):
  359. print "Compiled program architecture will be a 32 bit executable. (forcing bits=32)."
  360. else:
  361. print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup."
  362. if env["bits"] == "64":
  363. env.Append(CCFLAGS=['/D_WIN64'])
  364. else:
  365. # Workaround for MinGW. See:
  366. # http://www.scons.org/wiki/LongCmdLinesOnWin32
  367. env.use_windows_spawn_fix()
  368. # build using mingw
  369. env.Append(CCFLAGS=['-DWINVER=%s' % winver, '-D_WIN32_WINNT=%s' % winver])
  370. if (os.name == "nt"):
  371. env['ENV']['TMP'] = os.environ['TMP'] # way to go scons, you can be so stupid sometimes
  372. else:
  373. env["PROGSUFFIX"] = env["PROGSUFFIX"] + ".exe" # for linux cross-compilation
  374. mingw_prefix = ""
  375. if (env["bits"] == "default"):
  376. env["bits"] = "64" if "PROGRAMFILES(X86)" in os.environ else "32"
  377. if (env["bits"] == "32"):
  378. env.Append(LINKFLAGS=['-static'])
  379. env.Append(LINKFLAGS=['-static-libgcc'])
  380. env.Append(LINKFLAGS=['-static-libstdc++'])
  381. mingw_prefix = env["mingw_prefix"]
  382. else:
  383. env.Append(LINKFLAGS=['-static'])
  384. mingw_prefix = env["mingw_prefix_64"]
  385. nulstr = ""
  386. if (os.name == "posix"):
  387. nulstr = ">/dev/null"
  388. else:
  389. nulstr = ">nul"
  390. # if os.system(mingw_prefix+"gcc --version"+nulstr)!=0:
  391. # #not really super consistent but..
  392. # print("Can't find Windows compiler: "+mingw_prefix)
  393. # sys.exit(255)
  394. if (env["target"] == "release"):
  395. env.Append(CCFLAGS=['-msse2'])
  396. if (env["bits"] == "64"):
  397. env.Append(CCFLAGS=['-O3'])
  398. else:
  399. env.Append(CCFLAGS=['-O2'])
  400. env.Append(LINKFLAGS=['-Wl,--subsystem,windows'])
  401. elif (env["target"] == "release_debug"):
  402. env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
  403. elif (env["target"] == "debug"):
  404. env.Append(CCFLAGS=['-g', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
  405. env["CC"] = mingw_prefix + "gcc"
  406. env['AS'] = mingw_prefix + "as"
  407. env['CXX'] = mingw_prefix + "g++"
  408. env['AR'] = mingw_prefix + "ar"
  409. env['RANLIB'] = mingw_prefix + "ranlib"
  410. env['LD'] = mingw_prefix + "g++"
  411. env["x86_libtheora_opt_gcc"] = True
  412. #env['CC'] = "winegcc"
  413. #env['CXX'] = "wineg++"
  414. env.Append(CCFLAGS=['-DWINDOWS_ENABLED', '-mwindows'])
  415. env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED'])
  416. env.Append(CCFLAGS=['-DGLES2_ENABLED'])
  417. env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid'])
  418. # if (env["bits"]=="32"):
  419. # env.Append(LIBS=['gcc_s'])
  420. # #--with-arch=i686
  421. # env.Append(CPPFLAGS=['-march=i686'])
  422. # env.Append(LINKFLAGS=['-march=i686'])
  423. #'d3dx9d'
  424. env.Append(CPPFLAGS=['-DMINGW_ENABLED'])
  425. # env.Append(LINKFLAGS=['-g'])
  426. # resrc
  427. env['is_mingw'] = True
  428. env.Append(BUILDERS={'RES': env.Builder(action=build_res_file, suffix='.o', src_suffix='.rc')})
  429. import methods
  430. env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
  431. env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
  432. env.Append(BUILDERS={'HLSL9': env.Builder(action=methods.build_hlsl_dx9_headers, suffix='hlsl.h', src_suffix='.hlsl')})
  433. env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})