FreeBSD上のruby 2.2.xでgem sqlite3がインストールできなかった

* FreeBSDでsqlite3のgemをインストールするには、以下のようにsqlite3のヘッダファイルの位置などを補ってやる必要が従来からあった。

```bash
gem install sqlite3 -- --with-sqlite3-lib=/usr/local/lib --with-sqlite3-include=/usr/local/include
```
* Ruby 2.2では、それに加え、以下のようなコンパイルエラーが発生する。これはruby/ruby.hからマクロが削除されているためである。
 
```text
sqlite3.c:35:20: warning: implicit declaration of function 'RBIGNUM' is invalid in C99 [-Wimplicit-function-declaration]
  const long len = RBIGNUM_LEN(value);
                   ^
sqlite3.c:33:27: note: expanded from macro 'RBIGNUM_LEN'
#   define RBIGNUM_LEN(x) RBIGNUM(x)->len
                          ^
sqlite3.c:35:20: error: member reference type 'int' is not a pointer
  const long len = RBIGNUM_LEN(value);
                   ^~~~~~~~~~~~~~~~~~
sqlite3.c:33:39: note: expanded from macro 'RBIGNUM_LEN'
#   define RBIGNUM_LEN(x) RBIGNUM(x)->len
                          ~~~~~~~~~~  ^
sqlite3.c:40:19: error: use of undeclared identifier 'SIZEOF_BDIGITS'
  if (len > 63 / (SIZEOF_BDIGITS * CHAR_BIT) + 1) return 0;
                  ^
sqlite3.c:41:20: error: use of undeclared identifier 'SIZEOF_BDIGITS'
  if (len == 63 / (SIZEOF_BDIGITS * CHAR_BIT) + 1) {
                   ^
sqlite3.c:42:11: error: unknown type name 'BDIGIT'
    const BDIGIT *digits = RBIGNUM_DIGITS(value);
          ^
sqlite3.c:42:28: warning: implicit declaration of function 'RBIGNUM_DIGITS' is invalid in C99 [-Wimplicit-function-declaration]
    const BDIGIT *digits = RBIGNUM_DIGITS(value);
                           ^
sqlite3.c:43:5: error: use of undeclared identifier 'BDIGIT'
    BDIGIT blast = digits[len-1];
    ^
sqlite3.c:44:5: error: use of undeclared identifier 'BDIGIT'
    BDIGIT bmax = (BDIGIT)1UL << (63 % (CHAR_BIT * SIZEOF_BDIGITS));
    ^
sqlite3.c:45:9: error: use of undeclared identifier 'blast'
    if (blast > bmax) return 0;
        ^
sqlite3.c:45:17: error: use of undeclared identifier 'bmax'; did you mean 'fmax'?
    if (blast > bmax) return 0;
                ^~~~
                fmax
/usr/include/math.h:313:8: note: 'fmax' declared here
double  fmax(double, double) __pure2;
        ^
sqlite3.c:46:9: error: use of undeclared identifier 'blast'
    if (blast == bmax) {
        ^
sqlite3.c:46:18: error: use of undeclared identifier 'bmax'; did you mean 'fmax'?
    if (blast == bmax) {
                 ^~~~
                 fmax
/usr/include/math.h:313:8: note: 'fmax' declared here
double  fmax(double, double) __pure2;
        ^
2 warnings and 10 errors generated.
*** Error code 1

Stop.
make: stopped in /usr/home/(snip)/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.10/ext/sqlite3

make failed, exit code 1
```

* 弥縫策として、以下の記述をsqlite3_ruby.hに加えた。

```c
struct RBignum {
    struct RBasic basic;
    char sign;
    long len;
    void *digits;
};
#define RBIGNUM_SIGN(b) (FIX2LONG(rb_big_cmp((b), INT2FIX(0))) >= 0)
#define RBIGNUM_POSITIVE_P(b) (FIX2LONG(rb_big_cmp((b), INT2FIX(0))) >= 0)
#define RBIGNUM_NEGATIVE_P(b) (FIX2LONG(rb_big_cmp((b), INT2FIX(0))) < 0)
#define RBIGNUM_DIGITS(b)     (RBIGNUM(b)->digits)

#define R_CAST(st)   (struct st*)
#define RBASIC(obj)  (R_CAST(RBasic)(obj))
#define ROBJECT(obj) (R_CAST(RObject)(obj))
#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
#define RCLASS(obj)  (R_CAST(RClass)(obj))
#define RMODULE(obj) RCLASS(obj)
#define RSTRING(obj) (R_CAST(RString)(obj))
#define RREGEXP(obj) (R_CAST(RRegexp)(obj))
#define RARRAY(obj)  (R_CAST(RArray)(obj))
#define RDATA(obj)   (R_CAST(RData)(obj))
#define RTYPEDDATA(obj)   (R_CAST(RTypedData)(obj))
#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
#define RFILE(obj)   (R_CAST(RFile)(obj))

#ifndef BDIGIT
# if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
#  define BDIGIT unsigned int
#  define SIZEOF_BDIGITS SIZEOF_INT
#  define BDIGIT_DBL unsigned LONG_LONG
#  define BDIGIT_DBL_SIGNED LONG_LONG
#  define PRI_BDIGIT_PREFIX ""
#  define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
# elif SIZEOF_INT*2 <= SIZEOF_LONG
#  define BDIGIT unsigned int
#  define SIZEOF_BDIGITS SIZEOF_INT
#  define BDIGIT_DBL unsigned long
#  define BDIGIT_DBL_SIGNED long
#  define PRI_BDIGIT_PREFIX ""
#  define PRI_BDIGIT_DBL_PREFIX "l"
# elif SIZEOF_SHORT*2 <= SIZEOF_LONG
#  define BDIGIT unsigned short
#  define SIZEOF_BDIGITS SIZEOF_SHORT
#  define BDIGIT_DBL unsigned long
#  define BDIGIT_DBL_SIGNED long
#  define PRI_BDIGIT_PREFIX "h"
#  define PRI_BDIGIT_DBL_PREFIX "l"
# else
#  define BDIGIT unsigned short
#  define SIZEOF_BDIGITS (SIZEOF_LONG/2)
#  define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
#  define BDIGIT_DBL unsigned long
#  define BDIGIT_DBL_SIGNED long
#  define PRI_BDIGIT_PREFIX "h"
#  define PRI_BDIGIT_DBL_PREFIX "l"
# endif
#endif
#ifndef SIZEOF_ACTUAL_BDIGIT
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGITS
#endif
```

* その後、コンパイルが中断して保存されているgemのディレクトリで、``` ruby setup.rb all -- --with-sqlite3-lib=/usr/local/lib --with-sqlite3-include=/usr/local/include``` と実行したところ、適切にインストールされた。
* この現象はOS Xでは発生しないので、FreeBSDの環境に問題があるのかもしれない。