7d0df683bd649bbe78334912741c596deffaab1b
[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 BuildStem ;
9 use Data::Dumper ;
10
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)
14
15 my %requires ;
16
17 my $version_from = File::Spec->catfile( File::Spec->curdir, 'lib', 'Stem.pm' );
18
19 my $build = BuildStem->new(
20 #my $build = $class->new(
21         module_name             => 'Stem',
22         dist_version_from       => $version_from,
23         requires                => \%requires,
24         dist_abstract           => 'ABSTRACT GOES HERE',
25         license                 => 'gpl',
26         dynamic_config          => 1,
27         recursive_test_files    => 1,
28         create_makefile_pl      => 'passthrough'
29 );
30
31
32
33 $build->is_unixish() || die "Stem currently only installs properly on *nix-like platforms.\n";
34
35
36 print <<'EOT';
37
38 Building Stem
39
40 This script will ask you various questions in order to properly
41 configure, build and install Stem on your system.  Whenever a question
42 is asked, the default answer will be shown inside [brackets].
43 Pressing enter will accept the default answer. If a choice needs to be
44 made from a list of values, that list will be inside (parentheses).
45
46 If you have already configured Stem in a previous build, you can put
47 use_defaults=1 on the Build command line and you won't be prompted for
48 any answers and the previous settings will be used.
49
50 If you want to force a new build, run Build clean.
51
52 ----------------------------------------------------------------------------
53
54 EOT
55
56
57
58 print <<'EOT';
59
60 Stem configuration files are used to create and initialize Stem Cells
61 (objects). Stem needs to know the list of directories to search to
62 find its configurations files.
63
64 Note that the default has a single absolute path. You can test Stem
65 configurations easily setting this path when executing run_stem. You
66 can override or modify the path time with either a shell environment
67 variable or on the command line of run_stem. See the documentation on
68 run_stem for how so do this.
69
70 The first directory in the list is where the standard Stem
71 configuration files will be installed.
72
73 Enter a list of absolute directory paths separated by ':'.
74
75 EOT
76
77 my $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
90 print "\n\nChecking to see if you have a good C compiler...\n\n" ;
91 if ( $build->have_c_compiler() ) {
92         print <<'EOT';
93         
94         
95 ssfe (Split Screen Front End) is a compiled program optionally used by
96 the Stem demonstration scripts that provides a full screen interface
97 with command line editing and history. It is not required to run Stem
98 but it makes the demonstrations easier to work with and they look much
99 nicer. To use ssfe add the '-s' option when you run any demonstration
100 script. You can also use ssfe for your own programs.  Install ssfe in
101 some place in your $PATH ($conf->{'bin_path'} is where Stem executables
102 are being installed) so it can be used by the demo scripts. The ssfe
103 install script will do this for you or you can do it manually after
104 building it.
105
106 EOT
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
123 print <<'EOT';
124
125 Stem comes with a variety of demos to show how to get started and do some 
126 basic things.
127
128 EOT
129 my $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 ) ;
132 if ( $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
163 telnet was not found on this system. you can't run the demo programs
164 without telnet.  Make sure you enter a valid path to telnet or some other
165 terminal emulator.
166
167 NOTE: If you don't have an telnet, you can still run the demo scripts
168 by hand. Run a *_demo script and see what telnet commands it
169 issues. The run those telnet commands using your telnet or another
170 similar program.
171
172 EOT
173                 $telnet_path = $build->prompt(
174                           "Enter the path to telnet "
175                         . "(or another compatible telnet client)",
176             '/foo/usr/bin/telnet'
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
188 xterm was not found on this system. you can't run the demo programs
189 without xterm.  Make sure you enter a valid path to xterm or some other
190 terminal emulator.
191
192 NOTE: If you don't have an xterm, you can still run the demo scripts
193 by hand. Run a *_demo script and see what commands it issues. Take the
194 part after the -e and run that command in its own terminal window.
195
196 EOT
197                 $xterm_path = $build->prompt(
198                           "Enter the path to xterm "
199                         . "(or another compatible terminal emulator)",
200             '/foo/usr/bin/xterm'
201                 ) ;
202         }
203         $build->config_data( xterm_path => $xterm_path ) ;
204
205 }
206
207
208
209 my $script_dest = $build->install_destination('script') ;
210 my $run_stem_path = File::Spec->catfile( $script_dest, 'run_stem' ) ;
211 $build->config_data( run_stem_path => $run_stem_path ) ;
212
213
214
215
216 my $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
231
232 $build->create_build_script() ;
233
234 exit ;
235
236 1 ;