MarpaX-ESLIF
view release on metacpan or search on metacpan
etc/compile_marpaESLIF.pl view on Meta::CPAN
}
#print $config_h_in_cmake_fd "#define DLL_VARIABLE\n";
#print $config_h_in_cmake_fd "#define ICONV_CONST\n";
close($config_h_in_cmake_fd) || warn "Cannot close $config_h_in_cmake, $!";
close($config_h_in_fd) || warn "Cannot close $config_h_in, $!";
my $config_h = File::Spec->catfile($outdir, 'config.h');
configure_file($ac, $config_h_in_cmake, $config_h);
my $iconv_h_in = File::Spec->catfile($outdir, 'include', 'iconv.h.in');
my $iconv_h_in_cmake = File::Spec->catfile($outdir, 'include', 'iconv.h.in.cmake');
print "Generating $iconv_h_in_cmake\n";
open(my $iconv_h_in_fd, '<', $iconv_h_in) || die "Cannot open $iconv_h_in, $!";
open(my $iconv_h_in_cmake_fd, '>', $iconv_h_in_cmake) || die "Cannot open $iconv_h_in_cmake, $!";
while (defined(my $line = <$iconv_h_in_fd>)) {
$line =~ s/#define _LIBICONV_H/#define _LIBICONV_H\n#include <libiconv\/export.h>\n/;
$line =~ s/^\s*extern[ \t]+([a-zA-Z_])/extern libiconv_EXPORT $1/;
$line =~ s/LIBICONV_DLL_EXPORTED/libiconv_EXPORT/;
$line =~ s/\@EILSEQ\@/ENOENT/;
$line =~ s/\@DLL_VARIABLE\@/libiconv_EXPORT/;
$line =~ s/\@([^@]+)\@/$1/;
print $iconv_h_in_cmake_fd $line;
}
close($iconv_h_in_cmake_fd) || warn "Cannot close $iconv_h_in_cmake, $!";
close($iconv_h_in_fd) || warn "Cannot close $iconv_h_in, $!";
my $iconv_h = File::Spec->catfile($outdir, 'include', 'iconv.h');
configure_file($ac, $iconv_h_in_cmake, $iconv_h);
my $localcharset_h_in = File::Spec->catfile($outdir, 'libcharset', 'include', 'localcharset.h.in');
my $localcharset_h = File::Spec->catfile($outdir, 'libcharset', 'include', 'localcharset.h');
configure_file($ac, $localcharset_h_in, $localcharset_h);
my @extra_compiler_flags;
push(@extra_compiler_flags, "-DNO_I18N=1");
push(@extra_compiler_flags, "-DENABLE_NLS=0");
push(@extra_compiler_flags, "-DHAVE_WCHAR_T=" . ((exists($sizeof{'WCHAR_T'}) && $sizeof{'WCHAR_T'}) ? 1 : 0));
push(@extra_compiler_flags, "-DO_BINARY=" . ($have__O_BINARY ? 1 : 0));
push(@extra_compiler_flags, "-DHAVE_SETLOCALE=1") if (exists($HAVE_HEADERS{'locale.h'}) && $HAVE_HEADERS{'locale.h'});
push(@extra_compiler_flags, "-DHAVE_DECL_GETC_UNLOCKED=1") if ($have_getc_unlocked);
push(@extra_compiler_flags, "-DWORDS_LITTLEENDIAN=" . ($is_big_endian ? 0 : 1));
push(@extra_compiler_flags, "-DENABLE_EXTRA=1");
push(@extra_compiler_flags, "-DHAVE_WCRTOMB=" . ($have_wcrtomb ? 1 : 0));
push(@extra_compiler_flags, "-DHAVE_MBRTOWC=" . ($have_mbrtowc ? 1 : 0));
push(@extra_compiler_flags, "-DUSE_MBSTATE_T=" . (($have_wcrtomb && $have_mbrtowc) ? 1 : 0));
push(@extra_compiler_flags, "-DBROKEN_WCHAR_H=" . ($broken_wchar ? 1 : 0));
push(@extra_compiler_flags, "-DICONV_CONST=");
push(@extra_compiler_flags, "-DDLL_VARIABLE=");
if ($ENV{CC} =~ /\bcl\b/) {
#
# Too much noise with cl
#
push(@extra_compiler_flags, '/wd4311');
}
#
# Compile
#
my @sources = (
File::Spec->catfile($outdir, 'libcharset', 'lib', 'localcharset.c'),
File::Spec->catfile($outdir, 'lib', 'relocatable.c'),
File::Spec->catfile($outdir, 'lib', 'iconv.c'),
);
generate_export_h($ac, $outdir, 'libiconv', undef, undef, undef, undef, "#define ICONV_CONST\n");
my @include_dirs = (
File::Spec->catdir($outdir, 'libcharset', 'include'),
File::Spec->catdir($outdir, 'include'),
);
foreach my $source (@sources) {
build_object($source, include_dirs => \@include_dirs, extra_compiler_flags => \@extra_compiler_flags);
}
}
sub process_cchardet {
my ($ac) = @_;
my $tar = Archive::Tar->new;
my $input = File::Spec->catfile($EXTRACT_DIR, 'tconv', '3rdparty', 'tar', 'cchardet-1.0.0.tar.gz');
$tar->read($input);
my $outdir = $EXTRACT_DIR; # cchardet-1.0.0 is part of the tar
print "Extracting $input\n";
make_path($outdir);
{
local $CWD = $outdir;
$tar->extract();
}
$outdir = File::Spec->catdir($outdir, 'cchardet-1.0.0');
my $nspr_emu_dir = File::Spec->catdir($outdir, 'src', 'ext', 'libcharsetdetect', 'nspr-emu');
print "Suppress directory $nspr_emu_dir\n";
remove_tree($nspr_emu_dir, { safe => 1 });
print "Created directory $nspr_emu_dir\n";
make_path($nspr_emu_dir);
my $nsDebug_h = File::Spec->catdir($nspr_emu_dir, 'nsDebug.h');
print "Creating $nsDebug_h\n";
open(my $nsDebug_h_fd, '>', $nsDebug_h) || die "Cannot open $nsDebug_h, $!";
print $nsDebug_h_fd <<NSDEBUG_H;
#ifndef NSDEBUG_H
#define NSDEBUG_H
#endif /* NSDEBUG_H */
NSDEBUG_H
close($nsDebug_h_fd) || warn "Cannot close $nsDebug_h, $!";
my $prmem_h = File::Spec->catdir($nspr_emu_dir, 'prmem.h');
print "Creating $prmem_h\n";
open(my $prmem_h_fd, '>', $prmem_h) || die "Cannot open $prmem_h, $!";
print $prmem_h_fd <<PRMEM_H;
#ifndef PRMEM_H
#define PRMEM_H
/* Technically, this is the same as the original prmem.h */
#include "nscore.h"
PR_BEGIN_EXTERN_C
#include <stdlib.h>
PR_END_EXTERN_C
#define PR_Malloc malloc
#define PR_Calloc calloc
#define PR_Realloc realloc
#define PR_Free free
( run in 0.451 second using v1.01-cache-2.11-cpan-71847e10f99 )