automake
[Top][All Lists]
Advanced

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

Re: installing config.h


From: Thien-Thi Nguyen
Subject: Re: installing config.h
Date: 04 Sep 2002 13:06:15 -0400

Waldemar Rosenbach <address@hidden> writes:

   Is there another way to solve this kind of problem?

well, it's not clean, but you can process the headers on install.  this could
be a provisional approach (i.e., kludge) while you make the interface platform
independent.

see below for petrify-headers.  sample usage:

install-data-hook:
        $(srcdir)/petrify-headers $(srcdir) $(pkginclude_HEADERS)
        files=`ls *.petrified | sed 's/.petrified$$//g'`; \
        for f in $$files ; do \
          $(INSTALL_DATA) $$f.petrified $(DESTDIR)$(pkgincludedir)/$$f ; done
        rm -f *.petrified

you will need to munge things slightly to fit your setup, or better yet, reel
in horror and run away run away!

thi


_______________________________________________
#!/bin/sh
# Usage: petrify-headers SRCDIR [FILE ...]
#
# Description: Scan scmconfig.h and then for each SRCDIR/FILE ...
#              write ./FILE.petrified

if [ x"$1" = x ] ; then
    echo 'ERROR: no srcdir specified'
    exit 1
fi

srcdir=$1 ; shift

if [ x"$1" = x ] ; then
    echo 'ERROR: no files specified'
    exit 1
fi

one_syms=`awk '/^#define /{print $2}' scmconfig.h`
zero_syms=`awk '/^...#undef/{print $3}' scmconfig.h`

# first construct sed script
display_sed_script ()
{
echo 's,#include "libguile/scmconfig.h",,g'
for sym in $one_syms ; do
    echo 's,^# *if\(def\)* '"$sym"'$,#if 1 /* petrified '"$sym"' */,g'
done
for sym in $zero_syms ; do
    echo 's,^# *if\(def\)* '"$sym"'$,#if 0 /* petrified '"$sym"' */,g'
done
}

script=petrify-headers.sed
changed=petrify-headers.changed
unchanged=petrify-headers.unchanged

display_sed_script > $script

rm -f $changed $unchanged
touch $changed $unchanged

for f in "$@" ; do
    sed -f $script $srcdir/$f > $f.petrified
    if diff -q $srcdir/$f $f.petrified >/dev/null 2>&1 ; then
        rm $f.petrified ; echo $f >> $unchanged
    else
        echo $f >> $changed
    fi
done

rm -f $script

wc -l $changed $unchanged
rm -f $changed $unchanged

# petrify-headers ends here




reply via email to

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