diff options
Diffstat (limited to 'recipes-support/ruby-shadow/files/extconf.rb')
-rw-r--r-- | recipes-support/ruby-shadow/files/extconf.rb | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/recipes-support/ruby-shadow/files/extconf.rb b/recipes-support/ruby-shadow/files/extconf.rb new file mode 100644 index 0000000..570a6ee --- /dev/null +++ b/recipes-support/ruby-shadow/files/extconf.rb | |||
@@ -0,0 +1,75 @@ | |||
1 | # -*- ruby -*- | ||
2 | # extconf.rb | ||
3 | # | ||
4 | # Modified at: <1999/8/19 06:38:55 by ttate> | ||
5 | # | ||
6 | |||
7 | require 'mkmf' | ||
8 | require 'rbconfig' | ||
9 | |||
10 | $CFLAGS = case RUBY_VERSION | ||
11 | when /^1\.9/; '-DRUBY19' | ||
12 | when /^2\./; '-DRUBY19' | ||
13 | when /^3\./; '-DRUBY19' | ||
14 | else; '' | ||
15 | end | ||
16 | |||
17 | implementation = case CONFIG['host_os'] | ||
18 | when /linux/i; 'shadow' | ||
19 | when /sunos|solaris/i; 'shadow' | ||
20 | when /freebsd|mirbsd|netbsd|openbsd/i; 'pwd' | ||
21 | when /darwin/i; 'pwd' | ||
22 | else; nil | ||
23 | "This library works on OS X, FreeBSD, MirBSD, NetBSD, OpenBSD, Solaris and Linux." | ||
24 | end | ||
25 | |||
26 | # force this, we know we are building for linux | ||
27 | implementation = 'shadow' | ||
28 | |||
29 | # puts "Selected implementation: #{implementation}" | ||
30 | # puts "Host OS: #{CONFIG['host_os']}" | ||
31 | |||
32 | ok = true | ||
33 | |||
34 | case implementation | ||
35 | when 'shadow' | ||
36 | #$LDFLAGS = "-lshadow" | ||
37 | |||
38 | if( ! (ok &= have_library("shadow","getspent")) ) | ||
39 | $LDFLAGS = "" | ||
40 | ok = have_func("getspent") | ||
41 | end | ||
42 | |||
43 | ok &= have_func("fgetspent") | ||
44 | ok &= have_func("setspent") | ||
45 | ok &= have_func("endspent") | ||
46 | ok &= have_func("lckpwdf") | ||
47 | ok &= have_func("ulckpwdf") | ||
48 | |||
49 | if ok | ||
50 | if !have_func("sgetspent") | ||
51 | $CFLAGS += ' -DSOLARIS' | ||
52 | end | ||
53 | end | ||
54 | when 'pwd' | ||
55 | ok &= have_func("endpwent") | ||
56 | ok &= have_func("getpwent") | ||
57 | ok &= have_func("getpwnam") | ||
58 | ok &= have_func("getpwuid") | ||
59 | ok &= have_func("setpassent") | ||
60 | ok &= have_func("setpwent") | ||
61 | |||
62 | have_header("uuid/uuid.h") | ||
63 | have_header("uuid.h") | ||
64 | else | ||
65 | ok = false | ||
66 | end | ||
67 | |||
68 | have_header( "ruby/io.h") | ||
69 | |||
70 | if ok | ||
71 | |||
72 | create_makefile("shadow", implementation) | ||
73 | else | ||
74 | raise "You are missing some of the required functions from either shadow.h on Linux/Solaris, or pwd.h on FreeBSD/MirBSD/NetBSD/OpenBSD/OS X." | ||
75 | end | ||