240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
# File 'ext/extconf.rb', line 240
def pthread_check()
tcl_major_ver = nil
tcl_minor_ver = nil
case enable_config("tcl-thread")
when true
tcl_enable_thread = true
when false
tcl_enable_thread = false
else
tcl_enable_thread = nil
end
if (tclConfig = with_config("tclConfig-file"))
if tcl_enable_thread == true
puts("Warning: --with-tclConfig-file option is ignored, because --enable-tcl-thread option is given.")
elsif tcl_enable_thread == false
puts("Warning: --with-tclConfig-file option is ignored, because --disable-tcl-thread option is given.")
else
begin
tbl = parse_tclConfig(tclConfig)
if tbl['TCL_THREADS']
tcl_enable_thread = (tbl['TCL_THREADS'] == "1")
else
tcl_major_ver = tbl['TCL_MAJOR_VERSION'].to_i
tcl_minor_ver = tbl['TCL_MINOR_VERSION'].to_i
if tcl_major_ver < 8 || (tcl_major_ver == 8 && tcl_minor_ver == 0)
tcl_enable_thread = false
end
end
if tcl_enable_thread == nil
if tcl_major_ver
puts("Warning: '#{tclConfig}' doesn't include TCL_THREADS definition.")
else
puts("Warning: '#{tclConfig}' may not be a tclConfig file.")
end
tclConfig = false
end
rescue Exception
puts("Warning: fail to read '#{tclConfig}'!! --> ignore the file")
tclConfig = false
end
end
end
if tcl_enable_thread == nil && !tclConfig
begin
try_run_available = try_run("int main() { exit(0); }")
rescue Exception
puts(%Q'\
*****************************************************************************
**
** PTHREAD SUPPORT CHECK WARNING:
**
** We cannot check the consistency of pthread support between Ruby
** and the Tcl/Tk library in your environment (are you perhaps
** cross-compiling?). If pthread support for these 2 packages is
** inconsistent you may find you get errors when running Ruby/Tk
** (e.g. hangs or segmentation faults). We strongly recommend
** you to check the consistency manually.
**
*****************************************************************************
')
return true
end
end
if tcl_enable_thread == nil
if try_run("#include <tcl.h>\nint main() { \n Tcl_Interp *ip;\n ip = Tcl_CreateInterp();\n exit((Tcl_Eval(ip, \"set tcl_platform(threaded)\") == TCL_OK)? 0: 1);\n}\n")
tcl_enable_thread = true
elsif try_run("#include <tcl.h>\nstatic Tcl_ThreadDataKey dataKey;\nint main() { exit((Tcl_GetThreadData(&dataKey, 1) == dataKey)? 1: 0); }\n")
tcl_enable_thread = true
else
tcl_enable_thread = false
end
end
if (macro_defined?('HAVE_NATIVETHREAD', '#include "ruby.h"'))
unless tcl_enable_thread
puts(%Q'\
*****************************************************************************
**
** PTHREAD SUPPORT MODE WARNING:
**
** Ruby is compiled with --enable-pthread, but your Tcl/Tk library
** seems to be compiled without pthread support. Although you can
** create the tcltklib library, this combination may cause errors
** (e.g. hangs or segmentation faults). If you have no reason to
** keep the current pthread support status, we recommend you reconfigure
** and recompile the libraries so that both or neither support pthreads.
**
** If you want change the status of pthread support, please recompile
** Ruby without "--enable-pthread" configure option or recompile Tcl/Tk
** with "--enable-threads" configure option (if your Tcl/Tk is later
** than or equal to Tcl/Tk 8.1).
**
*****************************************************************************
')
end
if tcl_enable_thread
$CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=1'
else
$CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=0'
end
return true
else
if tcl_enable_thread
puts(%Q'\
*****************************************************************************
**
** PTHREAD SUPPORT MODE ERROR:
**
** Ruby is not compiled with --enable-pthread, but your Tcl/Tk
** library seems to be compiled with pthread support. This
** combination may cause frequent hang or segmentation fault
** errors when Ruby/Tk is working. We recommend that you NEVER
** create the library with such a combination of pthread support.
**
** Please recompile Ruby with the "--enable-pthread" configure option
** or recompile Tcl/Tk with the "--disable-threads" configure option.
**
*****************************************************************************
')
$CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=1'
return false
else
$CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=0'
return true
end
end
end
|