fixed run stem to work from build dir
[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
35
36print <<'EOT';
37
38Building Stem
39
40This script will ask you various questions in order to properly
41configure, build and install Stem on your system. Whenever a question
42is asked, the default answer will be shown inside [brackets].
43Pressing enter will accept the default answer. If a choice needs to be
44made from a list of values, that list will be inside (parentheses).
45
46If you have already configured Stem in a previous build, you can put
47use_defaults=1 on the Build command line and you won't be prompted for
48any answers and the previous settings will be used.
49
50If you want to force a new build, run Build clean.
51
52----------------------------------------------------------------------------
53
54EOT
55
56
57
58print <<'EOT';
59
60Stem configuration files are used to create and initialize Stem Cells
61(objects). Stem needs to know the list of directories to search to
62find its configurations files.
63
64Note that the default has a single absolute path. You can test Stem
65configurations easily setting this path when executing run_stem. You
66can override or modify the path time with either a shell environment
67variable or on the command line of run_stem. See the documentation on
68run_stem for how so do this.
69
70The first directory in the list is where the standard Stem
71configuration files will be installed.
72
73Enter a list of absolute directory paths separated by ':'.
74
75EOT
76
77my $conf_path = $build->prompt(
78 "What directories do you want Stem to search for configuration files?\n",
79 '.:./conf:~/.stem/conf:/usr/local/stem/conf'
80);
81$build->config_data(conf_path => $conf_path);
82
83
84
85
86
87
88=begin comment
89
90print "\n\nChecking to see if you have a good C compiler...\n\n" ;
91if ( $build->have_c_compiler() ) {
92 print <<'EOT';
93
94
95ssfe (Split Screen Front End) is a compiled program optionally used by
96the Stem demonstration scripts that provides a full screen interface
97with command line editing and history. It is not required to run Stem
98but it makes the demonstrations easier to work with and they look much
99nicer. To use ssfe add the '-s' option when you run any demonstration
100script. You can also use ssfe for your own programs. Install ssfe in
101some place in your $PATH ($conf->{'bin_path'} is where Stem executables
102are being installed) so it can be used by the demo scripts. The ssfe
103install script will do this for you or you can do it manually after
104building it.
105
106EOT
107 my $install_ssfe = $build->y_n("Do you want to install ssfe?\n", 'y');
108 $build->config_data(install_ssfe => $install_ssfe);
109 if ( $install_ssfe ) {
110
111 # Do horrible, nasty things.
112 # This really should be done with a proper makefile.
113
114 }
115}
116
117=cut
118
119
120
121
122
123print <<'EOT';
124
125Stem comes with a variety of demos to show how to get started and do some
126basic things.
127
128EOT
129my $install_demos = $build->y_n("\nDo you want to install the demos?\n",'n');
130$build->config_data( install_demos => $install_demos ) ;
131$build->config_data( build_demos => $install_demos ) ;
132if ( $install_demos ) {
133
134 my $demo_dir = $build->prompt(
135 "\nWhere do you want to install the demo scripts?\n",
136 '/usr/local/stem/demo'
137 );
138 $build->config_data(demo_dir => $demo_dir);
139 $build->install_path()->{demo} ||= $demo_dir;
140
141
142
143 my $demo_conf_dir = $build->prompt(
144 "\nWhere do you want to install the demo config files?\n",
145 '/usr/local/stem/conf'
146 );
147 $build->config_data(demo_conf_dir => $demo_conf_dir);
148 $build->install_path()->{conf} ||= $demo_conf_dir;
149 $build->add_build_element('conf');
150
151 my $cur_conf_path = $build->config_data('conf_path') ;
152 my $new_conf_path = $cur_conf_path =~ /(^|:)$demo_conf_dir(:|$)/ ?
153 $cur_conf_path : "$cur_conf_path:$demo_conf_dir" ;
154 $build->config_data( conf_path => $new_conf_path ) ;
155
156
157 # Check for telnet
158 my $telnet_path = $build->find_binary( 'telnet' ) || '' ;
159 while ( ! -x $telnet_path && ! $build->_is_unattended() ) {
160 print <<'EOT';
161
162
163telnet was not found on this system. you can't run the demo programs
164without telnet. Make sure you enter a valid path to telnet or some other
165terminal emulator.
166
167NOTE: If you don't have an telnet, you can still run the demo scripts
168by hand. Run a *_demo script and see what telnet commands it
169issues. The run those telnet commands using your telnet or another
170similar program.
171
172EOT
173 $telnet_path = $build->prompt(
174 "Enter the path to telnet "
175 . "(or another compatible telnet client)",
816e7ec7 176 '/usr/bin/telnet'
8e25eb98 177 ) ;
178 }
179 $build->config_data( telnet_path => $telnet_path ) ;
180
181
182 # Check for xterm
183 my $xterm_path = $build->find_binary( 'xterm' ) || '' ;
184 while ( ! -x $xterm_path && ! $build->_is_unattended() ) {
185 print <<'EOT';
186
187
188xterm was not found on this system. you can't run the demo programs
189without xterm. Make sure you enter a valid path to xterm or some other
190terminal emulator.
191
192NOTE: If you don't have an xterm, you can still run the demo scripts
193by hand. Run a *_demo script and see what commands it issues. Take the
194part after the -e and run that command in its own terminal window.
195
196EOT
197 $xterm_path = $build->prompt(
198 "Enter the path to xterm "
199 . "(or another compatible terminal emulator)",
816e7ec7 200 '/usr/bin/xterm'
8e25eb98 201 ) ;
202 }
203 $build->config_data( xterm_path => $xterm_path ) ;
204
205}
206
207
208
209my $script_dest = $build->install_destination('script') ;
210my $run_stem_path = File::Spec->catfile( $script_dest, 'run_stem' ) ;
211$build->config_data( run_stem_path => $run_stem_path ) ;
212
213
214
215
216my $bin_path = $build->install_destination('bin') ;
217$build->config_data( bin_path => $bin_path ) ;
218
219$build->config_data( perl_path => $build->config( 'perlpath' ) ) ;
220
221# Several different prefixes... which one to use??
222#$build->config_data( prefix => $build->prefix() ) ;
223$build->config_data( prefix => $build->config( 'install_base' ) ) ;
224
225
226$build->config_data( config_done => 1 ) ;
227
228
229#print Dumper \%{ $build->config_data() };
230
4536f655 231
232$build->create_build_script() ;
233
234exit ;
8e25eb98 235
2361 ;