-
Notifications
You must be signed in to change notification settings - Fork 4
/
extconf.rb
28 lines (22 loc) · 911 Bytes
/
extconf.rb
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
require "mkmf"
dir_config('tokyocabinet')
home = ENV["HOME"]
ENV["PATH"] = ENV["PATH"] + ":/usr/local/bin:$home/bin:.:..:../.."
tccflags = `tcucodec conf -i 2>/dev/null`.chomp
tcldflags = `tcucodec conf -l 2>/dev/null`.chomp
tcldflags = tcldflags.gsub(/-l[\S]+/, "").strip
tclibs = `tcucodec conf -l 2>/dev/null`.chomp
tclibs = tclibs.gsub(/-L[\S]+/, "").strip
tccflags = "-I/usr/local/include" if(tccflags.length < 1)
tcldflags = "-L/usr/local/lib" if(tcldflags.length < 1)
tclibs = "-ltokyocabinet -lz -lbz2 -lpthread -lm -lc" if(tclibs.length < 1)
$CFLAGS = "-I. -I.. -I../.. #{tccflags} -Wall #{$CFLAGS} -O2"
$LDFLAGS = "#{$LDFLAGS} -L. -L.. -L../.. #{tcldflags}"
$libs = "#{$libs} #{tclibs}"
printf("setting variables ...\n")
printf(" \$CFLAGS = %s\n", $CFLAGS)
printf(" \$LDFLAGS = %s\n", $LDFLAGS)
printf(" \$libs = %s\n", $libs)
if have_header('tcutil.h')
create_makefile('tokyocabinet')
end