Thread: Re: Just some unfinished stuff.

Re: Just some unfinished stuff.

From
Gerald Gryschuk
Date:
Thomas G. Lockhart wrote:
>
> The configure/makefile builds the sources just fine. But "make install"
> fails when I try installing within the Postgres tree as the postgres su:
>
> golem$ make install
> /usr/bin/install -c -m 444 iodbc.h /usr/local/include/iodbc/iodbc.h
> /usr/bin/install: /usr/local/include/iodbc/iodbc.h: Permission denied
> make: *** [install-headers] Error 1
>
> Shouldn't this be going to somewhere in the Postgres tree? Or not done
> at all if the target isn't writable?

Me again. I just took a quick look at the Makefile set up and I'm at
a loss to see why this happened. So.. can you elaborate on what you
did and if your using my second set of configuration changes or
the first?

Is this an integrated make? Did you do the 'make install' from the
top level of the Postgres distribution? Did you run configure from
the top level? You get the idea. Oh and check the Makefle.global
in the odbc driver directory, the variable PSQLODBC should be
the location of your installed Postgres installation. To be on
the safe side please send me one line from your GNUmakefile.
Specifically, the install-headers target should have 3 lines for
actions to perform, they should all read similarly like follows,
    $(INSTALL) $(INSTLOPTS) iodbc.h $(HEADERDIR)/iodbc/iodbc.h

HEADERDIR gets set in the Makefile.global to $(PSQLODBC)/include and
PSQLODBC should have been set to the "detected" Postgres installation
directory.

Thanks
--
Gerald Gryschuk
gerald.gryschuk@home.com
MidNightOil Consulting - "We burn the midnight oil so you don't have
to."

Re: Just some unfinished stuff.

From
"Thomas G. Lockhart"
Date:
> Me again. I just took a quick look at the Makefile set up and I'm at
> a loss to see why this happened. So.. can you elaborate on what you
> did and if your using my second set of configuration changes or
> the first?

OK, I've gotten your e-mails, and so now I understand where we are
starting from (maybe :). v6.3 had some brain-damage on the automatic
platform detection (or didn't try at all). Let me send you my patched
version of configure.in so you are starting with something closer to the
v6.4 behavior.

I'm also going to assume that I've got the most recent versions of
things, and will integrate and test changes here, then commit to the
Postgres source tree when we've worked through the configure stuff. Will
send the complete set to Byron for vetting at the same time, and we can
commit patches as he likes.

Uh, so here it is the configure.in...

                         - Tomdnl Process this file with autoconf to produce a configure script.
AC_INIT(bind.c)
AC_PREFIX_DEFAULT(/usr/local)

if test -d ../../interfaces
then
    if test "$prefix" = "NONE"
    then
        ODBCINSTDIR=$ac_default_prefix/pgsql
    else
        ODBCINSTDIR=$prefix
    fi
else
    if test "$prefix" = "NONE"
    then
        ODBCINSTDIR=$ac_default_prefix/share
    else
        ODBCINSTDIR=$prefix
    fi
fi

AC_CANONICAL_HOST

case "$host_os" in
 solaris*)
        case "$host_cpu" in
          sparc) os=sparc_solaris ;;
           i386) os=i386_solaris ;;
        esac ;;
   sunos*) os=sunos4 ;;
     aux*) os=aux ;;
   linux*) os=linux ;;
    bsdi*) os=bsdi ;;
 freebsd*|netbsd*|openbsd*) os=bsd ;;
    dgux*) os=dgux ;;
     aix*) os=aix ;;
nextstep*) os=nextstep ;;
  ultrix*) os=ultrix4 ;;
    irix*) os=irix5  ;;
    hpux*) os=hpux ;;
     osf*) os=alpha ;;
     sco*) os=sco ;;
 machten*) os=machten ;;
  cygwin*) os=win ;;
 sysv4.2*)
       case "$host_vendor" in
               univel) os=univel ;;
                    *) os=unknown ;;
       esac ;;
   sysv4*) os=svr4 ;;
*) echo ""
   echo "*************************************************************"
   echo "configure does not currently recognize your operating system,"
   echo "therefore you must do a manual configuration of:"
   echo "$host_os"
   echo "Please contact scrappy@hub.org to see about rectifying this, "
   echo "including the above 'checking host system type...' line "
   echo "*************************************************************"
   echo ""
   exit;;
esac


PORTNAME=${os}

AC_SUBST(PORTNAME)

echo "checking echo setting..."
if echo '\c' | grep -s c >/dev/null 2>&1
then
    ECHO_N="echo -n"
    ECHO_C=""
else
    ECHO_N="echo"
    ECHO_C='\c'
fi

cat <<EOT
**************************************************************
    Postodbc v0.0250 Installation Program

Welcome to the new improved Postodbc installation program.
This configuration program is for version 0.0250 of the
Postodbc software.

EOT

dnl this part selects the template from the one in the
dnl template directory.

dnl if test "X$with_template" != "X"
dnl then
dnl     TEMPLATE=template/$with_template
dnl else
dnl     TEMPLATE=DO_NOT_CHANGE_THIS_INVALID_FILENAME
dnl fi

AC_MSG_CHECKING(setting template to)
AC_ARG_WITH(template,
    [  --with-template=TEMPLATE
                            use operating system template file
                                see template directory],
    [  TEMPLATE=$withval ],
    [  host_no_ver=`echo "$host" | sed 's/[[0-9.]]*$//'`
        GUESS=`grep "$host_no_ver" template/.similar | sed 's/.*=//' | tail -1`
        if test "$GUESS"
        then   TEMPLATE="$GUESS"
        else   TEMPLATE=`uname -s | tr A-Z a-z`
        fi
    ])
AC_MSG_RESULT($TEMPLATE)

if test ! -f "template/$TEMPLATE"
then
    cat <<EOT
Please select a template from the ones listed below.  If no
template is available, then select the 'generic' one and
consider emailling scrappy@hub.org with the above line which
starts 'checking host system type...'
**************************************************************
EOT
    TEMPLATE=generic
    GUESS=`grep "^$host_no_ver=" template/.similar 2>/dev/null`
    if test ! "$GUESS"
    then    host_no_ver=`echo "$host" | sed 's/[[0-9.]]*$//'`
        GUESS=`grep "$host_no_ver" template/.similar 2>/dev/null`
    fi
    if test "$GUESS"
    then
        TEMPLATE=`echo $GUESS | sed 's/.*=//'`
    fi
    export TEMPLATE
    ls template
    echo "**************************************************************"
    $ECHO_N "Appropriate template file { $TEMPLATE }: $ECHO_C"
    read a
    if test "$a." != "."
    then
        TEMPLATE=$a
    fi
    if test ! -f template/$TEMPLATE
    then
        echo "You must choose an appropriate template file."
        exit
    fi
fi
TEMPLATE=template/$TEMPLATE
export TEMPLATE
echo ""

AROPT=`grep '^AROPT:' $TEMPLATE | awk -F: '{print $2}'`
SHARED_LIB=`grep '^SHARED_LIB:' $TEMPLATE | awk -F: '{print $2}'`
CFLAGS=`grep '^CFLAGS:' $TEMPLATE | awk -F: '{print $2}'`
SRCH_INC=`grep '^SRCH_INC:' $TEMPLATE | awk -F: '{print $2}'`
SRCH_LIB=`grep '^SRCH_LIB:' $TEMPLATE | awk -F: '{print $2}'`
DLSUFFIX=`grep '^DLSUFFIX:' $TEMPLATE | awk -F: '{print $2}'`
DL_LIB=`grep '^DL_LIB:' $TEMPLATE | awk -F: '{print $2}'`
CC=`grep '^CC:' $TEMPLATE | awk -F: '{print $2}'`
LIBS=`grep '^LIBS:' $TEMPLATE | awk -F: '{print $2}'`


a=$SRCH_INC
CPPFLAGS=`echo "$a" | sed 's@  *@ @g; s@^\([[^ ]]\)@-I\1@; s@ \([[^ ]]\)@ -I\1@g'`

export CPPFLAGS
echo "- setting CPPFLAGS=$CPPFLAGS"

a=$SRCH_LIB
LDFLAGS=`echo "$a" | sed 's@  *@ @g; s@^\([[^ ]]\)@-L\1@; s@ \([[^ ]]\)@ -L\1@g'`

export LDFLAGS
echo "- setting LDFLAGS=$LDFLAGS"

dnl Allow for overriding the default location of the odbcinst.ini
dnl file which is normally ${prefix}/share or ${prefix} if this is
dnl being compiled inside the postgres distribution.
AC_MSG_CHECKING(setting ODBCINST)
AC_ARG_WITH(
   odbcinst,
   [   --with-odbcinst=<datadir> change default directory for odbcinst.ini],
   AC_DEFINE_UNQUOTED(ODBCINST, ${with_odbcinst}) AC_MSG_RESULT($with_odbcinst),
   AC_DEFINE_UNQUOTED(ODBCINST, ${ODBCINSTDIR}) AC_MSG_RESULT(${ODBCINSTDIR})
)

if test "X$with_odbcinst" != "X"
then
    ODBCINSTDIR=$with_odbcinst
fi

AC_SUBST(ODBCINSTDIR)

if test "X$with_compiler" != "X"
then
        CC=$with_compiler
else
        AC_PROG_CC
fi

AC_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CPP

AC_SUBST(PORTNAME)
AC_SUBST(LDFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(AROPT)
AC_SUBST(SHARED_LIB)
AC_SUBST(CFLAGS)
AC_SUBST(DLSUFFIX)
AC_SUBST(DL_LIB)

INSTALLPATH="/usr/ucb:$PATH"
AC_PATH_PROGS(INSTALL, ginstall installbsd bsdinst scoinst install, NONE, $INSTALLPATH)
if test $INSTALL = "NONE"
then
   echo "- No Install Script found - aborting."
   exit 0;
fi

INSTLOPTS="-m 444"
INSTL_EXE_OPTS="-m 555"
INSTL_LIB_OPTS="-m 644"

case "`basename $INSTALL`" in
 install|installbsd|scoinst)
    INSTLOPTS="-c $INSTLOPTS"
    INSTL_EXE_OPTS="-c $INSTL_EXE_OPTS"
    INSTL_LIB_OPTS="-c $INSTL_LIB_OPTS";;
esac

echo "- Using $INSTALL"
AC_SUBST(INSTALL)
AC_SUBST(INSTLOPTS)
AC_SUBST(INSTL_LIB_OPTS)
AC_SUBST(INSTL_EXE_OPTS)

dnl Check the option to echo to inhibit newlines.
ECHO_N_OUT=`echo -n "" | wc -c`
ECHO_C_OUT=`echo "\c" | wc -c`
if test "$ECHO_N_OUT" -eq 0; then
  DASH_N='-n'
  BACKSLASH_C=
else
  if test "ECHO_C_OUT" -eq 0; then
    DASH_N=
    BACKSLASH_C='\\\\c'
  else
    AC_MSG_ERROR("echo behaviour undetermined")
  fi
fi
AC_SUBST(DASH_N)
AC_SUBST(BACKSLASH_C)

AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PATH_PROG(find, find)
AC_PATH_PROG(tar, tar)
AC_PATH_PROG(split,split)

AC_CHECK_LIB(c,        main)
AC_CHECK_LIB(m,        main)
AC_CHECK_LIB(dl,       main)

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/param.h pwd.h)

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Check for any "odd" conditions

dnl Checks for library functions.
AC_CHECK_FUNCS(stricmp)

dnl Check for X libraries

dnl Check for X library

AC_OUTPUT(GNUmakefile Makefile.global)

Re: [INTERFACES] Re: Just some unfinished stuff.

From
Gerald Gryschuk
Date:
Thomas G. Lockhart wrote:
 > OK, I've gotten your e-mails, and so now I understand where we are
> starting from (maybe :). v6.3 had some brain-damage on the automatic
> platform detection (or didn't try at all). Let me send you my patched
> version of configure.in so you are starting with something closer to the
> v6.4 behavior.
>
> I'm also going to assume that I've got the most recent versions of
> things, and will integrate and test changes here, then commit to the
> Postgres source tree when we've worked through the configure stuff. Will
> send the complete set to Byron for vetting at the same time, and we can
> commit patches as he likes.
>
> Uh, so here it is the configure.in...
>
>                          - Tom

I tried this new configure.in and it works the way I expected. The
PSQLODBC setting in Makefile.global
gets set to /usr/local/pgsql. I didn't try to make install but I see no
reason this shouldn't
work by putting the files where I expect them(i.e. headers should go to
/usr/local/pgsql/include/iodbc).

The above worked whether I configure'd from the psqlodbc directory
embedded in the 6.3 distribution or from the top level
Postgres 'src' directory. So... are you still having
problems with the 'make install' trying to use '/usr/local' when
your building within the Postgres distribution? If you are, there
is one possible explanation, although I don't see why this
would happen. The psqlodbc configure script checks that the
variable 'prefix' is set to 'NONE' if it's anything else
it will use that prefix. Maybe somehow the 'prefix' variable
is being set to '/usr/local'? The version of configure I'm using
was generated by autoconf 2.12. Maybe a different version of
autoconf causes this prefix variable to be set to something
other than 'NONE' on entry to the configure script. Note that
I was working from the observed behaviour that 'prefix' was
only set to something other than 'NONE' if the user specifically
supplied the '--prefix=' on the './configure' command line.

You should be able to check this by putting an
    'echo $prefix'

at the top of your configure.in and see what it spits out.

By the way, something's up with the html docs you sent. Netscape
version 4.05 refuses to display them. What's the magic command
to regenerate them from the sgml source?

--
Gerald Gryschuk
gerald.gryschuk@home.com
MidNightOil Consulting - "We burn the midnight oil so you don't have
to."

Re: [INTERFACES] Re: Just some unfinished stuff.

From
"Thomas G. Lockhart"
Date:
> I tried this new configure.in and it works the way I expected. The
> PSQLODBC setting in Makefile.global gets set to /usr/local/pgsql. I
> didn't try to make install but I see no reason this shouldn't
> work by putting the files where I expect them(i.e. headers should go
> to /usr/local/pgsql/include/iodbc).

I'll try again and let you know...

> By the way, something's up with the html docs you sent. Netscape
> version 4.05 refuses to display them. What's the magic command
> to regenerate them from the sgml source?

No way. They must have gotten munged in the mailing since I'm using the
same browser and it works fine. In fact my reader displayed them in the
mail message itself, and allowed me to save them to a file.

The "magic command" involves reading the v6.3 (or newer) guide to the
docs which has a couple of procedures for installing jade, style sheets,
and support code. It isn't always trivial, though the rpm packaging if
you're running on Linux makes it pretty easy.

I'll send a tar file for you if you still need to see the current
results.

                   - Tom

Re: [INTERFACES] Re: Just some unfinished stuff.

From
"Thomas G. Lockhart"
Date:
> > OK, I've gotten your e-mails, and so now I understand where we are
> > starting from (maybe :). v6.3 had some brain-damage on the automatic
> > platform detection (or didn't try at all).
> I tried this new configure.in and it works the way I expected.

OK, I went back and re-read your e-mails. I'd missed the details of the
one which described the changes I should put in to the main configure.in
and Makefile.global.in files. So I put those in, and...

Things seem to configure nicely, except that it is still trying to put
the odbc.h file into /usr/local/include rather than my actual Postgres
directory area /opt/postgres/current/include.

I'm not familiar with autoconf, so if you have any ideas let me know.
The alternative is for us to commit this to the cvs tree and let others
have a chance to look at it and make the corrections.

I hate sitting on these patches for any longer. Let me know if you think
I _shouldn't_ commit them to cvs as an "almost ready to go" set of code.
I'll go through and change WINDOWS to WIN32 beforehand.

Comments?

                 - Tom

Re: [INTERFACES] Re: Just some unfinished stuff.

From
"Thomas G. Lockhart"
Date:
> Things seem to configure nicely, except that it is still trying to put
> the odbc.h file into /usr/local/include rather than my actual Postgres
> directory area /opt/postgres/current/include.

Alright, I think I'm on the right track...

I've put a conditional include into the postodbc GNUmakefile.in to load
the Postgres Makefile.global if available. I've added a couple of
environment variables to that makefile to point to the right
installation locations, so if the odbc code is in the Postgres main tree
those locations determined locally are overridden by the main
installation parameters.

btw, you asked me to let you know if the interfaces/ area for psqlodbc
is _not_ named "psqlodbc". It isn't; it's always (afaik) been named
interfaces/odbc.

OK, so I've made some substantial changes to the source code and build
environment, and it now doesn't barf when the installation account is
not root, and it seems to do the right thing overall. I'll make the
WINDOWS->WIN32 changes, remove a few unused variables which gcc
complains about, and send you both a big tarball.

I'll commit the tarball to the Postgres distribution soon after that
unless I hear objections.

Talk to you soon...

                      - Tom

Re: [INTERFACES] Re: Just some unfinished stuff.

From
Gerald Gryschuk
Date:
Doh! I hate it when I do that, here the same message, this time replied
to All.

Thomas G. Lockhart wrote:
> OK, I went back and re-read your e-mails. I'd missed the details of the
> one which described the changes I should put in to the main configure.in
> and Makefile.global.in files. So I put those in, and...
>
> Things seem to configure nicely, except that it is still trying to put
> the odbc.h file into /usr/local/include rather than my actual Postgres
> directory area /opt/postgres/current/include.

Did you try putting 'echo $prefix' at the beginning of the odbc
configure.in
and rerunning autoconf on it? As I said previously this should spit out
the
prefix that is set before the rest of the odbc configure is run.
Other than the prefix being set prematurely
I can't think of any reason for this to fail. On the other hand given
that
your postgres directory is other than /usr/local/pgsql you must be
supplying
a --prefix on the Postgres configure command line right? If not please
explain how your getting your distribution into that directory.

Beyond this the only other thing is to check the odbc
Makefile.global.in.
Find the line that sets PSQLODBC and make sure it looks like this,
        PSQLODBC=@prefix@

I don't recall sending out a Makefile.global.in that didn't have this
but maybe I made I did.

>
> I'm not familiar with autoconf, so if you have any ideas let me know.
> The alternative is for us to commit this to the cvs tree and let others
> have a chance to look at it and make the corrections.

The only other thing I can think of is rather "drastic". Rather than
sending me all of v6.4 so I can try it myself just send me the 6.4
configure.in,Makefile.global.in and GNUmakefile.in so I can have
a look at them.

>
> I hate sitting on these patches for any longer. Let me know if you think
> I _shouldn't_ commit them to cvs as an "almost ready to go" set of code.
> I'll go through and change WINDOWS to WIN32 beforehand.

Well you can if you want to but I really would like to get this fixed
first, but you have a dead line so do what you think is best.



--
Gerald Gryschuk(ggryschuk@scf.sk.ca)
Programmer Analyst
Saskatoon Cancer Centre
((306)655-2746)

Re: [INTERFACES] Re: Just some unfinished stuff.

From
"Thomas G. Lockhart"
Date:
> Did you try putting 'echo $prefix' at the beginning of the odbc
> configure.in and rerunning autoconf on it? As I said previously this
> should spit out the prefix that is set before the rest of the odbc
> configure is run.
> Other than the prefix being set prematurely
> I can't think of any reason for this to fail. On the other hand given
> that your postgres directory is other than /usr/local/pgsql you must
> be supplying a --prefix on the Postgres configure command line right?
> If not please explain how your getting your distribution into that
> directory.

Ah! That's the source of our confusion! I install into
  /opt/postgres/current
rather than into /usr/local, but do so by setting the PGROOT environment
variable. I never have to specify any configure command-line options
when I build. Which is a good thing since I sometimes build several
times in a session as I'm developing backend code...

Now that I think about it, I also set PGLIB, so should make sure that
the odbc installation uses that rather than POSTGRESDIR/lib.

> Beyond this the only other thing is to check the odbc
> Makefile.global.in.
> Find the line that sets PSQLODBC and make sure it looks like this,
>         PSQLODBC=@prefix@
> I don't recall sending out a Makefile.global.in that didn't have this
> but maybe I made I did.

It does look like this, but the top of configure.in has the line

  AC_PREFIX_DEFAULT(/usr/local)

which pretty much sets everything which follows, and which is an
unconditional assignment. So without command-line switches, that's where
things went before my changes.

> The only other thing I can think of is rather "drastic". Rather than
> sending me all of v6.4 so I can try it myself just send me the 6.4
> configure.in,Makefile.global.in and GNUmakefile.in so I can have
> a look at them.

I will send you the 6.4 configure.in, Makefile.global.in, _and_ my
current interfaces/odbc directory. We need to make sure we are working
from the same set of complete sources so we don't drop any work.

The only thing which still annoys me is having to carry the template
directory inside interfaces/odbc. But I agree that it would be best to
have the Postgres tree carrying the full psqlodbc sources so that
someone can pick up just that part and carry it do a different client.
I've thought about having a "make standalone" which creates a tarball
with the template files included, but let's keep it simple (as-is) for
this release.

                   - Tom

Re: [INTERFACES] Re: Just some unfinished stuff.

From
"Thomas G. Lockhart"
Date:
> Ah! That's the source of our confusion! I install into
>   /opt/postgres/current
> rather than into /usr/local, but do so by setting the PGROOT
> environment variable.

Well, almost right. I actually have a Makefile.custom in src/ which
looks like:

# Makefile.custom
# Thomas Lockhart 1998-03-01

POSTGRESDIR= /opt/postgres/current
CFLAGS+= -m486 # -g -O0
YFLAGS+= -v
USE_TCL= true
TCL_LIB= -ltcl
X_LIBS= -L/usr/X11/lib
TK_LIB= -ltk

# documentation

HSTYLE= /home/tgl/SGML/db118.d/docbook/html
PSTYLE= /home/tgl/SGML/db118.d/docbook/print

which is where the POSTGRESDIR is actually coming from.

               - Tom

Re: [INTERFACES] Re: Just some unfinished stuff.

From
Gerald Gryschuk
Date:
Thomas G. Lockhart wrote:
> Ah! That's the source of our confusion! I install into
>   /opt/postgres/current
> rather than into /usr/local, but do so by setting the PGROOT environment
> variable. I never have to specify any configure command-line options
> when I build. Which is a good thing since I sometimes build several
> times in a session as I'm developing backend code...

No this shouldn't have mattered, I was trying to write the configure
script around the fact people might not install to /usr/local/pgsql.
However, I don't see how PGROOT and PGLIB get in here. I looked at
the 6.4 files you sent and back at the 6.3 files and none of them
(that I could see) make reference to PGROOT etc. So... is this something
new or what? How do these environment variables override anything, maybe
in the Postgres distribution Makefile.global.in that you didn't send me?

>
> Now that I think about it, I also set PGLIB, so should make sure that
> the odbc installation uses that rather than POSTGRESDIR/lib.

Well I think I have a more "comprehensive" solution. Not that yours is
bad. But it misses one semi-important file, the odbcinst.ini. Your
changes
will leave its installation directory unchanged. So the configure.in
file
you sent me would still cause it to be installed in /usr/local/share
even
with your changes.

More below.

>
> It does look like this, but the top of configure.in has the line
>
>   AC_PREFIX_DEFAULT(/usr/local)
>
> which pretty much sets everything which follows, and which is an
> unconditional assignment. So without command-line switches, that's where
> things went before my changes.

O.k. I see the problem now. The configure.in file that you sent was
based
on the first version I sent you. The second configure.in has changes
specifically
meant to overcome the problem your seeing, why this didn't occur to me
before I don't know. However, the changes I made to configure.in still
don't take into
account using the PGROOT etc. environment variables, so I had to make
changes to
the Makefile.global.in. I would be much happier if you could explain
exactly how these override anything.

Anyway, again see below for more on this.

> The only thing which still annoys me is having to carry the template
> directory inside interfaces/odbc. But I agree that it would be best to
> have the Postgres tree carrying the full psqlodbc sources so that
> someone can pick up just that part and carry it do a different client.
> I've thought about having a "make standalone" which creates a tarball
> with the template files included, but let's keep it simple (as-is) for
> this release.

Ask and you shall receive. I've made some more changes, had to anyway to
fix
your other problems. Note that I removed your changes to the GNUmakefile
for
the reason I mentioned above. I moved the possible use of PGROOT and
PGLIB to
the odbc Makefile.global using the only manner that I could think the
Postgres distribution files do it. As I said I'm still in a fog as to
how they exactly get used in the Postgres distribution but I think I
made
a good surmise.

Regardless, I had to make changes to the configure.in to fix the root
problem.
I also made changes so that we don't have to carry the templates
directory
around. Basically I added a variable to the odbc configure.in called
TEMPLATEDIR.
Depending on where the source is being built this will get set to
either,
    TEMPLATEDIR=../../template        (integrated build)
or
    TEMPLATEDIR=./template        (standalone, requires that the template
directory
                    be in the same directory as the odbc source)

I than simply added a variable SOURCES to the GNUmakefile.in which is a
list of
all the source files that are in the odbc directory, including the
Windows build
files etc.

Lastly I simply added the targets 'standalone' and 'integrated'.
'standalone' will
create a tar file with all the files in SOURCES than it backs up to the
Postgres
src directory and appends the Postgres 'template' directory.
'integrated' simply does
the first step.

Note that I also added a target 'distclean' which does 'clean' plus gets
rid of the
config.h GNUmakefile and Makefile.global.

Lastly could you please remove the READMEBYRONANDTHOMAS.txt file from
the distribution,
that was meant to be for your eyes only and than deleted or moved
anyway.

The changes I made can be found in the attached files,
configure.in,GNUmakefile.in
and Makefile.global.in.

After copying these files to the 'interfaces/odbc' directory don't
forget to do
an autoconf.

By the way you might like to do a 'make integrated', copy the resultant
tarball to any directory outside the Postgres distribution and see what
happens
when you go to configure it. Either that or just read the configure.in.

Oh yeah, do you think were ready to get rid of the old
Makefile/Makefile.unx stuff. If
you think we are maybe you shouldn't leave them in the release.
--
Gerald Gryschuk(ggryschuk@scf.sk.ca)
Programmer Analyst
Saskatoon Cancer Centre
((306)655-2746)#-------------------------------------------------------------------------
#
# Makefile.inc--
#    Build and install postgres.
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
#    $Header: /usr/local/cvsroot/pgsql/src/GNUmakefile.in,v 1.24 1998/01/17 23:39:05 scrappy Exp $
#
#-------------------------------------------------------------------------
@SET_MAKE@

NAME = psqlodbc
SRCDIR=@srcdir@
ODBCSRCDIR=@srcdir@
include $(ODBCSRCDIR)/Makefile.global

include Version.mk
PORTNAME= @PORTNAME@

FIND = @find@

# assuming gnu tar and split here
TAR  = @tar@
SPLIT = @split@

ifeq ($(PORTNAME), linux)
  install-shlib-dep := install-shlib
  shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
  LDFLAGS_SL = -shared -soname lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
  LDFLAGS_SL += -Bsymbolic $(LDFLAGS) -lc -lm
  CFLAGS += -I. $(CFLAGS_SL)
endif

ifeq ($(PORTNAME), bsd)
  ifdef BSD_SHLIB
    install-shlib-dep := install-shlib
    shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
    LDFLAGS_SL = -x -Bshareable -Bforcearchive $(LDFLAGS)
    CFLAGS += -I. $(CFLAGS_SL)
  endif
endif

SOURCES = *.c *.h *.in Config.mk Makefile Makefile.unx README.Linux \
    TODO.txt Version.mk config.guess config.sub configure \
    install-sh license.txt notice.txt odbcinst.ini patch \
    psqlodbc.aps psqlodbc.def psqlodbc.mak psqlodbc.mdp \
    psqlodbc.ncb psqlodbc.rc readme.txt

OBJECTS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
        environ.o execute.o lobj.o misc.o options.o \
        pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o \
        gpps.o tuple.o tuplelist.o dlg_specific.o $(OBJX)

CFLAGS += @DEFS@

all: libpsqlodbc.a $(shlib)

libpsqlodbc.a: $(OBJECTS)
    $(AR) $(AROPT) libpsqlodbc.a $(OBJS)
    $(RANLIB) libpsqlodbc.a

$(shlib): $(OBJECTS)
    $(LD) $(LDFLAGS_SL) $(OBJECTS) \
    -o $(shlib) $(LIBS)

.PHONY: beforeinstall-headers beforeinstall-ini install-headers

.PHONY: install install-libpsqlodbc install-shlib-dep

install: install-headers install-libpsqlodbc install-ini $(install-shlib-dep)

install-headers: beforeinstall-headers isql.h isqlext.h iodbc.h
    $(INSTALL) $(INSTLOPTS) iodbc.h $(HEADERDIR)/iodbc/iodbc.h
    $(INSTALL) $(INSTLOPTS) isql.h $(HEADERDIR)/iodbc/isql.h
    $(INSTALL) $(INSTLOPTS) isqlext.h $(HEADERDIR)/iodbc/isqlext.h

beforeinstall-headers:
    @if [ ! -d $(HEADERDIR)/iodbc ]; then mkdir $(HEADERDIR)/iodbc; fi

beforeinstall-ini:
    @if [ ! -d $(ODBCINST) ]; then mkdir $(ODBCINST); fi

install-libpsqlodbc: libpsqlodbc.a
    $(INSTALL) $(INSTL_LIB_OPTS) libpsqlodbc.a $(DESTDIR)$(LIBDIR)/lib$(NAME).a

install-shlib: $(shlib)
    $(INSTALL) $(INSTL_LIB_OPTS) $(shlib) $(DESTDIR)$(LIBDIR)/$(shlib)
    rm -f $(DESTDIR)$(LIBDIR)/lib$(NAME)$(DLSUFFIX)
    rm -f $(DESTDIR)$(LIBDIR)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
    cd $(DESTDIR)$(LIBDIR) && $(LN_S) -f $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
    cd $(DESTDIR)$(LIBDIR) && $(LN_S) -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX)

install-ini: beforeinstall-ini odbcinst.ini
    $(INSTALL) $(INSTL_LIB_OPTS) odbcinst.ini $(ODBCINST)/odbcinst.ini

depend dep:
    $(CC) -MM *.c >depend

.PHONY: clean

clean:
    -rm -f lib$(NAME).a $(shlib) $(OBJECTS) lib$(NAME)$(DLSUFFIX)
    -rm -f config.log config.cache config.status

.PHONY: distclean

distclean: clean
    -rm -f config.h GNUmakefile Makefile.global

.PHONY: standalone

standalone:
    -rm -f psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION).tar.gz
    tar -cf psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION).tar $(SOURCES)
    tar -r -C ../.. -f psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION).tar template
    gzip psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION).tar

.PHONY: integrated

integrated:
    -rm -f psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION)-int.tar.gz
    tar -cf psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION)-int.tar $(SOURCES)
    gzip psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION)-int.tar
#----------------------------------------------------------------------------
#
# Makefile.global--
#    global configuration for the Makefiles
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
#    $Header$
#
# NOTES
#    This is derived from the main Postgres makefile.
#
#    When running standalone:
#    To override the default setting, create a Makefile.custom in this
#    directory and put your defines there. (Makefile.custom is included
#    near the end of this file).  Sometimes, a variable gets set in
#    Makefile.global after Makefile.custom has been included, so you can't
#    simply set that variable in Makefile.custom.  In those cases, there is
#    often another variable (like CUSTOM_COPT) that you can set in
#    Makefile.custom that influences the later setting of the true variable
#    of interest (like CFLAGS) by Makefile.global.
#
#
#    If you change any of these defines you probably have to
#       make clean; make
#    since no dependencies are created for these. (of course you can
#    be crafty and check what files really depend on them and just remake
#    those).
#
#    Before including this file, you must set the SRCDIR variable to the
#    path of the top of the Postgres source tree (the directory that
#    contains this file).
#
#-------------------------------------------------------------------------


##############################################################################
#
# CONFIGURATION SECTION
#
# Following are settings pertaining to the postgres build and
# installation.
# of the port.
#
# Ignore LINUX_ELF if you're not using Linux.  But if you are, and you're
# compiling to a.out (which means you're using the dld dynamic loading
# library), set LINUX_ELF to null in Makefile.custom.
LINUX_ELF= true
#
# Ignore BSD_SHLIB if you're not using one of the BSD ports.  But if you
# are, and it's one that doesn't have shared libraries (NetBSD/vax is an
# example of this), set BSD_SHLIB to null in Makefile.custom.
BSD_SHLIB= true

# For convenience, PSQLODBCDIR is where BINDIR, and LIBDIR
# and other target destinations are rooted.  Of course, each of these is
# changable separately.

ifdef PGROOT
PSQLODBCDIR = $(PGROOT)
else
PSQLODBCDIR= @prefix@
endif

# Where the postgres executables live (changeable by just putting them
# somewhere else and putting that directory in your shell PATH)
BINDIR= $(PSQLODBCDIR)/bin

# Where libpsqlodbc.a gets installed.  You must put it where your loader will
# look for it if you wish to use the -lpq convention.  Otherwise you
# can just put the absolute pathname to the library at the end of your
# command line.

ifdef PGLIB
LIBDIR=$(PGLIB)
else
LIBDIR= $(PSQLODBCDIR)/lib
endif

# Where the man pages (suitable for use with "man") get installed.
POSTMANDIR= $(PSQLODBCDIR)/man

# Where the formatted documents (e.g., the reference manual) get installed.
POSTDOCDIR= $(PSQLODBCDIR)/doc

# Where the header files necessary to build frontend programs get installed.
HEADERDIR= $(PSQLODBCDIR)/include

# Where the odbcinst.ini file will be placed

ifdef PGROOT
ODBCINST=$(PGROOT)
else
ODBCINST= @ODBCINSTDIR@
endif

##############################################################################
#
# FEATURES
#
# To disable a feature, comment out the entire definition
# (that is, prepend '#', don't set it to "0" or "no").

##############################################################################
#
# Installation.
#
# For many ports, INSTALL is overridden below.
INSTALL= @INSTALL@
RANLIB= @RANLIB@

INSTLOPTS= @INSTLOPTS@
INSTL_EXE_OPTS= @INSTL_EXE_OPTS@
INSTL_LIB_OPTS= @INSTL_LIB_OPTS@

##############################################################################
#
# For building shell scripts:
#
# For many ports, these are overridden below.

# DASH_N is what we put before the text on an echo command when we don't
# want a trailing newline.  BACKSLASH_C is what we put at the end of the
# string on a echo command when we don't want a trailing newline.  On
# some systems, you do echo -n "no newline after this", while on others
# you do echo "no newline after this\c".

DASH_N= @DASH_N@
BACKSLASH_C= @BACKSLASH_C@



#-------------------------------------------------------------
# See the subdirectory template for default settings for these
#-------------------------------------------------------------
CC= @CC@
AROPT= @AROPT@
CFLAGS= -I$(ODBCSRCDIR) @CPPFLAGS@ @CFLAGS@
CFLAGS_SL= @SHARED_LIB@
LDFLAGS= @LDFLAGS@ @LIBS@
DLSUFFIX= @DLSUFFIX@
LN_S = @LN_S@

ifeq ($(CC), gcc)
CFLAGS+= -Wall -Wmissing-prototypes
endif

ifdef COPT
   CFLAGS+= $(COPT)
endif
dnl Process this file with autoconf to produce a configure script.
AC_INIT(bind.c)
AC_PREFIX_DEFAULT(/usr/local)

if test -d ../../interfaces
then
    TEMPLATEDIR=../../template
    if test "$prefix" = "NONE"
    then
        ac_default_prefix=/usr/local/pgsql
        ODBCINSTDIR=$ac_default_prefix
    else
        ODBCINSTDIR=$prefix
    fi
else
    TEMPLATEDIR=./template
    if test "$prefix" = "NONE"
    then
        ODBCINSTDIR=$ac_default_prefix/share
    else
        ODBCINSTDIR=$prefix
    fi
fi

echo "*** configuring psqlodbc ***"

AC_CANONICAL_HOST

case "$host_os" in
 solaris*)
        case "$host_cpu" in
          sparc) os=sparc_solaris ;;
           i386) os=i386_solaris ;;
        esac ;;
   sunos*) os=sunos4 ;;
     aux*) os=aux ;;
   linux*) os=linux ;;
    bsdi*) os=bsdi ;;
 freebsd*|netbsd*|openbsd*) os=bsd ;;
    dgux*) os=dgux ;;
     aix*) os=aix ;;
nextstep*) os=nextstep ;;
  ultrix*) os=ultrix4 ;;
    irix*) os=irix5  ;;
    hpux*) os=hpux ;;
     osf*) os=alpha ;;
     sco*) os=sco ;;
 machten*) os=machten ;;
  cygwin*) os=win ;;
 sysv4.2*)
       case "$host_vendor" in
               univel) os=univel ;;
                    *) os=unknown ;;
       esac ;;
   sysv4*) os=svr4 ;;
*) echo ""
   echo "*************************************************************"
   echo "configure does not currently recognize your operating system,"
   echo "therefore you must do a manual configuration of:"
   echo "$host_os"
   echo "Please contact scrappy@hub.org to see about rectifying this, "
   echo "including the above 'checking host system type...' line "
   echo "*************************************************************"
   echo ""
   exit;;
esac


PORTNAME=${os}

AC_SUBST(PORTNAME)

echo "checking echo setting..."
if echo '\c' | grep -s c >/dev/null 2>&1
then
    ECHO_N="echo -n"
    ECHO_C=""
else
    ECHO_N="echo"
    ECHO_C='\c'
fi

dnl cat <<EOT
dnl **************************************************************
dnl     Postodbc v0.0250 Installation Program
dnl
dnl Welcome to the new improved Postodbc installation program.
dnl This configuration program is for version 0.0250 of the
dnl Postodbc software.
dnl
dnl EOT

dnl this part selects the template from the one in the
dnl template directory.

dnl if test "X$with_template" != "X"
dnl then
dnl     TEMPLATE=template/$with_template
dnl else
dnl     TEMPLATE=DO_NOT_CHANGE_THIS_INVALID_FILENAME
dnl fi

AC_MSG_CHECKING(setting template to)
AC_ARG_WITH(template,
    [  --with-template=TEMPLATE
                            use operating system template file
                                see template directory],
    [  TEMPLATE=$withval ],
    [  host_no_ver=`echo "$host" | sed 's/[[0-9.]]*$//'`
        GUESS=`grep "$host_no_ver" $TEMPLATEDIR/.similar | sed 's/.*=//' | tail -1`
        if test "$GUESS"
        then   TEMPLATE="$GUESS"
        else   TEMPLATE=`uname -s | tr A-Z a-z`
        fi
    ])
AC_MSG_RESULT($TEMPLATE)

if test ! -d "$TEMPLATEDIR"
then
    cat << EOT
**************************************************************
You seem to be missing the template directory needed by
configure. If you just copied the source from the Postgres
distribution you should instead have issued the command
'make standalone' which would have built a distribution
containing the necessary template directory. The other
option is that your trying to build from the source
which is meant to be placed in the Postgres distribution
directory 'interfaces/odbc'. Depending on your case either get the
standalone source from the following Web site:

    www.insightdist.com/psqlodbc/

or issue the 'make standalone' command from the
'interfaces/odbc' directory of your Postgres Distribution,
or copy the distribution file you have to your Postgres
distribution's 'interfaces/odbc' directory and try
again.

If neither of these is the case than please complain
kindly to the maintainers, their e-mail addresses can
be found in the Readme files.
*************************************************************
EOT

exit
else

if test ! -f "$TEMPLATEDIR/$TEMPLATE"
then
    cat <<EOT
Please select a template from the ones listed below.  If no
template is available, then select the 'generic' one and
consider emailling scrappy@hub.org with the above line which
starts 'checking host system type...'
**************************************************************
EOT
    TEMPLATE=generic
    GUESS=`grep "^$host_no_ver=" $TEMPLATEDIR/.similar 2>/dev/null`
    if test ! "$GUESS"
    then    host_no_ver=`echo "$host" | sed 's/[[0-9.]]*$//'`
        GUESS=`grep "$host_no_ver" $TEMPLATEDIR/.similar 2>/dev/null`
    fi
    if test "$GUESS"
    then
        TEMPLATE=`echo $GUESS | sed 's/.*=//'`
    fi
    export TEMPLATE
    ls $TEMPLATEDIR
    echo "**************************************************************"
    $ECHO_N "Appropriate template file { $TEMPLATE }: $ECHO_C"
    read a
    if test "$a." != "."
    then
        TEMPLATE=$a
    fi
    if test ! -f $TEMPLATEDIR/$TEMPLATE
    then
        echo "You must choose an appropriate template file."
        exit
    fi
fi
fi

TEMPLATE=$TEMPLATEDIR/$TEMPLATE
export TEMPLATE
echo ""

AROPT=`grep '^AROPT:' $TEMPLATE | awk -F: '{print $2}'`
SHARED_LIB=`grep '^SHARED_LIB:' $TEMPLATE | awk -F: '{print $2}'`
CFLAGS=`grep '^CFLAGS:' $TEMPLATE | awk -F: '{print $2}'`
SRCH_INC=`grep '^SRCH_INC:' $TEMPLATE | awk -F: '{print $2}'`
SRCH_LIB=`grep '^SRCH_LIB:' $TEMPLATE | awk -F: '{print $2}'`
DLSUFFIX=`grep '^DLSUFFIX:' $TEMPLATE | awk -F: '{print $2}'`
DL_LIB=`grep '^DL_LIB:' $TEMPLATE | awk -F: '{print $2}'`
CC=`grep '^CC:' $TEMPLATE | awk -F: '{print $2}'`
LIBS=`grep '^LIBS:' $TEMPLATE | awk -F: '{print $2}'`


a=$SRCH_INC
CPPFLAGS=`echo "$a" | sed 's@  *@ @g; s@^\([[^ ]]\)@-I\1@; s@ \([[^ ]]\)@ -I\1@g'`

export CPPFLAGS
echo "- setting CPPFLAGS=$CPPFLAGS"

a=$SRCH_LIB
LDFLAGS=`echo "$a" | sed 's@  *@ @g; s@^\([[^ ]]\)@-L\1@; s@ \([[^ ]]\)@ -L\1@g'`

export LDFLAGS
echo "- setting LDFLAGS=$LDFLAGS"

dnl Allow for overriding the default location of the odbcinst.ini
dnl file which is normally ${prefix}/share or ${prefix} if this is
dnl being compiled inside the postgres distribution.
AC_MSG_CHECKING(setting ODBCINST)
AC_ARG_WITH(
   odbcinst,
   [   --with-odbcinst=<datadir> change default directory for odbcinst.ini],
   AC_DEFINE_UNQUOTED(ODBCINST, ${with_odbcinst}) AC_MSG_RESULT($with_odbcinst),
   AC_DEFINE_UNQUOTED(ODBCINST, ${ODBCINSTDIR}) AC_MSG_RESULT(${ODBCINSTDIR})
)

if test "X$with_odbcinst" != "X"
then
    ODBCINSTDIR=$with_odbcinst
fi

AC_SUBST(ODBCINSTDIR)

if test "X$with_compiler" != "X"
then
        CC=$with_compiler
else
        AC_PROG_CC
fi

AC_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CPP

AC_SUBST(PORTNAME)
AC_SUBST(LDFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(AROPT)
AC_SUBST(SHARED_LIB)
AC_SUBST(CFLAGS)
AC_SUBST(DLSUFFIX)
AC_SUBST(DL_LIB)

INSTALLPATH="/usr/ucb:$PATH"
AC_PATH_PROGS(INSTALL, ginstall installbsd bsdinst scoinst install, NONE, $INSTALLPATH)
if test $INSTALL = "NONE"
then
   echo "- No Install Script found - aborting."
   exit 0;
fi

INSTLOPTS="-m 444"
INSTL_EXE_OPTS="-m 555"
INSTL_LIB_OPTS="-m 644"

case "`basename $INSTALL`" in
 install|installbsd|scoinst)
    INSTLOPTS="-c $INSTLOPTS"
    INSTL_EXE_OPTS="-c $INSTL_EXE_OPTS"
    INSTL_LIB_OPTS="-c $INSTL_LIB_OPTS";;
esac

echo "- Using $INSTALL"
AC_SUBST(INSTALL)
AC_SUBST(INSTLOPTS)
AC_SUBST(INSTL_LIB_OPTS)
AC_SUBST(INSTL_EXE_OPTS)

dnl Check the option to echo to inhibit newlines.
ECHO_N_OUT=`echo -n "" | wc -c`
ECHO_C_OUT=`echo "\c" | wc -c`
if test "$ECHO_N_OUT" -eq 0; then
  DASH_N='-n'
  BACKSLASH_C=
else
  if test "ECHO_C_OUT" -eq 0; then
    DASH_N=
    BACKSLASH_C='\\\\c'
  else
    AC_MSG_ERROR("echo behaviour undetermined")
  fi
fi
AC_SUBST(DASH_N)
AC_SUBST(BACKSLASH_C)

AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PATH_PROG(find, find)
AC_PATH_PROG(tar, tar)
AC_PATH_PROG(split,split)

AC_CHECK_LIB(c,        main)
AC_CHECK_LIB(m,        main)
AC_CHECK_LIB(dl,       main)

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/param.h pwd.h)

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Check for any "odd" conditions

dnl Checks for library functions.
AC_CHECK_FUNCS(stricmp)

dnl Check for X libraries

dnl Check for X library

AC_OUTPUT(GNUmakefile Makefile.global)