# -*- Makefile -*-
# $Id: Makefile,v 1.27 1998/07/14 09:21:49 miyazaki Exp $
#
# Makefile for an SQL server. These sources should be compiled for an nCUBE2.
#
# Copyright (C) 1996-1998 by Haruo Yokota, 
#	Japan Advanced Inst. of Sci. and Tech.,
#	1-1 Asahidai, Tatsunokuchi, Ishikawa 923-1292, Japan.
#

SHELL		= /bin/sh
RM		= /bin/rm -f
IOMODULE	= fastio

NKLIC		= /usr/ncube/klic/bin/klic
#NKLICFLAGS	= -v -dp
NKLICFLAGS	= -v -O -dp

##### DO NOT DELETE THE FOLLOWING RULES
#.SUFFIXES:
#.SUFFIXES: .kl1 .o
#
#COMPILE.kl1	= $(NKLIC) $(NKLICFLAGS) -c
#LINK.kl1	= $(NKLIC) $(NKLICFLAGS)
#
#.kl1.o:
#	$(COMPILE.kl1) $<
#.kl1:
#	$(LINK.kl1) -o $@ $<
#
#####
TARGET	= rdbserv

LNSRC	= rdbserv.kl1 algebra.kl1 exec.kl1 trans.kl1 lock.kl1 \
	deadlock.kl1 log.kl1 util.kl1 paraio.kl1 selection.kl1 \
	processor.kl1 projection.kl1 fastio.kl1 join.kl1 \
	create.kl1 drop.kl1 insert.kl1 delete.kl1 rule.kl1 \
	pageio.kl1 access.kl1 gpage.c condition.c


BTSRC   = bt_get.kl1 bt_util.kl1 bt_add.kl1 bt_page.kl1\
	bt_del.kl1 bt_del1.kl1 bt_del2.kl1 bt_del3.kl1

SRC	= catalog.kl1 $(LNSRC) $(BTSRC)

SRVOBJ1	= rdbserv.o algebra.o exec.o trans.o lock.o \
	deadlock.o log.o util.o catalog.o paraio.o selection.o  \
	processor.o projection.o fastio.o join.o \
	create.o drop.o insert.kl1 delete.o rule.o \
	pageio.o access.o file.o gpage.o condition.o
BTOBJ   = bt_get.o bt_util.o bt_add.o bt_page.o \
	bt_del.o bt_del1.o bt_del2.o bt_del3.o

SRVOBJ  = $(SRVOBJ1) $(BTOBJ)

.PHONY:	all ncube pmake install.ncube sun install.sun  all-clean clean

all: setup ncube
ncube: setup rdbserv

rdbserv: $(SRC) gobjdef.h
	$(NKLIC) $(NKLICFLAGS) -o $@ $(SRC)

pmake: $(SRC) gobjdef.h
	$(NKLIC) $(NKLICFLAGS) -P2 -o $(TARGET) $(SRC)

install.ncube: $(TARGET)
	install -c -m 755 $(TARGET) ../bin
#
sun:
install.sun:

#
all-clean: clean
	$(RM) $(TARGET) $(LNSRC) $(BTSRC) core

clean:
	$(RM) $(SRVOBJ) $(BTOBJ) *.[cho] *.ext *.db

#
#
#
setup: link access.kl1 log.kl1 trans.kl1

access.kl1: ../../common/server/access.kl1
	sed -e s@IOMODULE@$(IOMODULE)@ \
		../../common/server/access.kl1 > access.kl1

log.kl1: ../../common/server/log.kl1
	sed -e s@IOMODULE@$(IOMODULE)@  ../../common/server/log.kl1 > log.kl1

trans.kl1: ../../common/server/trans.kl1
	sed -e s@IOMODULE@$(IOMODULE)@ \
		../../common/server/trans.kl1 > trans.kl1
link:
	- ln -s ../../common/server/rdbserv.kl1 .
	- ln -s ../../common/server/algebra.kl1 .
	- ln -s ../../common/server/exec.kl1 .
	- ln -s ../../common/server/lock.kl1 .
	- ln -s ../../common/server/deadlock.kl1 .
	- ln -s ../../common/server/join.kl1 .
	- ln -s ../../common/server/rule.kl1 .
	- ln -s ../../common/server/selection.kl1 .
	- ln -s ../../common/server/projection.kl1 .
	- ln -s ../../common/server/processor.kl1 .
	- ln -s ../../common/server/create.kl1 .
	- ln -s ../../common/server/insert.kl1 .
	- ln -s ../../common/server/delete.kl1 .
	- ln -s ../../common/server/drop.kl1 .
	- ln -s ../../common/server/pageio.kl1 .
	- ln -s ../../common/server/gobjdef.h .
	- ln -s ../../common/server/gpage.c .
	- ln -s ../../common/server/condition.c .
	- ln -s ../../common/server/btree/bt_get.kl1 .
	- ln -s ../../common/server/btree/bt_util.kl1 .
	- ln -s ../../common/server/btree/bt_add.kl1 .
	- ln -s ../../common/server/btree/bt_del.kl1 .
	- ln -s ../../common/server/btree/bt_del1.kl1 .
	- ln -s ../../common/server/btree/bt_del2.kl1 .
	- ln -s ../../common/server/btree/bt_del3.kl1 .
	- ln -s ../../common/server/btree/bt_page.kl1 .
	- ln -s ../../common/util/util.kl1 .
	- ln -s ../../common/coding/fastio.kl1 .
	- ln -s ../socket/paraio.kl1 .
