case $CONFIG in
'')
    if test ! -f config.sh; then
        ln ../config.sh . || \
        ln ../../config.sh . || \
        ln ../../../config.sh . || \
        (echo "Can't find config.sh."; exit 1)
    fi
    . ./config.sh
    ;;
esac
case "$0" in
*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
esac

vardir=`dirname $stage_dir`  

case "$d_locale" in
define)
	localetarget='$(ETC)/elm.mimecharsets $(ETC)/elm.terminalinfo'
	;;
*)
	localetarget=
	;;
esac

echo "Extracting Makefile-1 (with variable substitutions)"
cat >Makefile-1 <<!GROK!THIS!
#!$make
# $Id: Makefile-1.SH,v 1.19 2006/07/27 15:06:10 hurtta Exp $
#
#
#  Makefile for the ELM (ME+) mail program.
#
#  Author: Kari Hurtta <hurtta+elm@posti.FMI.FI> (was hurtta+elm@ozone.FMI.FI)
#
#
REG	= bin/elmregister
LIB		=	\$(ELM_ROOT)//$lib
ETC		=	\$(ELM_ROOT)//$etc
BIN		=	bin
STAGE		=	\$(ELM_ROOT)//$stage_dir
LOCALETARG	=	$localetarget
CHMOD		=	$chmod
STAGEP          = 	\$(ELM_ROOT)//$vardir

!GROK!THIS!

cat >>Makefile-1 <<'!NO!SUBS!'

all:
lint:
clean:

uninstall_s: 
	$(REG) rm -f $(LOCALETARG) $(LIB)/elm.map.bin/unidata.bin

install_s: $(LIB) $(ETC) $(STAGE) $(ETC)/elm.rc $(LOCALETARG) \
  $(LIB)/elm.map.bin/unidata.bin $(LIB)/elm.map.bin/bindata.bin \
  $(ETC)/elm.mimetypes libreg 

$(ETC)/elm.rc:	$(LIB)/elmrc-write doc/elmrc-info 
		$(REG) -s doc {$(LIB)/elmrc-write} -G -I -C {doc/elmrc-info} \
 -c {$(ETC)/elm.rc.old-values}
		$(REG) $(CHMOD) u=rw,go=r {$@}

$(LIB)/elm.map.bin/unidata.bin: $(LIB) $(LIB)/elm.map.bin \
 charset/UNIDATA/UNIDATA2.TXT $(LIB)/elmunidata 
		$(REG) -s unidata {$(LIB)/elmunidata} -I -s {charset/UNIDATA/UNIDATA2.TXT} 
		$(REG) -s unidata true {charset/UNIDATA/README.TXT}

$(LIB)/elm.map.bin/bindata.bin: $(LIB) $(LIB)/elm.map.bin $(LIB)/elmbindata  \
 $(ETC)/elm.mimecharsets
		$(REG) -s mappings {$(LIB)/elmbindata} -G -I \
  -S {charset/MAPPINGS/ISO8859} -S {charset/MAPPINGS} \
  -S {charset/MAPPINGS/MICSFT} 

$(ETC)/elm.mimecharsets: $(BIN)/elm.mimecharsets $(LIB)/elmcharset \
 ConfTool/killsets $(LIB)/elm.map.txt $(ETC)/elm.mimecharsets.NEW
		$(REG) -s mappings {$(LIB)/elmcharset} -G -I {ConfTool/killsets} -c \
  -S {charset/MAPPINGS/ISO8859} -S {charset/MAPPINGS} \
  -S {charset/MAPPINGS/MICSFT} {$(BIN)/elm.mimecharsets} 
		$(REG) $(CHMOD) u=rw,go=r {$@}

$(ETC)/elm.mimecharsets.NEW: $(BIN)/elm.mimecharsets \
 $(LIB)/elmcharset ConfTool/killsets $(LIB)/elm.map.txt
		$(REG) -s mappings {$(LIB)/elmcharset} -G -I {ConfTool/killsets} -w {$@} \
  -S {charset/MAPPINGS/ISO8859} -S {charset/MAPPINGS} \
  -S {charset/MAPPINGS/MICSFT} {$(BIN)/elm.mimecharsets} 

$(ETC)/elm.mimetypes: $(BIN)/elm.mimetypes $(LIB)/elmmimetypes \
 $(ETC)/elm.mimecharsets $(ETC)/elm.mimetypes.NEW
	$(REG) -s mappings {$(LIB)/elmmimetypes} -G -c {$(BIN)/elm.mimetypes}
	$(REG) $(CHMOD) u=rw,go=r {$@}

$(ETC)/elm.mimetypes.NEW: $(BIN)/elm.mimetypes $(LIB)/elmmimetypes \
 $(ETC)/elm.mimecharsets
	$(REG) -s mappings {$(LIB)/elmmimetypes} -G -w {$@} \
 {$(BIN)/elm.mimetypes}
	$(REG) $(CHMOD) u=rw,go=r {$@}

$(ETC)/elm.terminalinfo: $(BIN)/elm.terminalinfo $(LIB)/elmterminal \
 $(ETC)/elm.mimecharsets $(ETC)/elm.terminalinfo.NEW
	$(REG) -s terminal {$(LIB)/elmterminal} -G -c \
 {$(BIN)/elm.terminalinfo}
	$(REG) $(CHMOD) u=rw,go=r {$@}

$(ETC)/elm.terminalinfo.NEW: $(BIN)/elm.terminalinfo \
 $(LIB)/elmterminal $(ETC)/elm.mimecharsets
	$(REG) -s terminal {$(LIB)/elmterminal} -G -w {$@} {$(BIN)/elm.terminalinfo}

$(LIB):
		$(REG) mkdir $(LIB)

$(LIB)/elm.map.bin: 
		$(REG) mkdir $(LIB)/elm.map.bin

$(LIB)/elm.map.txt:
		$(REG) mkdir $(LIB)/elm.map.txt

$(STAGE):	$(STAGEP)
		$(REG) mkdir $(STAGE)

$(STAGEP):
		$(REG) mkdir $(STAGEP)

!NO!SUBS!


case "$d_dlopen_libs" in
define)  
	 aa=
	 if $test "$shared_register" != none ; then
	    aa="$shared_register"
	 fi
cat >>Makefile-1 <<!SUBS!

# Register new libraries and unregister removed libraries
# Also libraries which are not loadable are unregistered
libreg:
	\$(REG) {\$(LIB)/elmlibregister} -G -I -c {\$(ETC)/elm.rc.old-values}
!SUBS!
	for domake in $aa ; do
	    cat >>Makefile-1 <<!SUBS!
	\$(REG) -M "$domake" {\$(LIB)/elmlibregister} -G -I -c {\$(ETC)/elm.rc.old-values} $domake
!SUBS!
	done
	    cat >>Makefile-1 <<'!NO!SUBS!'
	$(REG) -M all -s doc {$(LIB)/elmrc-write} -G -I -C {doc/elmrc-info} \
 -c {$(ETC)/elm.rc.old-values} {$(ETC)/elm.rc.old-values}
!NO!SUBS!
	 ;;
*)	 

cat >>Makefile-1 <<'!NO!SUBS!'

libreg:
!NO!SUBS!
	;;
esac


syntax highlighted by Code2HTML, v. 0.9.1