#sccs	"@(#)libmain:Makefile	1.10"
# Makefile for building libraries

include $(MAKEINC)/Makepre.h

GLOBAL_SL=

POPDIRS = \
	libg \
	libl \
	libld \
	libplot \
	libc

SUBDIRS = \
	libPW \
	libcurses \
	libg \
	libl \
	libld \
	libhelp \
	libm \
	libplot \
	libdev \
	liby \
	libmath \
	malloc \
	tabset \
	tam \
	termlib

#	all will install libraries to make sure the Miniframe
#	Libraries are updated.

all:   libc_mk libc_install comall cominstall shlib_mk shlib_install

clobber: comclobber 
	cd libc; $(MAKE) clobber
	cd shlib; $(MAKE) clobber

clean: comclean
	cd libc; $(MAKE) clean
	cd shlib; $(MAKE) clean

#	The Shared Library is built and installed separately to
#	ensure that it extracts modules from the most recent versions
#	of libc and libtam. Thus these libraries MUST be installed
#	BEFORE shlib is built....
#
#	Libc is required to build a command in tam.... so we make and
#	install it first.....
#	The ifile install is used by the kernel to get its thing done

install: libc_install ifile_install cominstall shlib_install

libc_mk shlib_mk:
	cd `echo $@| sed -e 's/_mk//'`; $(MAKE) all 

libc_install shlib_install:
	cd `echo $@| sed -e 's/_install//'`; $(MAKE) install

ifile_install:
	chown bin ifile.0407 ifile.0410 ifile.0413
	chgrp bin ifile.0407 ifile.0410 ifile.0413
	chmod 644 ifile.0407 ifile.0410 ifile.0413 
	$(INSTALL) -i$(EXITFLAG) ifile.0407  $(INSDIR) $(PROTOFILE)
	$(INSTALL) -i$(EXITFLAG) ifile.0410  $(INSDIR) $(PROTOFILE)
	$(INSTALL) -i$(EXITFLAG) ifile.0413  $(INSDIR) $(PROTOFILE)
	ls ifile.0407 ifile.0410 ifile.0413 | cpio -pumv $(LIB)

populate: $(SUBDIRS) libc shlib
	for D in $(SUBDIRS) libc shlib; \
	do \
		(cd $$D; echo "$$D" >.unit; echo "** $$D **:"; getunit); \
	done
	for D in $(POPDIRS) ; \
	do \
		(cd $$D; echo "** $$D **:"; $(MAKE) populate); \
	done

$(SUBDIRS) shlib libc:
	mkdir $@

includes: comincludes
	cd libc; $(MAKE) includes
	cd shlib; $(MAKE) includes

include $(MAKEINC)/Makepost.h
