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?

In reply to Separating source files in YAML::XS by tinita

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.