tagged release 0.6.4
[parrot.git] / config / gen / config_h.pm
blobe07acd74a371af10c1f789a5b5742b2f01453a60
1 # Copyright (C) 2001-2007, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 config/gen/config_h.pm - Configuration Header
8 =head1 DESCRIPTION
10 Generates F<include/parrot/config.h> with platform-specific configuration
11 values, F<include/parrot/has_header.h> with platform-specific header
12 information, and F<include/parrot/feature.h> with information on optional
13 features.
15 =cut
17 package gen::config_h;
19 use strict;
20 use warnings;
22 use base qw(Parrot::Configure::Step);
24 use Parrot::Configure::Utils ':gen';
27 sub _init {
28 my $self = shift;
29 my %data;
30 $data{description} = q{Generating C headers};
31 $data{result} = q{};
32 return \%data;
35 sub runstep {
36 my ( $self, $conf ) = @_;
38 $conf->genfile('config/gen/config_h/config_h.in', 'include/parrot/config.h',
39 comment_type => '/*',
40 ignore_pattern => 'PARROT_CONFIG_DATE',
41 conditioned_lines => 1
44 $conf->genfile('config/gen/config_h/feature_h.in', 'include/parrot/feature.h',
45 comment_type => '/*',
46 ignore_pattern => 'PARROT_CONFIG_DATE',
47 feature_file => 1
50 my $hh = "include/parrot/has_header.h";
51 $conf->append_configure_log($hh);
52 open( my $HH, ">", "$hh.tmp" )
53 or die "Can't open has_header.h: $!";
55 print {$HH} <<EOF;
57 ** !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
59 ** This file is generated automatically by Configure.pl
62 #ifndef PARROT_HAS_HEADER_H_GUARD
63 #define PARROT_HAS_HEADER_H_GUARD
66 * i_(\\w+) header includes
69 EOF
71 for ( sort( $conf->data->keys() ) ) {
72 next unless /i_(\w+)/;
73 if ( $conf->data->get($_) ) {
74 print {$HH} "#define PARROT_HAS_HEADER_\U$1 1\n";
76 else {
77 print {$HH} "#undef PARROT_HAS_HEADER_\U$1\n";
81 my $osname = $conf->data->get_p5('OSNAME');
82 print {$HH} "\n#define BUILD_OS_NAME \"$osname\"\n";
84 my $define = $conf->options->get('define');
86 if ($define) {
87 my @vals = split /,/, $define;
88 print {$HH} <<EOF;
91 * defines from commandline
94 EOF
95 for (@vals) {
96 print {$HH} "#define PARROT_DEF_" . uc($_), " 1\n";
101 print {$HH} <<EOF;
104 * HAS_(\\w+) config entries
108 for ( sort( $conf->data->keys() ) ) {
109 next unless /HAS_(\w+)/;
110 if ( $conf->data->get($_) ) {
111 print {$HH} "#define PARROT_HAS_\U$1 1\n";
114 print {$HH} <<EOF;
117 * D_(\\w+) config entries
121 for ( sort( $conf->data->keys() ) ) {
122 next unless /D_(\w+)/;
123 my $val;
124 if ( $val = $conf->data->get($_) ) {
125 print {$HH} "#define PARROT_\U$1 $val\n";
129 # append the guard endif and C code coda
130 print {$HH} <<EOF;
132 #endif /* PARROT_HAS_HEADER_H_GUARD */
135 * Local variables:
136 * c-file-style: "parrot"
137 * End:
138 * vim: expandtab shiftwidth=4:
142 close $HH;
144 move_if_diff( "$hh.tmp", $hh );
146 return 1;
151 # Local Variables:
152 # mode: cperl
153 # cperl-indent-level: 4
154 # fill-column: 100
155 # End:
156 # vim: expandtab shiftwidth=4: