# SUBDIRS lists the components of Elk that are compiled and installed by
# running "make" and "make install".  The subdirectory "src" holds the
# interpreter proper; a mininum configuration requires the SUBDIRS include,
# scripts, src, and scm.
#
# Subdirectories if lib/ hold the standard extensions.  Delete them or
# parts of them from SUBDIRS if you don't want them to be compiled and
# installed; delete lib/xm and lib/xm/xt if you don't have Motif on your
# system.

SUBDIRS= include\
	 scripts\
	 src\
	 scm\
	 lib/misc\
	 lib/xlib\
	 lib/xt\
	 lib/xaw\
	 lib/xm\
	 lib/xm/xt

# ----------------------------------------------------------------------

SHELL= /bin/sh
MAKE=  make
GTAR=  gtar
ZIP=   zip

default:
	@for i in $(SUBDIRS) ;\
	do \
	    echo Making $$i...; \
	    ( cd $$i ; $(MAKE) ) \
	done

install:
	@for i in $(SUBDIRS) ;\
	do \
	    echo Installing $$i...; \
	    ( cd $$i ; $(MAKE) install ) \
	done

localize:
	@for i in $(SUBDIRS) ;\
	do \
	    echo Localizing $$i...; \
	    ( cd $$i ; $(MAKE) localize ) \
	done

lint:
	@for i in $(SUBDIRS) ;\
	do \
	    echo Linting $$i...; \
	    ( cd $$i ; $(MAKE) lint ) \
	done

clean:
	@for i in $(SUBDIRS) ;\
	do \
	    echo Cleaning $$i...; \
	    ( cd $$i ; $(MAKE) clean ) \
	done

distclean:
	@for i in $(SUBDIRS) ;\
	do \
	    echo Cleaning $$i...; \
	    ( cd $$i ; $(MAKE) distclean ) \
	done


# Package up all localized files (Makefile.local, include files, etc.)
# and source files into a zip file (to be compiled on a DOS system).
# The X11 extensions are not included.

LOCALF= Makefile config/system config/site include/*.h lib/misc/Makefile*\
        lib/misc/*.c scm/[a-z]* src/Makefile* `ls -1 src/*.c |grep -v hp9k`

localized.zip:
	$(MAKE) distclean
	$(MAKE) localize
	$(ZIP) -kr $@ $(LOCALF)


# Make a full distribution

DISTF= ANNOUNCE RELEASE README CHANGES INSTALL MACHINES COPYRIGHT CONTRIBUTORS\
       TODO MIGRATE Makefile config doc examples include lib scm scripts\
       src util contrib ExcludeFiles

dist:
	echo elk-`grep "^This is release" RELEASE | awk '{print $$4}'` > .rel
	rm -rf `cat .rel`
	mkdir `cat .rel`
	for i in $(DISTF) ;\
	do \
	    (cd `cat .rel`; ln -s ../$$i) \
	done
	cp config/site.dist config/site
	$(GTAR) -cvf `cat .rel`.tar -h -X ExcludeFiles `cat .rel`
	compress -f `cat .rel`.tar
	rm -rf `cat .rel` .rel
