I have the need to pass an argument multiple times to my ./configure like in this way:
./configure [...] --with-folder=/path/to/folder1 --with-folder=/path/to/folder2
and to store the path(s) in a variable as a list that I will use later in my makefile.
I've tried with this:
AC_DEFUN([ADDITIONAL_FOLDER],[
AC_MSG_CHECKING([for additional folder])
AC_ARG_WITH([folder],
[AS_HELP_STRING([--with-folder=DIR],
[specify additional folder])],
[
dnl Check if correct path was passed.
DIR="$(realpath "${withval}")"
if test ! -d "${DIR}"; then
AC_MSG_ERROR([incorrect folder])
fi
])
AC_SUBST([FOLDERS],["${FOLDERS} ${DIR}"])
AC_MSG_RESULT([${FOLDERS}])
])
But so far I was unable to tell autoconf to do that! Is it possible and how?
I need to correct my comment that this is probably "impossible".
However, while you can implement such option handling, you will need to deal with
"$@"in sh code yourself directly afterAC_INITwithout affecting any of the standard macros emitting shell code after that.See the last paragraph of https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/html_node/Initializing-configure.html:
So it might be possible to handle just your
--with-folderarguments from "$@" and save the values somewhere, and keep the remaining options in "$@" for the standard Autoconf generated code to deal with. It does not sound easy to implement, though:$@--with-folder=foo, addfootoFOLDERSand remove the argument from$@$@So I would still prefer something like
--with-folders=folder1,folder2,folder3similar towhich (just like the example in the question) only works for folders without spaces anywhere in their path.