cleaned up demo scripts locations
[urisagit/Stem.git] / Build.PL
1 #!/usr/bin/env perl
2
3 use strict ;
4 use warnings ;
5
6 use Config ;
7 use File::Spec ;
8 use Data::Dumper ;
9
10 use BuildStem ;
11
12 my $version_from = File::Spec->catfile( 
13     File::Spec->curdir, 'lib', 'Stem.pm' 
14 );
15
16 my $build = BuildStem->new(
17     module_name          => 'Stem',
18     dist_version_from    => $version_from,
19     requires             => {
20       YAML        => 0,
21     },
22     dist_abstract        => 
23         'An asynchronous message passing framework for Perl',
24     license              => 'gpl',
25     dynamic_config       => 1,
26     recursive_test_files => 1,
27     needs_compiler       => 0,
28     recommends           => {
29         DBI    => 0,
30         Event  => 0,
31     },
32     create_makefile_pl   => 'passthrough'
33 );
34
35
36
37 $build->is_unixish() or 
38   die "Stem currently only installs properly on *nix-like platforms.\n";
39
40
41 ### ask about the config path and where to install bundled config files
42
43 print <<'EOT';
44
45 Stem configuration files are used to create and initialize Stem Cells.
46 An included program called 'run_stem' will search a default path for 
47 a specified config file and use it to get everything going. You can see
48 this in action if you check out Stem's demo scripts.
49
50 Note that you can easily override this path with either a shell environment
51 variable or a command line agrument. See the documentation on run_stem for 
52 how to do this.
53
54 EOT
55
56 $build->config_data( 
57     conf_path => scalar $build->prompt(
58         "Please enter a list of directory paths separated by ':'\n",
59         '.:~/.stem/conf:/usr/local/stem/conf'
60     )
61 );
62
63
64 print <<'EOT';
65
66 Where would you like to install the config files bundled with Stem?
67 If you specify a directory not already in the path above, it will be
68 appended. If this directory does not exist, it will be created.
69
70 EOT
71
72 $build->config_data( 
73     conf_dir => scalar $build->prompt(
74         "Please enter a directory path:\n",
75         '/usr/local/stem/conf'
76     )
77 );
78
79 ### add the conf_dir to the conf_path, if necessary
80 {
81     my $conf_path = $build->config_data( 'conf_path' );
82     my $conf_dir  = $build->config_data( 'conf_dir' );
83     if ( $conf_path =~ /(^|:)\Q$conf_dir\E(:|$)/ ) {
84         $build->config_data( conf_path => "$conf_path:$conf_dir" );
85     }
86 }
87
88
89
90 ### ask about building the demo scripts
91 print <<'EOT';
92
93 Stem comes with a variety of demos to show how to get started and do some
94 basic things. If you wish to try them they will be available in the demo/
95 directory after you run ./Build. In any case, they will not be installed 
96 to the system, even after you install the rest of Stem.
97
98 EOT
99
100 $build->config_data(
101     build_demos => scalar $build->y_n(
102         "Do you want to build the demos?\n", 'y'
103     )
104 );
105
106
107 if ( $build->config_data( 'build_demos' ) ) {
108
109
110         ### Try to find telnet
111         my $telnet_path = $build->find_binary( 'telnet' ) || '' ;
112         while ( ! -x $telnet_path && ! $build->_is_unattended() ) {
113                 print <<'EOT';
114
115 telnet was not found on this system. the demo programs won't run properly
116 without telnet. Please enter a valid path to telnet, or a single <space> 
117 to give up trying.
118
119 EOT
120                 $telnet_path = $build->prompt(
121                           "Enter the path to telnet "
122                         . "(or another compatible telnet client)",
123                                               '/usr/bin/telnet'
124                 ) ;
125                 last if $telnet_path =~ s/^\w+$//;
126         }
127         $build->config_data( telnet_path => $telnet_path || undef ) ;
128
129
130
131
132         # Try to find xterm
133         my $xterm_path = $build->find_binary( 'xterm' ) || '' ;
134         while ( ! -x $xterm_path && ! $build->_is_unattended() ) {
135             print <<'EOT';
136
137 xterm was not found on this system. the demo programs won't run properly
138 without xterm.  Please enter a valid path to xterm or a single <space> to
139 give up trying.
140
141 EOT
142             $xterm_path = $build->prompt(
143                 "Enter the path to xterm "
144               . "(or another compatible terminal emulator)",
145               '/usr/bin/xterm'
146             ) ;
147             last if $xterm_path =~ s/^\w+$//;
148         }
149         $build->config_data( xterm_path => $xterm_path || undef ) ;
150
151
152     ### Only build ssfe if we have a working C compiler
153     if ( $build->have_c_compiler() ) {
154         print <<'EOT';
155
156 ssfe (Split Screen Front End) is a compiled program optionally used by
157 the Stem demonstration scripts that provides a full screen interface
158 with command line editing and history. It is not required to run Stem
159 but it makes the demonstrations easier to work with and they look much
160 nicer. To use ssfe add the '-s' option when you run any demonstration
161 script. You can also use ssfe for your own programs. If you build ssfe
162 it will be installed in the demo/ directory. You may copy it to a place
163 in your $PATH is you wish.
164
165 EOT
166         $build->config_data(
167             build_ssfe => scalar $build->y_n(
168                 "Do you want to build ssfe for the demos?\n", 'y'
169             )
170         );
171     }
172 }
173
174
175
176
177 ### NOTE: find out whether or not each of the following 
178 ### config_data settings are actually being *used* for anything
179
180 my $script_dest = $build->install_destination('script') ;
181 my $run_stem_path = File::Spec->catfile( $script_dest, 'run_stem' ) ;
182 $build->config_data( run_stem_path => $run_stem_path ) ;
183
184
185
186
187 my $bin_path = $build->install_destination('bin') ;
188 $build->config_data( bin_path => $bin_path ) ;
189
190 $build->config_data( perl_path => $build->config( 'perlpath' ) ) ;
191
192 # Several different prefixes... which one to use??
193 #$build->config_data( prefix => $build->prefix() ) ;
194 $build->config_data( prefix => $build->config( 'install_base' ) ) ;
195
196
197 $build->config_data( config_done => 1 ) ;
198
199
200 #print Dumper \%{ $build->config_data() };
201
202
203 $build->create_build_script() ;
204
205 exit ;
206
207 1 ;