Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create custom ./configure command line arguments

Tags:

autoconf

I'm updating a project to use autotools, and to maintain backwards compatibility with previous versions, I would like the user to be able to run ./configure --foo=bar to set a build option.

Based on reading the docs, it looks like I could set up ./configure --enable-foo, ./configure --with-foo, or ./configure foo=bar without any problem, but I'm not seeing anything allowing the desired behavior (specifically having a double dash -- before the option).

Any suggestions?

like image 271
profzoom Avatar asked Dec 01 '25 13:12

profzoom


1 Answers

There's no way I know of doing this in configure.ac. You'll have to patch configure. This can be done by running the patching script in a bootstrap.sh after running autoreconf. You'll have to add your option to the ac_option processing loop. The case for --x looks like a promising one to copy or replace to inject your new option, something like:

--foo=*)
      my_foo=$ac_optarg ;;

There's also some code that strips out commandline args when configure sometimes needs to be re-invoked. It'll be up to you to determine whether --foo should be stripped or not. I think this is probably why they don't allow this in the first place.

If it were me, I'd try and lobby for AC_ARG_WITH (e.g. --with-foo=bar). It seems like a lot less work.

like image 143
ldav1s Avatar answered Dec 04 '25 21:12

ldav1s