I'd like to seperate some *.c/*.h files in YAML::XS.
Currently the CPAN distribution looks like this: https://metacpan.org/source/TINITA/YAML-LibYAML-0.77
In the LibYAML directory there are copied files from the libyaml sources plus the bindings to perl (perl_libyaml.{c,h}).
I'd like to separate the libyaml sources into their own directories to make it easy to remove/ignore them and use the installed system libyaml instead, if one wants to.
Here I put the files into LibYAML/src and LibYAML/include: https://github.com/ingydotnet/yaml-libyaml-pm/tree/seperate-libyaml-source/YAML-LibYAML-0.77
The problem is I don't know how to change LibYAML/Makefile.PL.
Currently I'm getting this error because apparently it can't find the yaml.h:
Can't load '.../yaml-libyaml-pm/YAML-LibYAML-0.77/blib/arch/auto/YAML/
+XS/LibYAML/LibYAML.so' for
module YAML::XS::LibYAML: .../yaml-libyaml-pm/YAML-LibYAML-0.77/blib/
+arch/auto/YAML/XS/LibYAML/LibYAML.so: undefined symbol:
yaml_sequence_start_event_initialize at .../perl-5.24.1/lib/5.24.1/x86
+_64-linux/DynaLoader.pm
line 193, <CONFIG> line 1.
at .../yaml-libyaml-pm/YAML-LibYAML-0.77/blib/lib/YAML/XS.pm line 20.
Any ideas/pointers on how to set this up?
To reproduce:
Clone the git repo:
git clone https://github.com/ingydotnet/yaml-libyaml-pm -b seperate-libyaml-source
and go into the directory
YAML-LibYAML-0.77:
perl Makefile.PL
make
make test
edit:
Tux was working on it and came up with this:
use ExtUtils::MakeMaker;
use strict;
use Config;
my $s = join " " => sort glob ("*.c"), glob ("src/*.c"), glob ("*.xs"
+);
(my $o = $s) =~ s{\.(?:c|xs)\b}{$Config::Config{_o}}g;
(my $l = $o) =~ s{\bsrc/}{}g;
my $DEFINE = $^O eq 'MSWin32'
? '-DHAVE_CONFIG_H -DYAML_DECLARE_EXPORT'
: '-DHAVE_CONFIG_H';
WriteMakefile(
NAME => 'YAML::XS::LibYAML',
ABSTRACT_FROM => 'lib/YAML/XS/LibYAML.pm',
AUTHOR => 'Ingy döt Net <ingy@cpan.org>',
PREREQ_PM => {},
CCFLAGS => "-I. -Isrc -Iinclude $DEFINE",
OBJECT => $o,
LDFROM => $l,
);
It's working for me, thanks Tux!
The only weird thing is that it is compiling again whenever one does
make test.
Does anyone have an idea?