[Top][All Lists]

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

Dynamically creating output variables.

From: Craig Sanders
Subject: Dynamically creating output variables.
Date: Wed, 16 Jan 2008 21:34:14 +1100


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 

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 ;

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

    while read line
        # 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 

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.


- Craig Sanders

reply via email to

[Prev in Thread] Current Thread [Next in Thread]