Merge remote-tracking branch 'origin/pycurl' into planetlab-4_0-branch
[plcapi.git] / trunk / psycopg2 / scripts / maketypes.sh
1 #!/bin/sh
2
3 SCRIPTSDIR="`dirname $0`"
4 SRCDIR="`dirname $SCRIPTSDIR`/psycopg"
5
6 if [ -z "$1" ] ; then
7     echo Usage: $0 '<postgresql include directory>'
8     exit 1
9 fi
10
11 echo -n checking for pg_type.h ...
12 if [ -f "$1/catalog/pg_type.h" ] ; then
13     PGTYPE="$1/catalog/pg_type.h"
14 else
15     if [ -f "$1/server/catalog/pg_type.h" ] ; then
16         PGTYPE="$1/server/catalog/pg_type.h"
17     else
18         echo
19         echo "error: can't find pg_type.h under $1"
20         exit 2
21     fi
22 fi
23 echo " found"
24
25 PGVERSION="`sed -n -e 's/.*PG_VERSION \"\([0-9]\.[0-9]\).*\"/\1/p' $1/pg_config.h`"
26 PGMAJOR="`echo $PGVERSION | cut -d. -f1`"
27 PGMINOR="`echo $PGVERSION | cut -d. -f2`"
28
29 echo checking for postgresql major: $PGMAJOR
30 echo checking for postgresql minor: $PGMINOR
31     
32 echo -n generating pgtypes.h ...
33 awk '/#define .+OID/ {print "#define " $2 " " $3}' "$PGTYPE" \
34     > $SRCDIR/pgtypes.h
35 echo " done"
36 echo -n generating typecast_builtins.c ...
37 awk '/#define .+OID/ {print $2 " " $3}' "$PGTYPE" | \
38     python $SCRIPTSDIR/buildtypes.py >$SRCDIR/typecast_builtins.c
39 echo " done"
40
41