#-------------------------------------------------------------------------
#
# Makefile
#    Makefile for the plpgsql shared object
#
# IDENTIFICATION
#    $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/Makefile.in,v 1.14 1999/02/07 22:10:47 tgl Exp $
#
#-------------------------------------------------------------------------

NAME= plpgsql
SO_MAJOR_VERSION= 1
SO_MINOR_VERSION= 0

SRCDIR= @top_srcdir@
include $(SRCDIR)/Makefile.global

CFLAGS+= -I$(LIBPQDIR) -I$(SRCDIR)/include

# For fmgr.h
CFLAGS+= -I$(SRCDIR)/backend

LFLAGS+= -i -l

OBJS=	pl_parse.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o

SHLIB_LINK+= -L$(LIBPQDIR) -lpq

# If crypt is a separate library, rather than part of libc, it may need
# to be referenced separately to keep (broken) linkers happy.  (This is
# braindead; users of libpq should not need to know what it depends on.)
SHLIB_LINK+= $(findstring -lcrypt,$(LIBS))

# Shared library stuff, also default 'all' target
include $(SRCDIR)/Makefile.shlib


# In order to use Makefile.shlib, we allow it to build a static library
# libplpgsql.a, which we just ignore, as well as a shared library that
# it will insist on naming $(shlib).  We don't want to call it that when
# installed, however, so we ignore the install-shlib rule and do this
# instead:

install: $(shlib)
ifneq ($(shlib),)
	$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/plpgsql$(DLSUFFIX)
else
	@echo "plpgsql not installed due to lack of shared library support."
endif


pl_handler.o:	pl_handler.c plpgsql.h pl.tab.h

pl_comp.o:	pl_comp.c plpgsql.h pl.tab.h

pl_exec.o:	pl_exec.c plpgsql.h pl.tab.h

pl_funcs.o:	pl_funcs.c plpgsql.h pl.tab.h

pl_parse.o:	pl_gram.c pl_scan.c plpgsql.h
	$(CC) $(CFLAGS) -c -o $@ pl_gram.c

pl_gram.c:	gram.c
	sed -e 's/yy/plpgsql_yy/g' -e 's/YY/PLPGSQL_YY/g' <gram.c >pl_gram.c
	sed -e 's/yy/plpgsql_yy/g' -e 's/YY/PLPGSQL_YY/g' <y.tab.h >pl.tab.h

pl_scan.c:	scan.c
	sed -e 's/yy/plpgsql_yy/g' -e 's/YY/PLPGSQL_YY/g' <scan.c >pl_scan.c

gram.c:		gram.y

scan.c:		scan.l

pl.tab.h:	pl_gram.c


.PHONY: install clean

clean:
	rm -f lib$(NAME).a $(shlib)
	rm -f *.o pl.tab.h pl_gram.c pl_scan.c
ifeq ($(PORTNAME), win)
	rm -f $(NAME).def
endif
