Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept --enable and --with configure flags interchangeably #2

Open
nikic opened this issue Jun 16, 2020 · 2 comments
Open

Accept --enable and --with configure flags interchangeably #2

nikic opened this issue Jun 16, 2020 · 2 comments

Comments

@nikic
Copy link
Member

nikic commented Jun 16, 2020

./configure currently distinguishes between --enable-extname and --with-extname flags, where --enable is used for extensions without dependencies, and --with for those with dependencies.

In practice, the actual usage is very inconsistent, and there's plenty of edge cases (what about extensions that have a dependency, but the dependency is bundled?) Since the pkg-config migration in PHP 7.4, most --with options don't even accept a library directory anymore, so the difference between these flags eroded further.

In PHP 7.4, we tried to normalize the usage of --enable and --with somewhat, but this only went partway, and I think was a pretty bad idea in hindsight, because it just broke existing configure scripts without much benefit.

I think it would be better to give up on this distinction entirely, make all extensions enabled via --enable-extname (in docs), but accept --with-extname as an alias.

I'm not sure how this would be done technically, but the right starting point is probably the macro definitions starting at https://github.com/php/php-src/blob/c260613c6f166dc25d7c3a4ed090df5c08735491/build/php.m4#L684.

@cmb69
Copy link
Member

cmb69 commented Sep 22, 2024

In my opinion, this makes sense, especially since this distinction never made sense on Windows, where only few options take a path anyway (one notable exception is --enable-object-out-dir ;). I don't know what would need to be changed for non Windows systems, but there the following patch should do to accept either variant.

Patch for Windows
 win32/build/confutils.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/win32/build/confutils.js b/win32/build/confutils.js
index 5a28719f31..f6e230816b 100644
--- a/win32/build/confutils.js
+++ b/win32/build/confutils.js
@@ -224,13 +224,19 @@ function condense_path(path)
 function ConfigureArg(type, optname, helptext, defval)
 {
 	var opptype = type == "enable" ? "disable" : "without";
+	var alttype = type == "enable" ? "with" : "enable";
+	var altopptype = type == "enable" ? "without" : "disable";
 
 	if (defval == "yes" || defval == "yes,shared") {
 		this.arg = "--" + opptype + "-" + optname;
 		this.imparg = "--" + type + "-" + optname;
+		this.altarg = "--" + altopptype + "-" + optname;
+		this.altimparg = "--" + alttype + "-" + optname;
 	} else {
 		this.arg = "--" + type + "-" + optname;
 		this.imparg = "--" + opptype + "-" + optname;
+		this.altarg = "--" + alttype + "-" + optname;
+		this.altimparg = "--" + altopptype + "-" + optname;
 	}
 
 	this.optname = optname;
@@ -348,7 +354,7 @@ function conf_process_args()
 			configure_help_mode = true;
 			break;
 		}
-		if (arg == "--disable-all") {
+		if (arg == "--disable-all" || arg == "--without-all") {
 			disable_all = true;
 			continue;
 		}
@@ -365,7 +371,7 @@ function conf_process_args()
 		// Find the arg
 		found = false;
 		for (j = 0; j < configure_args.length; j++) {
-			if (argname == configure_args[j].imparg || argname == configure_args[j].arg) {
+			if (argname == configure_args[j].imparg || argname == configure_args[j].arg || argname == configure_args[j].altimparg || argname == configure_args[j].altarg) {
 				found = true;
 
 				arg = configure_args[j];
@@ -381,7 +387,7 @@ function conf_process_args()
 				}
 				argval = analyzed[1];
 
-				if (argname == arg.imparg) {
+				if (argname == arg.imparg || argname == arg.altimparg) {
 					/* we matched the implicit, or default arg */
 					if (argval == null) {
 						argval = arg.defval;

@Girgias
Copy link
Member

Girgias commented Sep 22, 2024

Probably @petk would know about autotools?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants