YAML::XSのインストールに手間どった

使用する予定のスクリプトPerlYAML::XSに依存しており、cpanmでインストールしようとしたが、以下のエラーでこける。

cpanm (App::cpanminus) 1.7039 on perl 5.018002 built for darwin-thread-multi-2level
Work directory is /Users/yasuhisa/.cpanm/work/1451969883.62015
You have make /usr/bin/make
You have LWP 6.05
You have /usr/bin/tar: bsdtar 2.8.3 - libarchive 2.8.3
You have /usr/bin/unzip
Searching YAML::LibYAML () on cpanmetadb ...
--> Working on YAML::LibYAML
Fetching http://www.cpan.org/authors/id/I/IN/INGY/YAML-LibYAML-0.59.tar.gz
-> OK
Unpacking YAML-LibYAML-0.59.tar.gz
Entering YAML-LibYAML-0.59
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.10)
Configuring YAML-LibYAML-0.59
Running Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for YAML::XS::LibYAML
Writing MYMETA.yml and MYMETA.json
Generating a Unix-style Makefile
Writing Makefile for YAML::LibYAML
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.10)
Building and testing YAML-LibYAML-0.59
cp lib/YAML/LibYAML.pm blib/lib/YAML/LibYAML.pm
cp lib/YAML/LibYAML.pod blib/lib/YAML/LibYAML.pod
cp lib/YAML/XS.pod blib/lib/YAML/XS.pod
cp lib/YAML/XS.pm blib/lib/YAML/XS.pm
cp lib/YAML/XS/LibYAML.pm ../blib/lib/YAML/XS/LibYAML.pm
Running Mkbootstrap for YAML::XS::LibYAML ()
chmod 644 "LibYAML.bs"
cc -c  -I. -arch x86_64 -arch i386 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -Os   -DVERSION=\"\" -DXS_VERSION=\"\"  "-I/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE"  -DHAVE_CONFIG_H api.c
api.c:11:12: error: use of undeclared identifier 'YAML_VERSION_STRING'
    return YAML_VERSION_STRING;
           ^
api.c:21:14: error: use of undeclared identifier 'YAML_VERSION_MAJOR'
    *major = YAML_VERSION_MAJOR;
             ^
api.c:22:14: error: use of undeclared identifier 'YAML_VERSION_MINOR'
    *minor = YAML_VERSION_MINOR;
             ^
api.c:23:14: error: use of undeclared identifier 'YAML_VERSION_PATCH'
    *patch = YAML_VERSION_PATCH;
             ^
4 errors generated.
make[1]: *** [api.o] Error 1
make: *** [subdirs] Error 2
-> FAIL Installing YAML::LibYAML failed. See /Users/yasuhisa/.cpanm/work/1451969883.62015/build.log for details. Retry with --force to force install it.

XSなので、C拡張を使っていると思うのだが、修正めんどい...。どうやるのが一番いいのか分からないが、とりあえず解決したので方法をメモ。cpanm YAML::XSとやってこけた後に、/Users/yasuhisa/.cpanm/latest-build/YAML-LibYAML-0.59に移動。perl Makefile.plした後、api.cの先頭に

#include "config.h"

と書いて、make && make installすればインストールできる。どうするのが正しいのか。