#!/bin/bash ###################################################################### # $Id: makeinc,v 1.12 2008/02/20 14:46:55 perette Exp perette $ # Author: Perette Barella # Purpose: This script generates an m4 include file for html (web # pages). This allows references to standard graphics # from various directories, using standard macros for # the directory names which use relative paths so when # the page is pushed to a differing production server # everything still works. ###################################################################### arg0=$(basename $0) if [ $# -eq 0 ] then [ "$WEBBASE" = "" ] && WEBBASE=$HOME/Web else WEBBASE="$1" fi INCNAME="stddefs.m4" dircheck="$(echo $PWD | cut -c 1-${#WEBBASE})" if [ "$dircheck" != "$WEBBASE" ] then echo "$arg0: $PWD not in $WEBBASE hierarchy" exit 1 fi dirwork=$(echo $PWD | cut -c ${#WEBBASE}- | cut -c 2-) if [ "$(echo $dirwork | cut -c1)" = "/" ] then dirwork="$(echo $dirwork | cut -c2-)" fi if [ "$dirwork" = "" ] then DIR_REL="." BACKPATH="." else DIR_REL="$dirwork" BACKPATH=".." dirwork=$(dirname $dirwork) while [ "$dirwork" != "." ] do BACKPATH="../$BACKPATH" dirwork=$(dirname $dirwork) done fi export TZ="CUT0" echo " m4_define(DIR_TOP,\`$BACKPATH') m4_define(DIR_GFX,\`$BACKPATH/Graphics') m4_define(DIR_INCLUDE,\`$BACKPATH/Include') m4_define(DIR_HERE,\`$DIR_REL') m4_include(${BACKPATH}/Include/html.m4) m4_include(DIR_TOP/siteinfo.m4) _REVISION(\`\`$INCNAME built $(date '+%Y-%m-%d %H:%M:%S') by makeinc "'$Revision: 1.12 $'"'') " > $INCNAME