#! /bin/sh

# Handle exceptional cases in Geomview source distribution.
# We read the distribution list, and insert -C ... -C ${GEOM} sequences
# for each file we know about.  For example
# Where "data/.geomview" appears in the given file,
# replace it with the sequence
#  -C
#  dist
#  data/.geomview
#  -C
#  ..

# GNU tar interprets the -C's as embedded chdir commands.
# The effect is that we can distribute dist/data/.geomview in place of our own.

GEOM=`pwd`

# Ensure that the packed-up copy of makefiles/Makedefs.global is writable
(cd makefiles;
  rm -f dist/Makedefs.global
  cp Makedefs.global dist/Makedefs.global
  chmod u+w dist/Makedefs.global
)

awk 'BEGIN { BACK = "-C\n'"${GEOM}"'"; }

    /makefiles\/(mk.site.*|mk.NeXT|Makedefs.global)$/ \
	{ print "-C\nmakefiles/dist"; print $0; print BACK; next; }

    { print }
    
' $@
