config.w32.phpize.in 11 KB

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