# ----------------
#    NOTE: THIS PMAKEFILE IS INCOMPLETE - DO NOT ATTEMPT TO USE - cim
# ----------------

# ----------------------------------------------------------------
#	Makefile for POSTGRES test programs
#
#	$Header: /private/postgres/src/test/RCS/Makefile,v 1.3 1989/09/05 16:53:57 mao Version_2 $
# ----------------------------------------------------------------

# ----------------
#    conf.local contains all the configuration definitions
# ----------------

#include "conf.local"

# ----------------
#    support settings - here only for example
# ----------------

AMIINT		=	$(DATAHOME)/bin/amiint
SCRDIR		=	$(DATAHOME)/src/support

DFLAGS		=	-DAMIINT='"$(AMIINT)"' \
			-DSCRDIR='"$(SCRDIR)"' \
			-DDATAHOME='"$(DATAHOME)"'

BUFIFLAGS	=	-I$(OBJDIR)/storage/buffer

IFLAGS		=	-I$(HDRDIR)

CFLAGS		=	-O -DEBUG -DPOSTMASTERLOG -DVACUUMDLOG $(IFLAGS)

LIBS		=	-lm -ll

# ----------------
#    clean these up
# ----------------

SUPPORT=../support
IFLAGS=	-I../h
CP=	cp
CFLAGS= -g $(IFLAGS)
CHMOD=	chmod
MALLOC=	/usr/lib/debug/malloc.o
BINMODE=751
SUMODE=	751
ROMODE=	444
SHMOD=	755

DEFAULT=@echo "***" No default

# ----------------
#    port.mk contains port-specific information, including
#    PORTSRCDIR and PORTOBJDIR
# ----------------

#include "CONF/port.mk"

# ----------------
#    Definition of search paths
# ----------------

PMAKE_VPATH_SRCS ?=	./ \
			$(SRCDIR)/$(LISPLIB) \
			$(SRCDIR)/access/genam \
			$(SRCDIR)/access/heap \
			$(SRCDIR)/access/index-btree \
			$(SRCDIR)/access/spam \
			$(SRCDIR)/access/tuple \
			$(SRCDIR)/commands \
			$(SRCDIR)/lib/C \
			$(SRCDIR)/lib/libpq \
			$(SRCDIR)/lib/libpq/demo \
			$(SRCDIR)/lib/libpqcl \
			$(SRCDIR)/lib/catalog \
			$(SRCDIR)/parser \
			$(SRCDIR)/storage/buffer \
			$(SRCDIR)/storage/ipc \
			$(SRCDIR)/storage/lmgr \
			$(SRCDIR)/storage/page \
			$(SRCDIR)/storage/file \
			$(SRCDIR)/support \
			$(SRCDIR)/test \
			$(SRCDIR)/utils/adt \
			$(SRCDIR)/utils/cache \
			$(SRCDIR)/utils/fmgr \
			$(SRCDIR)/utils/init \
			$(SRCDIR)/utils/mmgr \
			$(SRCDIR)/utils/error \
			$(SRCDIR)/utils/comm \
			$(SRCDIR)/utils/xact \
			$(SRCDIR)/utils/time \
			$(SRCDIR)/utils/rules

PMAKE_VPATH_HDRS ?=	./ $(SRCDIR) $(HDRDIR)

PMAKE_VPATH_OBJS ?=	./ \
			$(OBJDIR)/$(LISPLIB) \
			$(OBJDIR)/access/genam \
			$(OBJDIR)/access/heap \
			$(OBJDIR)/access/index-btree \
			$(OBJDIR)/access/spam \
			$(OBJDIR)/access/tuple \
			$(OBJDIR)/commands \
			$(OBJDIR)/lib/C \
			$(OBJDIR)/lib/libpq \
			$(OBJDIR)/lib/libpq/demo \
			$(OBJDIR)/lib/libpqcl \
			$(OBJDIR)/lib/catalog \
			$(OBJDIR)/parser \
			$(OBJDIR)/storage/buffer \
			$(OBJDIR)/storage/ipc \
			$(OBJDIR)/storage/lmgr \
			$(OBJDIR)/storage/page \
			$(OBJDIR)/storage/file \
			$(OBJDIR)/support \
			$(OBJDIR)/test \
			$(OBJDIR)/utils/adt \
			$(OBJDIR)/utils/cache \
			$(OBJDIR)/utils/fmgr \
			$(OBJDIR)/utils/init \
			$(OBJDIR)/utils/mmgr \
			$(OBJDIR)/utils/error \
			$(OBJDIR)/utils/comm \
			$(OBJDIR)/utils/xact \
			$(OBJDIR)/utils/time \
			$(OBJDIR)/utils/rules

# ----------------
#    Definition of sources
# ----------------


MAINCODE= testinit.c

MAINOBJ= testinit.o

CFILES=	testinit.c \
	testbtdel.c \
	testbtree.c \
	testbuf.c \
	testcache.c \
	testlock.c \
	testmmgr.c \
	testpsort.c \
	testxact.c \
	testxid.c \
	testxlog.c

SPECIAL1SRC=	../fmgr/fmgr.c
SPECIAL2SRC=	../util/syscache.c
SPECIAL1=	fmgr.o
SPECIAL2=	syscache.o
SPECIAL= \
	$(SPECIAL1) \
	$(SPECIAL2)


LIBSSPAM=\
	initspam.o \
	log-blocktuple.o \
	log-primitives.o \
	log-scan.o \
	log-tuple.o \
	spam-accessors.o \
	spam-control.o \
	spam-debug.o \
	spam-index.o \
	spam-mmgr.o \
	spam-primitives.o \
	spam-utils.o \
	time-blocktuple.o \
	time-dirtuple.o \
	time-primitives.o \
	var-access.o \
	xlog.o \
	xtim.o 

LIBS0=	$(LIBSSPAM) \
	$(SPECIAL) \
	access.o \
	assert.o \
	att.o \
	attnum.o \
	attval.o \
	bit.o \
	block.o \
	bool.o \
	btdata.o \
	bthacks.o \
	bthdr.o \
	btinsrt.o \
	btitem.o \
	btkey.o \
	btlock.o \
	btnode.o \
	btpage.o \
	btqual.o \
	btree.o \
	btscan.o \
	btsrch.o \
	btstk.o \
	btstrat.o \
	buf.o \
	bufmgr.o \
	bufpage.o \
	buf_sync.o \
	catalog.o \
	catcache.o \
	catname.o \
	char.o \
	cinit.o \
	context.o \
	create.o \
	creati.o \
	date.o \
	datum.o \
	dlog.o \
	dt.o \
	elog.o \
	fd.o \
	float.o \
	form.o \
	format.o \
	ftup.o \
	genam.o \
	geo-ops.o \
	geo-selfuncs.o \
	hash.o \
	hashlib.o \
	heapam.o \
	hio.o \
	hrnd.o \
	htup.o \
	imark.o \
	int.o \
	inval.o \
	ipc.o \
	ipci.o \
	iqual.o \
	isop.o \
	istrat.o \
	itemid.o \
	itemptr.o \
	itup.o \
	linval.o \
	lmgr.o \
	magic.o \
	mmgr.o \
	name.o \
	newam.o \
	numutils.o \
	off.o \
	oid.o \
	order.o \
	page.o \
	pagenum.o \
	part.o \
	pcomm.o \
	pladt.o \
	pladtdeb.o \
	pldebug.o \
	plm.o \
	plsync.o \
	pos.o \
	pskip.o \
	rac.o \
	regproc.o \
	rel.o \
	relcache.o \
	sdir.o \
	selfuncs.o \
	sinval.o \
	sinvaladt.o \
	skey.o \
	tim.o \
	tqual.o \
	trange.o \
	tup.o \
	tuple.o \
	utils.o \
	valid.o \
	varlena.o \
	xcxt.o \
	xid.o \
	xstate.o


LIBSCACHE=	$(LIBS0) printtup.o

LIBSPS=	$(LIBS0) \
	lselect.o \
	psort.o

LIBSSHM=	$(LIBS0) shmbuf.o


SRCS=	$(HFILES) $(CFILES)


ALL=	testbtree testbtdel testbuf testcache testlock testmmgr testpsort \
	testxact testxid testxlog testvacuum

stdout		?=	/dev/tty

# ----------------
#    default.mk contains standard make information like
#    transformation rules, what compiler to use, etc.
# ----------------

#include "CONF/default.mk"

# ----------------
#    targets
# ----------------

.MAIN:	Main

Main:	$(ALL)

# ----------------
#	targets - for the most part ok
# ----------------

#vacuum.o: $(SUPPORT)/vacuum.c
#	$(cc) -c $(SUPPORT)/vacuum.c

testvacuum: $(MAINOBJ) testvacuum.o $(LIBS0) vacuum.o
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS)
	$(chmod) $(BINMODE) $(.TARGET)

testbtdel: $(MAINOBJ) testbtdel.o $(LIBS0)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

testbtree: $(MAINOBJ) testbtree.o $(LIBS0)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

testbuf: $(MAINOBJ) testbuf.o $(LIBS0)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

testcache: $(MAINOBJ) testcache.o $(LIBSCACHE)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

testdefine: $(MAINOBJ) testdefine.o $(LIBS0)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

testlock: $(MAINOBJ) testlock.o $(LIBS0)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

testmmgr: $(MAINOBJ) testmmgr.o $(LIBS0)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

testpsort: $(MAINOBJ) testpsort.o $(LIBSPS)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(SUMODE) $(.TARGET)

testshm: $(MAINOBJ) testshm.o $(LIBSSHM)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

testxact: $(MAINOBJ) testxact.o $(LIBS0)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

testxid: $(MAINOBJ) testxid.o $(LIBS0)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

# ----------------
#	change programs to $variables
# ----------------

testxlog: $(MAINOBJ) testxlog.o xlog_parser.o xlog_lexer.o $(LIBS0)
	$(echo) $(LIBS0) > testxlog.tmp
	$(mv) testxlog.tmp testxlog.files
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

xlog_parser.o:  xlog_parser.y
	$(yacc) xlog_parser.y
	$(mv) y.tab.c xlog_parser.c
	$(cc) -c $(CFLAGS) xlog_parser.c

xlog_lexer.o:   xlog_lexer.c
	$(cc) -c $(CFLAGS) xlog_lexer.c

xlog_lexer.c:
	$(lex) xlog_lexer.l
	$(mv) lex.yy.c xlog_lexer.c

# ----------------
#	incomplete - fix this
# ----------------

$(SPECIAL1): $(SPECIAL1SRC)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

	echo "Making $@ ... "
	(cd $(SUPPORT) && \
		exec make $(MFLAGS) $(SPECIAL1))
	cmp -s $(SUPPORT)/$(SPECIAL1) $@ || cp $(SUPPORT)/$(SPECIAL1) $@
				    
$(SPECIAL2): $(SPECIAL2SRC)
	$(cc) -o $(.TARGET) $(.ALLSRC) $(LIBS) 
	$(chmod) $(BINMODE) $(.TARGET)

	echo "Making $@ ... "
	(cd $(SUPPORT) && \
		exec make $(MFLAGS) $(SPECIAL2))
	cmp -s $(SUPPORT)/$(SPECIAL2) $@ || cp $(SUPPORT)/$(SPECIAL2) $@

# ----------------
#	clean these up
# ----------------

clean:
	$(rm) eddep makedep tags *.o

lint:	$(SRCS)
	$(lint) $(SRCS)

tags:	$(SRCS)
	$(ctags) $(SRCS)

print:	$(SRCS)
	$(pr) Makefile $(SRCS)

# ----------------
#    subroutine to print a starting message
# ----------------
START : .ZEROTIME .SILENT .IGNORE
	$(echo) "PMake in progress..." >> $(stdout)
