Dynamically creating output variables.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

Is it possible to dynamically create output variables using AC_SUBST or some other means? The reason that I ask is because I am considering the idea of setting up a master configuration file for a project which I am working on. This master configuration file will contain a number of settings which are stored as key-value pairs. I then want to use AC_SUBST, or some other mechanism to make these key-value pairs available to output files when they are generated by AC_OUTPUT.

I have written a test Autoconf macro to try this out, but it doesn't work for me the way I expected. The problem is with the AC_SUBST command. My test macro is implemented as follows ;

AC_DEFUN([FOO_PROCESS_SETTINGS],
[         
    # Settings should be stored in the configuration file 
    # as key-value pairs, e.g. ;
    #
    #   PROJECT_NAME = foo

    while read line
    do
        # Extract the key from the string.
	key=$(echo ${line} | sed -e 's/ =.*//g')

	# Extract the value from the string.
	value=$(echo ${line} | sed -e 's/.*= //g')

	AC_MSG_NOTICE("---> ${NAME_MACRO} : ${key} -> ${value}")

        # The following line of code doesn't work as intended.

	AC_SUBST([${key}], [${value}])

    done < ./project-settings.conf
])

When I examine the configure file which is produced by Autoconf, it contains the following line ;

${key} = ${value}

which I assume was generated from the call to the AC_SUBST macro in my own macro.

Can I maybe accomplish this task by using some m4 code embedded into my macro? I have also considered using the AC_SUBST_FILE macro as well, but I don't think that this is going to work for me either.

Any help or pointers on this matter would be greatly appreciated.

Thankyou.


- Craig Sanders


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux