Makefile 4.1 KB
Newer Older
1 2
#-------------------------------------------------------------------------
#
3
# Makefile for the pltcl shared object
4
#
5
# $Header: /cvsroot/pgsql/src/pl/tcl/Makefile,v 1.32 2001/05/09 21:42:29 momjian Exp $
6 7 8
#
#-------------------------------------------------------------------------

9 10
subdir = src/pl/tcl
top_builddir = ../../..
11
include $(top_builddir)/src/Makefile.global
12

13
-include Makefile.tcldefs
14

15 16 17 18 19 20
# 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.

21 22 23 24 25 26 27 28 29
ifndef TCL_SHARED_BUILD
ifneq (,$(findstring $(DLSUFFIX),$(TCL_LIB_FILE)))
TCL_SHARED_BUILD=1
else
TCL_SHARED_BUILD=0
endif
endif


30 31 32 33 34 35 36
# Change following to how shared library that contains references to
# libtcl must get built on your system. Since these definitions come
# from the tclConfig.sh script, they should work if the shared build
# of tcl was successful on this system. However, tclConfig.sh lies to
# us a little bit (at least in versions 7.6 through 8.0.4) --- it
# doesn't mention -lc in TCL_LIBS, but you still need it on systems
# that want to hear about dependent libraries...
37 38 39 40 41

ifneq ($(TCL_SHLIB_LD_LIBS),)
# link command for a shared lib must mention shared libs it uses
SHLIB_EXTRA_LIBS=$(TCL_LIBS) -lc
else
42 43 44 45 46
ifeq ($(PORTNAME), hpux)
# link command for a shared lib must mention shared libs it uses,
# even though Tcl doesn't think so...
SHLIB_EXTRA_LIBS=$(TCL_LIBS) -lc
else
47 48 49
# link command for a shared lib must NOT mention shared libs it uses
SHLIB_EXTRA_LIBS=
endif
50
endif
51

52
%$(TCL_SHLIB_SUFFIX): %.o
53
	$(TCL_SHLIB_LD) -o $@ $< $(TCL_LIB_SPEC) $(SHLIB_EXTRA_LIBS)
54 55


56 57
CC = $(TCL_CC)

58 59 60 61
# Since we are using Tcl's choice of C compiler, which might not be
# the same one selected for Postgres, do NOT use CFLAGS from
# Makefile.global. Instead use TCL's CFLAGS plus necessary -I
# directives.
62

63 64
# Can choose either TCL_CFLAGS_OPTIMIZE or TCL_CFLAGS_DEBUG here, as
# needed
65 66
override CPPFLAGS += $(TCL_DEFS)
override CFLAGS = $(TCL_CFLAGS_OPTIMIZE) $(TCL_SHLIB_CFLAGS)
67 68 69 70 71 72


# Uncomment the following to enable the unknown command lookup on the
# first of all calls to the call handler. See the doc in the modules
# directory about details.

73
ifeq ($(enable_pltcl_unknown), yes)
74
override CPPFLAGS+= -DPLTCL_UNKNOWN_SUPPORT
75 76 77
TCL_UNKNOWN_MODS=	modules/pltcl_loadmod \
			modules/pltcl_delmod \
			modules/pltcl_listmod
78
endif
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

#
# DLOBJS is the dynamically-loaded object file.
#
DLOBJS= pltcl$(DLSUFFIX)

INFILES= $(DLOBJS) 

#
# plus exports files
#
ifdef EXPSUFF
INFILES+= $(DLOBJS:.o=$(EXPSUFF))
endif

94

95 96 97
# Provide dummy targets for the case where we can't build the shared library.

ifeq ($(TCL_SHARED_BUILD), 1)
98

99
all: $(INFILES) $(TCL_UNKNOWN_MODS)
100

101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
modules/pltcl_loadmod: modules/pltcl_loadmod.in \
	$(top_builddir)/src/Makefile.global
	sed -e 's,@TCLSH@,$(TCLSH),g' \
	  $< >$@
	chmod a+x $@

modules/pltcl_delmod: modules/pltcl_delmod.in \
	$(top_builddir)/src/Makefile.global
	sed -e 's,@TCLSH@,$(TCLSH),g' \
	  $< >$@
	chmod a+x $@

modules/pltcl_listmod: modules/pltcl_listmod.in \
	$(top_builddir)/src/Makefile.global
	sed -e 's,@TCLSH@,$(TCLSH),g' \
	  $< >$@
	chmod a+x $@

119 120
pltcl$(DLSUFFIX): pltcl.o

121
install: all installdirs
122
	$(INSTALL_SHLIB) $(DLOBJS) $(DESTDIR)$(libdir)/$(DLOBJS)
123
ifeq ($(enable_pltcl_unknown), yes)
124 125 126 127 128 129 130 131 132
	$(INSTALL_SCRIPT) modules/pltcl_loadmod \
		$(DESTDIR)$(bindir)/pltcl_loadmod
	$(INSTALL_SCRIPT) modules/pltcl_delmod \
		$(DESTDIR)$(bindir)/pltcl_delmod
	$(INSTALL_SCRIPT) modules/pltcl_listmod \
		$(DESTDIR)$(bindir)/pltcl_listmod
	$(INSTALL_DATA) modules/unknown.pltcl \
		$(DESTDIR)$(datadir)/unknown.pltcl
endif
133

134
installdirs:
135
	$(mkinstalldirs) $(DESTDIR)$(libdir)
136

137
uninstall:
138
	rm -f $(DESTDIR)$(libdir)/$(DLOBJS)
139

140
else
141

142 143 144 145
all install:
	@echo "*****"; \
	 echo "* Cannot build pltcl because Tcl is not a shared library; skipping it."; \
	 echo "*****"
146 147 148
endif

Makefile.tcldefs: mkMakefile.tcldefs.sh
149
	$(SHELL) $< '$(TCL_CONFIG_SH)' '$@'
150

151
clean distclean maintainer-clean:
152
	rm -f $(INFILES) pltcl.o Makefile.tcldefs modules/pltcl_listmod modules/pltcl_loadmod modules/pltcl_delmod