14 @ISA = qw(Module::Build);
20 if ( $self->config_data( 'build_demos' ) ) {
21 $self->build_demo_scripts();
24 if ( $self->config_data( 'build_ssfe' ) ) {
28 $self->SUPER::ACTION_build();
32 # yes, hard coded, will fix some other time
35 print "Compiling ssfe\n";
36 system( "cd extras; tar xzf sirc-2.211.tar.gz; cp sirc-2.211/ssfe.c ../demo" );
37 system( "cc -o demo/ssfe demo/ssfe.c -ltermcap 2>/dev/null" );
38 $self->add_to_cleanup(qw(demo/ssfe demo/ssfe.c ));
43 sub build_demo_scripts {
46 my $demo_dir = 'demo';
48 my @files = <bin/demo/*>;
50 for my $file (@files) {
51 my $result = $self->copy_if_modified(
52 $file, $demo_dir, 'flatten');
54 $self->fix_shebang_line($result) if $self->is_unixish();
55 $self->make_executable($result);
56 $self->add_to_cleanup($result);
61 ###########################################################
62 # Find stem config files under the build dir and notify M::B about them.
63 sub process_conf_files {
65 my $files = $self->_find_file_by_type('stem','conf');
66 return unless keys %$files;
68 my $conf_dir = File::Spec->catdir($self->blib, 'conf');
69 File::Path::mkpath( $conf_dir );
71 foreach my $file (keys %$files) {
72 my $result = $self->copy_if_modified(
73 $file, $conf_dir, 'flatten');
80 ###########################################################
81 # A horrible hack to attempt to find the location of a binary program...
82 # It would be nice if this functionality was already part of M::B
83 # or there was a CPAN module for it that didn't suck.
85 my ( $self, $prog ) = @_ ;
86 # make sure the command will succeed before extracting the path.
87 if ( $self->do_system( "which $prog >/dev/null" ) ) {
88 my $path = `which $prog` ;
97 ###########################################################
98 # Various convenience routines.
100 # To use ACTION_foo, call ./Build foo
104 # ACTION: grep through MANIFEST
108 # do we need this action?
111 sub ACTION_grep_manifest {
115 my @manifest_sublist = $self->grep_manifest() ;
117 print join( "\n", @manifest_sublist ), "\n" ;
123 # grep through all matched files
125 # files=<regex> (default is all .pm files)
132 my $args = $self->{'args'} ;
134 my $file_regex = $args->{ files } || qr/\.pm$/ ;
135 my $grep_regex = $args->{ re } or die "need grep regex" ;
137 my @manifest_sublist = $self->grep_manifest( $file_regex ) ;
139 local( @ARGV ) = @manifest_sublist ;
143 next unless /$grep_regex/ ;
155 my ( @manifest_lines ) ;
157 # MANIFEST helper subs
161 my( $self, $file_regex ) = @_ ;
163 $file_regex ||= $self->{ args }{ files } || qr/.*/ ;
167 return grep( /$file_regex/, @manifest_lines ) ;
172 return if @manifest_lines ;
174 @manifest_lines = grep ! /^\s*$|^\s*#/, read_file( 'MANIFEST' ) ;
176 chomp @manifest_lines ;
183 my ( $file_name ) = @_ ;
187 open( FH, $file_name ) || die "Can't open $file_name $!";
189 return <FH> if wantarray;
191 read FH, my $buf, -s FH;