guile-user
[Top][All Lists]
Advanced

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

petrify-headers + Makefile.am usage


From: Thien-Thi Nguyen
Subject: petrify-headers + Makefile.am usage
Date: Fri, 16 Aug 2002 16:58:15 -0700

folks,

here's a libguile/Makefile.am fragment that calls petrify-headers
(appended below) to process all the libguile/*.h immediately prior to
install.

  ## Delete any mis-installs from the past that we can guarantee never to be
  ## installed in the future.  Also, replace some installed headers w/ 
petrified.
  install-data-hook:
        rm -f $(DESTDIR)$(modincludedir)/scmconfig.h
        $(srcdir)/petrify-headers $(srcdir) $(modinclude_HEADERS)
        files=`ls *.petrified | sed 's/.petrified$$//g'`; \
        for f in $$files ; do \
          $(INSTALL_DATA) $$f.petrified $(DESTDIR)$(modincludedir)/$$f ; done
        rm -f *.petrified

let me know if this rubs anyone wrong or if there is a better way to do
the same thing i haven't discovered.  if not, this will go into guile
1.4.2 as a way to eliminate scmconfig.h cpp symbol pollution.  to play,
comment out some of the "rm -f" commands and look at the intermediate
files.

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]