PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/win32/build/config.w32.phpize.in

http://github.com/infusion/PHP
Autoconf | 353 lines | 297 code | 56 blank | 0 comment | 116 complexity | 01f959277a23b98b36ab97239fe7b44b MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause
  1. // vim:ft=javascript
  2. // $Id: config.w32 305923 2010-12-02 23:23:14Z pajoye $
  3. // "Master" config file; think of it as a configure.in
  4. // equivalent.
  5. var PHP_CYGWIN="notset";
  6. PHP_CL = PATH_PROG('cl', null, 'PHP_CL');
  7. if (!PHP_CL) {
  8. ERROR("MS C++ compiler is required");
  9. }
  10. /* For the record here: */
  11. // 1200 is VC6
  12. // 1300 is vs.net 2002
  13. // 1310 is vs.net 2003
  14. // 1400 is vs.net 2005
  15. // 1500 is vs.net 2008
  16. // 1600 is vs.net 2010
  17. // Which version of the compiler do we have?
  18. VCVERS = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
  19. STDOUT.WriteLine(" Detected compiler " + VC_VERSIONS[VCVERS]);
  20. AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version");
  21. DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
  22. AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
  23. // do we use x64 or 80x86 version of compiler?
  24. X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL');
  25. if (X64) {
  26. STDOUT.WriteLine(" Detected 64-bit compiler");
  27. } else {
  28. STDOUT.WriteLine(" Detected 32-bit compiler");
  29. }
  30. AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture");
  31. DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86');
  32. // cygwin now ships with link.exe. Avoid searching the cygwin path
  33. // for this, as we want the MS linker, not the fileutil
  34. PATH_PROG('link', WshShell.Environment("Process").Item("PATH"));
  35. PATH_PROG('nmake');
  36. // we don't want to define LIB, as that will override the default library path
  37. // that is set in that env var
  38. PATH_PROG('lib', null, 'MAKE_LIB');
  39. if (!PATH_PROG('bison')) {
  40. ERROR('bison is required')
  41. }
  42. // There's a minimum requirement for re2c..
  43. MINRE2C = "0.13.4";
  44. RE2C = PATH_PROG('re2c');
  45. if (RE2C) {
  46. var intvers, intmin;
  47. var pattern = /\./g;
  48. RE2CVERS = probe_binary(RE2C, "version");
  49. STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS);
  50. intvers = RE2CVERS.replace(pattern, '') - 0;
  51. intmin = MINRE2C.replace(pattern, '') - 0;
  52. if (intvers < intmin) {
  53. STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C);
  54. STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c');
  55. DEFINE('RE2C', '');
  56. } else {
  57. DEFINE('RE2C_FLAGS', '');
  58. }
  59. } else {
  60. STDOUT.WriteLine('Parsers will not be regenerated');
  61. }
  62. PATH_PROG('zip');
  63. PATH_PROG('lemon');
  64. // avoid picking up midnight commander from cygwin
  65. PATH_PROG('mc', WshShell.Environment("Process").Item("PATH"));
  66. // Try locating manifest tool
  67. if (VCVERS > 1200) {
  68. PATH_PROG('mt', WshShell.Environment("Process").Item("PATH"));
  69. }
  70. // stick objects somewhere outside of the source tree
  71. ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', '');
  72. if (PHP_OBJECT_OUT_DIR.length) {
  73. PHP_OBJECT_OUT_DIR = FSO.GetAbsolutePathName(PHP_OBJECT_OUT_DIR);
  74. if (!FSO.FolderExists(PHP_OBJECT_OUT_DIR)) {
  75. ERROR('you chosen output directory ' + PHP_OBJECT_OUT_DIR + ' does not exist');
  76. }
  77. PHP_OBJECT_OUT_DIR += '\\';
  78. } else if (X64) {
  79. if (!FSO.FolderExists("x64")) {
  80. FSO.CreateFolder("x64");
  81. }
  82. PHP_OBJECT_OUT_DIR = 'x64\\';
  83. }
  84. ARG_ENABLE('debug', 'Compile with debugging symbols', "no");
  85. ARG_ENABLE('debug-pack', 'Release binaries with external debug symbols (--enable-debug must not be specified)', 'no');
  86. if (PHP_DEBUG == "yes" && PHP_DEBUG_PACK == "yes") {
  87. ERROR("Use of both --enable-debug and --enable-debug-pack not allowed.");
  88. }
  89. DEFINE('PHP_PREFIX', PHP_PREFIX);
  90. DEFINE("BASE_INCLUDES", "/I " + PHP_DIR + "/include /I " + PHP_DIR + "/include/main /I " + PHP_DIR + "/include/Zend /I " + PHP_DIR + "/include/TSRM /I " + PHP_DIR + "/include/ext ");
  91. // CFLAGS for building the PHP dll
  92. DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP5DLLTS_EXPORTS /D PHP_EXPORTS \
  93. /D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=0x500");
  94. DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)');
  95. // General CFLAGS for building objects
  96. DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \
  97. /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 ");
  98. if (VCVERS < 1400) {
  99. // Enable automatic precompiled headers
  100. ADD_FLAG('CFLAGS', ' /YX ');
  101. if (PHP_DEBUG == "yes") {
  102. // Set some debug/release specific options
  103. ADD_FLAG('CFLAGS', ' /GZ ');
  104. }
  105. }
  106. if (VCVERS >= 1400) {
  107. // fun stuff: MS deprecated ANSI stdio and similar functions
  108. // disable annoying warnings. In addition, time_t defaults
  109. // to 64-bit. Ask for 32-bit.
  110. if (X64) {
  111. ADD_FLAG('CFLAGS', ' /wd4996 /Wp64 ');
  112. } else {
  113. ADD_FLAG('CFLAGS', ' /wd4996 /D_USE_32BIT_TIME_T=1 ');
  114. }
  115. if (PHP_DEBUG == "yes") {
  116. // Set some debug/release specific options
  117. ADD_FLAG('CFLAGS', ' /RTC1 ');
  118. }
  119. }
  120. ARG_WITH('prefix', 'PHP installation prefix', '');
  121. ARG_WITH('mp', 'Tell VC9+ use up to [n,auto,disable] processes for compilation', 'auto');
  122. if (VCVERS >= 1500 && PHP_MP != 'disable') {
  123. // no from disable-all
  124. if(PHP_MP == 'auto' || PHP_MP == 'no') {
  125. ADD_FLAG('CFLAGS', ' /MP ');
  126. } else {
  127. if(parseInt(PHP_MP) != 0) {
  128. ADD_FLAG('CFLAGS', ' /MP'+ PHP_MP +' ');
  129. } else {
  130. STDOUT.WriteLine('WARNING: Invalid argument for MP: ' + PHP_MP);
  131. }
  132. }
  133. }
  134. /* For snapshot builders, where can we find the additional
  135. * files that make up the snapshot template? */
  136. ARG_WITH("snapshot-template", "Path to snapshot builder template dir", "no");
  137. // General DLL link flags
  138. DEFINE("DLL_LDFLAGS", "/dll ");
  139. // PHP DLL link flags
  140. DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)");
  141. // General libs
  142. // urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib
  143. DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib");
  144. // Set some debug/release specific options
  145. if (PHP_DEBUG == "yes") {
  146. ADD_FLAG("CFLAGS", "/LDd /MDd /W3 /Gm /Od /D _DEBUG /D ZEND_DEBUG=1 " +
  147. (X64?"/Zi":"/ZI"));
  148. ADD_FLAG("LDFLAGS", "/debug");
  149. // Avoid problems when linking to release libraries that use the release
  150. // version of the libc
  151. ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:msvcrt");
  152. } else {
  153. // Generate external debug files when --enable-debug-pack is specified
  154. if (PHP_DEBUG_PACK == "yes") {
  155. ADD_FLAG("CFLAGS", "/Zi");
  156. ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf");
  157. }
  158. // Equivalent to Release_TSInline build -> best optimization
  159. ADD_FLAG("CFLAGS", "/LD /MD /W3 /Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0");
  160. // if you have VS.Net /GS hardens the binary against buffer overruns
  161. // ADD_FLAG("CFLAGS", "/GS");
  162. }
  163. if (PHP_ZTS == "yes") {
  164. ADD_FLAG("CFLAGS", "/D ZTS=1");
  165. }
  166. DEFINE("PHP_ZTS_ARCHIVE_POSTFIX", PHP_ZTS == "yes" ? '' : "-nts");
  167. // we want msvcrt in the PHP DLL
  168. ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt");
  169. // set up the build dir and DLL name
  170. if (PHP_DEBUG == "yes" && PHP_ZTS == "yes") {
  171. DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug_TS");
  172. if (!MODE_PHPIZE) {
  173. DEFINE("PHPDLL", "php" + PHP_VERSION + "ts_debug.dll");
  174. DEFINE("PHPLIB", "php" + PHP_VERSION + "ts_debug.lib");
  175. }
  176. } else if (PHP_DEBUG == "yes" && PHP_ZTS == "no") {
  177. DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug");
  178. if (!MODE_PHPIZE) {
  179. DEFINE("PHPDLL", "php" + PHP_VERSION + "_debug.dll");
  180. DEFINE("PHPLIB", "php" + PHP_VERSION + "_debug.lib");
  181. }
  182. } else if (PHP_DEBUG == "no" && PHP_ZTS == "yes") {
  183. DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release_TS");
  184. if (!MODE_PHPIZE) {
  185. DEFINE("PHPDLL", "php" + PHP_VERSION + "ts.dll");
  186. DEFINE("PHPLIB", "php" + PHP_VERSION + "ts.lib");
  187. }
  188. } else if (PHP_DEBUG == "no" && PHP_ZTS == "no") {
  189. DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release");
  190. if (!MODE_PHPIZE) {
  191. DEFINE("PHPDLL", "php" + PHP_VERSION + ".dll");
  192. DEFINE("PHPLIB", "php" + PHP_VERSION + ".lib");
  193. }
  194. }
  195. if (MODE_PHPIZE) {
  196. DEFINE("PHPDLL", PHP_DLL);
  197. DEFINE("PHPLIB", PHP_DLL_LIB);
  198. }
  199. // Find the php_build dir - it contains headers and libraries
  200. // that we need
  201. ARG_WITH('php-build', 'Path to where you extracted the development libraries (http://wiki.php.net/internals/windows/libs). Assumes that it is a sibling of this source dir (..\\deps) if not specified', 'no');
  202. if (PHP_PHP_BUILD == 'no') {
  203. if (FSO.FolderExists("..\\deps")) {
  204. PHP_PHP_BUILD = "..\\deps";
  205. } else {
  206. if (FSO.FolderExists("..\\php_build")) {
  207. PHP_PHP_BUILD = "..\\php_build";
  208. } else {
  209. if (X64) {
  210. if (FSO.FolderExists("..\\win64build")) {
  211. PHP_PHP_BUILD = "..\\win64build";
  212. } else if (FSO.FolderExists("..\\php-win64-dev\\php_build")) {
  213. PHP_PHP_BUILD = "..\\php-win64-dev\\php_build";
  214. }
  215. } else {
  216. if (FSO.FolderExists("..\\win32build")) {
  217. PHP_PHP_BUILD = "..\\win32build";
  218. } else if (FSO.FolderExists("..\\php-win32-dev\\php_build")) {
  219. PHP_PHP_BUILD = "..\\php-win32-dev\\php_build";
  220. }
  221. }
  222. }
  223. }
  224. PHP_PHP_BUILD = FSO.GetAbsolutePathName(PHP_PHP_BUILD);
  225. }
  226. DEFINE("PHP_BUILD", PHP_PHP_BUILD);
  227. ARG_WITH('extra-includes', 'Extra include path to use when building everything', '');
  228. ARG_WITH('extra-libs', 'Extra library path to use when linking everything', '');
  229. var php_usual_include_suspects = PHP_PHP_BUILD+"\\include";
  230. var php_usual_lib_suspects = PHP_PHP_BUILD+"\\lib";
  231. ADD_FLAG("CFLAGS", '/I "' + php_usual_include_suspects + '" ');
  232. ADD_FLAG("LDFLAGS", '/libpath:"\\"' + php_usual_lib_suspects + '\\"" ');
  233. // Poke around for some headers
  234. function probe_basic_headers()
  235. {
  236. var p;
  237. if (PHP_PHP_BUILD != "no") {
  238. php_usual_include_suspects += ";" + PHP_PHP_BUILD + "\\include";
  239. php_usual_lib_suspects += ";" + PHP_PHP_BUILD + "\\lib";
  240. }
  241. }
  242. function add_extra_dirs()
  243. {
  244. var path, i, f;
  245. if (PHP_EXTRA_INCLUDES.length) {
  246. path = PHP_EXTRA_INCLUDES.split(';');
  247. for (i = 0; i < path.length; i++) {
  248. f = FSO.GetAbsolutePathName(path[i]);
  249. if (FSO.FolderExists(f)) {
  250. ADD_FLAG("CFLAGS", '/I "' + f + '" ');
  251. }
  252. }
  253. }
  254. if (PHP_EXTRA_LIBS.length) {
  255. path = PHP_EXTRA_LIBS.split(';');
  256. for (i = 0; i < path.length; i++) {
  257. f = FSO.GetAbsolutePathName(path[i]);
  258. if (FSO.FolderExists(f)) {
  259. if (VCVERS <= 1200 && f.indexOf(" ") >= 0) {
  260. ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" ');
  261. } else {
  262. ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" ');
  263. }
  264. }
  265. }
  266. }
  267. }
  268. probe_basic_headers();
  269. add_extra_dirs();
  270. //DEFINE("PHP_BUILD", PHP_PHP_BUILD);
  271. STDOUT.WriteBlankLines(1);
  272. STDOUT.WriteLine("Build dir: " + get_define('BUILD_DIR'));
  273. STDOUT.WriteLine("PHP Core: " + get_define('PHPDLL') + " and " + get_define('PHPLIB'));
  274. if (VCVERS == 1200) {
  275. AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1);
  276. }
  277. if (VCVERS >= 1400) {
  278. AC_DEFINE('HAVE_STRNLEN', 1);
  279. }
  280. STDOUT.WriteBlankLines(1);
  281. if (PHP_SNAPSHOT_TEMPLATE == "no") {
  282. /* default is as a sibling of the php_build dir */
  283. if (FSO.FolderExists(PHP_PHP_BUILD + "\\template")) {
  284. PHP_SNAPSHOT_TEMPLATE = FSO.GetAbsolutePathName(PHP_PHP_BUILD + "\\template");
  285. } else if (FSO.FolderExists(PHP_PHP_BUILD + "\\..\\template")) {
  286. PHP_SNAPSHOT_TEMPLATE = FSO.GetAbsolutePathName(PHP_PHP_BUILD + "\\..\\template");
  287. }
  288. }
  289. DEFINE('SNAPSHOT_TEMPLATE', PHP_SNAPSHOT_TEMPLATE);
  290. if (PHP_DSP != "no") {
  291. if (FSO.FolderExists("tmp")) {
  292. FSO.DeleteFolder("tmp");
  293. }
  294. FSO.CreateFolder("tmp");
  295. }
  296. AC_DEFINE("PHP_DIR", PHP_DIR);
  297. DEFINE("PHP_DIR", PHP_DIR);