1#!/bin/bash -norc
2dnl	This file is an input file used by the GNU "autoconf" program to
3dnl	generate the file "configure", which is run during Tcl installation
4dnl	to configure the system for the local environment.
5#
6# $Id: configure.in 371 2014-09-12 19:37:00Z lbayuk $
7
8#-----------------------------------------------------------------------
9# configure.in for pgtcl-ng Tcl Extension.
10#-----------------------------------------------------------------------
11
12#-----------------------------------------------------------------------
13# __CHANGE__
14# Set your package name and version numbers here.
15#
16# This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION
17# set as provided.  These will also be added as -D defs in your Makefile
18# so you can encode the package version directly into the source files.
19#-----------------------------------------------------------------------
20
21AC_INIT([pgtcl], [2.1.1])
22
23#--------------------------------------------------------------------
24# Call TEA_INIT as the first TEA_ macro to set up initial vars.
25# This will define a ${TEA_PLATFORM} variable == "unix" or "windows"
26# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
27#--------------------------------------------------------------------
28
29TEA_INIT([3.5])
30
31AC_CONFIG_AUX_DIR(tclconfig)
32
33#--------------------------------------------------------------------
34# Load the tclConfig.sh file
35#--------------------------------------------------------------------
36
37TEA_PATH_TCLCONFIG
38TEA_LOAD_TCLCONFIG
39
40#--------------------------------------------------------------------
41# Load the tkConfig.sh file if necessary (Tk extension)
42#--------------------------------------------------------------------
43
44#TEA_PATH_TKCONFIG
45#TEA_LOAD_TKCONFIG
46
47#-----------------------------------------------------------------------
48# Handle the --prefix=... option by defaulting to what Tcl gave.
49# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER.
50#-----------------------------------------------------------------------
51
52TEA_PREFIX
53
54#-----------------------------------------------------------------------
55# Standard compiler checks.
56# This sets up CC by using the CC env var, or looks for gcc otherwise.
57# This also calls AC_PROG_CC, AC_PROG_INSTALL and a few others to create
58# the basic setup necessary to compile executables.
59#-----------------------------------------------------------------------
60
61TEA_SETUP_COMPILER
62
63#--------------------------------------------------------------------
64# __CHANGE__
65# Specify the C source files to compile in TEA_ADD_SOURCES,
66# public headers that need to be installed in TEA_ADD_HEADERS,
67# stub library C source files to compile in TEA_ADD_STUB_SOURCES,
68# and runtime Tcl library files in TEA_ADD_TCL_SOURCES.
69# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS
70# and PKG_TCL_SOURCES.
71#-----------------------------------------------------------------------
72
73TEA_ADD_SOURCES([pgtcl.c pgtclCmds.c pgtclId.c])
74TEA_ADD_HEADERS([libpgtcl.h])
75TEA_ADD_INCLUDES([])
76TEA_ADD_LIBS([])
77TEA_ADD_CFLAGS([])
78TEA_ADD_STUB_SOURCES([])
79TEA_ADD_TCL_SOURCES([])
80
81#--------------------------------------------------------------------
82# __CHANGE__
83# A few miscellaneous platform-specific items:
84#
85# Define a special symbol for Windows (BUILD_sample in this case) so
86# that we create the export library with the dll.
87#
88# Windows creates a few extra files that need to be cleaned up.
89# You can add more files to clean if your extension creates any extra
90# files.
91#
92# TEA_ADD_* any platform specific compiler/build info here.
93#--------------------------------------------------------------------
94
95if test "${TEA_PLATFORM}" = "windows" ; then
96    AC_DEFINE(BUILD_sample, 1, [Build windows export dll])
97    CLEANFILES="pkgIndex.tcl *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
98    #TEA_ADD_SOURCES([win/winFile.c])
99    #TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"])
100else
101    CLEANFILES="pkgIndex.tcl"
102    #TEA_ADD_SOURCES([unix/unixFile.c])
103    #TEA_ADD_LIBS([-lsuperfly])
104fi
105AC_SUBST(CLEANFILES)
106
107#--------------------------------------------------------------------
108# __CHANGE__
109# Choose which headers you need.  Extension authors should try very
110# hard to only rely on the Tcl public header files.  Internal headers
111# contain private data structures and are subject to change without
112# notice.
113# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG
114#--------------------------------------------------------------------
115
116TEA_PUBLIC_TCL_HEADERS
117#TEA_PRIVATE_TCL_HEADERS
118
119#TEA_PUBLIC_TK_HEADERS
120#TEA_PRIVATE_TK_HEADERS
121#TEA_PATH_X
122
123#--------------------------------------------------------------------
124# Check whether --enable-threads or --disable-threads was given.
125# This auto-enables if Tcl was compiled threaded.
126#--------------------------------------------------------------------
127
128#TEA_ENABLE_THREADS
129
130#--------------------------------------------------------------------
131# The statement below defines a collection of symbols related to
132# building as a shared library instead of a static library.
133#--------------------------------------------------------------------
134
135TEA_ENABLE_SHARED
136
137#--------------------------------------------------------------------
138# This macro figures out what flags to use with the compiler/linker
139# when building shared/static debug/optimized objects.  This information
140# can be taken from the tclConfig.sh file, but this figures it all out.
141#--------------------------------------------------------------------
142
143TEA_CONFIG_CFLAGS
144
145#--------------------------------------------------------------------
146# Set the default compiler switches based on the --enable-symbols option.
147#--------------------------------------------------------------------
148
149TEA_ENABLE_SYMBOLS
150
151#--------------------------------------------------------------------
152# Everyone should be linking against the Tcl stub library.  If you
153# can't for some reason, remove this definition.  If you aren't using
154# stubs, you also need to modify the SHLIB_LD_LIBS setting below to
155# link against the non-stubbed Tcl library.  Add Tk too if necessary.
156#--------------------------------------------------------------------
157
158AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs])
159#AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs])
160
161#--------------------------------------------------------------------
162# Get the path to the PostgreSQL installation.
163#--------------------------------------------------------------------
164
165LIBPG=""
166AC_ARG_WITH(postgres-include,[  --with-postgres-include=DIR   PostgreSQL includes are in DIR],
167	PG_INC_DIR=$withval, PG_INC_DIR="")
168AC_ARG_WITH(postgres-lib,[  --with-postgres-lib=DIR       PostgreSQL libraries are in DIR],
169	PG_LIB_DIR=$withval, PG_LIB_DIR="")
170
171# Use pg_config (if found) to supply missing paths, if needed.
172if test "$PG_INC_DIR" = "" -o "$PG_LIB_DIR" = ""; then
173  AC_PATH_PROG(PG_CONFIG,pg_config)
174  if test "$PG_CONFIG" = ""; then
175    AC_MSG_ERROR([cannot find pg_config program on PATH. Without pg_config,
176you must specify both --with-postgres-include and --with-postgres-lib])
177  fi
178  if test "$PG_INC_DIR" = ""; then
179    PG_INC_DIR=`$PG_CONFIG --includedir`
180    AC_MSG_NOTICE([pg_config says includedir is $PG_INC_DIR])
181  fi
182  if test "$PG_LIB_DIR" = ""; then
183    PG_LIB_DIR=`$PG_CONFIG --libdir`
184    AC_MSG_NOTICE([pg_config says libdir is $PG_LIB_DIR])
185  fi
186fi
187
188PG_INCLUDES="-I$PG_INC_DIR"
189PG_LIBS="-L$PG_LIB_DIR -lpq"
190if test ! "$PG_LIB_DIR" = ""; then
191  LIBPG="libpq${SHLIB_SUFFIX}"
192fi
193
194AC_SUBST(LIBPG)
195AC_SUBST(PG_INCLUDES)
196AC_SUBST(PG_LIBS)
197AC_SUBST(PG_LIB_DIR)
198
199#--------------------------------------------------------------------
200# Function availability tests for the PostgreSQL library:
201#--------------------------------------------------------------------
202save_LIBS="$LIBS"
203LIBS="$PG_LIBS $LIBS"
204AC_CHECK_FUNCS(lo_truncate PQencryptPassword)
205AC_CHECK_FUNCS(PQescapeStringConn PQescapeByteaConn)
206# Note this test which defines HAVE_PQDESCRIBEPREPARED is used for
207# PQdescribePrepared, PQdescribePortal, PQnparams, and PQparamtype -
208# all of which were added in the same PostgreSQL release 8.2.
209AC_CHECK_FUNCS(PQdescribePrepared)
210# This test which defines HAVE_LO_TELL64 also covers lo_seek64 and
211# lo_truncate64, all of which are added in PostgreSQL 9.3.
212AC_CHECK_FUNCS(lo_tell64)
213# This test which defines HAVE_PQESCAPELITERAL covers both
214# PQescapeliteral and PQescapeIdentifier, both added in PostgreSQL 9.0.
215AC_CHECK_FUNCS(PQescapeLiteral)
216LIBS="$save_LIBS"
217
218#--------------------------------------------------------------------
219# This macro generates a line to use when building a library.  It
220# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS,
221# and TEA_LOAD_TCLCONFIG macros above.
222#--------------------------------------------------------------------
223
224TEA_MAKE_LIB
225
226#--------------------------------------------------------------------
227# Determine the name of the tclsh and/or wish executables in the
228# Tcl and Tk build directories or the location they were installed
229# into. These paths are used to support running test cases only,
230# the Makefile should not be making use of these paths to generate
231# a pkgIndex.tcl file or anything else at extension build time.
232#--------------------------------------------------------------------
233
234TEA_PROG_TCLSH
235#TEA_PROG_WISH
236
237#--------------------------------------------------------------------
238# Finally, substitute all of the various values into the Makefile.
239# You may alternatively have a special pkgIndex.tcl.in or other files
240# which require substituting th AC variables in.  Include these here.
241#--------------------------------------------------------------------
242
243# Don't know why this is needed.
244AC_SUBST(LD_SEARCH_FLAGS)
245
246AC_CONFIG_FILES([Makefile pkgIndex.tcl])
247AC_OUTPUT
248