# $Id: makefile,v 1.2 1999/10/17 17:12:30 mayoff release-1_0_1 $
#
# Make sure that all variables are defined
#

DIRNAME = contrib/dqd_db2

ifndef SRCBASE
    SRCBASE = $(shell cd ../..; pwd)
    include ../../makevars
endif

#
# Define the output files
#

LIB = dqd_db2.so

#
# Set the libraries
#

LIBS=-L$(INSTHOME)/sqllib/lib -ldb2 -ltcl
CFLAGS += -I$(INSTHOME)/sqllib/include

#
# Set the objects to build
#

OBJS = db2.o

#
# Let the building begin!
#

all: checklib $(LIB)

%.o: %.c
	$(CC) -c $(CFLAGS) $(SRCBASE)/$(DIRNAME)/$< -o $@

#
# Build the final target(s)
#

$(LIB): $(OBJS)
	$(LDSO) $(LDSOFLAGS) -o $(LIB) $(OBJS) $(LIBS)

checklib: force
	@if [ -z "$(INSTHOME)" ]; then \
	    echo "INSTHOME must be set to DB/2 instance home"; \
	    echo "Note: make you just need to type 'export INSTHOME'"; \
	    false; \
	fi

force:

install: all
	cp $(LIB) $(ROOTDIR)/bin

clean:
	$(RM) $(LIB) $(OBJS) so_locations

