File: pg_buildext

package info (click to toggle)
postgresql-common 113%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 688 kB
  • ctags: 100
  • sloc: perl: 2,249; sh: 387; makefile: 11
file content (109 lines) | stat: -rwxr-xr-x 2,047 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
#
# build a PostgreSQL module based on PGXS for give list of supported major
# versions
#
# Author: Dimitri Fontaine <dfontaine@hi-media.com>

action="$1"
srcdir="$2"
target="$3"
opt="$4"

prepare_env() {
    if [ ! -d $srcdir ]; then
	echo "Error: no such directory '$srcdir'"
	exit 1
    fi
    version=$1
    vtarget=`echo $target | sed -e "s:%v:$version:"`
    pgc="/usr/lib/postgresql/$version/bin/pg_config"
    cflags=`$pgc --cflags`
}

build() {
    prepare_env $1

    mkdir -p $vtarget
    cd $vtarget
    make -f $srcdir/Makefile CFLAGS="$cflags $opt" PG_CONFIG="$pgc" VPATH="$srcdir"
    cd -
}

clean() {
    prepare_env $1
    make clean PG_CONFIG="$pgc"
    rm -rf $vtarget
}

versions() {
    for v in `/usr/share/postgresql-common/supported-versions`
    do
	grep -q "^$v" $srcdir/debian/pgversions && echo $v
    done
}

for v in `versions`
do
    case "$action" in
	"supported-versions")
	    echo $v
	    ;;

	build|clean)
	    # be verbose?
	    $action $v
	    ;;

	*)
	    echo "$0: unsupported $action."
	    ;;
    esac
done

exit 0

# POD follows here

=head1 NAME

pg_buildext - Build and install a PostgreSQL extension

=head1 SYNOPSIS

B<pg_buildext> I<action> I<srcdir> I<target> I<opts>

=head1 DESCRIPTION

B<pg_buildext> is a script that will build a PostgreSQL extension in a
C<VPATH> way. It only supports the B<build> and B<clean> actions, and will
choose to build the versions known in C<debian/pgversions> and in
C</usr/share/postgresql-common/supported-versions>.

=head1 OPTIONS

=over 4

=item B<action>

Either I<clean> or I<build>.

=item B<srcdir>

Where to find the extension sources, including the C<debian> subdirectory.

=item B<target>

The target directory where to build the sources, it will get created for you
if it does not exist. If the B<target> contains a C<%v> sign, it will get
replaced by the specific version of PostgreSQL being built against.

=item B<opts>

Custom C<CFLAGS> options to use for the build.

=back

=head1 AUTHOR

Dimitri Fontaine L<E<lt>dim@tapoueh.orgE<gt>>