cleaned up demo scripts locations
[urisagit/Stem.git] / Build.PL
CommitLineData
b3407611 1#!/usr/bin/env perl
4536f655 2
b3407611 3use strict ;
4use warnings ;
4536f655 5
b3407611 6use Config ;
7use File::Spec ;
b3407611 8use Data::Dumper ;
4536f655 9
09baddbd 10use BuildStem ;
4536f655 11
09baddbd 12my $version_from = File::Spec->catfile(
13 File::Spec->curdir, 'lib', 'Stem.pm'
14);
4536f655 15
16my $build = BuildStem->new(
09baddbd 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'
4536f655 33);
34
4536f655 35
b3407611 36
09baddbd 37$build->is_unixish() or
38 die "Stem currently only installs properly on *nix-like platforms.\n";
b3407611 39
b3407611 40
09baddbd 41### ask about the config path and where to install bundled config files
b3407611 42
09baddbd 43print <<'EOT';
b3407611 44
09baddbd 45Stem configuration files are used to create and initialize Stem Cells.
46An included program called 'run_stem' will search a default path for
47a specified config file and use it to get everything going. You can see
48this in action if you check out Stem's demo scripts.
b3407611 49
50Note that you can easily override this path with either a shell environment
09baddbd 51variable or a command line agrument. See the documentation on run_stem for
52how to do this.
b3407611 53
b3407611 54EOT
55
09baddbd 56$build->config_data(
57 conf_path => scalar $build->prompt(
58 "Please enter a list of directory paths separated by ':'\n",
b3407611 59 '.:~/.stem/conf:/usr/local/stem/conf'
09baddbd 60 )
b3407611 61);
b3407611 62
63
09baddbd 64print <<'EOT';
b3407611 65
09baddbd 66Where would you like to install the config files bundled with Stem?
67If you specify a directory not already in the path above, it will be
68appended. If this directory does not exist, it will be created.
3e03d89e 69
09baddbd 70EOT
3e03d89e 71
09baddbd 72$build->config_data(
73 conf_dir => scalar $build->prompt(
74 "Please enter a directory path:\n",
75 '/usr/local/stem/conf'
76 )
77);
b3407611 78
09baddbd 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 }
b3407611 86}
87
b3407611 88
09baddbd 89
90### ask about building the demo scripts
b3407611 91print <<'EOT';
92
3e03d89e 93Stem comes with a variety of demos to show how to get started and do some
09baddbd 94basic things. If you wish to try them they will be available in the demo/
95directory after you run ./Build. In any case, they will not be installed
96to the system, even after you install the rest of Stem.
b3407611 97
98EOT
b3407611 99
09baddbd 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
107if ( $build->config_data( 'build_demos' ) ) {
108
109
110 ### Try to find telnet
b3407611 111 my $telnet_path = $build->find_binary( 'telnet' ) || '' ;
112 while ( ! -x $telnet_path && ! $build->_is_unattended() ) {
113 print <<'EOT';
114
09baddbd 115telnet was not found on this system. the demo programs won't run properly
116without telnet. Please enter a valid path to telnet, or a single <space>
117to give up trying.
b3407611 118
119EOT
120 $telnet_path = $build->prompt(
121 "Enter the path to telnet "
122 . "(or another compatible telnet client)",
09baddbd 123 '/usr/bin/telnet'
b3407611 124 ) ;
09baddbd 125 last if $telnet_path =~ s/^\w+$//;
b3407611 126 }
09baddbd 127 $build->config_data( telnet_path => $telnet_path || undef ) ;
128
129
b3407611 130
131
09baddbd 132 # Try to find xterm
b3407611 133 my $xterm_path = $build->find_binary( 'xterm' ) || '' ;
134 while ( ! -x $xterm_path && ! $build->_is_unattended() ) {
09baddbd 135 print <<'EOT';
136
137xterm was not found on this system. the demo programs won't run properly
138without xterm. Please enter a valid path to xterm or a single <space> to
139give up trying.
140
141EOT
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 ) ;
b3407611 150
151
09baddbd 152 ### Only build ssfe if we have a working C compiler
153 if ( $build->have_c_compiler() ) {
154 print <<'EOT';
b3407611 155
09baddbd 156ssfe (Split Screen Front End) is a compiled program optionally used by
157the Stem demonstration scripts that provides a full screen interface
158with command line editing and history. It is not required to run Stem
159but it makes the demonstrations easier to work with and they look much
160nicer. To use ssfe add the '-s' option when you run any demonstration
161script. You can also use ssfe for your own programs. If you build ssfe
162it will be installed in the demo/ directory. You may copy it to a place
163in your $PATH is you wish.
b3407611 164
165EOT
09baddbd 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 }
3e03d89e 172}
b3407611 173
b3407611 174
175
176
09baddbd 177### NOTE: find out whether or not each of the following
178### config_data settings are actually being *used* for anything
179
b3407611 180my $script_dest = $build->install_destination('script') ;
181my $run_stem_path = File::Spec->catfile( $script_dest, 'run_stem' ) ;
182$build->config_data( run_stem_path => $run_stem_path ) ;
183
184
185
186
187my $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
4536f655 202
203$build->create_build_script() ;
204
205exit ;
b3407611 206
2071 ;