autoconf
[Top][All Lists]
Advanced

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

Autoconf Data Representation


From: Ryan Collins
Subject: Autoconf Data Representation
Date: Wed, 5 Dec 2001 03:35:25 -0500 (EST)

I've been running into some trouble when trying to use autoconf with
some programs I've written in scheme shell, and I think my general
solution may be useful enough to include in future versions of autoconf.

The problem I have is that autoconf represents all of its data as
strings, while scsh requires commands that are passed to (exec ...)
to be lists.

Autoconf has
   @INSTALL@ -->  /usr/bin/install -c
while I need
   @INSTALL@ --> '(/usr/bin/install -c) or
   @INSTALL@ --> '("/usr/bin/install" "-c")

I modified my copy of autoconf to add the following extra variables:
   @INSTALL_atom@ -->  "/usr/bin/install -c"
   @INSTALL_list@ -->  '("/usr/bin/install" "-c")
(I added the atom option so that I can have directory names rendered as
scheme strings.)

This could be extended to other languages that want data that isn't
structured as a simple string (for example, exec() calls in C).  I think
it'd probably be useful to include something like this in the next 
version of autoconf, since scripting languages which have structured 
data, such as scsh and perl, are increasing in popularity.  

Here's the code I modified to get this to work.  I'm not a great shell
programmer, so I'm sure someone else can find a more elegant solution
than this.  I did make it backwards compatible with the old autoconf
variable names, although that runs the risk of variable name collision.  

(Both of these macros are in acgeneral.m4)

m4_define([AC_SUBST],
[m4_ifvaln([$2], [$1=$2])[]dnl
_AC_SUBST([$1], [s,@$1@,[$]$1,;t t])
_AC_SUBST([$1_atom], [`makesexp atom $1 [$]$1`,;t t])
_AC_SUBST([$1_list], [`makesexp list $1 [$]$1`,;t t])dnl
])# AC_SUBST

# ...

m4_define([_AC_OUTPUT_FILES],
[
# Makesexp function
makesexp()
{
  type=[$]1;
  symbol=[$]2;
  shift
  shift
 
  printf -- "s,@${symbol}_${type}@,"
 
  if test [$]type = "list";
  then
        printf "'("
  else
        printf "\""
  fi
 
  while test [$]# -gt 1;
  do
        y=`echo "[$]1" | sed -e 's/\"/\\\"/g'`
 
        if test [$]type = "list" ;
        then
                printf "\""
        fi
 
        printf -- "[$]y"
 
        if test [$]type = "list" ;
        then
                printf "\" "
        else
                printf " "
        fi
 
        shift
  done
  
  y=`echo "[$]1" | sed -e 's/\"/\\\"/g'`
 
  if test [$]type = "list";
  then
        printf "\""
  fi
 
  printf -- "[$]y"
 
  if test [$]type = "list" ;
  then
        printf "\")"
  else
        printf "\""
  fi
}

# ...


                                        
-Ryan Collins (address@hidden)




reply via email to

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