@@ -49,6 +49,12 @@ def port_path
49
49
"#{ target } /#{ RUBY_PLATFORM } "
50
50
end
51
51
52
+ # Add "--prefix=/", to avoid our actual build install path compiled into the binary.
53
+ # Instead use DESTDIR variable of make to set our install path.
54
+ def configure_prefix
55
+ "--prefix="
56
+ end
57
+
52
58
def cook_and_activate
53
59
checkpoint = File . join ( self . target , "#{ self . name } -#{ self . version } -#{ RUBY_PLATFORM } .installed" )
54
60
unless File . exist? ( checkpoint )
@@ -70,13 +76,13 @@ def configure
70
76
envs = [ ]
71
77
envs << "CFLAGS=-DDSO_WIN32 -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /mingw|mswin/
72
78
envs << "CFLAGS=-fPIC -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /linux|darwin/
73
- execute ( 'configure' , [ 'env' , *envs , "./Configure" , openssl_platform , "threads" , "-static" , "CROSS_COMPILE=#{ host } -" , configure_prefix ] , altlog : "config.log" )
79
+ execute ( 'configure' , [ 'env' , *envs , "./Configure" , openssl_platform , "threads" , "-static" , "CROSS_COMPILE=#{ host } -" , "--prefix=/" ] , altlog : "config.log" )
74
80
end
75
81
def compile
76
82
execute ( 'compile' , "#{ make_cmd } build_libs" )
77
83
end
78
84
def install
79
- execute ( 'install' , "#{ make_cmd } install_dev" )
85
+ execute ( 'install' , "#{ make_cmd } install_dev DESTDIR= #{ path } " )
80
86
end
81
87
end
82
88
@@ -104,6 +110,9 @@ def configure
104
110
end
105
111
super
106
112
end
113
+ def install
114
+ execute ( 'install' , "#{ make_cmd } install DESTDIR=#{ path } " )
115
+ end
107
116
end
108
117
# We specify -fcommon to get around duplicate definition errors in recent gcc.
109
118
# See https://github.com/cockroachdb/cockroach/issues/49734
@@ -112,6 +121,7 @@ def configure
112
121
recipe . configure_options << "--without-keyutils"
113
122
recipe . configure_options << "--disable-nls"
114
123
recipe . configure_options << "--disable-silent-rules"
124
+ recipe . configure_options << "--disable-rpath"
115
125
recipe . configure_options << "--without-system-verto"
116
126
recipe . configure_options << "krb5_cv_attr_constructor_destructor=yes"
117
127
recipe . configure_options << "ac_cv_func_regcomp=yes"
@@ -146,12 +156,13 @@ def configure_defaults
146
156
'--without-zlib' ,
147
157
'--without-icu' ,
148
158
'--without-readline' ,
159
+ '--disable-rpath' ,
149
160
'ac_cv_search_gss_store_cred_into=' ,
150
161
]
151
162
end
152
163
def compile
153
- execute 'compile include' , "#{ make_cmd } -C src/include install"
154
- execute 'compile interfaces' , "#{ make_cmd } -C src/interfaces install"
164
+ execute 'compile include' , "#{ make_cmd } -C src/include install DESTDIR= #{ path } "
165
+ execute 'compile interfaces' , "#{ make_cmd } -C src/interfaces install DESTDIR= #{ path } "
155
166
end
156
167
def install
157
168
end
@@ -169,15 +180,16 @@ def install
169
180
# Use our own library name for libpq to avoid loading of system libpq by accident.
170
181
FileUtils . ln_sf File . join ( postgresql_recipe . port_path , "lib/#{ libpq_orig } " ) ,
171
182
File . join ( postgresql_recipe . port_path , "lib/#{ libpq_rubypg } " )
183
+ # Link to libpq_rubypg in our ports directory without adding it as rpath (like dir_config does)
184
+ $CFLAGS << " -I#{ postgresql_recipe . path } /include"
185
+ $LDFLAGS << " -L#{ postgresql_recipe . path } /lib"
172
186
# Avoid dependency to external libgcc.dll on x86-mingw32
173
187
$LDFLAGS << " -static-libgcc" if RUBY_PLATFORM =~ /mingw|mswin/
174
188
# Avoid: "libpq.so: undefined reference to `dlopen'" in cross-ruby-2.7.8
175
189
$LDFLAGS << " -Wl,--no-as-needed" if RUBY_PLATFORM !~ /aarch64|arm64|darwin/
176
190
# Find libpq in the ports directory coming from lib/3.x
177
191
# It is shared between all compiled ruby versions.
178
192
$LDFLAGS << " '-Wl,-rpath=$$ORIGIN/../../ports/#{ gem_platform } /lib'" if RUBY_PLATFORM =~ /linux/
179
- # Don't use pg_config for cross build, but --with-pg-* path options
180
- dir_config ( 'pg' , "#{ postgresql_recipe . path } /include" , "#{ postgresql_recipe . path } /lib" )
181
193
182
194
$defs. push ( "-DPG_IS_BINARY_GEM" )
183
195
else
0 commit comments