pg 0.9.0.pre156-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/BSD +23 -0
- data/ChangeLog +471 -0
- data/Contributors +30 -0
- data/GPL +340 -0
- data/LICENSE +58 -0
- data/README +68 -0
- data/README.OS_X +19 -0
- data/README.ja +183 -0
- data/README.windows +72 -0
- data/Rakefile.local +239 -0
- data/ext/compat.c +541 -0
- data/ext/compat.h +180 -0
- data/ext/extconf.rb +126 -0
- data/ext/pg.c +4250 -0
- data/ext/pg.h +49 -0
- data/lib/1.8/pg_ext.so +0 -0
- data/lib/1.9/pg_ext.so +0 -0
- data/lib/pg.rb +11 -0
- data/rake/191_compat.rb +26 -0
- data/rake/dependencies.rb +76 -0
- data/rake/helpers.rb +435 -0
- data/rake/hg.rb +273 -0
- data/rake/manual.rb +782 -0
- data/rake/packaging.rb +123 -0
- data/rake/publishing.rb +274 -0
- data/rake/rdoc.rb +30 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +668 -0
- data/rake/testing.rb +187 -0
- data/rake/verifytask.rb +64 -0
- data/spec/lib/helpers.rb +216 -0
- data/spec/m17n_spec.rb +139 -0
- data/spec/pgconn_spec.rb +291 -0
- data/spec/pgresult_spec.rb +218 -0
- metadata +113 -0
data/README.OS_X
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= Compiling on MacOS X
|
2
|
+
|
3
|
+
If you are building/installing ruby-pg on MacOS X, and the installation doesn't work at first, here are a few things you can try.
|
4
|
+
|
5
|
+
== Compiling With the Correct Architecture
|
6
|
+
|
7
|
+
OS X supports both architecture-specific binaries (e.g. i386), as well as universal binaries (i.e. i386 & ppc). If ruby is built as a universal binary and postgresql is not, you need to specify the path to the appropriate pg_config binary or set the environment variable ARCHFLAGS appropriately.
|
8
|
+
|
9
|
+
For example, if you're using the stock Ruby binary, and PostgreSQL 8.4.x installed from MacPorts (without specifying the {{{+universal}}} variant), do:
|
10
|
+
|
11
|
+
gem install -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
|
12
|
+
|
13
|
+
Alternatively, if the build system can't figure out which architectures it should include, you may need to set the 'ARCHFLAGS' environment variable explicitly:
|
14
|
+
|
15
|
+
sudo env ARCHFLAGS='-arch i386' gem install pg
|
16
|
+
|
17
|
+
or, if you're building from source:
|
18
|
+
|
19
|
+
rake compile ARCHFLAGS="-arch i386"
|
data/README.ja
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
PostgreSQL$BMQ3HD%%i%$%V%i%j(B version 0.7.1
|
2
|
+
|
3
|
+
$B$^$D$b$H(B $B$f$-$R$m(B
|
4
|
+
$B$^$D$b$H(B $B$($$$8(B
|
5
|
+
|
6
|
+
$B@$OC?M(B: $B@FF#(B $BEP(B
|
7
|
+
|
8
|
+
- What's this ?
|
9
|
+
|
10
|
+
$BK\%i%$%V%i%j$O!"(BRuby$B$+$i(BPostgreSQL$B$X%"%/%;%9$9$k$?$a$N3HD%%i%$%V%i%j$G$9!#(B
|
11
|
+
$B%5%]!<%H$7$F$$$k(BPostgreSQL$B$N%P!<%8%g%s$O!"(B6.5/7.0/7.1/7.2 $B$G$9!#(B6.3$B0JA0$N(B
|
12
|
+
$B%P!<%8%g%s$G$b(B($B$A$g$C$H$7$?JQ99$G(B)$BF0:n$9$k$H;W$$$^$9$,!"%F%9%H$7$F$$$^$;$s!#(B
|
13
|
+
|
14
|
+
- How to install ?
|
15
|
+
*** requirement ***
|
16
|
+
PostgreSQL module$B$r;H$&$s$G$9$+$i!$EvA3(BPostgreSQL$B$OI,MW$G$9$M!%:#$N$H$3$m(B
|
17
|
+
$B%m!<%+%k$K(BPostgreSQL$B$,%$%s%9%H!<%k$5$l$F$$$k$3$H$rA0Ds$K$7$F$$$^$9$,!$(B
|
18
|
+
$BI,MW$J%X%C%@$H(Blibpq$B$5$($"$l$P!$%5!<%P$OI,$:$7$b%m!<%+%k$GF0:n$7$F$$$kI,MW(B
|
19
|
+
$B$O$"$j$^$;$s!%(B
|
20
|
+
|
21
|
+
$B%G%U%)%k%H$G$O!$(BPostgreSQL$B$,(B/usr/local/pgsql$BG[2<$K%$%s%9%H!<%k$5$l$F$$$k(B
|
22
|
+
$B$H$7$F$$$^$9!%JL$N>l=j$K%$%s%9%H!<%k$7$F$$$k>l9g$K$O!$4D6-JQ?t(BPGLIB$B$K(Blibpq
|
23
|
+
$B%i%$%V%i%j$,CV$$$F$"$k(Bdirectory$B$K@_Dj$7$F2<$5$$!#(B
|
24
|
+
|
25
|
+
$BG$0U$N>l=j$G!$$3$N%"!<%+%$%V$rE83+$7$F$/$@$5$$!%8e$O(B
|
26
|
+
|
27
|
+
ruby extconf.rb
|
28
|
+
make
|
29
|
+
su ($B$b$7I,MW$J$i(B)
|
30
|
+
make install
|
31
|
+
|
32
|
+
$B$H$9$k$@$1$G$9!%(BPostgreSQL$B$N%$%s%/%k!<%I%U%!%$%k!"%i%$%V%i%j%U%!%$%k$N(B
|
33
|
+
$B%$%s%9%H!<%k>l=j$,I8=`$N0LCV$G$O$J$/%3%s%Q%$%i$,8+IU$1$k$3$H$,$G$-$J$$(B
|
34
|
+
$B>l9g$K$O(B
|
35
|
+
|
36
|
+
--with-pgsql-include-dir=<$B%$%s%/%k!<%I%U%!%$%k%G%#%l%/%H%j(B>
|
37
|
+
--with-pgsql-lib-dir=<$B%i%$%V%i%j%G%#%l%/%H%j(B>
|
38
|
+
$B$^$?$O(B
|
39
|
+
--with-pgsql-dir=<$B%G%#%l%/%H%j(B>
|
40
|
+
$B$3$l$O0J2<$N$h$&$K;XDj$7$?$H$-$H$*$J$8$G$9!#(B
|
41
|
+
--with-pgsql-include-dir=<$B%G%#%l%/%H%j(B>/include
|
42
|
+
--with-pgsql-lib-dir=<$B%G%#%l%/%H%j(B>/lib
|
43
|
+
|
44
|
+
|
45
|
+
$BNc$($P(B
|
46
|
+
|
47
|
+
ruby extconf.rb --with-pgsql-include-dir=/usr/local/pgsql/include \
|
48
|
+
--with-pgsql-lib-dir=/usr/local/pgsql/lib
|
49
|
+
$B$^$?$O(B
|
50
|
+
ruby extconf.rb --with-pgsql-dir=/usr/local/pgsql
|
51
|
+
|
52
|
+
$B$N$h$&$K;XDj$7$F$/$@$5$$!#(B
|
53
|
+
|
54
|
+
- How to use ?
|
55
|
+
|
56
|
+
require "postgres"
|
57
|
+
|
58
|
+
$B$H$7$F$+$i8f;HMQ2<$5$$!#(B
|
59
|
+
|
60
|
+
- What function can I use ?
|
61
|
+
|
62
|
+
$B4pK\E*$K!"(BC$B$N(Blibpq$B%$%s%?%U%'!<%9$GDj5A$5$l$F$$$k4X?t$O%5%]!<%H$7$F$$$^$9!#(B
|
63
|
+
ver 0.6.0 $B$+$i?7$7$/(B Large Object $B%$%s%?!<%U%'%$%9$,DI2C$5$l$^$7$?!#(B
|
64
|
+
|
65
|
+
$B%5%]!<%H$7$F$$$k%a%=%C%I$N0lMw$O0J2<$NDL$j$G$9!#(B
|
66
|
+
|
67
|
+
PGconn$B%/%i%9(B:
|
68
|
+
|
69
|
+
$B%/%i%9%a%=%C%I(B
|
70
|
+
new
|
71
|
+
connect
|
72
|
+
setdb
|
73
|
+
setdblogin
|
74
|
+
escape
|
75
|
+
quote
|
76
|
+
escape_bytea
|
77
|
+
|
78
|
+
$B%a%=%C%I(B
|
79
|
+
db
|
80
|
+
host
|
81
|
+
options
|
82
|
+
port
|
83
|
+
tty
|
84
|
+
status
|
85
|
+
error
|
86
|
+
finish
|
87
|
+
close
|
88
|
+
reset
|
89
|
+
user
|
90
|
+
trace
|
91
|
+
untrace
|
92
|
+
|
93
|
+
exec
|
94
|
+
query
|
95
|
+
async_exec
|
96
|
+
async_query
|
97
|
+
get_notify
|
98
|
+
insert_table
|
99
|
+
putline
|
100
|
+
getline
|
101
|
+
endcopy
|
102
|
+
notifies
|
103
|
+
|
104
|
+
lo_import
|
105
|
+
lo_export
|
106
|
+
lo_create
|
107
|
+
lo_open
|
108
|
+
lo_unlink
|
109
|
+
|
110
|
+
client_encoding
|
111
|
+
set_client_encoding
|
112
|
+
|
113
|
+
PGresult$B%/%i%9(B:
|
114
|
+
|
115
|
+
$B%a%=%C%I(B
|
116
|
+
each
|
117
|
+
[]
|
118
|
+
status
|
119
|
+
result
|
120
|
+
fields
|
121
|
+
num_tuples
|
122
|
+
num_fields
|
123
|
+
fieldname
|
124
|
+
fieldnum
|
125
|
+
type
|
126
|
+
size
|
127
|
+
getvalue
|
128
|
+
getlength
|
129
|
+
cmdstatus
|
130
|
+
print
|
131
|
+
clear
|
132
|
+
|
133
|
+
PGlarge$B%/%i%9(B:
|
134
|
+
|
135
|
+
$B%a%=%C%I(B
|
136
|
+
open
|
137
|
+
close
|
138
|
+
read
|
139
|
+
write
|
140
|
+
lseek
|
141
|
+
tell
|
142
|
+
unlink
|
143
|
+
oid
|
144
|
+
size
|
145
|
+
export
|
146
|
+
|
147
|
+
- Acknowledgement
|
148
|
+
|
149
|
+
$BK\3HD%%i%$%V%i%j$r:n@.$9$k$K$"$?$C$F!"(Bruby-list, ruby-dev,
|
150
|
+
ruby-talk,$B5Z$S(B pgsql-jp$B%a!<%j%s%0%j%9%H$N%a%s%P!<$K!"B?$/$NM-1W$J(B
|
151
|
+
$B%"%I%P%$%9$rD:$-$^$7$?!#$3$3$K46<U$N0U$rI=$7$^$9!#(B
|
152
|
+
|
153
|
+
- Copying
|
154
|
+
|
155
|
+
$BK\3HD%%i%$%V%i%j$NCx:n8"$O!"$^$D$b$H(B $B$f$-$R$m$H$^$D$b$H(B $B$($$$8$,(B
|
156
|
+
$BJ];}$7$^$9!#(B
|
157
|
+
|
158
|
+
$BK\3HD%%i%$%V%i%j$O!"(BRuby$BK\BN$HF1$8G[I[>r7o$K=>$C$F:FG[I[$9$k$3$H(B
|
159
|
+
$B$,$G$-$^$9!#(BRuby$BK\BN$NG[I[>r7o$K$D$$$F$O!"(BRuby$BG[I[J*Cf$N(BREADME.jp
|
160
|
+
$B$K=q$+$l$F$$$^$9!#(B
|
161
|
+
|
162
|
+
$B8=:_$O@FF#(B $BEP$,(B maintainer $B$r>5$C$F$$$k$N$G!"Ld$$9g$o$;$O$3$A$i$NJ}$K(B
|
163
|
+
$B$*4j$$$7$^$9!#(B
|
164
|
+
|
165
|
+
- Author
|
166
|
+
|
167
|
+
$B$^$D$b$H(B $B$f$-$R$m(B <matz@ruby-lang.org>
|
168
|
+
Author of Ruby
|
169
|
+
|
170
|
+
$B$^$D$b$H(B $B$($$$8(B <usagi@ruby.club.or.jp>
|
171
|
+
One of users who loves Ruby
|
172
|
+
|
173
|
+
$B$3$N$U$?$j$O7;Do$G$O$"$j$^$;$s!#(B :-)
|
174
|
+
|
175
|
+
- Special Thanks
|
176
|
+
|
177
|
+
Guy Decoux ts <decoux@moulon.inra.fr>
|
178
|
+
|
179
|
+
- maintainer
|
180
|
+
|
181
|
+
$B@FF#(B $BEP(B <noborus@netlab.jp>
|
182
|
+
$B$^$D$b$H$G$J$/$F$9$$$^$;$s(B :-)
|
183
|
+
|
data/README.windows
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
= Compiling on MS Windows
|
3
|
+
|
4
|
+
In order to build this extension on MS Windows you will need a couple things.
|
5
|
+
|
6
|
+
First, a compiler. For the one click installer this means you should either
|
7
|
+
use VC++ 6.0 or the compiler that comes with cygwin or mingw if you're
|
8
|
+
building on that platform.
|
9
|
+
|
10
|
+
If you've built Ruby yourself, you should use the same compiler to build
|
11
|
+
this library that you used to build Ruby.
|
12
|
+
|
13
|
+
Second, PostgreSQL. Be sure you installed it with the development header
|
14
|
+
files if you installed it using the standard PostgreSQL installer for
|
15
|
+
Windows. If you didn't, you can run the installer again, select "modify",
|
16
|
+
and then select the 'development headers' option to install them.
|
17
|
+
|
18
|
+
I recommend making sure that 'pg_config.exe' is in your PATH. The PostgreSQL
|
19
|
+
installer for Windows does not necessarily update your PATH when it installs
|
20
|
+
itself, so you may need to do this manually. This isn't strictly necessary,
|
21
|
+
however.
|
22
|
+
|
23
|
+
In order to build ruby-pg, just run 'rake'. If the pg_config.exe executable
|
24
|
+
is not in your PATH, you'll need to explicitly point ruby-pg to where your
|
25
|
+
PostgreSQL headers and libraries are with something like this:
|
26
|
+
|
27
|
+
rake --with-pg-dir=c:/progra~1/postgr~1/8.3
|
28
|
+
|
29
|
+
Adjust your path accordingly. BE SURE TO USE THE SHORT PATH NAMES! If you
|
30
|
+
try to use a path with spaces in it, the nmake.exe program will choke.
|
31
|
+
|
32
|
+
|
33
|
+
== Cross compiling for mswin32
|
34
|
+
|
35
|
+
Using rake-compiler a cross compiled pg-gem can be build on a linux host for
|
36
|
+
the win32 platform. The generated gem is statically linked against libpq and
|
37
|
+
libssl. OpenSSL and PostgreSQL are downloaded and compiled from the sources.
|
38
|
+
There are no runtime dependencies to any but the standard Windows DLLs.
|
39
|
+
|
40
|
+
Install mingw32. On a debian based system this should work:
|
41
|
+
|
42
|
+
apt-get install mingw32
|
43
|
+
|
44
|
+
On MacOS X, if you have MacPorts installed:
|
45
|
+
|
46
|
+
port install i386-mingw32-gcc
|
47
|
+
|
48
|
+
Install the rake-compiler:
|
49
|
+
|
50
|
+
gem install rake-compiler
|
51
|
+
|
52
|
+
Download and cross compile ruby for win32:
|
53
|
+
|
54
|
+
rake-compiler cross-ruby VERSION=1.8.6-p287
|
55
|
+
|
56
|
+
Download and cross compile pg for win32:
|
57
|
+
|
58
|
+
rake cross native gem RUBY_CC_VERSION=1.8.6 OPENSSL_VERSION=0.9.8l POSTGRESQL_VERSION=8.4.2
|
59
|
+
|
60
|
+
If everything works, there should be pg-VERSION-x86-mswin32.gem in the pkg
|
61
|
+
directory.
|
62
|
+
|
63
|
+
|
64
|
+
If you have any problems you can submit them via the project's issue-tracker:
|
65
|
+
|
66
|
+
http://bitbucket.org/ged/ruby-pg/issues/new/
|
67
|
+
|
68
|
+
Or you can join the mailing list:
|
69
|
+
|
70
|
+
ruby-pg-general@rubyforge.org
|
71
|
+
|
72
|
+
And submit questions, problems, or solutions, so that it can be improved.
|
data/Rakefile.local
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
#!rake
|
2
|
+
|
3
|
+
require 'rake/extensiontask'
|
4
|
+
require 'rake/extensioncompiler'
|
5
|
+
require 'rbconfig'
|
6
|
+
|
7
|
+
# C extension constants
|
8
|
+
EXT_MAKEFILE = EXTDIR + 'Makefile'
|
9
|
+
EXT_SOURCES = FileList[ EXTDIR + '*.c' ]
|
10
|
+
EXT_SO = EXTDIR + "pg.#{CONFIG['DLEXT']}"
|
11
|
+
|
12
|
+
SITEARCH_DIR = LIBDIR + Config::CONFIG['sitearch']
|
13
|
+
|
14
|
+
NUM_CPUS = if File.exist?('/proc/cpuinfo')
|
15
|
+
File.read('/proc/cpuinfo').scan('processor').length
|
16
|
+
else
|
17
|
+
1
|
18
|
+
end
|
19
|
+
|
20
|
+
# Cross-compilation constants
|
21
|
+
COMPILE_HOME = File.expand_path("~/.rake-compiler")
|
22
|
+
OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '0.9.8l'
|
23
|
+
POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '8.4.2'
|
24
|
+
|
25
|
+
CROSS_PREFIX = if RUBY_PLATFORM.include?( 'darwin' )
|
26
|
+
'i386-mingw32'
|
27
|
+
else
|
28
|
+
'i586-mingw32msvc'
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
#####################################################################
|
33
|
+
### T A S K S
|
34
|
+
#####################################################################
|
35
|
+
|
36
|
+
# Make both the default task and the spec task depend on building the extension
|
37
|
+
task :local => :compile
|
38
|
+
task :spec => :compile
|
39
|
+
namespace :spec do
|
40
|
+
task :doc => [ :compile ]
|
41
|
+
task :quiet => [ :compile ]
|
42
|
+
task :html => [ :compile ]
|
43
|
+
task :text => [ :compile ]
|
44
|
+
end
|
45
|
+
|
46
|
+
ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
|
47
|
+
|
48
|
+
Rake::ExtensionTask.new do |ext|
|
49
|
+
ext.name = 'pg_ext'
|
50
|
+
ext.gem_spec = GEMSPEC
|
51
|
+
ext.ext_dir = 'ext'
|
52
|
+
ext.lib_dir = 'lib'
|
53
|
+
ext.source_pattern = "*.{c,h}"
|
54
|
+
|
55
|
+
# If there's an explicit 'compile' argument, use everything after it as options.
|
56
|
+
if offset = ARGV.index( 'compile' )
|
57
|
+
trace "config options = %p" % [ ARGV[(offset + 1)..-1] ]
|
58
|
+
ext.config_options = ARGV[ (offset + 1)..-1 ]
|
59
|
+
# Otherwise, just grab everything from the first option onward
|
60
|
+
elsif offset = ARGV.index( ARGV.find {|arg| arg =~ /^--/ } )
|
61
|
+
trace "config options = %p" % [ ARGV[offset..-1] ]
|
62
|
+
ext.config_options = ARGV[ offset..-1 ]
|
63
|
+
else
|
64
|
+
trace "No config options (ARGV = %p)" % [ ARGV ]
|
65
|
+
end
|
66
|
+
|
67
|
+
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
|
68
|
+
ext.cross_platform = %w[i386-mswin32 i386-mingw32] # forces the Windows platform instead of the default one
|
69
|
+
|
70
|
+
# configure options only for cross compile
|
71
|
+
ext.cross_config_options += [
|
72
|
+
"--with-pg-include=#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/interfaces/libpq",
|
73
|
+
"--with-opt-include=#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/include",
|
74
|
+
"--with-pg-lib=#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/interfaces/libpq",
|
75
|
+
"--with-opt-lib=#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}",
|
76
|
+
"--enable-static-build",
|
77
|
+
]
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
desc "Stop any Postmaster instances that remain after testing."
|
83
|
+
task :cleanup_testing_dbs do
|
84
|
+
require 'spec/lib/helpers'
|
85
|
+
PgTestingHelpers.stop_existing_postmasters()
|
86
|
+
Rake::Task[:clean].invoke
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
#####################################################################
|
91
|
+
### C R O S S - C O M P I L A T I O N - T A S K S
|
92
|
+
#####################################################################
|
93
|
+
|
94
|
+
|
95
|
+
# define a location where sources will be stored
|
96
|
+
directory "#{COMPILE_HOME}/sources"
|
97
|
+
directory "#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}"
|
98
|
+
|
99
|
+
# clean intermediate files and folders
|
100
|
+
CLEAN.include("#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}")
|
101
|
+
|
102
|
+
# openssl source file should be stored there
|
103
|
+
file "#{COMPILE_HOME}/sources/openssl-#{OPENSSL_VERSION}.tar.gz" => ["#{COMPILE_HOME}/sources"] do |t|
|
104
|
+
# download the source file using wget or curl
|
105
|
+
chdir File.dirname(t.name) do
|
106
|
+
#http://www.openssl.org/source/openssl-0.9.8k.tar.gz
|
107
|
+
url = "http://www.openssl.org/source/#{File.basename(t.name)}"
|
108
|
+
sh "wget #{url} || curl -O #{url}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Extract the openssl builds
|
113
|
+
file "#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}" => ["#{COMPILE_HOME}/sources/openssl-#{OPENSSL_VERSION}.tar.gz"] do |t|
|
114
|
+
chdir File.dirname(t.name) do
|
115
|
+
t.prerequisites.each { |f| sh "tar xfz ../sources/#{File.basename(f)}" }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# generate the makefile in a clean build location
|
120
|
+
file "#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}/Makefile" =>
|
121
|
+
["#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}"] do |t|
|
122
|
+
|
123
|
+
chdir File.dirname(t.name) do
|
124
|
+
sh File.expand_path("Configure"), 'mingw'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# make
|
129
|
+
file "#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}/libssleay32.a" => ["#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}/Makefile"] do |t|
|
130
|
+
chdir File.dirname(t.prerequisites.first) do
|
131
|
+
sh <<-EOT
|
132
|
+
export cross=#{CROSS_PREFIX}- &&
|
133
|
+
make -j#{NUM_CPUS} CC="${cross}gcc -DDSO_WIN32" AR="${cross}ar r" RANLIB="${cross}ranlib" build_libs &&
|
134
|
+
cp libcrypto.a libeay32.a &&
|
135
|
+
cp libssl.a libssleay32.a
|
136
|
+
EOT
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
#desc 'compile static libssl.a'
|
141
|
+
task 'openssl-make' => ["#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}/libssleay32.a"]
|
142
|
+
|
143
|
+
|
144
|
+
# define a location where sources will be stored
|
145
|
+
directory "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}"
|
146
|
+
|
147
|
+
# clean intermediate files and folders
|
148
|
+
CLEAN.include("#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}")
|
149
|
+
|
150
|
+
|
151
|
+
# postgresql source file should be stored there
|
152
|
+
file "#{COMPILE_HOME}/sources/postgresql-#{POSTGRESQL_VERSION}.tar.bz2" => ["#{COMPILE_HOME}/sources"] do |t|
|
153
|
+
# download the source file using wget or curl
|
154
|
+
chdir File.dirname(t.name) do
|
155
|
+
#http://wwwmaster.postgresql.org/redir/53/h/source/v8.4.0/postgresql-8.4.0.tar.bz2
|
156
|
+
url = "http://wwwmaster.postgresql.org/redir/53/h/source/v#{POSTGRESQL_VERSION}/#{File.basename(t.name)}"
|
157
|
+
sh "wget #{url} || curl -O #{url}"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# Extract the postgresql sources
|
162
|
+
file "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}" => ["#{COMPILE_HOME}/sources/postgresql-#{POSTGRESQL_VERSION}.tar.bz2"] do |t|
|
163
|
+
chdir File.dirname(t.name) do
|
164
|
+
t.prerequisites.each { |f| sh "tar xfj ../sources/#{File.basename(f)}" }
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# generate the makefile in a clean build location
|
169
|
+
file "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.global" =>
|
170
|
+
["#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}",
|
171
|
+
"#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}/libssleay32.a"] do |t|
|
172
|
+
|
173
|
+
options = [
|
174
|
+
'--target=i386-mingw32',
|
175
|
+
"--host=#{Rake::ExtensionCompiler.mingw_host}",
|
176
|
+
'--with-openssl',
|
177
|
+
'--without-zlib',
|
178
|
+
'--disable-shared',
|
179
|
+
]
|
180
|
+
|
181
|
+
chdir "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}" do
|
182
|
+
configure_path = File.expand_path("#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/configure")
|
183
|
+
sh <<-EOT
|
184
|
+
export CFLAGS=-L#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION} &&
|
185
|
+
export LDFLAGS=-L#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION} &&
|
186
|
+
export LDFLAGS_SL=-L#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION} &&
|
187
|
+
export "LIBS=-lwsock32 -lgdi32" &&
|
188
|
+
export CPPFLAGS=-I#{COMPILE_HOME}/builds/openssl-#{OPENSSL_VERSION}/include &&
|
189
|
+
#{configure_path} #{options.join(" ")}
|
190
|
+
EOT
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# backup Makefile.shlib
|
195
|
+
file "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.shlib.bak" => ["#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.global"] do |t|
|
196
|
+
cp "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.shlib", t.name
|
197
|
+
end
|
198
|
+
|
199
|
+
# patch the Makefile.shlib
|
200
|
+
file "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.shlib" => ["#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.shlib.bak"] do |t|
|
201
|
+
content = File.open(t.name, 'rb') { |f| f.read }
|
202
|
+
|
203
|
+
out = ""
|
204
|
+
|
205
|
+
content.each_line do |line|
|
206
|
+
if line =~ /^(\s*haslibarule\s*=\s*yes)/
|
207
|
+
out << "##{$1}\n"
|
208
|
+
else
|
209
|
+
out << line
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
when_writing("Patching Makefile.shlib") {
|
214
|
+
File.open(t.name, 'wb') { |f| f.write(out) }
|
215
|
+
}
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
# make libpq.a
|
220
|
+
file "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/interfaces/libpq/libpq.a" => ["#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.global", "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/Makefile.shlib"] do |t|
|
221
|
+
chdir File.dirname(t.name) do
|
222
|
+
sh "make -j#{NUM_CPUS} libpq.a PORTNAME=win32"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
#desc 'compile static libpg.a'
|
227
|
+
task 'postgresql-make' => ['openssl-make', "#{COMPILE_HOME}/builds/postgresql-#{POSTGRESQL_VERSION}/src/interfaces/libpq/libpq.a"]
|
228
|
+
|
229
|
+
desc 'cross compile pg for win32'
|
230
|
+
task 'cross' => [:mingw32, 'postgresql-make']
|
231
|
+
|
232
|
+
task :mingw32 do
|
233
|
+
# Use Rake::ExtensionCompiler helpers to find the proper host
|
234
|
+
unless Rake::ExtensionCompiler.mingw_host then
|
235
|
+
warn "You need to install mingw32 cross compile functionality to be able to continue."
|
236
|
+
warn "Please refer to your distribution/package manager documentation about installation."
|
237
|
+
fail
|
238
|
+
end
|
239
|
+
end
|