1#!/bin/sh
2#
3#	process - expand certain macro expressions in text files
4#	Usage: process <file>
5#	AYM 1999-08-13
6#
7
8# In <file>, replace occurrences of
9# - "$COPYRIGHT_MAN" by the contents of the file cache/copyright.man.
10# - "$COPYRIGHT_TXT" by the contents of the file cache/copyright.txt.
11# - "$DATE"          by the YYYY-MM-DD current time,
12# - "$FILES_ETC"     by the contents of the file obj/0/file_etc.man
13# - "$FILES_SHARE"   by the contents of the file obj/0/file_share.man
14# - "$SELF_DATE"     by the YYYY-MM-DD mtime of <file>,
15# - "$SOURCE_DATE"   by the contents of the file cache/srcdate,
16# - "$VERPREV"       by the contents of the file ./VERPREV.
17# - "$VERSION"       by the contents of the file ./VERSION.
18# Output is written on stdout.
19
20file=$1
21shift
22sed -e "/\$COPYRIGHT_MAN/ {
23	  r cache/copyright.man
24	  d
25	}
26	/\$COPYRIGHT_TXT/ {
27	  r cache/copyright.txt
28	  d
29	}
30	/\$FILES_ETC/ {
31	  r obj/0/files_etc.man
32	  d
33	}
34	/\$FILES_SHARE/ {
35	  r obj/0/files_share.man
36	  d
37	}
38	s/\$DATE/`date +%Y-%m-%d`/g
39	s/\$SELF_DATE/`obj/0/ftime -d $file`/g
40	s/\$SOURCE_DATE/`cat cache/srcdate`/g
41	s/\$VERPREV/`test -r VERPREV && cat VERPREV`/g
42	s/\$VERSION/`cat VERSION`/g" $file
43