#! /bin/csh -f set usage = "$0 [ -undo ] CPACKAGE" # Copies the source files in ${STOLFIHOME}/programs/c/PACKAGE # to ${STOLFIHOME}/EXPORT/software/c/PACKAGE. # Renames the ".make" file to "Makefile", removing directory names. # Also creates the file ".www_browsable". set path = ( /usr/ucb /usr/bsd /usr/bin /bin ) unset undo while ( ( $#argv > 0 ) && ( "x$1" =~ x-* ) ) if ( "x$1" == "x-undo" ) then set undo; shift else echo "unrecognized option: $1" echo "usage: ${usage}"; exit 1 endif end if ( $#argv != 1 ) then echo "usage: ${usage}"; exit 1 endif set pkg = "$1"; shift set EXP = "${STOLFIHOME}/EXPORT/software/c/${pkg}" set SRC = "${STOLFIHOME}/programs/c/${pkg}" if ( $?undo ) then echo "undoing export of ${pkg}..." if ( ! ( -d ${EXP}~ ) ) then echo "cant undo: ${EXP}~ missing"; exit 1 endif if ( -d ${EXP}@ ) then echo "remove ${EXP}@ first"; exit 1 endif if ( -d ${EXP} ) then echo "moving ${EXP} to ${EXP}@" mv ${EXP} ${EXP}@ endif echo "moving ${EXP}~ to ${EXP}" mv ${EXP}~ ${EXP} if ( -d ${EXP}~~ ) then echo "moving ${EXP}~~ to ${EXP}~" mv ${EXP}~~ ${EXP}~ endif exit 0 endif # Save backups: if ( -d ${EXP}~~ ) then echo "$0: please remove ${EXP}~~ first"; exit 1 endif if ( -d ${EXP}~ ) then mv ${EXP}~ ${EXP}~~ endif if ( -d ${EXP} ) then mv ${EXP} ${EXP}~ endif # Create new directory: mkdir -p ${EXP} cp -p ${SRC}/*.c ${SRC}/*.h ${SRC}/*.1 ${EXP}/ touch ${EXP}/.www_browsable # Copy the "makefile" set mkfs = ( `cd ${SRC} && ls -1d . *.make` ) if ( $#mkfs < 2 ) then echo "${SRC}/*.make not found" else if ( $#mkfs > 2 ) then echo "too many .make files in ${SRC}" else if ( "x$mkfs[1]" == "x." ) then set mkf = $mkfs[2] cat ${SRC}/${mkf} \ | sed -e 's/^INSTALLDIR *= *.*$/INSTALLDIR = INSTALLDIR_IS_UNDEFINED/g' \ > ${EXP}/Makefile else echo "funny filename ${SRC}/${mkfs[1]}" endif # Report results echo ${EXP} ls -la ${EXP} if ( -d ${EXP}~ ) then set dff = /tmp/diff-$$ diff -r ${EXP}~ ${EXP} \ | ${STOLFIHOME}/bin/prettify-diff-output \ > ${dff} mv ${dff} ${EXP}/.diffs endif # Remove old backups if ( ( -d ${EXP}~~ ) && ( -d ${EXP} ) ) then chmod u+w ${EXP}~~ rm -rf ${EXP}~~ endif