config.w32 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. // vim:ft=javascript
  2. // "Master" config file; think of it as a configure.ac
  3. // equivalent.
  4. ARG_WITH("verbosity", "Output verbosity, 0-2.", "1");
  5. setup_verbosity();
  6. ARG_WITH("toolset", "Toolset to use for the compilation, give: vs, clang, icc. " +
  7. "The only recommended and supported toolset for production use " +
  8. "is Visual Studio. Use others at your own risk.", "vs");
  9. toolset_option_handle();
  10. ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin');
  11. toolset_setup_compiler();
  12. // do we use x64 or 80x86 version of compiler?
  13. X64 = toolset_is_64();
  14. toolset_setup_arch();
  15. toolset_setup_linker();
  16. toolset_setup_project_tools();
  17. // stick objects somewhere outside of the source tree
  18. ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', '');
  19. object_out_dir_option_handle();
  20. ARG_ENABLE('debug', 'Compile with debugging symbols', "no");
  21. ARG_ENABLE('debug-pack', 'Release binaries with external debug symbols (--enable-debug must not be specified)', 'no');
  22. if (PHP_DEBUG == "yes" && PHP_DEBUG_PACK == "yes") {
  23. ERROR("Use of both --enable-debug and --enable-debug-pack not allowed.");
  24. }
  25. if (PHP_DEBUG == "yes") {
  26. ADD_FLAG("CFLAGS"," /Wall ");
  27. ADD_FLAG("LDFLAGS", " /verbose ");
  28. }
  29. ARG_ENABLE('pgi', 'Generate PGO instrumented binaries', 'no');
  30. ARG_WITH('pgo', 'Compile optimized binaries using training data from folder', 'no');
  31. if (PHP_PGI == "yes" || PHP_PGO != "no") {
  32. PGOMGR = PATH_PROG('pgomgr', WshShell.Environment("Process").Item("PATH"));
  33. if (!PGOMGR) {
  34. ERROR("--enable-pgi and --with-pgo options can only be used if PGO capable compiler is present.");
  35. }
  36. if (PHP_PGI == "yes" && PHP_PGO != "no") {
  37. ERROR("Use of both --enable-pgi and --with-pgo not allowed.");
  38. }
  39. }
  40. ARG_ENABLE('zts', 'Thread safety', 'yes');
  41. // Configures the hard-coded installation dir
  42. ARG_WITH('prefix', 'where PHP will be installed', '');
  43. if (PHP_PREFIX == '') {
  44. PHP_PREFIX = "C:\\php";
  45. if (PHP_DEBUG == "yes")
  46. PHP_PREFIX += "\\debug";
  47. }
  48. DEFINE('PHP_PREFIX', PHP_PREFIX);
  49. DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext ");
  50. toolset_setup_common_cflags();
  51. if (VS_TOOLSET) {
  52. ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto');
  53. var PHP_MP_DISABLED = true;
  54. if (PHP_MP != 'disable') {
  55. if(PHP_DEBUG == 'yes') {
  56. STDOUT.WriteLine('WARNING: Debug builds cannot be built using multi processing');
  57. } else {
  58. // no from disable-all
  59. if(PHP_MP == 'auto' || PHP_MP == 'no') {
  60. ADD_FLAG('CFLAGS', ' /MP ');
  61. PHP_MP_DISABLED = false;
  62. } else {
  63. if(parseInt(PHP_MP) != 0) {
  64. ADD_FLAG('CFLAGS', ' /MP'+ PHP_MP +' ');
  65. PHP_MP_DISABLED = false;
  66. } else {
  67. STDOUT.WriteLine('WARNING: Invalid argument for MP: ' + PHP_MP);
  68. }
  69. }
  70. }
  71. }
  72. if (!PHP_MP_DISABLED) {
  73. STDOUT.WriteLine('Enabling multi process build');
  74. }
  75. }
  76. // General link flags
  77. toolset_setup_common_ldlags();
  78. // General libs
  79. toolset_setup_common_libs();
  80. // Set some debug/release specific options
  81. toolset_setup_build_mode();
  82. setup_zts_stuff();
  83. // CFLAGS, LDFLAGS and BUILD_DIR are defined
  84. // Add compiler and link flags if PGO options are selected
  85. if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
  86. ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
  87. DEFINE("PGOPGD_DIR", "$(BUILD_DIR)");
  88. }
  89. else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
  90. ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
  91. DEFINE("PGOPGD_DIR", ((PHP_PGO.length == 0 || PHP_PGO == "yes") ? "$(BUILD_DIR)" : PHP_PGO));
  92. }
  93. // Find the php_build dir - it contains headers and libraries
  94. // that we need
  95. 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');
  96. php_build_option_handle();
  97. ARG_WITH('extra-includes', 'Extra include path to use when building everything', '');
  98. ARG_WITH('extra-libs', 'Extra library path to use when linking everything', '');
  99. var php_usual_include_suspects = PHP_PHP_BUILD+"\\include";
  100. var php_usual_lib_suspects = PHP_PHP_BUILD+"\\lib";
  101. ADD_FLAG("CFLAGS", '/I "' + php_usual_include_suspects + '" ');
  102. ADD_FLAG("LDFLAGS", '/libpath:"' + php_usual_lib_suspects + '" ');
  103. ADD_FLAG("ARFLAGS", '/nologo /libpath:"' + php_usual_lib_suspects + '" ');
  104. probe_basic_headers();
  105. add_extra_dirs();
  106. //DEFINE("PHP_BUILD", PHP_PHP_BUILD);
  107. ARG_WITH("analyzer", "Enable static analyzer. Pass vs for Visual Studio, clang for clang, cppcheck for Cppcheck, pvs for PVS-Studio", "no");
  108. if (PHP_ANALYZER == "vs") {
  109. ADD_FLAG("CFLAGS", " /analyze ");
  110. ADD_FLAG("CFLAGS", " /wd6308 ");
  111. } else if (PHP_ANALYZER == "clang") {
  112. var clang_cl = false;
  113. if (FSO.FileExists(PROGRAM_FILES + "\\LLVM\\bin\\clang-cl.exe")) {
  114. clang_cl = PROGRAM_FILES + "\\LLVM\\bin\\clang-cl.exe";
  115. } else if (FSO.FileExists(PROGRAM_FILESx86 + "\\LLVM\\bin\\clang-cl.exe")) {
  116. clang_cl = PROGRAM_FILESx86 + "\\LLVM\\bin\\clang-cl.exe";
  117. }
  118. if (!clang_cl) {
  119. if (false == PATH_PROG('clang-cl', null, 'CLANG_CL')) {
  120. WARNING("Couldn't find clang binaries, static analyze was disabled");
  121. PHP_ANALYZER = "no";
  122. }
  123. } else {
  124. DEFINE("CLANG_CL", clang_cl);
  125. }
  126. } else if (PHP_ANALYZER == "cppcheck") {
  127. var cppcheck = false;
  128. if (FSO.FileExists(PROGRAM_FILES + "\\Cppcheck\\cppcheck.exe")) {
  129. cppcheck = PROGRAM_FILES + "\\Cppcheck\\cppcheck.exe";
  130. } else if (FSO.FileExists(PROGRAM_FILESx86 + "\\Cppcheck\\cppcheck.exe")) {
  131. cppcheck = PROGRAM_FILESx86 + "\\Cppcheck\\cppcheck.exe";
  132. }
  133. if (!cppcheck) {
  134. if (false == PATH_PROG('cppcheck', null, 'CPPCHECK')) {
  135. WARNING("Couldn't find Cppcheck binaries, static analyze was disabled");
  136. PHP_ANALYZER = "no";
  137. } else {
  138. cppcheck = get_define("CPPCHECK");
  139. }
  140. } else {
  141. DEFINE("CPPCHECK", cppcheck);
  142. }
  143. if (cppcheck) {
  144. var _tmp = execute(cppcheck + " --version").split(/ /)[1];
  145. var cppcheck_ver = [
  146. parseInt(_tmp.split(".")[0]),
  147. parseInt(_tmp.split(".")[1]),
  148. ];
  149. if (cppcheck_ver[0] > 1 || cppcheck_ver[0] == 1 && cppcheck_ver[1] >= 77) {
  150. var build_dir = get_define("BUILD_DIR");
  151. var cppcheck_build_dir = build_dir + "\\cppcheck_build";
  152. if (!FSO.FolderExists(cppcheck_build_dir)) {
  153. FSO.CreateFolder(cppcheck_build_dir);
  154. }
  155. DEFINE("CPPCHECK_BUILD_DIR", cppcheck_build_dir);
  156. }
  157. }
  158. } else if (PHP_ANALYZER == "pvs") {
  159. var pvs_studio = false;
  160. if (FSO.FileExists(PROGRAM_FILES + "\\PVS-Studio\\x64\\PVS-Studio.exe")) {
  161. pvs_studio = PROGRAM_FILES + "\\PVS-Studio\\x86\\PVS-Studio.exe";
  162. } else if (FSO.FileExists(PROGRAM_FILESx86 + "\\PVS-Studio\\x64\\PVS-Studio.exe")) {
  163. pvs_studio = PROGRAM_FILESx86 + "\\PVS-Studio\\x64\\PVS-Studio.exe";
  164. }
  165. if (!pvs_studio) {
  166. WARNING("Couldn't find PVS-Studio binaries, static analyze was disabled");
  167. PHP_ANALYZER = "no";
  168. } else {
  169. var pvscfg = FSO.CreateTextFile("PVS-Studio.conf", true);
  170. DEFINE("PVS_STUDIO", pvs_studio);
  171. pvscfg.WriteLine("exclude-path = " + VCINSTALLDIR);
  172. if (FSO.FolderExists(PROGRAM_FILESx86 + "\\windows kits\\")) {
  173. pvscfg.WriteLine("exclude-path = " + PROGRAM_FILESx86 + "\\windows kits\\");
  174. } else if (FSO.FolderExists(PROGRAM_FILES + "\\windows kits\\")) {
  175. pvscfg.WriteLine("exclude-path = " + PROGRAM_FILES + "\\windows kits\\");
  176. }
  177. pvscfg.WriteLine("vcinstalldir = " + VCINSTALLDIR);
  178. pvscfg.WriteLine("platform = " + (X64 ? 'x64' : 'Win32'));
  179. pvscfg.WriteLine("preprocessor = visualcpp");
  180. pvscfg.WriteLine("language = C");
  181. pvscfg.WriteLine("skip-cl-exe = no");
  182. }
  183. } else {
  184. PHP_ANALYZER = "no"
  185. }
  186. STDOUT.WriteBlankLines(1);
  187. STDOUT.WriteLine("Build dir: " + get_define('BUILD_DIR'));
  188. STDOUT.WriteLine("PHP Core: " + get_define('PHPDLL') + " and " + get_define('PHPLIB'));
  189. ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \
  190. zend_ini_parser.c zend_ini_scanner.c zend_alloc.c zend_compile.c \
  191. zend_constants.c zend_exceptions.c \
  192. zend_execute_API.c zend_highlight.c \
  193. zend_llist.c zend_vm_opcodes.c zend_opcode.c zend_operators.c zend_ptr_stack.c \
  194. zend_stack.c zend_variables.c zend.c zend_API.c zend_extensions.c \
  195. zend_hash.c zend_list.c zend_builtin_functions.c \
  196. zend_sprintf.c zend_ini.c zend_sort.c zend_multibyte.c zend_ts_hash.c \
  197. zend_stream.c zend_iterators.c zend_interfaces.c zend_objects.c \
  198. zend_object_handlers.c zend_objects_API.c \
  199. zend_default_classes.c zend_execute.c zend_strtod.c zend_gc.c zend_closures.c \
  200. zend_float.c zend_string.c zend_generators.c zend_virtual_cwd.c zend_ast.c \
  201. zend_inheritance.c zend_smart_str.c zend_cpuinfo.c");
  202. ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
  203. /* XXX inspect this for other toolsets */
  204. //AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1);
  205. ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \
  206. php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
  207. strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \
  208. php_open_temporary_file.c output.c internal_functions.c php_sprintf.c \
  209. php_syslog.c");
  210. ADD_FLAG("CFLAGS_BD_MAIN", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
  211. AC_DEFINE('HAVE_STRNLEN', 1);
  212. ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c plain_wrapper.c \
  213. userspace.c transports.c xp_socket.c mmap.c glob_wrapper.c");
  214. ADD_FLAG("CFLAGS_BD_MAIN_STREAMS", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
  215. ADD_SOURCES("win32", "dllmain.c glob.c readdir.c \
  216. registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c \
  217. getrusage.c ftok.c ioutil.c codepage.c nice.c \
  218. inet.c fnmatch.c sockets.c console.c");
  219. ADD_FLAG("CFLAGS_BD_WIN32", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
  220. PHP_INSTALL_HEADERS("", "Zend/ TSRM/ main/ main/streams/ win32/");
  221. STDOUT.WriteBlankLines(1);
  222. /* Can we build with IPv6 support? */
  223. ARG_ENABLE("ipv6", "Disable IPv6 support (default is turn it on if available)", "yes");
  224. var main_network_has_ipv6 = 0;
  225. if (PHP_IPV6 == "yes") {
  226. main_network_has_ipv6 = CHECK_HEADER_ADD_INCLUDE("wspiapi.h", "CFLAGS") ? 1 : 0;
  227. }
  228. if (main_network_has_ipv6) {
  229. STDOUT.WriteLine("Enabling IPv6 support");
  230. }
  231. AC_DEFINE('HAVE_GETADDRINFO', main_network_has_ipv6);
  232. AC_DEFINE('HAVE_GAI_STRERROR', main_network_has_ipv6);
  233. AC_DEFINE('HAVE_IPV6', main_network_has_ipv6);
  234. /* this allows up to 256 sockets to be select()ed in a single
  235. * call to select(), instead of the usual 64 */
  236. ARG_ENABLE('fd-setsize', "Set maximum number of sockets for select(2)", "256");
  237. ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE));
  238. AC_DEFINE('HAVE_USLEEP', 1);
  239. AC_DEFINE('HAVE_STRCOLL', 1);
  240. /* For snapshot builders, where can we find the additional
  241. * files that make up the snapshot template? */
  242. ARG_WITH("snapshot-template", "Path to snapshot builder template dir", "no");
  243. if (PHP_SNAPSHOT_TEMPLATE == "no") {
  244. /* default is as a sibling of the php_build dir */
  245. if (FSO.FolderExists(PHP_PHP_BUILD + "\\template")) {
  246. PHP_SNAPSHOT_TEMPLATE = FSO.GetAbsolutePathName(PHP_PHP_BUILD + "\\template");
  247. } else if (FSO.FolderExists(PHP_PHP_BUILD + "\\..\\template")) {
  248. PHP_SNAPSHOT_TEMPLATE = FSO.GetAbsolutePathName(PHP_PHP_BUILD + "\\..\\template");
  249. }
  250. }
  251. DEFINE('SNAPSHOT_TEMPLATE', PHP_SNAPSHOT_TEMPLATE);
  252. ARG_ENABLE("security-flags", "Disable the compiler security flags", "yes");
  253. if (PHP_SECURITY_FLAGS == "yes") {
  254. ADD_FLAG("LDFLAGS", "/NXCOMPAT /DYNAMICBASE ");
  255. }
  256. if (CLANG_TOOLSET) {
  257. ARG_WITH("uncritical-warn-choke", "Disable some uncritical warnings", "yes");
  258. if (PHP_UNCRITICAL_WARN_CHOKE != "no") {
  259. ADD_FLAG("CFLAGS", "-Wno-ignored-attributes -Wno-deprecated-declarations -Wno-missing-braces " +
  260. "-Wno-logical-op-parentheses -Wno-msvc-include -Wno-invalid-source-encoding -Wno-unknown-pragmas " +
  261. "-Wno-unused-command-line-argument -Wno-unused-function -Wno-ignored-pragma-optimize");
  262. }
  263. ARG_ENABLE("sanitizer", "Enable address sanitizer extension", "no");
  264. if (PHP_SANITIZER == "yes") {
  265. if (COMPILER_NUMERIC_VERSION < 500) {
  266. ERROR("Clang at least 5.0.0 required for sanitation plugins");
  267. }
  268. add_asan_opts("CFLAGS", "LIBS", "LDFLAGS");
  269. }
  270. }
  271. ARG_WITH("codegen-arch", "Architecture for code generation: ia32. Use --enable-native-intrinsics to enable SIMD optimizations.", "no");
  272. toolset_setup_codegen_arch();
  273. ARG_WITH("all-shared", "Force all the non obligatory extensions to be shared", "no");
  274. // Config profiles (--with-config-profile=<name>) will save a certain config to php-src/config.<name>.bat
  275. // so that it can be executed like: cofig.<name> instead of a long list of parameters
  276. //
  277. // Note, nice as a name is disallowed and will generate a warning and skip saving
  278. ARG_WITH('config-profile', 'Name of the configuration profile to save this to in php-src/config.name.bat', 'no');
  279. ARG_ENABLE("test-ini", "Enable automatic php.ini generation. The test.ini will be put \
  280. into the build dir and used to automatically load the shared extensions.", "yes");
  281. ARG_WITH("test-ini-ext-exclude", "Comma separated list of shared extensions to \
  282. be excluded from the test.ini", "no");
  283. ARG_ENABLE("native-intrinsics", "Comma separated list of intrinsic optimizations to enable. \
  284. Available instruction set names are sse, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2. \
  285. SSE and SSE2 are enabled by default. The best instruction set specified will \
  286. automatically enable all the older instruction sets. Note, that the produced binary \
  287. might not work properly, if the chosen instruction sets are not available on the target \
  288. processor.", "no");
  289. toolset_setup_intrinsic_cflags();