是否有类似MakeMaker的Perl库用于cmake项目?

时间:2014-10-02 08:03:44

标签: perl makefile cmake makemaker

我一直在使用一个使用MySQL的C ++代码作为库的Perl项目。它使用一个名为MakeMaker的Perl库来生成与G ++兼容的Makefile,它依赖于MySQL源代码。

以下代码是用于生成Makefile(source file on Github)的Perl代码:

use ExtUtils::MakeMaker;

use strict;

# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.

if ($ARGV[0] eq '') {
    print "Usage: perl Makefile.PL \"<MySQL source path>\"\n";
    exit 1;
}

my $mysql_path = $ARGV[0].'/';
my $check_file = $mysql_path."libmysqld/libmysqld.a";
if (! -e $check_file) {
    print "File $check_file does not exist: $!. Please try again.\n";
    exit 1;
}

my $makefile_path = $mysql_path.'/libmysql/Makefile';

my $libmysqld_path = $mysql_path.'/libmysqld/libmysqld.a';

if (! -e $libmysqld_path) {
    print "$libmysqld_path does not exist. Did you run ./configure --with-embedded-server && make ? \n";
    exit 1;
}

#
# CCFLAGS must be taken from the flags used to compile libmysqld. The reason for that is that if the flags are not
# identical, the THD class behaves differently in libmysqld than it does in my_parse_cc.cc, namely, the thd->command
# member is located in a different place in memory. No attempt was made to determine which compile flag causes this behavoir.
#
# Also, if we compile our stuff with DDEBUG and libmysqld.so is not compiled with DDEBUG, crap will result.


my $ccflags = `grep "^CXXFLAGS =" $makefile_path`;

$ccflags =~ s{^CXXFLAGS = }{}sio;
$ccflags =~ s{[\r\n\t]}{}sio;
$ccflags .= " -DNO_EMBEDDED_ACCESS_CHECKS ";
print "CCFLAGS = $ccflags\n";


my $libs = '-L'.$mysql_path.'/libmysql -L'.$mysql_path.'/libmysqld -lmysqld -lz -lpthread -lcrypt -lnsl -lm -lpthread -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv -lrt';

print "LIBS = $libs\n";

WriteMakefile(
    NAME        => 'DBIx::MyParse',
    VERSION_FROM    => 'lib/DBIx/MyParse.pm', # finds $VERSION
    ABSTRACT_FROM   => 'lib/DBIx/MyParse.pm',
    AUTHOR      => 'Philip Stoev <philip@stoev.org>',
    LIBS            => qq{-L$mysql_path/libmysqld -L$mysql_path/libmysql -lmysqld -lz }.$libs,
    'INC'       => qq{-I. -I$mysql_path -I$mysql_path/sql -I$mysql_path/include -I$mysql_path/regex},

    CCFLAGS     => '-DEMBEDDED_LIBRARY -DMYSQL_SERVER -Wall '.$ccflags,
    OBJECT      => 'my_enum.o my_define.o my_parse_c.o my_parse_cc.o MyParse.o',
    LD      => 'g++',
    CC      => 'g++',
    depend => {
    'my_parse_cc.cc' => 'my_parse.h',
    'my_parse_cc.cc' => 'my_define.h',
    'my_parse_cc.cc' => 'my_enum.h',
    'my_enum.o' => 'my_enum.c',
    'my_enum.o' => 'my_enum.h',
    'my_enum.0' => ' my_parse.h',
    'my_define.o' => 'my_define.h',
    'my_define.o' => 'my_define.c',
    'my_define.o' => 'my_parse.h',

    'my_enum.h' => "parse_enum.pl
    perl parse_enum.pl $mysql_path
",
    'my_enum_priv.h' => "parse_enum.pl
    perl parse_enum.pl $mysql_path
",
    'my_define.h' => "parse_define.pl
    perl parse_define.pl $mysql_path
",
    'my_define.c' => "parse_define.pl
    perl parse_define.pl $mysql_path
",
    'my_enum.c' => "parse_define.pl
    perl parse_enum.pl $mysql_path
"},
    clean => 
      {FILES => "my_enum_priv.h my_enum.h my_define.h my_define.c my_enum.c"}

);

我现在想让这个项目发展并使用MariaDB而不是MySQL。但是MariaDB是使用cmake而不是g ++编译的。因此,我不能再使用MakeMaker为MariaDB。我想知道是否有一个类似的工具用于使用cmake编译的源代码。 如果存在这样的事情,另一种选择是以另一种方式将Perl项目链接到MySQL源。

编辑:到目前为止我还没有尝试过任何东西,因为我不知道Perl中是否存在这样的工具(我没有在网上找到它的任何痕迹,但我可能没有正确的关键字)。如果没有,我怎么能实现我的原始目标,即在Perl或C ++代码中使用MariaDB源代码,就像使用以前代码的MySQL一样?

0 个答案:

没有答案