updated more stuff
[urisagit/Stem.git] / Build.PL
CommitLineData
8e25eb98 1#!/usr/bin/env perl
4536f655 2
8e25eb98 3use strict ;
4use warnings ;
4536f655 5
8e25eb98 6use Config ;
7use File::Spec ;
4536f655 8use BuildStem ;
8e25eb98 9use Data::Dumper ;
4536f655 10
8e25eb98 11# I wonder if I should add the ability to put the Docs and Design etc
12# directories in apropriate spots, like
13# /usr/local/share/stem (site) or /usr/share/stem (vendor)
4536f655 14
15my %requires ;
16
17my $version_from = File::Spec->catfile( File::Spec->curdir, 'lib', 'Stem.pm' );
18
19my $build = BuildStem->new(
8e25eb98 20#my $build = $class->new(
4536f655 21 module_name => 'Stem',
22 dist_version_from => $version_from,
23 requires => \%requires,
8e25eb98 24 dist_abstract => 'ABSTRACT GOES HERE',
4536f655 25 license => 'gpl',
26 dynamic_config => 1,
27 recursive_test_files => 1,
28 create_makefile_pl => 'passthrough'
29);
30
4536f655 31
8e25eb98 32
33$build->is_unixish() || die "Stem currently only installs properly on *nix-like platforms.\n";
34
015117d3 35### this will come in handy for some refactoring...
36## $build->config( 'install_base' )
8e25eb98 37
38print <<'EOT';
39
40Building Stem
41
42This script will ask you various questions in order to properly
43configure, build and install Stem on your system. Whenever a question
44is asked, the default answer will be shown inside [brackets].
45Pressing enter will accept the default answer. If a choice needs to be
46made from a list of values, that list will be inside (parentheses).
47
48If you have already configured Stem in a previous build, you can put
49use_defaults=1 on the Build command line and you won't be prompted for
50any answers and the previous settings will be used.
51
52If you want to force a new build, run Build clean.
53
54----------------------------------------------------------------------------
55
56EOT
57
8e25eb98 58print <<'EOT';
59
015117d3 60Stem comes with a utility called 'run_stem' which takes care of things
61like initalizing Stem with a configuration file and controlling it's
62operation via various parameters you can pass in as environment
63variables or command line arguments.
64
8e25eb98 65Stem configuration files are used to create and initialize Stem Cells
015117d3 66(objects). run_stem can search a path list for config files, so you
67can set that list of directories here.
8e25eb98 68
015117d3 69Note that you can easily override this path with either a shell environment
8e25eb98 70variable or on the command line of run_stem. See the documentation on
71run_stem for how so do this.
72
015117d3 73The last directory in the list is where the standard and demo Stem
8e25eb98 74configuration files will be installed.
75
015117d3 76Please enter a list of directory paths separated by ':'.
8e25eb98 77
78EOT
79
80my $conf_path = $build->prompt(
81 "What directories do you want Stem to search for configuration files?\n",
015117d3 82 '.:~/.stem/conf:/usr/local/stem/conf'
8e25eb98 83);
84$build->config_data(conf_path => $conf_path);
85
86
87
88
89
90
91=begin comment
92
93print "\n\nChecking to see if you have a good C compiler...\n\n" ;
94if ( $build->have_c_compiler() ) {
95 print <<'EOT';
96
97
98ssfe (Split Screen Front End) is a compiled program optionally used by
99the Stem demonstration scripts that provides a full screen interface
100with command line editing and history. It is not required to run Stem
101but it makes the demonstrations easier to work with and they look much
102nicer. To use ssfe add the '-s' option when you run any demonstration
103script. You can also use ssfe for your own programs. Install ssfe in
104some place in your $PATH ($conf->{'bin_path'} is where Stem executables
105are being installed) so it can be used by the demo scripts. The ssfe
106install script will do this for you or you can do it manually after
107building it.
108
109EOT
110 my $install_ssfe = $build->y_n("Do you want to install ssfe?\n", 'y');
111 $build->config_data(install_ssfe => $install_ssfe);
112 if ( $install_ssfe ) {
113
114 # Do horrible, nasty things.
115 # This really should be done with a proper makefile.
116
117 }
118}
119
120=cut
121
122
123
124
125
126print <<'EOT';
127
128Stem comes with a variety of demos to show how to get started and do some
129basic things.
130
131EOT
132my $install_demos = $build->y_n("\nDo you want to install the demos?\n",'n');
133$build->config_data( install_demos => $install_demos ) ;
134$build->config_data( build_demos => $install_demos ) ;
135if ( $install_demos ) {
136
137 my $demo_dir = $build->prompt(
138 "\nWhere do you want to install the demo scripts?\n",
139 '/usr/local/stem/demo'
140 );
141 $build->config_data(demo_dir => $demo_dir);
142 $build->install_path()->{demo} ||= $demo_dir;
143
144
145
146 my $demo_conf_dir = $build->prompt(
147 "\nWhere do you want to install the demo config files?\n",
148 '/usr/local/stem/conf'
149 );
150 $build->config_data(demo_conf_dir => $demo_conf_dir);
151 $build->install_path()->{conf} ||= $demo_conf_dir;
152 $build->add_build_element('conf');
153
154 my $cur_conf_path = $build->config_data('conf_path') ;
155 my $new_conf_path = $cur_conf_path =~ /(^|:)$demo_conf_dir(:|$)/ ?
156 $cur_conf_path : "$cur_conf_path:$demo_conf_dir" ;
157 $build->config_data( conf_path => $new_conf_path ) ;
158
159
160 # Check for telnet
161 my $telnet_path = $build->find_binary( 'telnet' ) || '' ;
162 while ( ! -x $telnet_path && ! $build->_is_unattended() ) {
163 print <<'EOT';
164
165
166telnet was not found on this system. you can't run the demo programs
167without telnet. Make sure you enter a valid path to telnet or some other
168terminal emulator.
169
170NOTE: If you don't have an telnet, you can still run the demo scripts
171by hand. Run a *_demo script and see what telnet commands it
172issues. The run those telnet commands using your telnet or another
173similar program.
174
175EOT
176 $telnet_path = $build->prompt(
177 "Enter the path to telnet "
178 . "(or another compatible telnet client)",
816e7ec7 179 '/usr/bin/telnet'
8e25eb98 180 ) ;
181 }
182 $build->config_data( telnet_path => $telnet_path ) ;
183
184
185 # Check for xterm
186 my $xterm_path = $build->find_binary( 'xterm' ) || '' ;
187 while ( ! -x $xterm_path && ! $build->_is_unattended() ) {
188 print <<'EOT';
189
190
191xterm was not found on this system. you can't run the demo programs
192without xterm. Make sure you enter a valid path to xterm or some other
193terminal emulator.
194
195NOTE: If you don't have an xterm, you can still run the demo scripts
196by hand. Run a *_demo script and see what commands it issues. Take the
197part after the -e and run that command in its own terminal window.
198
199EOT
200 $xterm_path = $build->prompt(
201 "Enter the path to xterm "
202 . "(or another compatible terminal emulator)",
816e7ec7 203 '/usr/bin/xterm'
8e25eb98 204 ) ;
205 }
206 $build->config_data( xterm_path => $xterm_path ) ;
207
208}
209
210
211
212my $script_dest = $build->install_destination('script') ;
213my $run_stem_path = File::Spec->catfile( $script_dest, 'run_stem' ) ;
214$build->config_data( run_stem_path => $run_stem_path ) ;
215
216
217
218
219my $bin_path = $build->install_destination('bin') ;
220$build->config_data( bin_path => $bin_path ) ;
221
222$build->config_data( perl_path => $build->config( 'perlpath' ) ) ;
223
224# Several different prefixes... which one to use??
225#$build->config_data( prefix => $build->prefix() ) ;
226$build->config_data( prefix => $build->config( 'install_base' ) ) ;
227
228
229$build->config_data( config_done => 1 ) ;
230
231
232#print Dumper \%{ $build->config_data() };
233
4536f655 234
235$build->create_build_script() ;
236
237exit ;
8e25eb98 238
2391 ;