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 extras/sirc-2.211 ));
43 sub build_demo_scripts {
46 my $demo_dir = 'demo';
48 my @files = <bin/demo/*>;
50 for my $file (@files) {
52 my $result = $self->copy_if_modified(
53 $file, $demo_dir, 'flatten');
57 $self->fix_shebang_line($result) if $self->is_unixish();
58 $self->make_executable($result);
59 $self->add_to_cleanup($result);
64 ###########################################################
65 # Find stem config files under the build dir and notify M::B about them.
66 sub process_conf_files {
68 my $files = $self->_find_file_by_type('stem','conf');
69 return unless keys %$files;
71 my $conf_dir = File::Spec->catdir($self->blib, 'conf');
72 File::Path::mkpath( $conf_dir );
74 foreach my $file (keys %$files) {
75 my $result = $self->copy_if_modified(
76 $file, $conf_dir, 'flatten');
83 ###########################################################
84 # A horrible hack to attempt to find the location of a binary program...
85 # It would be nice if this functionality was already part of M::B
86 # or there was a CPAN module for it that didn't suck.
88 my ( $self, $prog ) = @_ ;
89 # make sure the command will succeed before extracting the path.
90 if ( $self->do_system( "which $prog >/dev/null" ) ) {
91 my $path = `which $prog` ;
100 ###########################################################
101 # Various convenience routines.
103 # To use ACTION_foo, call ./Build foo
107 # ACTION: grep through MANIFEST
111 # do we need this action?
114 sub ACTION_grep_manifest {
118 my @manifest_sublist = $self->grep_manifest() ;
120 print join( "\n", @manifest_sublist ), "\n" ;
126 # grep through all matched files
128 # files=<regex> (default is all .pm files)
135 my $args = $self->{'args'} ;
137 my $file_regex = $args->{ files } || qr/\.pm$/ ;
138 my $grep_regex = $args->{ re } or die "need grep regex" ;
140 my @manifest_sublist = $self->grep_manifest( $file_regex ) ;
142 local( @ARGV ) = @manifest_sublist ;
146 next unless /$grep_regex/ ;
158 my ( @manifest_lines ) ;
160 # MANIFEST helper subs
164 my( $self, $file_regex ) = @_ ;
166 $file_regex ||= $self->{ args }{ files } || qr/.*/ ;
170 return grep( /$file_regex/, @manifest_lines ) ;
175 return if @manifest_lines ;
177 @manifest_lines = grep ! /^\s*$|^\s*#/, read_file( 'MANIFEST' ) ;
179 chomp @manifest_lines ;
186 my ( $file_name ) = @_ ;
190 open( FH, $file_name ) || die "Can't open $file_name $!";
192 return <FH> if wantarray;
194 read FH, my $buf, -s FH;