Re: patch for configure for enabling of pl/tcl unknown support - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: patch for configure for enabling of pl/tcl unknown support
Date
Msg-id 200105092034.f49KYSY07501@candle.pha.pa.us
Whole thread Raw
In response to Re: patch for configure for enabling of pl/tcl unknown support  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: patch for configure for enabling of pl/tcl unknown support  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-patches
> Bruce Momjian writes:
>
> > > This patch adds a new configure option --with-pltcl-unknown which
> > > enables pltcl unknown support.
>
> > > After patching files
> > >   src/pl/tcl/modules/pltcl_listmod
> > >   src/pl/tcl/modules/pltcl_loadmod
> > >   src/pl/tcl/modules/pltcl_delmod
> > > must be renamed(copied,repocopied) to
> > >   src/pl/tcl/modules/pltcl_listmod.in
> > >   src/pl/tcl/modules/pltcl_loadmod.in
> > >   src/pl/tcl/modules/pltcl_delmod.in
>
> These files should be build in a makefile.  Creating them with
> config.status is not going to fly.

OK, Peter, I have removed the generation of rht pltcl's from configure,
added TCLSH to Makefile.global.in, and added something to the
pl/tcl/Makefile to generate them from *.in files using sed.

I am attaching the new Makefile.  I was a little confused on the
Makefile dependencies when the actual files are not generated unless
then ask for --enable-pltcl-unknown:

    all: $(INFILES) tcl_unknown

    tcl_unknown: $(top_builddir)/src/Makefile.global \
            modules/pltcl_loadmod.in \
            modules/pltcl_delmod.in \
            modules/pltcl_listmod.in
    ifeq ($(enable_pltcl_unknown), yes)
            sed -e 's,@TCLSH@,$(TCLSH),g' modules/pltcl_loadmod.in > modules/pltcl_$
            sed -e 's,@TCLSH@,$(TCLSH),g' modules/pltcl_delmod.in > modules/pltcl_d$
            sed -e 's,@TCLSH@,$(TCLSH),g' modules/pltcl_listmod.in > modules/pltcl_$
            chmod a+x modules/pltcl_loadmod modules/pltcl_delmod modules/pltcl_list$
    endif

I am not sure about the dependencies.  If I knew I was making them all
the time, I could easily create proper dependencies for the files, but I
only generate them if enabled.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#-------------------------------------------------------------------------
#
# Makefile for the pltcl shared object
#
# $Header: /home/projects/pgsql/cvsroot/pgsql/src/pl/tcl/Makefile,v 1.30 2001/05/09 20:30:09 momjian Exp $
#
#-------------------------------------------------------------------------

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

-include Makefile.tcldefs

# 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


# 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...

ifneq ($(TCL_SHLIB_LD_LIBS),)
# link command for a shared lib must mention shared libs it uses
SHLIB_EXTRA_LIBS=$(TCL_LIBS) -lc
else
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
# link command for a shared lib must NOT mention shared libs it uses
SHLIB_EXTRA_LIBS=
endif
endif

%$(TCL_SHLIB_SUFFIX): %.o
    $(TCL_SHLIB_LD) -o $@ $< $(TCL_LIB_SPEC) $(SHLIB_EXTRA_LIBS)


CC = $(TCL_CC)

# 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.

# Can choose either TCL_CFLAGS_OPTIMIZE or TCL_CFLAGS_DEBUG here, as
# needed
override CPPFLAGS += $(TCL_DEFS)
override CFLAGS = $(TCL_CFLAGS_OPTIMIZE) $(TCL_SHLIB_CFLAGS)


# 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.

ifeq ($(enable_pltcl_unknown), yes)
override CPPFLAGS+= -DPLTCL_UNKNOWN_SUPPORT
endif

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

INFILES= $(DLOBJS)

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


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

ifeq ($(TCL_SHARED_BUILD), 1)

all: $(INFILES) tcl_unknown

tcl_unknown: $(top_builddir)/src/Makefile.global \
    modules/pltcl_loadmod.in \
    modules/pltcl_delmod.in \
    modules/pltcl_listmod.in
ifeq ($(enable_pltcl_unknown), yes)
    sed -e 's,@TCLSH@,$(TCLSH),g' modules/pltcl_loadmod.in > modules/pltcl_loadmod
    sed -e 's,@TCLSH@,$(TCLSH),g' modules/pltcl_delmod.in > modules/pltcl_delmod
    sed -e 's,@TCLSH@,$(TCLSH),g' modules/pltcl_listmod.in > modules/pltcl_listmod
    chmod a+x modules/pltcl_loadmod modules/pltcl_delmod modules/pltcl_listmod
endif

pltcl$(DLSUFFIX): pltcl.o

install: all installdirs
    $(INSTALL_SHLIB) $(DLOBJS) $(DESTDIR)$(libdir)/$(DLOBJS)
ifeq ($(enable_pltcl_unknown), yes)
    $(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

installdirs:
    $(mkinstalldirs) $(DESTDIR)$(libdir)

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

else

all install:
    @echo "*****"; \
     echo "* Cannot build pltcl because Tcl is not a shared library; skipping it."; \
     echo "*****"
endif

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

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

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: patch for configure for enabling of pl/tcl unknown support
Next
From: Bruce Momjian
Date:
Subject: Re: [Fwd: dbf2pg improvements (password, charset convertions, etc.)]