# Make file for elm directory
#
# Things you might want to change.  Pass them in on the command line:
# ROOT - should point to the root where the commands will be installed
#        (e.g. /deliver/INETSVCS/indnetwk)

ROOT=

UTILS=/usr/bin/elm \
	/usr/bin/elmalias \
	/usr/bin/mailfrom \
	/usr/bin/newmail \
	/usr/bin/readmail

SRCDIR=/usr/lib/nls/msg/C/elm.cat

HELPFILES=/usr/share/lib/elm/elmrc-info

#Commands used by this makefile
MKDIR=/usr/bin/mkdir

# Defaults file containing the shell, compiler options, etc
BUILDRULES=/source/INETSVCS/$(LOGNAME)/config/defaults

include ${BUILDRULES}

INCLUDES=-I../include -I/usr/include
CCFLAGS=$(INCLUDES) -DNLS $(CFLAGS)

#Install database name
INSTALLDB=/source/INETSVCS/$(LOGNAME)/config/installdb

#Script called to parse the install deliverable
INSTALLSCPT=/source/INETSVCS/$(LOGNAME)/config/install_script

default: all

all: clean build install

clean:
	cd src ; \
	$(MAKE) -f makefile clobber clean

install:
	cd bin ; \
	for file in $(UTILS) ; do \
		pwd ; \
		$(INSTALLSCPT) $$file $(INSTALLDB) ;  \
	done

	cd src ; \
	for file in $(SRCDIR) ; do \
		$(INSTALLSCPT) $$file $(INSTALLDB) ;  \
	done

	cd lib ;\
	for file in $(HELPFILES) ; do \
		$(INSTALLSCPT) $$file $(INSTALLDB) ;  \
	done

build:  elm elm.cat elm_utils

elm:   
	$(ECHO) "Building elm..."
	if [ ! -d bin ]; then $(MKDIR) bin; fi
	cd src ; \
	$(MAKE) CFLAGS="$(CCFLAGS)" LDFLAGS="$(LDFLAGS)" -f makefile elm

elm.cat:
	$(ECHO) "Building elm.cat..."
	if [ ! -d bin ]; then $(MKDIR) bin; fi
	cd src ; \
	$(MAKE) -f makefile elm.cat

elm_utils:
	$(ECHO) "Building elm utils..."
	if [ ! -d bin ]; then $(MKDIR) bin; fi
	cd utils ; \
	$(MAKE) CFLAGS="$(CCFLAGS)" LDFLAGS="$(LDFLAGS)" -f makefile utils
