• Peter Eisentraut's avatar
    Implement a few changes to how shared libraries and dynamically loadable · 46e76373
    Peter Eisentraut authored
    modules are built.  Foremost, it creates a solid distinction between these two
    types of targets based on what had already been implemented and duplicated in
    ad hoc ways before.  Specifically,
    
    - Dynamically loadable modules no longer get a soname.  The numbers previously
    set in the makefiles were dummy numbers anyway, and the presence of a soname
    upset a few packaging tools, so it is nicer not to have one.
    
    - The cumbersome detour taken on installation (build a libfoo.so.0.0.0 and
    then override the rule to install foo.so instead) is removed.
    
    - Lots of duplicated code simplified.
    46e76373
Makefile 2.58 KB
#-------------------------------------------------------------------------
#
# Makefile for the pltcl shared object
#
# $PostgreSQL: pgsql/src/pl/tcl/Makefile,v 1.51 2008/04/07 14:15:58 petere Exp $
#
#-------------------------------------------------------------------------

subdir = src/pl/tcl
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global


override CPPFLAGS := $(TCL_INCLUDE_SPEC) $(CPPFLAGS)


# Find out whether Tcl was built as a shared library --- if not, we
# can't link a shared library that depends on it, and have to forget
# about building pltcl. In Tcl 8, tclConfig.sh sets TCL_SHARED_BUILD
# for us, but in older Tcl releases it doesn't. In that case we guess
# based on the name of the Tcl library.

ifndef TCL_SHARED_BUILD
ifneq (,$(findstring $(DLSUFFIX),$(TCL_LIB_FILE)))
TCL_SHARED_BUILD=1
else
TCL_SHARED_BUILD=0
endif
endif


SHLIB_LINK = $(TCL_LIB_SPEC)
ifneq ($(PORTNAME), win32)
SHLIB_LINK += $(TCL_LIBS) -lc
endif

NAME = pltcl
OBJS = pltcl.o

REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=pltcl
REGRESS = pltcl_setup pltcl_queries
# where to find psql for running the tests
PSQLDIR = $(bindir)

include $(top_srcdir)/src/Makefile.shlib

ifeq ($(TCL_SHARED_BUILD), 1)

all: all-lib
	$(MAKE) -C modules $@

# When doing a VPATH build, copy over the .sql and .out files so that the
# test script can find them.  See comments in src/test/regress/GNUmakefile.
ifdef VPATH

ifneq ($(PORTNAME),win32)
abs_srcdir := $(shell cd $(srcdir) && pwd)
abs_builddir := $(shell pwd)
else
abs_srcdir := $(shell cd $(srcdir) && pwd -W)
abs_builddir := $(shell pwd -W)
endif

test_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out)
test_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(test_files_src))

all: $(test_files_build)
$(test_files_build): $(abs_builddir)/%: $(srcdir)/%
	ln -s $< $@

endif

install: all installdirs install-lib
	$(MAKE) -C modules $@

installdirs: installdirs-lib
	$(MAKE) -C modules $@

uninstall: uninstall-lib
	$(MAKE) -C modules $@

installcheck: submake
	$(top_builddir)/src/test/regress/pg_regress --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)

.PHONY: submake
submake:
	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)

else # TCL_SHARED_BUILD = 0

# Provide dummy targets for the case where we can't build the shared library.
all:
	@echo "*****"; \
	 echo "* Cannot build PL/Tcl because Tcl is not a shared library; skipping it."; \
	 echo "*****"

endif # TCL_SHARED_BUILD = 0

clean distclean maintainer-clean: clean-lib
	rm -f $(OBJS)
	rm -rf results
	rm -f regression.diffs regression.out
	$(MAKE) -C modules $@