sqlite3-ruby 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sqlite3-ruby might be problematic. Click here for more details.
- data/README +24 -5
- data/doc/faq/faq.html +58 -32
- data/ext/sqlite3_api/Makefile +143 -0
- data/ext/sqlite3_api/extconf.rb +7 -2
- data/ext/sqlite3_api/sqlite3_api.i +12 -0
- data/ext/sqlite3_api/sqlite3_api_wrap.c +3095 -0
- data/ext/sqlite3_api/win32/build.bat +7 -0
- data/lib/sqlite3/database.rb +4 -3
- data/lib/sqlite3/driver/dl/driver.rb +4 -0
- data/lib/sqlite3/driver/native/driver.rb +35 -10
- data/lib/sqlite3/errors.rb +1 -1
- data/lib/sqlite3/resultset.rb +1 -0
- data/lib/sqlite3/statement.rb +22 -4
- data/lib/sqlite3/translator.rb +1 -0
- data/lib/sqlite3/version.rb +1 -1
- data/test/driver/dl/tc_driver.rb +262 -260
- data/test/mocks.rb +3 -0
- data/test/tc_integration.rb +64 -16
- metadata +61 -54
- data/ext/sqlite3_api/post-clean.rb +0 -3
- data/ext/sqlite3_api/post-distclean.rb +0 -4
data/README
CHANGED
@@ -18,19 +18,38 @@ Simply do the following, after installing SQLite3:
|
|
18
18
|
Alternatively, you can download and install the RubyGem package for
|
19
19
|
SQLite3/Ruby (you must have RubyGems and SQLite3 installed, first):
|
20
20
|
|
21
|
-
gem install
|
21
|
+
gem install sqlite3-ruby
|
22
22
|
|
23
|
+
If you have sqlite3 installed in a non-standard location, you can specify the location of the include and lib files by doing:
|
24
|
+
|
25
|
+
gem install sqlite3-ruby -- --with-sqlite3-include=/opt/local/include \
|
26
|
+
--with-sqlite3-lib=/opt/local/lib
|
27
|
+
|
28
|
+
Also, the gem ships with the C source-code pre-built, so (as of version 1.1.1)
|
29
|
+
you no longer need to have SWIG installed. However, if you have SWIG installed
|
30
|
+
and you want to generate the C file yourself, you can specify the
|
31
|
+
<code>--with-swig</code> option.
|
23
32
|
|
24
33
|
== Usage
|
25
34
|
|
26
35
|
For help figuring out the SQLite3/Ruby interface, check out the
|
27
36
|
FAQ[http://sqlite-ruby.rubyforge.org/sqlite3/faq.html]. It includes examples of
|
28
37
|
usage. If you have any questions that you feel should be address in the
|
29
|
-
FAQ, please send them to
|
38
|
+
FAQ, please send them to jamis@37signals.com
|
39
|
+
|
40
|
+
== Source Code
|
41
|
+
|
42
|
+
The source repository is accessible via subversion:
|
43
|
+
|
44
|
+
svn co http://svn.jamisbuck.org/sqlite3-ruby/trunk
|
45
|
+
|
46
|
+
Individual releases are tagged in the tags directory:
|
30
47
|
|
48
|
+
svn co http://svn.jamisbuck.org/sqlite3-ruby/tags
|
31
49
|
|
32
50
|
== Contact Information
|
33
51
|
|
34
|
-
The project page is http://rubyforge.org/projects/sqlite-ruby. There, you can
|
35
|
-
links to mailing lists and forums that you can use to discuss this
|
36
|
-
there are trackers for submitting bugs and feature
|
52
|
+
The project page is http://rubyforge.org/projects/sqlite-ruby. There, you can
|
53
|
+
find links to mailing lists and forums that you can use to discuss this
|
54
|
+
library. Additionally, there are trackers for submitting bugs and feature
|
55
|
+
requests. Feel free to use them!
|
data/doc/faq/faq.html
CHANGED
@@ -62,25 +62,25 @@
|
|
62
62
|
<ul>
|
63
63
|
<li>How do I do a database query?
|
64
64
|
<ul>
|
65
|
-
<li><a href='#
|
66
|
-
<li><a href='#
|
67
|
-
<li><a href='#
|
68
|
-
<li><a href='#
|
69
|
-
<li><a href='#
|
65
|
+
<li><a href='#3228052'>I just want an array of the rows…</a></li>
|
66
|
+
<li><a href='#3227912'>I’d like to use a block to iterate through the rows…</a></li>
|
67
|
+
<li><a href='#3227772'>I need to get the column names as well as the rows…</a></li>
|
68
|
+
<li><a href='#3227652'>I just want the first row of the result set…</a></li>
|
69
|
+
<li><a href='#3227532'>I just want the first value of the first row of the result set…</a></li>
|
70
70
|
</ul>
|
71
71
|
</li>
|
72
|
-
<li><a href='#
|
73
|
-
<li><a href='#
|
74
|
-
<li><a href='#
|
75
|
-
<li><a href='#
|
76
|
-
<li><a href='#
|
77
|
-
<li><a href='#
|
78
|
-
<li><a href='#
|
79
|
-
<li><a href='#
|
80
|
-
<li><a href='#
|
72
|
+
<li><a href='#3227292'>How do I prepare a statement for repeated execution?</a></li>
|
73
|
+
<li><a href='#3227192'>How do I use placeholders in an <span class="caps">SQL</span> statement?</a></li>
|
74
|
+
<li><a href='#3227072'>How do I discover metadata about a query?</a></li>
|
75
|
+
<li><a href='#3226852'>I’d like the rows to be indexible by column name.</a></li>
|
76
|
+
<li><a href='#3226702'>I’d like the values from a query to be the correct types, instead of String.</a></li>
|
77
|
+
<li><a href='#3226552'>How do insert binary data into the database?</a></li>
|
78
|
+
<li><a href='#3226372'>How do I do a <span class="caps">DDL</span> (insert, update, delete) statement?</a></li>
|
79
|
+
<li><a href='#3226232'>How do I execute multiple statements in a single string?</a></li>
|
80
|
+
<li><a href='#3226102'>How do I begin/end a transaction?</a></li>
|
81
81
|
</ul>
|
82
82
|
</div>
|
83
|
-
<a name='
|
83
|
+
<a name='3228052'></a>
|
84
84
|
<div class='faq-title'>How do I do a database query? I just want an array of the rows…</div>
|
85
85
|
<div class='faq-answer'><p>Use the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> method. If you don’t give it a block, it will return an array of all the rows:</p>
|
86
86
|
|
@@ -91,7 +91,7 @@
|
|
91
91
|
db = SQLite3::<a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database</a>.new( "test.db" )
|
92
92
|
rows = db.execute( "select * from test" )
|
93
93
|
</pre></div>
|
94
|
-
<a name='
|
94
|
+
<a name='3227912'></a>
|
95
95
|
<div class='faq-title'>How do I do a database query? I’d like to use a block to iterate through the rows…</div>
|
96
96
|
<div class='faq-answer'><p>Use the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> method. If you give it a block, each row of the result will be yielded to the block:</p>
|
97
97
|
|
@@ -104,7 +104,7 @@
|
|
104
104
|
...
|
105
105
|
end
|
106
106
|
</pre></div>
|
107
|
-
<a name='
|
107
|
+
<a name='3227772'></a>
|
108
108
|
<div class='faq-title'>How do I do a database query? I need to get the column names as well as the rows…</div>
|
109
109
|
<div class='faq-answer'><p>Use the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute2</a> method. This works just like <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a>; if you don’t give it a block, it returns an array of rows; otherwise, it will yield each row to the block. <em>However</em>, the first row returned is always an array of the column names from the query:</p>
|
110
110
|
|
@@ -126,7 +126,7 @@
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
</pre></div>
|
129
|
-
<a name='
|
129
|
+
<a name='3227652'></a>
|
130
130
|
<div class='faq-title'>How do I do a database query? I just want the first row of the result set…</div>
|
131
131
|
<div class='faq-answer'><p>Easy. Just call <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#get_first_row</a>:</p>
|
132
132
|
|
@@ -134,8 +134,9 @@
|
|
134
134
|
<pre>
|
135
135
|
row = db.get_first_row( "select * from table" )
|
136
136
|
</pre>
|
137
|
+
|
137
138
|
<p>This also supports bind variables, just like <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> and friends.</p></div>
|
138
|
-
<a name='
|
139
|
+
<a name='3227532'></a>
|
139
140
|
<div class='faq-title'>How do I do a database query? I just want the first value of the first row of the result set…</div>
|
140
141
|
<div class='faq-answer'><p>Also easy. Just call <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#get_first_value</a>:</p>
|
141
142
|
|
@@ -143,8 +144,9 @@
|
|
143
144
|
<pre>
|
144
145
|
count = db.get_first_value( "select count(*) from table" )
|
145
146
|
</pre>
|
147
|
+
|
146
148
|
<p>This also supports bind variables, just like <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> and friends.</p></div>
|
147
|
-
<a name='
|
149
|
+
<a name='3227292'></a>
|
148
150
|
<div class='faq-title'>How do I prepare a statement for repeated execution?</div>
|
149
151
|
<div class='faq-answer'><p>If the same statement is going to be executed repeatedly, you can speed things up a bit by <em>preparing</em> the statement. You do this via the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#prepare</a> method. It returns a <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement</a> object, and you can then invoke #execute on that to get the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/ResultSet.html'>ResultSet</a>:</p>
|
150
152
|
|
@@ -170,17 +172,22 @@
|
|
170
172
|
end
|
171
173
|
end
|
172
174
|
</pre>
|
175
|
+
|
173
176
|
<p>This is made more useful by the ability to bind variables to placeholders via the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement#bind_param</a> and <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement#bind_params</a> methods. (See the next <span class="caps">FAQ</span> for details.)</p></div>
|
174
|
-
<a name='
|
177
|
+
<a name='3227192'></a>
|
175
178
|
<div class='faq-title'>How do I use placeholders in an <span class="caps">SQL</span> statement?</div>
|
176
179
|
<div class='faq-answer'><p>Placeholders in an <span class="caps">SQL</span> statement take any of the following formats:</p>
|
180
|
+
|
181
|
+
|
177
182
|
<ul>
|
178
183
|
<li><code>?</code></li>
|
179
|
-
<li><code
|
180
|
-
<li><code
|
184
|
+
<li><code>?_nnn_</code></li>
|
185
|
+
<li><code>:_word_</code></li>
|
181
186
|
</ul>
|
182
187
|
|
183
|
-
|
188
|
+
|
189
|
+
<p>Where <em>n_ is an integer, and _word</em> is an alpha-numeric identifier (or number). When the placeholder is associated with a number, that number identifies the index of the bind variable to replace it with. When it is an identifier, it identifies the name of the correponding bind variable. (In the instance of the first format-<del>a single question mark</del>-the placeholder is assigned a number one greater than the last index used, or 1 if it is the first.)</p>
|
190
|
+
|
184
191
|
|
185
192
|
<p>For example, here is a query using these placeholder formats:</p>
|
186
193
|
|
@@ -192,10 +199,13 @@
|
|
192
199
|
and d = :name
|
193
200
|
and e = :1
|
194
201
|
</pre>
|
202
|
+
|
195
203
|
<p>This defines 5 different placeholders: 1, 2, 3, and “name”.</p>
|
196
204
|
|
205
|
+
|
197
206
|
<p>You replace these placeholders by <em>binding</em> them to values. This can be accomplished in a variety of ways.</p>
|
198
207
|
|
208
|
+
|
199
209
|
<p>The <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a>, and <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute2</a> methods all accept additional arguments following the <span class="caps">SQL</span> statement. These arguments are assumed to be bind parameters, and they are bound (positionally) to their corresponding placeholders:</p>
|
200
210
|
|
201
211
|
|
@@ -204,8 +214,10 @@
|
|
204
214
|
"hello",
|
205
215
|
"world" )
|
206
216
|
</pre>
|
217
|
+
|
207
218
|
<p>The above would replace the first question mark with ‘hello’ and the second with ‘world’. If the placeholders have an explicit index given, they will be replaced with the bind parameter at that index (1-based).</p>
|
208
219
|
|
220
|
+
|
209
221
|
<p>If a Hash is given as a bind parameter, then its key/value pairs are bound to the placeholders. This is how you bind by name:</p>
|
210
222
|
|
211
223
|
|
@@ -214,6 +226,7 @@
|
|
214
226
|
"name" => "bob",
|
215
227
|
"value" => "priceless" )
|
216
228
|
</pre>
|
229
|
+
|
217
230
|
<p>You can also bind explicitly using the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement</a> object itself. Just pass additional parameters to the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement#execute</a> statement:</p>
|
218
231
|
|
219
232
|
|
@@ -222,6 +235,7 @@
|
|
222
235
|
stmt.execute "value", "name" => "bob"
|
223
236
|
end
|
224
237
|
</pre>
|
238
|
+
|
225
239
|
<p>Or do a <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#prepare</a> to get the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement</a>, and then use either <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement#bind_param</a> or <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement#bind_params</a>:</p>
|
226
240
|
|
227
241
|
|
@@ -235,10 +249,11 @@
|
|
235
249
|
|
236
250
|
stmt.bind_params( "value", "name" => "bob" )
|
237
251
|
</pre></div>
|
238
|
-
<a name='
|
252
|
+
<a name='3227072'></a>
|
239
253
|
<div class='faq-title'>How do I discover metadata about a query?</div>
|
240
254
|
<div class='faq-answer'><p>If you ever want to know the names or types of the columns in a result set, you can do it in several ways.</p>
|
241
255
|
|
256
|
+
|
242
257
|
<p>The first way is to ask the row object itself. Each row will have a property “fields” that returns an array of the column names. The row will also have a property “types” that returns an array of the column types:</p>
|
243
258
|
|
244
259
|
|
@@ -247,6 +262,7 @@
|
|
247
262
|
p rows[0].fields
|
248
263
|
p rows[0].types
|
249
264
|
</pre>
|
265
|
+
|
250
266
|
<p>Obviously, this approach requires you to execute a statement that actually returns data. If you don’t know if the statement will return any rows, but you still need the metadata, you can use <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#query</a> and ask the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/ResultSet.html'>ResultSet</a> object itself:</p>
|
251
267
|
|
252
268
|
|
@@ -257,6 +273,7 @@
|
|
257
273
|
...
|
258
274
|
end
|
259
275
|
</pre>
|
276
|
+
|
260
277
|
<p>Lastly, you can use <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#prepare</a> and ask the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement</a> object what the metadata are:</p>
|
261
278
|
|
262
279
|
|
@@ -265,10 +282,11 @@
|
|
265
282
|
p stmt.columns
|
266
283
|
p stmt.types
|
267
284
|
</pre></div>
|
268
|
-
<a name='
|
285
|
+
<a name='3226852'></a>
|
269
286
|
<div class='faq-title'>I’d like the rows to be indexible by column name.</div>
|
270
287
|
<div class='faq-answer'><p>By default, each row from a query is returned as an Array of values. This means that you can only obtain values by their index. Sometimes, however, you would like to obtain values by their column name.</p>
|
271
288
|
|
289
|
+
|
272
290
|
<p>The first way to do this is to set the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database</a> property “results_as_hash” to true. If you do this, then all rows will be returned as Hash objects, with the column names as the keys. (In this case, the “fields” property is unavailable on the row, although the “types” property remains.)</p>
|
273
291
|
|
274
292
|
|
@@ -279,6 +297,7 @@
|
|
279
297
|
p row['column2']
|
280
298
|
end
|
281
299
|
</pre>
|
300
|
+
|
282
301
|
<p>The other way is to use Ara Howard’s <a href="http://rubyforge.org/projects/arrayfields">ArrayFields</a> module. Just require “arrayfields”, and all of your rows will be indexable by column name, even though they are still arrays!</p>
|
283
302
|
|
284
303
|
|
@@ -291,7 +310,7 @@
|
|
291
310
|
p row[1] == row['column2']
|
292
311
|
end
|
293
312
|
</pre></div>
|
294
|
-
<a name='
|
313
|
+
<a name='3226702'></a>
|
295
314
|
<div class='faq-title'>I’d like the values from a query to be the correct types, instead of String.</div>
|
296
315
|
<div class='faq-answer'><p>You can turn on “type translation” by setting <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#type_translation</a> to true:</p>
|
297
316
|
|
@@ -302,8 +321,10 @@
|
|
302
321
|
p row
|
303
322
|
end
|
304
323
|
</pre>
|
324
|
+
|
305
325
|
<p>By doing this, each return value for each row will be translated to its correct type, based on its declared column type.</p>
|
306
326
|
|
327
|
+
|
307
328
|
<p>You can even declare your own translation routines, if (for example) you are using an <span class="caps">SQL</span> type that is not handled by default:</p>
|
308
329
|
|
309
330
|
|
@@ -327,7 +348,7 @@
|
|
327
348
|
obj = db.get_first_value( "select thing from objects where name='bob'" )
|
328
349
|
p obj == h
|
329
350
|
</pre></div>
|
330
|
-
<a name='
|
351
|
+
<a name='3226552'></a>
|
331
352
|
<div class='faq-title'>How do insert binary data into the database?</div>
|
332
353
|
<div class='faq-answer'><p>Use blobs. Blobs are new features of SQLite3. You have to use bind variables to make it work:</p>
|
333
354
|
|
@@ -337,19 +358,21 @@
|
|
337
358
|
SQLite3::Blob.new( "\0\1\2\3\4\5" ),
|
338
359
|
SQLite3::Blob.new( "a\0b\0c\0d ) )
|
339
360
|
</pre>
|
361
|
+
|
340
362
|
<p>The blob values must be indicated explicitly by binding each parameter to a value of type SQLite3::Blob.</p></div>
|
341
|
-
<a name='
|
342
|
-
<div class='faq-title'>How do I do a <span class="caps">DDL
|
363
|
+
<a name='3226372'></a>
|
364
|
+
<div class='faq-title'>How do I do a <span class="caps">DDL</span> (insert, update, delete) statement?</div>
|
343
365
|
<div class='faq-answer'><p>You can actually do inserts, updates, and deletes in exactly the same way as selects, but in general the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> method will be most convenient:</p>
|
344
366
|
|
345
367
|
|
346
368
|
<pre>
|
347
369
|
db.execute( "insert into table values ( ?, ? )", *bind_vars )
|
348
370
|
</pre></div>
|
349
|
-
<a name='
|
371
|
+
<a name='3226232'></a>
|
350
372
|
<div class='faq-title'>How do I execute multiple statements in a single string?</div>
|
351
373
|
<div class='faq-answer'><p>The standard query methods (<a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a>, <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute2</a>, <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#query</a>, and <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement#execute</a>) will only execute the first statement in the string that is given to them. Thus, if you have a string with multiple <span class="caps">SQL</span> statements, each separated by a string, you can’t use those methods to execute them all at once.</p>
|
352
374
|
|
375
|
+
|
353
376
|
<p>Instead, use <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute_batch</a>:</p>
|
354
377
|
|
355
378
|
|
@@ -367,16 +390,19 @@
|
|
367
390
|
|
368
391
|
db.execute_batch( sql )
|
369
392
|
</pre>
|
393
|
+
|
370
394
|
<p>Unlike the other query methods, <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute_batch</a> accepts no block. It will also only ever return <ins>nil</ins>. Thus, it is really only suitable for batch processing of <span class="caps">DDL</span> statements.</p></div>
|
371
|
-
<a name='
|
395
|
+
<a name='3226102'></a>
|
372
396
|
<div class='faq-title'>How do I begin/end a transaction?</div>
|
373
397
|
<div class='faq-answer'><p>Use <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#transaction</a> to start a transaction. If you give it a block, the block will be automatically committed at the end of the block, unless an exception was raised, in which case the transaction will be rolled back. (Never explicitly call <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#commit</a> or <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#rollback</a> inside of a transaction block—you’ll get errors when the block terminates!)</p>
|
374
398
|
|
375
399
|
|
376
400
|
<pre> database.transaction do |db| db.execute( "insert into table values ( 'a', 'b', 'c' )" ) ... end </pre>
|
401
|
+
|
377
402
|
<p>Alternatively, if you don’t give a block to <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#transaction</a>, the transaction remains open until you explicitly call <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#commit</a> or <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#rollback</a>.</p>
|
378
403
|
|
379
404
|
|
380
405
|
<pre> db.transaction db.execute( "insert into table values ( 'a', 'b', 'c' )" ) db.commit </pre>
|
406
|
+
|
381
407
|
<p>Note that SQLite does not allow nested transactions, so you’ll get errors if you try to open a new transaction while one is already active. Use <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#transaction_active</a>? to determine whether a transaction is active or not.</p></div>
|
382
408
|
</body></html>
|
@@ -0,0 +1,143 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
#### Start of system configuration section. ####
|
5
|
+
|
6
|
+
srcdir = .
|
7
|
+
topdir = /opt/local/lib/ruby/1.8/i686-darwin8.5.2
|
8
|
+
hdrdir = $(topdir)
|
9
|
+
VPATH = $(srcdir):$(topdir):$(hdrdir)
|
10
|
+
prefix = $(DESTDIR)/opt/local
|
11
|
+
exec_prefix = $(DESTDIR)/opt/local
|
12
|
+
sitedir = $(prefix)/lib/ruby/site_ruby
|
13
|
+
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
14
|
+
archdir = $(rubylibdir)/$(arch)
|
15
|
+
sbindir = $(exec_prefix)/sbin
|
16
|
+
vendordir = $(prefix)/lib/ruby/vendor_ruby
|
17
|
+
datadir = $(prefix)/share
|
18
|
+
includedir = $(prefix)/include
|
19
|
+
infodir = $(prefix)/info
|
20
|
+
sysconfdir = $(prefix)/etc
|
21
|
+
mandir = $(DESTDIR)/opt/local/share/man
|
22
|
+
libdir = $(DESTDIR)/opt/local/lib
|
23
|
+
sharedstatedir = $(prefix)/com
|
24
|
+
oldincludedir = $(DESTDIR)/usr/include
|
25
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
26
|
+
vendorarchdir = $(vendorlibdir)/$(vendorarch)
|
27
|
+
bindir = $(exec_prefix)/bin
|
28
|
+
localstatedir = $(prefix)/var
|
29
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
30
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
31
|
+
libexecdir = $(exec_prefix)/libexec
|
32
|
+
|
33
|
+
CC = gcc
|
34
|
+
LIBRUBY = $(LIBRUBY_SO)
|
35
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
36
|
+
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
37
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
38
|
+
|
39
|
+
CFLAGS = -fno-common -O -pipe -I/opt/local/include -fno-common -pipe -fno-common
|
40
|
+
CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) -DHAVE_SQLITE3_H -I/usr/local/include -O -pipe -I/opt/local/include
|
41
|
+
CXXFLAGS = $(CFLAGS)
|
42
|
+
DLDFLAGS = -L/opt/local/lib
|
43
|
+
LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace
|
44
|
+
AR = ar
|
45
|
+
EXEEXT =
|
46
|
+
|
47
|
+
RUBY_INSTALL_NAME = ruby
|
48
|
+
RUBY_SO_NAME = ruby
|
49
|
+
arch = i686-darwin8.5.2
|
50
|
+
sitearch = i686-darwin8.5.2
|
51
|
+
vendorarch = i686-darwin8.5.2
|
52
|
+
ruby_version = 1.8
|
53
|
+
ruby = /opt/local/bin/ruby
|
54
|
+
RUBY = $(ruby)
|
55
|
+
RM = rm -f
|
56
|
+
MAKEDIRS = mkdir -p
|
57
|
+
INSTALL = /usr/bin/install -c
|
58
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
59
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
60
|
+
COPY = cp
|
61
|
+
|
62
|
+
#### End of system configuration section. ####
|
63
|
+
|
64
|
+
preload =
|
65
|
+
|
66
|
+
libpath = /usr/local/lib $(libdir)
|
67
|
+
LIBPATH = -L"/usr/local/lib" -L"$(libdir)"
|
68
|
+
DEFFILE =
|
69
|
+
|
70
|
+
CLEANFILES =
|
71
|
+
DISTCLEANFILES =
|
72
|
+
|
73
|
+
extout =
|
74
|
+
extout_prefix =
|
75
|
+
target_prefix =
|
76
|
+
LOCAL_LIBS =
|
77
|
+
LIBS = $(LIBRUBYARG_SHARED) -lsqlite3 -lpthread -ldl -lobjc
|
78
|
+
SRCS = sqlite3_api_wrap.c
|
79
|
+
OBJS = sqlite3_api_wrap.o
|
80
|
+
TARGET = sqlite3_api
|
81
|
+
DLLIB = $(TARGET).bundle
|
82
|
+
STATIC_LIB =
|
83
|
+
|
84
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
85
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
86
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
87
|
+
|
88
|
+
TARGET_SO = $(DLLIB)
|
89
|
+
CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
|
90
|
+
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
|
91
|
+
|
92
|
+
all: $(DLLIB)
|
93
|
+
static: $(STATIC_LIB)
|
94
|
+
|
95
|
+
clean:
|
96
|
+
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
97
|
+
|
98
|
+
distclean: clean
|
99
|
+
@-$(RM) Makefile extconf.h conftest.* mkmf.log
|
100
|
+
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
101
|
+
|
102
|
+
realclean: distclean
|
103
|
+
install: install-so install-rb
|
104
|
+
|
105
|
+
install-so: $(RUBYARCHDIR)
|
106
|
+
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
107
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
108
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
109
|
+
install-rb: pre-install-rb install-rb-default
|
110
|
+
install-rb-default: pre-install-rb-default
|
111
|
+
pre-install-rb: Makefile
|
112
|
+
pre-install-rb-default: Makefile
|
113
|
+
$(RUBYARCHDIR):
|
114
|
+
$(MAKEDIRS) $@
|
115
|
+
|
116
|
+
site-install: site-install-so site-install-rb
|
117
|
+
site-install-so: install-so
|
118
|
+
site-install-rb: install-rb
|
119
|
+
|
120
|
+
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
121
|
+
|
122
|
+
.cc.o:
|
123
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
124
|
+
|
125
|
+
.cxx.o:
|
126
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
127
|
+
|
128
|
+
.cpp.o:
|
129
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
130
|
+
|
131
|
+
.C.o:
|
132
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
133
|
+
|
134
|
+
.c.o:
|
135
|
+
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
136
|
+
|
137
|
+
$(DLLIB): $(OBJS)
|
138
|
+
@-$(RM) $@
|
139
|
+
$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $@ $(OBJS) $(LOCAL_LIBS) $(LIBS)
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
$(OBJS): ruby.h defines.h
|