###################################################################
###################################################################
###								###
###								###
###	*****    *   *    *****    ****     *****     ****	###
###	  *      **  *    *        *   *    *        *    	###
###	  *      * * *    * ***    ****     ***       *** 	###
###	  *      *  **    *   *    *  *     *            *	###
###	*****    *   *    *****    *   *    *****    **** 	###
###								###
###								###
###	      A relational database management system		###
###								###
###			    RELEASE 8				###
###								###
###################################################################
###################################################################
#
#	For information contact:
#		Mike Stonebraker
#		Dept. of Electrical Engineering &
#		  Computer Science
#		University of California
#		Berkeley, California  94720
#
#	For information on Linux/386BSD port contact:
#		Zeyd M. Ben-Halim
#		zmbenhalim@netcom.com

#
#	@(#)Makefile	8.4	12/24/86
#

#
#  This makefile compiles most of the modules for the bulk of
#  the INGRES system.  The modules affected are those used by
#  the "ingres" command itself.  Stand-alone utilities such as
#  "printr" and "restore" are in the 'support' directory.
#

#
#	Major recompilation will take place from this directory.
#	There are several interesting entry points:
#		allclean	cleans all cruft from all
#				directories.
#		allinstall	installs binaries in the INGRES
#				bin directory.
#			INSTALL=actual entry point called.
#
#	Examples of usage:
#		To recompile entire system from sources:
#			make allclean allinstall
#		To install INGRES for general users:
#			make allinstall 
#			run .../INSTALL.ME
#

include ../Config

#
#  General system paths
#

# the ingres subtree
INGRES=	../..
# the location of the system header files
H=	../h
# the residence of the system (internal) libraries
LIB=	$(INGRES)/lib
# the residence of the system (internal) binaries
# this entry must be reflected in the process table
BIN=	$(INGRES)/bin
# the location of user binaries
SYSBIN=	/usr/local
# the location of user libraries (libq.a)
SYSLIB=	/usr/local/lib

ALL=	monitor univingres sysmonitor sysmodfunc sysdump

SRCS=	monitor.c univingres.c sysdump.c version.c sysmonitor.c sysmodfunc.c

#
#  Libraries
#
#	Libraries should be loaded in the order listed below.
#
CTLMOD=	$(LIB)/ctlmod
IUTIL=	$(LIB)/iutil
GUTIL=	$(LIB)/gutil
MATH=	-lm

ALLLIB=	$(CTLMOD) $(IUTIL) $(GUTIL)

#
#  Binaries
#
MONITOR=$(LIB)/monitor
SYSMONITOR=$(LIB)/sysmonlib
PARSER=	$(LIB)/parser
QRYMOD=	$(LIB)/qrymod
DECOMP=	$(LIB)/decomp
OVQP=	$(LIB)/ovqp
DBULIB=	$(LIB)/dbulib

#
#  Assorted commands & other garbage
#
CFLAGS=	$(CONFIG) -I$H -O
LDFLAGS= 
CHMOD=	install -m
BINMODE=751
SUMODE=	4751
CP=	cp
HEADER=	Configuration Tables
MAKE=	make 
MFLAGS=	-k
INSTALL=install 

#
#  And the processes....
#
#	Proper loading order is:
#		conf table
#		library(s) for modules
#		ctlmod library
#		iutil library
#		gutil library
#
#  Sysmodfunc

sysmodfunc: version.o sysmodfunc.o $(DBULIB) $(CTLMOD) $(ALLLIB)
	$(CC) $(LDFLAGS) version.o $@.o $(DBULIB) $(OTHERS) $(ALLLIB)  -o $@
	$(INSTALL) -m $(SUMODE) $@ $(BIN)
	rm $@

#  Sysdump

sysdump: version.o sysdump.o $(CTLMOD) $(ALLLIB)
	$(CC) $(LDFLAGS) version.o $@.o $(OTHERS) $(ALLLIB)  -o $@
	$(INSTALL) -m $(SUMODE) $@ $(BIN)
	rm $@

#  Monitor

monitor: version.o monitor.o $(MONITOR) $(CTLMOD) $(IUTIL) $(GUTIL)
	$(CC) $(LDFLAGS) version.o $@.o $(OTHERS) $(MONITOR) $(CTLMOD) $(IUTIL) $(GUTIL) -o $@
	$(INSTALL) -m $(BINMODE) $@ $(BIN)
	rm $@

#  SysMonitor 

sysmonitor: version.o sysmonitor.o $(SYSMONITOR) $(DBULIB) $(IUTIL) $(GUTIL)
	$(CC) $(LDFLAGS) version.o $@.o $(OTHERS) $(SYSMONITOR) $(CTLMOD) $(IUTIL) $(GUTIL) -o $@
	$(INSTALL) -m $(BINMODE) $@ $(BIN)
	rm $@

#  Full System

ALLLIBS=$(PARSER) $(QRYMOD) $(DECOMP) $(OVQP) $(DBULIB) $(ALLLIB)

univingres: version.o univingres.o $(ALLLIBS)
	$(CC) $(LDFLAGS) version.o $@.o $(OTHERS) $(ALLLIBS) $(MATH)  -o $@
	$(INSTALL) -m $(SUMODE) $@ $(BIN)
	rm $@

allinstall: version.o all1 all 

all: $(ALL)

all1:
	cd ../h; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../gutil; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../iutil; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../ctlmod; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../dbu; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../decomp; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../equel; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../libq; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../monitor; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../ovqp; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../parser; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../qrymod; $(MAKE) $(MFLAGS) $(INSTALL)
	cd ../support; $(MAKE) $(MFLAGS) $(INSTALL)

#################################################################
#
#	Miscellaneous entries
#

new:
	rm -f $(ALL)

clean: new
	rm -f *.o
	rm -f a.out core

allclean: clean
	cd ../h; $(MAKE) $(MFLAGS) clean
	cd ../gutil; $(MAKE) $(MFLAGS) clean
	cd ../iutil; $(MAKE) $(MFLAGS) clean
	cd ../ctlmod; $(MAKE) $(MFLAGS) clean
	cd ../dbu; $(MAKE) $(MFLAGS) clean
	cd ../decomp; $(MAKE) $(MFLAGS) clean
	cd ../equel; $(MAKE) $(MFLAGS) clean
	cd ../libq; $(MAKE) $(MFLAGS) clean
	cd ../monitor; $(MAKE) $(MFLAGS) clean
	cd ../ovqp; $(MAKE) $(MFLAGS) clean
	cd ../parser; $(MAKE) $(MFLAGS) clean
	cd ../qrymod; $(MAKE) $(MFLAGS) clean
	cd ../support; $(MAKE) $(MFLAGS) clean

