forked from Homebrew/homebrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcflow.rb
63 lines (56 loc) · 1.75 KB
/
cflow.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Cflow < Formula
desc "Generate call graphs from C code"
homepage "https://www.gnu.org/software/cflow/"
url "https://ftp.gnu.org/gnu/cflow/cflow-1.6.tar.bz2"
mirror "https://ftpmirror.gnu.org/cflow/cflow-1.6.tar.bz2"
sha256 "34487b4116e9b7ecde142b24480ce036887921ed5defb2958068bb069c1fedd7"
bottle do
cellar :any_skip_relocation
sha256 "a96f9cf3cb35851c27ed602f6a05489da2d64e75ab6daccecc3e23156d9fe968" => :mojave
sha256 "50a816924cb91e1c4055923285ea3ceb0d815b4641477906ae5f6abdae337d52" => :high_sierra
sha256 "5e88f5310c34255947032f24227cf779aa8a42fe595f585605e814f001f4a151" => :sierra
end
def install
system "./configure", "--prefix=#{prefix}",
"--infodir=#{info}",
"--disable-debug",
"--disable-dependency-tracking",
"--with-lispdir=#{elisp}"
system "make", "install"
end
test do
(testpath/"whoami.c").write <<~EOS
#include <pwd.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
int
who_am_i (void)
{
struct passwd *pw;
char *user = NULL;
pw = getpwuid (geteuid ());
if (pw)
user = pw->pw_name;
else if ((user = getenv ("USER")) == NULL)
{
fprintf (stderr, "I don't know!\n");
return 1;
}
printf ("%s\n", user);
return 0;
}
int
main (int argc, char **argv)
{
if (argc > 1)
{
fprintf (stderr, "usage: whoami\n");
return 1;
}
return who_am_i ();
}
EOS
assert_match /getpwuid()/, shell_output("#{bin}/cflow --main who_am_i #{testpath}/whoami.c")
end
end