unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* petrify-headers + Makefile.am usage
@ 2002-08-16 23:58 Thien-Thi Nguyen
  0 siblings, 0 replies; only message in thread
From: Thien-Thi Nguyen @ 2002-08-16 23:58 UTC (permalink / raw)


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


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-08-16 23:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-16 23:58 petrify-headers + Makefile.am usage Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).