langscan 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/AUTHORS.txt +19 -0
  2. data/History.txt +126 -0
  3. data/Manifest.txt +167 -0
  4. data/README.rdoc +89 -0
  5. data/Rakefile +40 -0
  6. data/ext/langscan/_make_c.rb +20 -0
  7. data/ext/langscan/_make_h.rb +30 -0
  8. data/ext/langscan/_template.c +134 -0
  9. data/ext/langscan/_template.h +53 -0
  10. data/ext/langscan/c/c/Makefile +157 -0
  11. data/ext/langscan/c/c/c.c +134 -0
  12. data/ext/langscan/c/c/c.h +66 -0
  13. data/ext/langscan/c/c/ctok.c +4622 -0
  14. data/ext/langscan/c/c/ctok.l +212 -0
  15. data/ext/langscan/c/c/extconf.rb +3 -0
  16. data/ext/langscan/c/c/modulename.txt +1 -0
  17. data/ext/langscan/c/c/tokenlist.txt +13 -0
  18. data/ext/langscan/csharp/csharp/Makefile +157 -0
  19. data/ext/langscan/csharp/csharp/csharp.c +134 -0
  20. data/ext/langscan/csharp/csharp/csharp.h +65 -0
  21. data/ext/langscan/csharp/csharp/csharptok.c +2965 -0
  22. data/ext/langscan/csharp/csharp/csharptok.l +200 -0
  23. data/ext/langscan/csharp/csharp/extconf.rb +3 -0
  24. data/ext/langscan/csharp/csharp/modulename.txt +1 -0
  25. data/ext/langscan/csharp/csharp/tokenlist.txt +12 -0
  26. data/ext/langscan/d/d/Makefile +157 -0
  27. data/ext/langscan/d/d/d.c +134 -0
  28. data/ext/langscan/d/d/d.h +64 -0
  29. data/ext/langscan/d/d/dtok.c +5461 -0
  30. data/ext/langscan/d/d/dtok.l +282 -0
  31. data/ext/langscan/d/d/extconf.rb +3 -0
  32. data/ext/langscan/d/d/modulename.txt +1 -0
  33. data/ext/langscan/d/d/tokenlist.txt +11 -0
  34. data/ext/langscan/elisp/elisp/Makefile +157 -0
  35. data/ext/langscan/elisp/elisp/elisp.c +134 -0
  36. data/ext/langscan/elisp/elisp/elisp.h +62 -0
  37. data/ext/langscan/elisp/elisp/elisptok.c +2101 -0
  38. data/ext/langscan/elisp/elisp/elisptok.l +151 -0
  39. data/ext/langscan/elisp/elisp/extconf.rb +3 -0
  40. data/ext/langscan/elisp/elisp/modulename.txt +1 -0
  41. data/ext/langscan/elisp/elisp/tokenlist.txt +9 -0
  42. data/ext/langscan/java/java/Makefile +157 -0
  43. data/ext/langscan/java/java/extconf.rb +3 -0
  44. data/ext/langscan/java/java/java.c +134 -0
  45. data/ext/langscan/java/java/java.h +64 -0
  46. data/ext/langscan/java/java/javatok.c +2090 -0
  47. data/ext/langscan/java/java/javatok.l +155 -0
  48. data/ext/langscan/java/java/modulename.txt +1 -0
  49. data/ext/langscan/java/java/tokenlist.txt +11 -0
  50. data/ext/langscan/javascript/javascript/Makefile +157 -0
  51. data/ext/langscan/javascript/javascript/extconf.rb +3 -0
  52. data/ext/langscan/javascript/javascript/javascript.c +134 -0
  53. data/ext/langscan/javascript/javascript/javascript.h +63 -0
  54. data/ext/langscan/javascript/javascript/javascripttok.c +2051 -0
  55. data/ext/langscan/javascript/javascript/javascripttok.l +147 -0
  56. data/ext/langscan/javascript/javascript/modulename.txt +1 -0
  57. data/ext/langscan/javascript/javascript/tokenlist.txt +10 -0
  58. data/ext/langscan/pairmatcher/pairmatcher/Makefile +157 -0
  59. data/ext/langscan/pairmatcher/pairmatcher/extconf.rb +3 -0
  60. data/ext/langscan/pairmatcher/pairmatcher/pairmatcher.c +890 -0
  61. data/ext/langscan/php/php/Makefile +157 -0
  62. data/ext/langscan/php/php/extconf.rb +3 -0
  63. data/ext/langscan/php/php/modulename.txt +1 -0
  64. data/ext/langscan/php/php/php.c +134 -0
  65. data/ext/langscan/php/php/php.h +64 -0
  66. data/ext/langscan/php/php/phptok.c +2406 -0
  67. data/ext/langscan/php/php/phptok.l +212 -0
  68. data/ext/langscan/php/php/tokenlist.txt +11 -0
  69. data/ext/langscan/post-distclean.rb +21 -0
  70. data/ext/langscan/pre-config.rb +57 -0
  71. data/ext/langscan/python/python/Makefile +157 -0
  72. data/ext/langscan/python/python/extconf.rb +3 -0
  73. data/ext/langscan/python/python/modulename.txt +1 -0
  74. data/ext/langscan/python/python/python.c +134 -0
  75. data/ext/langscan/python/python/python.h +61 -0
  76. data/ext/langscan/python/python/pythontok.c +2102 -0
  77. data/ext/langscan/python/python/pythontok.l +155 -0
  78. data/ext/langscan/python/python/tokenlist.txt +8 -0
  79. data/ext/langscan/ruby/compat/ripper/Makefile +158 -0
  80. data/ext/langscan/ruby/compat/ripper/depend +1 -0
  81. data/ext/langscan/ruby/compat/ripper/extconf.rb +4 -0
  82. data/ext/langscan/ruby/compat/ripper/include/eventids1.c +251 -0
  83. data/ext/langscan/ruby/compat/ripper/include/eventids2.c +277 -0
  84. data/ext/langscan/ruby/compat/ripper/include/lex.c +138 -0
  85. data/ext/langscan/ruby/compat/ripper/ripper.c +14420 -0
  86. data/ext/langscan/scheme/scheme/Makefile +157 -0
  87. data/ext/langscan/scheme/scheme/extconf.rb +3 -0
  88. data/ext/langscan/scheme/scheme/modulename.txt +1 -0
  89. data/ext/langscan/scheme/scheme/scheme.c +134 -0
  90. data/ext/langscan/scheme/scheme/scheme.h +60 -0
  91. data/ext/langscan/scheme/scheme/schemetok.c +2447 -0
  92. data/ext/langscan/scheme/scheme/schemetok.l +177 -0
  93. data/ext/langscan/scheme/scheme/tokenlist.txt +7 -0
  94. data/ext/langscan/sh/sh/Makefile +157 -0
  95. data/ext/langscan/sh/sh/extconf.rb +3 -0
  96. data/ext/langscan/sh/sh/modulename.txt +1 -0
  97. data/ext/langscan/sh/sh/sh.c +134 -0
  98. data/ext/langscan/sh/sh/sh.h +61 -0
  99. data/ext/langscan/sh/sh/shtok.c +2470 -0
  100. data/ext/langscan/sh/sh/shtok.l +325 -0
  101. data/ext/langscan/sh/sh/tokenlist.txt +8 -0
  102. data/lib/langscan.rb +124 -0
  103. data/lib/langscan/_common.rb +50 -0
  104. data/lib/langscan/_easyscanner.rb +78 -0
  105. data/lib/langscan/_pairmatcher.rb +46 -0
  106. data/lib/langscan/_type.rb +125 -0
  107. data/lib/langscan/autoconf.rb +51 -0
  108. data/lib/langscan/automake.rb +51 -0
  109. data/lib/langscan/brainfuck.rb +48 -0
  110. data/lib/langscan/c.rb +144 -0
  111. data/lib/langscan/csharp.rb +101 -0
  112. data/lib/langscan/css.rb +109 -0
  113. data/lib/langscan/d.rb +201 -0
  114. data/lib/langscan/eiffel.rb +167 -0
  115. data/lib/langscan/elisp.rb +132 -0
  116. data/lib/langscan/io.rb +84 -0
  117. data/lib/langscan/java.rb +95 -0
  118. data/lib/langscan/javascript.rb +97 -0
  119. data/lib/langscan/lua.rb +116 -0
  120. data/lib/langscan/ocaml.rb +298 -0
  121. data/lib/langscan/ocaml/camlexer.ml +28 -0
  122. data/lib/langscan/ocaml/lexer.mll +230 -0
  123. data/lib/langscan/ocaml/types.ml +36 -0
  124. data/lib/langscan/perl.rb +87 -0
  125. data/lib/langscan/perl/tokenizer.pl +231 -0
  126. data/lib/langscan/php.rb +80 -0
  127. data/lib/langscan/python.rb +101 -0
  128. data/lib/langscan/rpmspec.rb +71 -0
  129. data/lib/langscan/ruby.rb +164 -0
  130. data/lib/langscan/ruby/compat/README +5 -0
  131. data/lib/langscan/ruby/compat/ripper.rb +4 -0
  132. data/lib/langscan/ruby/compat/ripper/core.rb +918 -0
  133. data/lib/langscan/ruby/compat/ripper/filter.rb +70 -0
  134. data/lib/langscan/ruby/compat/ripper/lexer.rb +179 -0
  135. data/lib/langscan/ruby/compat/ripper/sexp.rb +100 -0
  136. data/lib/langscan/scheme.rb +160 -0
  137. data/lib/langscan/sh.rb +116 -0
  138. data/lib/langscan/text.rb +37 -0
  139. data/metaconfig +2 -0
  140. data/script/console +10 -0
  141. data/script/destroy +14 -0
  142. data/script/generate +14 -0
  143. data/script/makemanifest.rb +21 -0
  144. data/setup.rb +1604 -0
  145. data/tasks/extconf.rake +13 -0
  146. data/tasks/extconf/langscan.rake +42 -0
  147. data/test/langscan/brainfuck/test/test_scan.rb +55 -0
  148. data/test/langscan/c/test/test_scan.rb +216 -0
  149. data/test/langscan/c/test/test_token.rb +41 -0
  150. data/test/langscan/csharp/test/test_scan.rb +157 -0
  151. data/test/langscan/css/test/test_css.rb +79 -0
  152. data/test/langscan/d/test/test_scan.rb +233 -0
  153. data/test/langscan/d/test/test_token.rb +205 -0
  154. data/test/langscan/eiffel/test/test_eiffel.rb +95 -0
  155. data/test/langscan/elisp/test/test_elisp.rb +177 -0
  156. data/test/langscan/io/test/test_io.rb +79 -0
  157. data/test/langscan/java/test/test_java.rb +74 -0
  158. data/test/langscan/javascript/test/test_javascript.rb +39 -0
  159. data/test/langscan/lua/test/test_lua.rb +69 -0
  160. data/test/langscan/ocaml/test/test_ocaml.rb +161 -0
  161. data/test/langscan/php/test/test_scan.rb +138 -0
  162. data/test/langscan/python/test/test_scan.rb +105 -0
  163. data/test/langscan/rpmspec/test/test_rpmspec.rb +51 -0
  164. data/test/langscan/ruby/test/test_scan.rb +71 -0
  165. data/test/langscan/scheme/test/test_scan.rb +198 -0
  166. data/test/test_helper.rb +7 -0
  167. data/test/test_langscan.rb +123 -0
  168. metadata +296 -0
@@ -0,0 +1,212 @@
1
+ /*
2
+ * phptok.l - a lex rule for PHP
3
+ *
4
+ * Copyright (C) 2005 MATSUNO Tokuhiro <tokuhirom at yahoo.co.jp>
5
+ * All rights reserved.
6
+ * This is free software with ABSOLUTELY NO WARRANTY.
7
+ *
8
+ * You can redistribute it and/or modify it under the terms of
9
+ * the GNU General Public License version 2.
10
+ */
11
+
12
+ %option reentrant
13
+ %option prefix="langscan_php_lex_"
14
+ %option noyywrap
15
+ %option nodefault
16
+
17
+ %x CLASSDEF
18
+ %x FUNDEF
19
+ %x SCRIPT
20
+ %x HEREDOC
21
+ %x HEREDOCBEG
22
+
23
+ newline (\r\n|\r|\n)
24
+ escseq \\.
25
+ string '([^\\\']|{escseq})*'|\"([^\\\"]|{escseq})*\"
26
+ integer 0x[0-9a-fA-F]+|[0-9]+
27
+ pointfloat [0-9]*\.[0-9]+|[0-9]+\.[0-9]*
28
+ exponent [eE][+\-][0-9]+
29
+ ident [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
30
+ floatnumber {pointfloat}{exponent}?|[0-9]+{exponent}
31
+ space [ \t\r\n]
32
+
33
+ slash \/
34
+ star \*
35
+ nonstar [^\*]
36
+ nonslashstar [^\/\*]
37
+ commentcontent {star}+{nonslashstar}{nonstar}*
38
+ mullinecomment {slash}{star}{nonstar}*{commentcontent}*{star}+{slash}
39
+
40
+ %{
41
+
42
+ #include "php.h"
43
+
44
+ #define YY_EXTRA_TYPE langscan_php_lex_extra_t *
45
+
46
+ #if YY_NULL != 0
47
+ #error "YY_NULL is not 0."
48
+ #endif
49
+
50
+ #define YY_DECL langscan_php_token_t langscan_php_lex_lex(yyscan_t yyscanner)
51
+
52
+ #define YY_INPUT(buf,result,max_size) \
53
+ if (!yyextra->eof) { \
54
+ result = yyextra->user_read(&(yyextra->user_data), (buf), (max_size)); \
55
+ if (result == 0) \
56
+ yyextra->eof = 1; \
57
+ }
58
+
59
+ #define UPD update_pos(yyextra, yytext, yyleng)
60
+ static void update_pos(langscan_php_lex_extra_t *, char *, int);
61
+
62
+ #define report(token) \
63
+ do { \
64
+ yyextra->text = yytext; \
65
+ yyextra->leng = yyleng; \
66
+ return langscan_php_##token; \
67
+ } while (0)
68
+
69
+ char *heredocident=NULL;
70
+ int heredocidentlen=0;
71
+ %}
72
+
73
+
74
+ %%
75
+ <INITIAL>"<script"{space}+language{space}*={space}*(php|\"php\"|\'php\'){space}*> { UPD; BEGIN(SCRIPT); report(ident);}
76
+ <INITIAL><%=?|"<?"=? { UPD; BEGIN(SCRIPT); report(ident);}
77
+ <INITIAL>"<?php"{space} { UPD; BEGIN(SCRIPT); report(ident);}
78
+ <INITIAL>([^<]|<[^?s%])+ { UPD; report(comment);}
79
+ <INITIAL>. { UPD; report(comment);}
80
+
81
+ <HEREDOC>{ident};?{newline} {
82
+ int identlen = strpbrk(yytext, ";\r\n")-yytext;
83
+ if (heredocidentlen==identlen && !strncmp(heredocident, yytext, identlen)) {
84
+ free(heredocident);
85
+ heredocident = NULL;
86
+ BEGIN(SCRIPT);
87
+ yyless(0);
88
+ } else {
89
+ UPD;
90
+ report(string);
91
+ }
92
+ }
93
+ <HEREDOC>[^\r\n]*{newline} { UPD; report(string);}
94
+
95
+ <HEREDOCBEG>[ \t]* { UPD; report(space); }
96
+ <HEREDOCBEG>{ident} { UPD; heredocident=strdup(yytext); heredocidentlen=yyleng; report(ident); }
97
+ <HEREDOCBEG>{newline} { UPD;
98
+ if(heredocident) {
99
+ BEGIN(HEREDOC);
100
+ report(space);
101
+ } else { /* invalid here-document */
102
+ BEGIN(SCRIPT);
103
+ report(space);
104
+ }
105
+ }
106
+
107
+ <SCRIPT>class { UPD; BEGIN(CLASSDEF); report(keyword); }
108
+ <SCRIPT>function { UPD; BEGIN(FUNDEF); report(keyword); }
109
+ <CLASSDEF>{ident} { UPD; BEGIN(SCRIPT); report(classdef); }
110
+ <FUNDEF>{ident} { UPD; BEGIN(SCRIPT); report(fundef); }
111
+ <SCRIPT><<< { UPD; BEGIN(HEREDOCBEG); report(punct); }
112
+ <SCRIPT>::|<>|=>|"++"|--|"||"|&&|AND|XOR|<<|>> { UPD; report(punct); }
113
+ <SCRIPT,FUNDEF>[={}+\-;:,.\[\]()|^&/*%!~$<>?@] { UPD; report(punct); }
114
+ <SCRIPT>(==|!=|<<|>>)= { UPD; report(punct); }
115
+ <SCRIPT>[<>+\-!*/.%&|^]= { UPD; report(punct); }
116
+ <SCRIPT>[?%]>|"</script"{space}*">" { UPD; BEGIN(INITIAL); report(ident);}
117
+ <SCRIPT,CLASSDEF,FUNDEF>{mullinecomment} { UPD; report(comment);}
118
+ <SCRIPT,CLASSDEF,FUNDEF>[ \t\f]+ { UPD; report(space); }
119
+ <SCRIPT,CLASSDEF,FUNDEF>{newline} { UPD; report(space); }
120
+ <SCRIPT,CLASSDEF,FUNDEF>(#|"//")([^?%\r\n]|[?%][^>])*{newline}? { UPD; report(comment); }
121
+ <SCRIPT>{string} { UPD; report(string); }
122
+ <SCRIPT>{integer} { UPD; report(integer); }
123
+ <SCRIPT>{floatnumber} { UPD; report(floating); }
124
+ <SCRIPT>{ident}{space}*\( { yyless(strpbrk(yytext, " \t\b\f\r\n(")-yytext); UPD; report(funcall); }
125
+ <SCRIPT>\$?{ident} { UPD; report(ident); }
126
+ <SCRIPT,HEREDOCBEG,FUNDEF,CLASSDEF>. { UPD; fprintf(stderr, "Token Error : %s\n", yytext); report(punct); }
127
+
128
+ %%
129
+
130
+ static void update_pos(
131
+ langscan_php_lex_extra_t *extra,
132
+ char *text,
133
+ int leng)
134
+ {
135
+ int i, j;
136
+ extra->beg_byteno = extra->end_byteno;
137
+ extra->beg_lineno = extra->end_lineno;
138
+ extra->beg_columnno = extra->end_columnno;
139
+ j = 0;
140
+ for (i = 0; i < leng; i++) {
141
+ if (text[i] == '\r' || (i == 0 || text[i - 1] != '\r') && text[i] == '\n') {
142
+ extra->end_lineno++;
143
+ j = i + 1;
144
+ extra->end_columnno = 0;
145
+ }
146
+ }
147
+ extra->end_columnno += leng - j;
148
+ extra->end_byteno += leng;
149
+ }
150
+
151
+ langscan_php_tokenizer_t *langscan_php_make_tokenizer(
152
+ size_t (*user_read)(void **user_data_p, char *buf, size_t maxlen),
153
+ void *user_data)
154
+ {
155
+ langscan_php_tokenizer_t *tokenizer;
156
+ langscan_php_lex_extra_t *extra;
157
+ tokenizer = (langscan_php_tokenizer_t *)malloc(sizeof(langscan_php_tokenizer_t));
158
+ if (tokenizer == NULL)
159
+ return NULL;
160
+ extra = (langscan_php_lex_extra_t *)malloc(sizeof(langscan_php_lex_extra_t));
161
+ if (extra == NULL)
162
+ return NULL;
163
+ extra->user_read = user_read;
164
+ extra->user_data = user_data;
165
+ extra->beg_lineno = 1;
166
+ extra->beg_columnno = 0;
167
+ extra->beg_byteno = 0;
168
+ extra->end_lineno = 1;
169
+ extra->end_columnno = 0;
170
+ extra->end_byteno = 0;
171
+ extra->eof = 0;
172
+ tokenizer->extra = extra;
173
+ langscan_php_lex_lex_init(&tokenizer->scanner);
174
+ langscan_php_lex_set_extra(extra, tokenizer->scanner);
175
+ return tokenizer;
176
+ }
177
+
178
+ langscan_php_token_t langscan_php_get_token(langscan_php_tokenizer_t *tokenizer)
179
+ {
180
+ return langscan_php_lex_lex(tokenizer->scanner);
181
+ }
182
+
183
+ void langscan_php_free_tokenizer(langscan_php_tokenizer_t *tokenizer)
184
+ {
185
+ langscan_php_lex_extra_t *extra = langscan_php_lex_get_extra(tokenizer->scanner);
186
+ free((void *)extra);
187
+ langscan_php_lex_lex_destroy(tokenizer->scanner);
188
+ free((void *)tokenizer);
189
+ free(heredocident);
190
+ }
191
+
192
+ user_read_t langscan_php_tokenizer_get_user_read(langscan_php_tokenizer_t *tokenizer)
193
+ {
194
+ return tokenizer->extra->user_read;
195
+ }
196
+
197
+ void *langscan_php_tokenizer_get_user_data(langscan_php_tokenizer_t *tokenizer)
198
+ {
199
+ return tokenizer->extra->user_data;
200
+ }
201
+
202
+ const char *langscan_php_token_name(langscan_php_token_t token)
203
+ {
204
+ static char *token_names[] = {
205
+ "*eof*",
206
+ #define LANGSCAN_PHP_TOKEN(name) #name,
207
+ LANGSCAN_PHP_TOKEN_LIST
208
+ #undef LANGSCAN_PHP_TOKEN
209
+ };
210
+
211
+ return token_names[token];
212
+ }
@@ -0,0 +1,11 @@
1
+ integer
2
+ floating
3
+ string
4
+ ident
5
+ keyword
6
+ fundef
7
+ funcall
8
+ classdef
9
+ punct
10
+ comment
11
+ space
@@ -0,0 +1,21 @@
1
+ require "fileutils"
2
+
3
+ def remove(iPath)
4
+ if ( File.exist?( iPath ) )
5
+ File.delete( iPath )
6
+ end
7
+ end
8
+
9
+ srcdirectories.each do |sub_name|
10
+ path = File.join( curr_srcdir, sub_name, sub_name )
11
+
12
+ flex_file = ( sub_name + "tok.l" )
13
+ flex_file = File.join( path, flex_file )
14
+ next unless ( File.file?( flex_file ) )
15
+ flex_outh = File.basename( flex_file, ".l" ) << ".h"
16
+ flex_outc = File.basename( flex_file, ".l" ) << ".c"
17
+ [flex_outh, flex_outc, sub_name + ".h", sub_name + ".c", "extconf.rb"].each do |x|
18
+ x = File.join( path, x )
19
+ remove( x )
20
+ end
21
+ end
@@ -0,0 +1,57 @@
1
+ require "fileutils"
2
+
3
+ r = system( "flex -V" )
4
+ unless ( r )
5
+ raise "not available flex command."
6
+ end
7
+
8
+ ruby_exe = "ruby"
9
+ flex_exe = "flex"
10
+ nounistd = ( "yes" == config('nounistd') ? '--nounistd' : '' )
11
+
12
+
13
+ srcdirectories.each do |sub_name|
14
+ path = File.join( curr_srcdir, sub_name, sub_name )
15
+
16
+ flex_file = ( sub_name + "tok.l" )
17
+ flex_file = File.join( path, flex_file )
18
+ next unless ( File.file?( flex_file ) )
19
+
20
+ flex_out = File.basename( flex_file, ".l" ) << ".c"
21
+ flex_out = File.join( path, flex_out )
22
+ dist = flex_out + ".dist"
23
+
24
+ module_name = File.read( File.join( path, "modulename.txt" ) )
25
+
26
+ r = system( %Q;#{flex_exe} #{nounistd} -L -t "#{flex_file}" > "#{flex_out}"; )
27
+ if ( r && File.exist?( dist ) )
28
+ FileUtils.copy( dist, flex_out )
29
+ end
30
+
31
+ # cmp -s javatok.c javatok.c.dist
32
+ if ( File.exist?( dist ) )
33
+ s = File.read( flex_out ).gsub( /\s+/m, " " )
34
+ d = File.read( dist ).gsub( /\s+/m, " " )
35
+ if ( s != d )
36
+ FileUtils.copy( flex_out, dist )
37
+ end
38
+ end
39
+
40
+ mh = File.join( curr_srcdir, "_make_h.rb" )
41
+ tp = File.join( curr_srcdir, "_template.h" )
42
+ tl = File.join( curr_srcdir, sub_name, sub_name, "tokenlist.txt" )
43
+ r = system( %Q;#{ruby_exe} "#{mh}" "#{tp}" "#{path}" "#{tl}" #{sub_name} #{module_name}; )
44
+ raise "fail: _make_h.rb #{sub_name}." unless (r)
45
+ mc = File.join( curr_srcdir, "_make_c.rb" )
46
+ tp = File.join( curr_srcdir, "_template.c" )
47
+ r = system( %Q;#{ruby_exe} "#{mc}" "#{tp}" "#{path}" #{sub_name} #{module_name}; )
48
+ raise "fail: _make_c.rb #{sub_name}." unless (r)
49
+
50
+ open( File.join( path, "extconf.rb" ), "w" ) do |h|
51
+ h.write( <<-EOS )
52
+ require "mkmf"
53
+ dir_config( 'include' )
54
+ create_makefile('langscan/#{sub_name}/#{sub_name}')
55
+ EOS
56
+ end
57
+ end
@@ -0,0 +1,157 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ #### Start of system configuration section. ####
5
+
6
+ srcdir = /Users/osuka/devel/git/langscan/ext/langscan/python/python
7
+ topdir = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0
8
+ hdrdir = $(topdir)
9
+ VPATH = $(srcdir):$(topdir):$(hdrdir)
10
+ exec_prefix = $(prefix)
11
+ prefix = $(DESTDIR)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr
12
+ sharedstatedir = $(prefix)/com
13
+ mandir = $(DESTDIR)/usr/share/man
14
+ psdir = $(docdir)
15
+ oldincludedir = $(DESTDIR)/usr/include
16
+ localedir = $(datarootdir)/locale
17
+ bindir = $(exec_prefix)/bin
18
+ libexecdir = $(exec_prefix)/libexec
19
+ sitedir = $(DESTDIR)/Library/Ruby/Site
20
+ htmldir = $(docdir)
21
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
22
+ includedir = $(prefix)/include
23
+ infodir = $(DESTDIR)/usr/share/info
24
+ vendorlibdir = $(vendordir)/$(ruby_version)
25
+ sysconfdir = $(prefix)/etc
26
+ libdir = $(exec_prefix)/lib
27
+ sbindir = $(exec_prefix)/sbin
28
+ rubylibdir = $(libdir)/ruby/$(ruby_version)
29
+ docdir = $(datarootdir)/doc/$(PACKAGE)
30
+ dvidir = $(docdir)
31
+ vendordir = $(libdir)/ruby/vendor_ruby
32
+ datarootdir = $(prefix)/share
33
+ pdfdir = $(docdir)
34
+ archdir = $(rubylibdir)/$(arch)
35
+ sitearchdir = $(sitelibdir)/$(sitearch)
36
+ datadir = $(datarootdir)
37
+ localstatedir = $(prefix)/var
38
+ sitelibdir = $(sitedir)/$(ruby_version)
39
+
40
+ CC = gcc
41
+ LIBRUBY = $(LIBRUBY_SO)
42
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
43
+ LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
44
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)
45
+
46
+ RUBY_EXTCONF_H =
47
+ CFLAGS = -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common $(cflags)
48
+ INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
49
+ DEFS =
50
+ CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
51
+ CXXFLAGS = $(CFLAGS)
52
+ ldflags = -L. -arch i386 -arch x86_64
53
+ dldflags =
54
+ archflag =
55
+ DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
56
+ LDSHARED = cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup
57
+ AR = ar
58
+ EXEEXT =
59
+
60
+ RUBY_INSTALL_NAME = ruby
61
+ RUBY_SO_NAME = ruby
62
+ arch = universal-darwin10.0
63
+ sitearch = universal-darwin10.0
64
+ ruby_version = 1.8
65
+ ruby = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
66
+ RUBY = $(ruby)
67
+ RM = rm -f
68
+ MAKEDIRS = mkdir -p
69
+ INSTALL = /usr/bin/install -c
70
+ INSTALL_PROG = $(INSTALL) -m 0755
71
+ INSTALL_DATA = $(INSTALL) -m 644
72
+ COPY = cp
73
+
74
+ #### End of system configuration section. ####
75
+
76
+ preload =
77
+
78
+ libpath = . $(libdir)
79
+ LIBPATH = -L. -L$(libdir)
80
+ DEFFILE =
81
+
82
+ CLEANFILES = mkmf.log
83
+ DISTCLEANFILES =
84
+
85
+ extout =
86
+ extout_prefix =
87
+ target_prefix = /langscan/python
88
+ LOCAL_LIBS =
89
+ LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl
90
+ SRCS = python.c pythontok.c
91
+ OBJS = python.o pythontok.o
92
+ TARGET = python
93
+ DLLIB = $(TARGET).bundle
94
+ EXTSTATIC =
95
+ STATIC_LIB =
96
+
97
+ BINDIR = $(bindir)
98
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
99
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
100
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
101
+
102
+ TARGET_SO = $(DLLIB)
103
+ CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
104
+ CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
105
+
106
+ all: $(DLLIB)
107
+ static: $(STATIC_LIB)
108
+
109
+ clean:
110
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
111
+
112
+ distclean: clean
113
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
114
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
115
+
116
+ realclean: distclean
117
+ install: install-so install-rb
118
+
119
+ install-so: $(RUBYARCHDIR)
120
+ install-so: $(RUBYARCHDIR)/$(DLLIB)
121
+ $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
122
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
123
+ install-rb: pre-install-rb install-rb-default
124
+ install-rb-default: pre-install-rb-default
125
+ pre-install-rb: Makefile
126
+ pre-install-rb-default: Makefile
127
+ $(RUBYARCHDIR):
128
+ $(MAKEDIRS) $@
129
+
130
+ site-install: site-install-so site-install-rb
131
+ site-install-so: install-so
132
+ site-install-rb: install-rb
133
+
134
+ .SUFFIXES: .c .m .cc .cxx .cpp .C .o
135
+
136
+ .cc.o:
137
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
138
+
139
+ .cxx.o:
140
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
141
+
142
+ .cpp.o:
143
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
144
+
145
+ .C.o:
146
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
147
+
148
+ .c.o:
149
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
150
+
151
+ $(DLLIB): $(OBJS) Makefile
152
+ @-$(RM) $@
153
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
154
+
155
+
156
+
157
+ $(OBJS): ruby.h defines.h