How to combine AC_SUBST and AC_DEFINE?

I have a configure.ac file containing lines like:

 AC_DEFINE(CONF_XDISP, ":8", "X screen number") 

These constants are used in source C to set the default parameters for compilation. I also have a conf/bumblebee.conf configuration file in which these default values ​​should be set. I was told that AC_SUBST can be used to get @ CONF_XDISP@ replaced with ":8" such that the following line:

 VGL_DISPLAY=@CONF _XDISP@ 

becomes:

 VGL_DISPLAY=":8" 

Creating an AC_SUBST line for each AC_DEFINE does not look the best to me, as it involves a lot of line duplication. How can I combine these parameters so that I can use something like AC_DEFINE_SUBST ? Other ideas and suggestions for improving this are also welcome.

+4
source share
2 answers

Thanks to thinton, I could prepare the code below:

 # AC_DEFINE_SUBST(NAME, VALUE, DESCRIPTION) # ----------------------------------------- AC_DEFUN([AC_DEFINE_SUBST], [ AC_DEFINE([$1], [$2], [$3]) AC_SUBST([$1], ['$2']) ]) 

In AC_DEFINE_SUBST(CONF_XDISP, ":8", "X screen number") , a configure file is created containing:

 $as_echo "#define CONF_XDISP \":8 \$PWD\"" >>confdefs.h CONF_XDISP='":8"' 

Related documents:

+5
source

m4 is a macro language, after all, something like

  AC_DEFUN([AC_DEFINE_SUBST], [AC_DEFINE($1,$2,$3) AC_SUBST($1)]) 

gotta do the trick. You may need to play a little with [ to slip away.

+6
source

Source: https://habr.com/ru/post/1389340/


All Articles