Convert-Binary-C
view release on metacpan or search on metacpan
bin/ccconfig view on Meta::CPAN
#!/usr/bin/perl -w
################################################################################
#
# PROGRAM: ccconfig
#
################################################################################
#
# DESCRIPTION: Get Convert::Binary::C configuration for a compiler.
#
################################################################################
#
# Copyright (c) 2002-2024 Marcus Holland-Moritz. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
################################################################################
use IO::File;
use Getopt::Long;
use Data::Dumper;
use strict;
my($NAME) = $0 =~ /([\w\.]+)$/;
my $VERSION = '0.86';
my $MESSAGE = "\nThis is $NAME, v$VERSION ($0).\n";
my %OPT = (
'output-format' => 'dumper',
);
unless( GetOptions( \%OPT, qw(
cc|c=s inc-path|I=s@ basename=s
output-file|o=s output-format|f=s
preprocess=s compile-obj=s compile-exe=s
obj-ext=s exe-ext=s c-ext=s pp-ext=s
version debug quiet status! run! delete!
) ) ) {
# poor man's pod2usage...
my($USAGE) = do { local(@ARGV,$/)=($0); <> }
=~ /^__END__.*?^=head\d\s+SYNOPSIS(.*?)^=/ms;
my %M = ( 'I' => '*' ); # minimal markup
$USAGE =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
$USAGE =~ s/^/ /gm;
print STDERR "\nUsage:$USAGE",
"Try `perldoc $NAME' for more information.\n\n";
exit 2;
}
if( $OPT{version} ) {
print <<VERSION;
$MESSAGE
Copyright (c) 2002-2024 Marcus Holland-Moritz. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
VERSION
exit 0;
}
STDERR->autoflush(1);
$OPT{quiet} or print STDERR $MESSAGE, "\n";
my $output = \*STDOUT;
if (exists $OPT{'output-file'}) {
$output = new IO::File ">$OPT{'output-file'}"
or die "Cannot open $OPT{'output-file'}: $!\n";
}
my %format = (
dumper => sub {
my $cfg = shift;
local $Data::Dumper::Sortkeys = 1;
return Data::Dumper->Dump([$cfg], ['*config']);
},
require => sub {
my $cfg = shift;
local $Data::Dumper::Indent = 1;
local $Data::Dumper::Sortkeys = 1;
my $dump = Data::Dumper->Dump([$cfg], ['config']);
$dump =~ s/.*(?={)//;
return $dump;
},
);
unless (exists $format{$OPT{'output-format'}}) {
my $valid = join ', ', sort keys %format;
die <<EOM;
Invalid output format: '$OPT{'output-format'}'
Valid output formats are: $valid
EOM
}
my $cc = new Compiler::Config %OPT, ccflags => [@ARGV];
my $cfg = $cc->get_config;
$cc->cleanup;
unless( $OPT{quiet} ) {
( run in 0.819 second using v1.01-cache-2.11-cpan-98e64b0badf )