sstat 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/#console# +14 -0
- data/ext/extconf.rb +4 -0
- data/ext/lib/distribution.h +274 -0
- data/ext/lib/global_utility.h +17 -0
- data/ext/lib/survival.h +6 -0
- data/ext/lib/survival_def.h +47 -0
- data/ext/lib/survival_func.h +204 -0
- data/ext/lib/survival_utility.h +292 -0
- data/ext/lib/type_def.h +35 -0
- data/ext/sstat/lib/histogram/histogram.h +8 -0
- data/ext/sstat/lib/histogram/histogram_error.h +35 -0
- data/ext/sstat/lib/histogram/histogram_stat.h +73 -0
- data/ext/sstat/lib/histogram/histogram_type.h +14 -0
- data/ext/sstat/lib/survival.h +1 -0
- data/ext/sstat/lib/survival_def.h +100 -4
- data/ext/sstat/lib/survival_func.h +16 -43
- data/ext/sstat/lib/survival_kaplan_meier.h +314 -0
- data/ext/sstat/lib/survival_utility.h +2 -123
- data/ext/sstat/lib/type_def.h +15 -0
- data/ext/sstat/sstat.c +80 -14
- data/ext/sstat/sstat.h +20 -9
- data/lib/simple_statistics/version.rb +1 -1
- data/lib/sstat.so +0 -0
- metadata +17 -3
- data/ext/sstat/Makefile +0 -238
|
@@ -88,128 +88,7 @@ int find_first_index_has(double* arr, int size, double value)
|
|
|
88
88
|
return -1;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
struct
|
|
92
|
-
{
|
|
93
|
-
int i, count_at, uncensored_num_at, censored_num_at;
|
|
94
|
-
double tmp, time_at;
|
|
95
|
-
|
|
96
|
-
// sort time and censored based on time together, time can censored array
|
|
97
|
-
struct point* time_censored_array = (struct point*) malloc(size * sizeof(struct point));
|
|
98
|
-
|
|
99
|
-
//censored, if censored[] is positive
|
|
100
|
-
for (i = 0; i < size; i++)
|
|
101
|
-
{
|
|
102
|
-
time_censored_array[i].x = time[i];
|
|
103
|
-
if (censored[i] > 0)
|
|
104
|
-
time_censored_array[i].y = 1;
|
|
105
|
-
else
|
|
106
|
-
time_censored_array[i].y = -1;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
qsort(time_censored_array, size, sizeof(struct point), &point_compare_x);
|
|
110
|
-
|
|
111
|
-
//count unique uncensored time point
|
|
112
|
-
int count = 0;
|
|
113
|
-
for (i = 0; i < size; i++)
|
|
114
|
-
{ //uncensored
|
|
115
|
-
if (time_censored_array[i].y < 0)
|
|
116
|
-
{
|
|
117
|
-
if (count == 0)
|
|
118
|
-
{
|
|
119
|
-
count++;
|
|
120
|
-
tmp = time_censored_array[i].x;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (count > 0)
|
|
124
|
-
{ //unique
|
|
125
|
-
if (time_censored_array[i].x != tmp)
|
|
126
|
-
{
|
|
127
|
-
count++;
|
|
128
|
-
tmp = time_censored_array[i].x;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
double* unique_uncensored_time = (double *) malloc(count * sizeof(double));
|
|
135
|
-
|
|
136
|
-
count = 0;
|
|
137
|
-
|
|
138
|
-
for (i = 0; i < size; i++)
|
|
139
|
-
{
|
|
140
|
-
if (time_censored_array[i].y < 0)
|
|
141
|
-
{
|
|
142
|
-
if (count == 0)
|
|
143
|
-
{
|
|
144
|
-
count++;
|
|
145
|
-
unique_uncensored_time[count] = time_censored_array[i].x;
|
|
146
|
-
tmp = time_censored_array[i].x;
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (count > 0)
|
|
151
|
-
{
|
|
152
|
-
if (time_censored_array[i].x != tmp)
|
|
153
|
-
{
|
|
154
|
-
unique_uncensored_time[count] = time_censored_array[i].x;
|
|
155
|
-
|
|
156
|
-
count++;
|
|
157
|
-
tmp = time_censored_array[i].x;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
int* uncensored_num = (int *) malloc(count * sizeof(int));
|
|
164
|
-
int* censored_num = (int *) malloc(count * sizeof(int));
|
|
165
|
-
|
|
166
|
-
//record current time point
|
|
167
|
-
time_at = unique_uncensored_time[0];
|
|
168
|
-
count_at = 0;
|
|
169
|
-
uncensored_num_at = 0;
|
|
170
|
-
censored_num_at = 0;
|
|
171
|
-
|
|
172
|
-
for (i = 0; i < size; i++)
|
|
173
|
-
{
|
|
174
|
-
if (time_censored_array[i].x <= time_at)
|
|
175
|
-
{
|
|
176
|
-
if (time_censored_array[i].y > 0)
|
|
177
|
-
censored_num_at++;
|
|
178
|
-
else
|
|
179
|
-
uncensored_num_at++;
|
|
180
|
-
|
|
181
|
-
if (i == size - 1)
|
|
182
|
-
{
|
|
183
|
-
uncensored_num[count_at] = uncensored_num_at;
|
|
184
|
-
censored_num[count_at] = censored_num_at;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
} else {
|
|
188
|
-
uncensored_num[count_at] = uncensored_num_at;
|
|
189
|
-
censored_num[count_at] = censored_num_at;
|
|
190
|
-
count_at++;
|
|
191
|
-
|
|
192
|
-
uncensored_num_at = 0;
|
|
193
|
-
censored_num_at = 0;
|
|
194
|
-
time_at = unique_uncensored_time[count_at];
|
|
195
|
-
//we need to update here
|
|
196
|
-
if (time_censored_array[i].y > 0)
|
|
197
|
-
censored_num_at++;
|
|
198
|
-
else
|
|
199
|
-
uncensored_num_at++;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
Group_N at_risk_result;
|
|
204
|
-
at_risk_result.uncensored = uncensored_num;
|
|
205
|
-
at_risk_result.censored = censored_num;
|
|
206
|
-
at_risk_result.size = count;
|
|
207
|
-
at_risk_result.time = unique_uncensored_time;
|
|
208
|
-
free(time_censored_array);
|
|
209
|
-
return at_risk_result;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
struct Group_N group_N_given_range(double* time, int* censored, int size, double* unique_time, int unique_time_size)
|
|
91
|
+
struct CENS_UC_NUM group_N_given_range(double* time, int* censored, int size, double* unique_time, int unique_time_size)
|
|
213
92
|
{
|
|
214
93
|
int i, count_at, uncensored_num_at, censored_num_at;
|
|
215
94
|
double time_at;
|
|
@@ -278,7 +157,7 @@ struct Group_N group_N_given_range(double* time, int* censored, int size, double
|
|
|
278
157
|
}
|
|
279
158
|
}
|
|
280
159
|
|
|
281
|
-
|
|
160
|
+
CENS_UC_NUM at_risk_result;
|
|
282
161
|
at_risk_result.uncensored = uncensored_num;
|
|
283
162
|
at_risk_result.censored = censored_num;
|
|
284
163
|
at_risk_result.size = unique_time_size;
|
data/ext/sstat/lib/type_def.h
CHANGED
|
@@ -32,4 +32,19 @@ typedef struct array{
|
|
|
32
32
|
int size;
|
|
33
33
|
} array;
|
|
34
34
|
|
|
35
|
+
point* alloc_points(size_t size)
|
|
36
|
+
{
|
|
37
|
+
return (struct point*) malloc(size * sizeof(struct point));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void print_curve(struct curve* curve)
|
|
41
|
+
{
|
|
42
|
+
int i;
|
|
43
|
+
for(i = 0; i < curve->size; i++)
|
|
44
|
+
{
|
|
45
|
+
printf("x: %f y: %f\n", curve->point_array[i].x, curve->point_array[i].y);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
35
50
|
#endif
|
data/ext/sstat/sstat.c
CHANGED
|
@@ -17,6 +17,23 @@ static VALUE rb_percentile(VALUE self, VALUE array, VALUE target)
|
|
|
17
17
|
return DBL2NUM(_percentile);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
static VALUE rb_percentile_index(VALUE self, VALUE array, VALUE target)
|
|
21
|
+
{
|
|
22
|
+
int size = RARRAY_LEN(array);
|
|
23
|
+
int i;
|
|
24
|
+
double _target = NUM2DBL(target);
|
|
25
|
+
int _percentile_index;
|
|
26
|
+
double* c_array = (double *)malloc(sizeof(double) * size);
|
|
27
|
+
|
|
28
|
+
for (i = 0; i < size; i++) {
|
|
29
|
+
c_array[i] = NUM2DBL(rb_ary_entry(array, i));
|
|
30
|
+
}
|
|
31
|
+
_percentile_index = precentile_index(c_array, size, _target);
|
|
32
|
+
free(c_array);
|
|
33
|
+
|
|
34
|
+
return INT2NUM(_percentile_index);
|
|
35
|
+
}
|
|
36
|
+
|
|
20
37
|
static VALUE rb_index_less_equal(VALUE self, VALUE array, VALUE target)
|
|
21
38
|
{
|
|
22
39
|
int size = RARRAY_LEN(array);
|
|
@@ -40,6 +57,7 @@ static VALUE rb_kaplan_meier(VALUE self, VALUE time, VALUE censored)
|
|
|
40
57
|
int size = RARRAY_LEN(time);
|
|
41
58
|
int i;
|
|
42
59
|
struct curve KM_curve;
|
|
60
|
+
int proc_status;
|
|
43
61
|
VALUE result;
|
|
44
62
|
double* _time = (double *)malloc(sizeof(double) * size);
|
|
45
63
|
int* _censored = (int *)malloc(sizeof(int) * size);
|
|
@@ -48,24 +66,72 @@ static VALUE rb_kaplan_meier(VALUE self, VALUE time, VALUE censored)
|
|
|
48
66
|
|
|
49
67
|
_censored[i] = NUM2INT(rb_ary_entry(censored, i));
|
|
50
68
|
}
|
|
51
|
-
KM_curve = kaplan_meier(_time, _censored, size);
|
|
52
69
|
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
proc_status = kaplan_meier(_time, _censored, size, &KM_curve);
|
|
71
|
+
if (proc_status == 0 )
|
|
72
|
+
{
|
|
73
|
+
VALUE KM_x = rb_ary_new2(KM_curve.size);
|
|
74
|
+
VALUE KM_y = rb_ary_new2(KM_curve.size);
|
|
75
|
+
|
|
76
|
+
for (i = 0; i < KM_curve.size; i++)
|
|
77
|
+
{
|
|
78
|
+
rb_ary_store(KM_x, i, DBL2NUM(KM_curve.point_array[i].x));
|
|
79
|
+
rb_ary_store(KM_y, i, DBL2NUM(KM_curve.point_array[i].y));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
result = rb_hash_new();
|
|
83
|
+
|
|
84
|
+
rb_hash_aset(result, rb_str_new2("time"), KM_x);
|
|
85
|
+
rb_hash_aset(result, rb_str_new2("prob"), KM_y);
|
|
86
|
+
|
|
87
|
+
free(_time);
|
|
88
|
+
free(_censored);
|
|
89
|
+
free(KM_curve.point_array);
|
|
90
|
+
return result;
|
|
91
|
+
} else {
|
|
92
|
+
return Qfalse;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static VALUE rb_kaplan_meier_3p_extraploation(VALUE self, VALUE time, VALUE censored)
|
|
97
|
+
{
|
|
98
|
+
int size = RARRAY_LEN(time);
|
|
99
|
+
int i;
|
|
100
|
+
struct curve KM_curve;
|
|
101
|
+
int proc_status;
|
|
102
|
+
VALUE result;
|
|
103
|
+
double* _time = (double *)malloc(sizeof(double) * size);
|
|
104
|
+
int* _censored = (int *)malloc(sizeof(int) * size);
|
|
105
|
+
for (i = 0; i < size; i++) {
|
|
106
|
+
_time[i] = NUM2DBL(rb_ary_entry(time, i));
|
|
107
|
+
|
|
108
|
+
_censored[i] = NUM2INT(rb_ary_entry(censored, i));
|
|
109
|
+
}
|
|
55
110
|
|
|
56
|
-
|
|
111
|
+
proc_status = kaplan_meier_3p_extrapolation(_time, _censored, size, &KM_curve);
|
|
112
|
+
if (proc_status == 0 )
|
|
57
113
|
{
|
|
58
|
-
|
|
59
|
-
|
|
114
|
+
VALUE KM_x = rb_ary_new2(KM_curve.size);
|
|
115
|
+
VALUE KM_y = rb_ary_new2(KM_curve.size);
|
|
116
|
+
|
|
117
|
+
for (i = 0; i < KM_curve.size; i++)
|
|
118
|
+
{
|
|
119
|
+
rb_ary_store(KM_x, i, DBL2NUM(KM_curve.point_array[i].x));
|
|
120
|
+
rb_ary_store(KM_y, i, DBL2NUM(KM_curve.point_array[i].y));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
result = rb_hash_new();
|
|
124
|
+
|
|
125
|
+
rb_hash_aset(result, rb_str_new2("time"), KM_x);
|
|
126
|
+
rb_hash_aset(result, rb_str_new2("prob"), KM_y);
|
|
127
|
+
|
|
128
|
+
free(_time);
|
|
129
|
+
free(_censored);
|
|
130
|
+
free(KM_curve.point_array);
|
|
131
|
+
return result;
|
|
132
|
+
} else {
|
|
133
|
+
return Qfalse;
|
|
60
134
|
}
|
|
61
|
-
result = rb_hash_new();
|
|
62
|
-
rb_hash_aset(result, rb_str_new2("time"), KM_x);
|
|
63
|
-
rb_hash_aset(result, rb_str_new2("prob"), KM_y);
|
|
64
|
-
|
|
65
|
-
free(_time);
|
|
66
|
-
free(_censored);
|
|
67
|
-
free(KM_curve.point_array);
|
|
68
|
-
return result;
|
|
69
135
|
}
|
|
70
136
|
|
|
71
137
|
static VALUE rb_log_rank_test(VALUE self, VALUE _time_1, VALUE _cens_1, VALUE _time_2, VALUE _cens_2)
|
data/ext/sstat/sstat.h
CHANGED
|
@@ -6,23 +6,34 @@
|
|
|
6
6
|
#include "lib/survival.h"
|
|
7
7
|
#include "lib/global_utility.h"
|
|
8
8
|
#include "lib/distribution.h"
|
|
9
|
+
#include "lib/histogram/histogram.h"
|
|
9
10
|
|
|
10
11
|
static VALUE rb_percentile(VALUE self, VALUE arg, VALUE target);
|
|
12
|
+
static VALUE rb_percentile_index(VALUE self, VALUE arg, VALUE target);
|
|
11
13
|
static VALUE rb_index_less_equal(VALUE self, VALUE arg, VALUE target);
|
|
12
14
|
static VALUE rb_kaplan_meier(VALUE self, VALUE time, VALUE censor);
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* rb_kaplan_meier_3p_extraploation is not a standard Kaplan meier.
|
|
18
|
+
* A extrapolation based on the last 3 points is used in the calculation
|
|
19
|
+
*/
|
|
20
|
+
static VALUE rb_kaplan_meier_3p_extraploation(VALUE self, VALUE time, VALUE censor);
|
|
21
|
+
|
|
13
22
|
static VALUE rb_log_rank_test(VALUE self, VALUE time_1, VALUE censor_1,VALUE time_2, VALUE censor_2);
|
|
23
|
+
|
|
14
24
|
static VALUE rb_cdf_unormal_Q(VALUE self, VALUE x);
|
|
15
25
|
|
|
16
|
-
//rb_ary_storde(unmasked, i, INT2NUM(p ^ m));
|
|
17
26
|
void Init_sstat() {
|
|
18
27
|
VALUE sstat_module = rb_define_module("SStat");
|
|
19
|
-
VALUE
|
|
20
|
-
|
|
21
|
-
rb_define_method(
|
|
22
|
-
rb_define_method(
|
|
23
|
-
rb_define_method(
|
|
24
|
-
rb_define_method(
|
|
25
|
-
rb_define_method(
|
|
28
|
+
VALUE surv_class = rb_define_class_under(sstat_module, "Surv", rb_cObject);
|
|
29
|
+
VALUE dist_class = rb_define_class_under(sstat_module, "Dist", rb_cObject);
|
|
30
|
+
rb_define_method(surv_class, "percentile_index", rb_percentile_index, 2);
|
|
31
|
+
rb_define_method(surv_class, "percentile", rb_percentile, 2);
|
|
32
|
+
rb_define_method(surv_class, "index_less_equal", rb_index_less_equal, 2);
|
|
33
|
+
rb_define_method(surv_class, "kaplan_meier", rb_kaplan_meier, 2);
|
|
34
|
+
rb_define_method(surv_class, "log_rank_test", rb_log_rank_test, 4);
|
|
35
|
+
rb_define_method(surv_class, "kaplan_meier_3p_extraploation", rb_kaplan_meier_3p_extraploation, 2);
|
|
36
|
+
rb_define_method(dist_class, "cdf_unormal_Q", rb_cdf_unormal_Q, 1);
|
|
26
37
|
}
|
|
27
38
|
|
|
28
|
-
#endif
|
|
39
|
+
#endif
|
data/lib/sstat.so
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sstat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Haipeng Li
|
|
@@ -10,24 +10,38 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2016-
|
|
13
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
description:
|
|
16
16
|
email: haipeng3@ualberta.ca
|
|
17
17
|
executables: []
|
|
18
18
|
extensions:
|
|
19
|
+
- ext/extconf.rb
|
|
19
20
|
- ext/sstat/extconf.rb
|
|
20
21
|
extra_rdoc_files: []
|
|
21
22
|
files:
|
|
23
|
+
- bin/#console#
|
|
22
24
|
- bin/console
|
|
23
25
|
- bin/setup
|
|
24
|
-
- ext/
|
|
26
|
+
- ext/extconf.rb
|
|
27
|
+
- ext/lib/distribution.h
|
|
28
|
+
- ext/lib/global_utility.h
|
|
29
|
+
- ext/lib/survival.h
|
|
30
|
+
- ext/lib/survival_def.h
|
|
31
|
+
- ext/lib/survival_func.h
|
|
32
|
+
- ext/lib/survival_utility.h
|
|
33
|
+
- ext/lib/type_def.h
|
|
25
34
|
- ext/sstat/extconf.rb
|
|
26
35
|
- ext/sstat/lib/distribution.h
|
|
27
36
|
- ext/sstat/lib/global_utility.h
|
|
37
|
+
- ext/sstat/lib/histogram/histogram.h
|
|
38
|
+
- ext/sstat/lib/histogram/histogram_error.h
|
|
39
|
+
- ext/sstat/lib/histogram/histogram_stat.h
|
|
40
|
+
- ext/sstat/lib/histogram/histogram_type.h
|
|
28
41
|
- ext/sstat/lib/survival.h
|
|
29
42
|
- ext/sstat/lib/survival_def.h
|
|
30
43
|
- ext/sstat/lib/survival_func.h
|
|
44
|
+
- ext/sstat/lib/survival_kaplan_meier.h
|
|
31
45
|
- ext/sstat/lib/survival_utility.h
|
|
32
46
|
- ext/sstat/lib/type_def.h
|
|
33
47
|
- ext/sstat/sstat.c
|
data/ext/sstat/Makefile
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
SHELL = /bin/sh
|
|
3
|
-
|
|
4
|
-
# V=0 quiet, V=1 verbose. other values don't work.
|
|
5
|
-
V = 0
|
|
6
|
-
Q1 = $(V:1=)
|
|
7
|
-
Q = $(Q1:0=@)
|
|
8
|
-
ECHO1 = $(V:1=@:)
|
|
9
|
-
ECHO = $(ECHO1:0=@echo)
|
|
10
|
-
|
|
11
|
-
#### Start of system configuration section. ####
|
|
12
|
-
|
|
13
|
-
srcdir = .
|
|
14
|
-
topdir = /home/chizhang/.rvm/rubies/ruby-2.1.1/include/ruby-2.1.0
|
|
15
|
-
hdrdir = $(topdir)
|
|
16
|
-
arch_hdrdir = /home/chizhang/.rvm/rubies/ruby-2.1.1/include/ruby-2.1.0/x86_64-linux
|
|
17
|
-
PATH_SEPARATOR = :
|
|
18
|
-
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
|
19
|
-
prefix = $(DESTDIR)/home/chizhang/.rvm/rubies/ruby-2.1.1
|
|
20
|
-
rubysitearchprefix = $(rubylibprefix)/$(sitearch)
|
|
21
|
-
rubyarchprefix = $(rubylibprefix)/$(arch)
|
|
22
|
-
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
|
23
|
-
exec_prefix = $(prefix)
|
|
24
|
-
vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
|
|
25
|
-
sitearchhdrdir = $(sitehdrdir)/$(sitearch)
|
|
26
|
-
rubyarchhdrdir = $(rubyhdrdir)/$(arch)
|
|
27
|
-
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
|
28
|
-
sitehdrdir = $(rubyhdrdir)/site_ruby
|
|
29
|
-
rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
|
|
30
|
-
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
|
31
|
-
vendorlibdir = $(vendordir)/$(ruby_version)
|
|
32
|
-
vendordir = $(rubylibprefix)/vendor_ruby
|
|
33
|
-
sitearchdir = $(sitelibdir)/$(sitearch)
|
|
34
|
-
sitelibdir = $(sitedir)/$(ruby_version)
|
|
35
|
-
sitedir = $(rubylibprefix)/site_ruby
|
|
36
|
-
rubyarchdir = $(rubylibdir)/$(arch)
|
|
37
|
-
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
|
38
|
-
sitearchincludedir = $(includedir)/$(sitearch)
|
|
39
|
-
archincludedir = $(includedir)/$(arch)
|
|
40
|
-
sitearchlibdir = $(libdir)/$(sitearch)
|
|
41
|
-
archlibdir = $(libdir)/$(arch)
|
|
42
|
-
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
|
43
|
-
mandir = $(datarootdir)/man
|
|
44
|
-
localedir = $(datarootdir)/locale
|
|
45
|
-
libdir = $(exec_prefix)/lib
|
|
46
|
-
psdir = $(docdir)
|
|
47
|
-
pdfdir = $(docdir)
|
|
48
|
-
dvidir = $(docdir)
|
|
49
|
-
htmldir = $(docdir)
|
|
50
|
-
infodir = $(datarootdir)/info
|
|
51
|
-
docdir = $(datarootdir)/doc/$(PACKAGE)
|
|
52
|
-
oldincludedir = $(DESTDIR)/usr/include
|
|
53
|
-
includedir = $(prefix)/include
|
|
54
|
-
localstatedir = $(prefix)/var
|
|
55
|
-
sharedstatedir = $(prefix)/com
|
|
56
|
-
sysconfdir = $(prefix)/etc
|
|
57
|
-
datadir = $(datarootdir)
|
|
58
|
-
datarootdir = $(prefix)/share
|
|
59
|
-
libexecdir = $(exec_prefix)/libexec
|
|
60
|
-
sbindir = $(exec_prefix)/sbin
|
|
61
|
-
bindir = $(exec_prefix)/bin
|
|
62
|
-
archdir = $(rubyarchdir)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
CC = gcc
|
|
66
|
-
CXX = g++
|
|
67
|
-
LIBRUBY = $(LIBRUBY_SO)
|
|
68
|
-
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
|
69
|
-
LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
|
|
70
|
-
LIBRUBYARG_STATIC = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
|
|
71
|
-
empty =
|
|
72
|
-
OUTFLAG = -o $(empty)
|
|
73
|
-
COUTFLAG = -o $(empty)
|
|
74
|
-
|
|
75
|
-
RUBY_EXTCONF_H =
|
|
76
|
-
cflags = $(optflags) $(debugflags) $(warnflags)
|
|
77
|
-
optflags = -O3 -fno-fast-math
|
|
78
|
-
debugflags = -ggdb3
|
|
79
|
-
warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
|
|
80
|
-
CCDLFLAGS = -fPIC
|
|
81
|
-
CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC -std=gnu99 -Wno-declaration-after-statement $(ARCH_FLAG)
|
|
82
|
-
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
|
83
|
-
DEFS =
|
|
84
|
-
CPPFLAGS = $(DEFS) $(cppflags)
|
|
85
|
-
CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
|
|
86
|
-
ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
|
|
87
|
-
dldflags =
|
|
88
|
-
ARCH_FLAG =
|
|
89
|
-
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
|
|
90
|
-
LDSHARED = $(CC) -shared
|
|
91
|
-
LDSHAREDXX = $(CXX) -shared
|
|
92
|
-
AR = ar
|
|
93
|
-
EXEEXT =
|
|
94
|
-
|
|
95
|
-
RUBY_INSTALL_NAME = ruby
|
|
96
|
-
RUBY_SO_NAME = ruby
|
|
97
|
-
RUBYW_INSTALL_NAME =
|
|
98
|
-
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
|
|
99
|
-
RUBYW_BASE_NAME = rubyw
|
|
100
|
-
RUBY_BASE_NAME = ruby
|
|
101
|
-
|
|
102
|
-
arch = x86_64-linux
|
|
103
|
-
sitearch = $(arch)
|
|
104
|
-
ruby_version = 2.1.0
|
|
105
|
-
ruby = $(bindir)/ruby
|
|
106
|
-
RUBY = $(ruby)
|
|
107
|
-
ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
|
|
108
|
-
|
|
109
|
-
RM = rm -f
|
|
110
|
-
RM_RF = $(RUBY) -run -e rm -- -rf
|
|
111
|
-
RMDIRS = rmdir --ignore-fail-on-non-empty -p
|
|
112
|
-
MAKEDIRS = /bin/mkdir -p
|
|
113
|
-
INSTALL = /usr/bin/install -c
|
|
114
|
-
INSTALL_PROG = $(INSTALL) -m 0755
|
|
115
|
-
INSTALL_DATA = $(INSTALL) -m 644
|
|
116
|
-
COPY = cp
|
|
117
|
-
TOUCH = exit >
|
|
118
|
-
|
|
119
|
-
#### End of system configuration section. ####
|
|
120
|
-
|
|
121
|
-
preload =
|
|
122
|
-
|
|
123
|
-
libpath = . $(libdir)
|
|
124
|
-
LIBPATH = -L. -L$(libdir) -Wl,-R$(libdir)
|
|
125
|
-
DEFFILE =
|
|
126
|
-
|
|
127
|
-
CLEANFILES = mkmf.log
|
|
128
|
-
DISTCLEANFILES =
|
|
129
|
-
DISTCLEANDIRS =
|
|
130
|
-
|
|
131
|
-
extout =
|
|
132
|
-
extout_prefix =
|
|
133
|
-
target_prefix =
|
|
134
|
-
LOCAL_LIBS =
|
|
135
|
-
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lcrypt -lm -lc
|
|
136
|
-
ORIG_SRCS = sstat.c
|
|
137
|
-
SRCS = $(ORIG_SRCS)
|
|
138
|
-
OBJS = sstat.o
|
|
139
|
-
HDRS = $(srcdir)/sstat.h
|
|
140
|
-
TARGET = sstat
|
|
141
|
-
TARGET_NAME = sstat
|
|
142
|
-
TARGET_ENTRY = Init_$(TARGET_NAME)
|
|
143
|
-
DLLIB = $(TARGET).so
|
|
144
|
-
EXTSTATIC =
|
|
145
|
-
STATIC_LIB =
|
|
146
|
-
|
|
147
|
-
TIMESTAMP_DIR = .
|
|
148
|
-
BINDIR = $(bindir)
|
|
149
|
-
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
|
150
|
-
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
|
151
|
-
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
|
152
|
-
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
|
153
|
-
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
|
154
|
-
|
|
155
|
-
TARGET_SO = $(DLLIB)
|
|
156
|
-
CLEANLIBS = $(TARGET).so
|
|
157
|
-
CLEANOBJS = *.o *.bak
|
|
158
|
-
|
|
159
|
-
all: $(DLLIB)
|
|
160
|
-
static: $(STATIC_LIB)
|
|
161
|
-
.PHONY: all install static install-so install-rb
|
|
162
|
-
.PHONY: clean clean-so clean-static clean-rb
|
|
163
|
-
|
|
164
|
-
clean-static::
|
|
165
|
-
clean-rb-default::
|
|
166
|
-
clean-rb::
|
|
167
|
-
clean-so::
|
|
168
|
-
clean: clean-so clean-static clean-rb-default clean-rb
|
|
169
|
-
-$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
|
|
170
|
-
|
|
171
|
-
distclean-rb-default::
|
|
172
|
-
distclean-rb::
|
|
173
|
-
distclean-so::
|
|
174
|
-
distclean-static::
|
|
175
|
-
distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
|
|
176
|
-
-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
|
177
|
-
-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
|
178
|
-
-$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
|
|
179
|
-
|
|
180
|
-
realclean: distclean
|
|
181
|
-
install: install-so install-rb
|
|
182
|
-
|
|
183
|
-
install-so: $(DLLIB) $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
|
|
184
|
-
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
|
185
|
-
clean-static::
|
|
186
|
-
-$(Q)$(RM) $(STATIC_LIB)
|
|
187
|
-
install-rb: pre-install-rb install-rb-default
|
|
188
|
-
install-rb-default: pre-install-rb-default
|
|
189
|
-
pre-install-rb: Makefile
|
|
190
|
-
pre-install-rb-default: Makefile
|
|
191
|
-
pre-install-rb-default:
|
|
192
|
-
$(ECHO) installing default sstat libraries
|
|
193
|
-
$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
|
|
194
|
-
$(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
|
|
195
|
-
$(Q) $(TOUCH) $@
|
|
196
|
-
|
|
197
|
-
site-install: site-install-so site-install-rb
|
|
198
|
-
site-install-so: install-so
|
|
199
|
-
site-install-rb: install-rb
|
|
200
|
-
|
|
201
|
-
.SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
|
|
202
|
-
|
|
203
|
-
.cc.o:
|
|
204
|
-
$(ECHO) compiling $(<)
|
|
205
|
-
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
|
206
|
-
|
|
207
|
-
.mm.o:
|
|
208
|
-
$(ECHO) compiling $(<)
|
|
209
|
-
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
|
210
|
-
|
|
211
|
-
.cxx.o:
|
|
212
|
-
$(ECHO) compiling $(<)
|
|
213
|
-
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
|
214
|
-
|
|
215
|
-
.cpp.o:
|
|
216
|
-
$(ECHO) compiling $(<)
|
|
217
|
-
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
|
218
|
-
|
|
219
|
-
.C.o:
|
|
220
|
-
$(ECHO) compiling $(<)
|
|
221
|
-
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
|
222
|
-
|
|
223
|
-
.c.o:
|
|
224
|
-
$(ECHO) compiling $(<)
|
|
225
|
-
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
|
226
|
-
|
|
227
|
-
.m.o:
|
|
228
|
-
$(ECHO) compiling $(<)
|
|
229
|
-
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
|
230
|
-
|
|
231
|
-
$(DLLIB): $(OBJS) Makefile
|
|
232
|
-
$(ECHO) linking shared-object $(DLLIB)
|
|
233
|
-
-$(Q)$(RM) $(@)
|
|
234
|
-
$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
$(OBJS): $(HDRS) $(ruby_headers)
|