Commit | Line | Data |
b3407611 |
1 | #!/usr/bin/env perl |
4536f655 |
2 | |
b3407611 |
3 | use strict ; |
4 | use warnings ; |
4536f655 |
5 | |
b3407611 |
6 | use Config ; |
7 | use File::Spec ; |
4536f655 |
8 | use BuildStem ; |
b3407611 |
9 | use Data::Dumper ; |
4536f655 |
10 | |
b3407611 |
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 | |
15 | my %requires ; |
16 | |
17 | my $version_from = File::Spec->catfile( File::Spec->curdir, 'lib', 'Stem.pm' ); |
18 | |
19 | my $build = BuildStem->new( |
b3407611 |
20 | #my $build = $class->new( |
4536f655 |
21 | module_name => 'Stem', |
22 | dist_version_from => $version_from, |
23 | requires => \%requires, |
b3407611 |
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 | |
b3407611 |
32 | |
33 | $build->is_unixish() || die "Stem currently only installs properly on *nix-like platforms.\n"; |
34 | |
35 | ### this will come in handy for some refactoring... |
36 | ## $build->config( 'install_base' ) |
37 | |
38 | print <<'EOT'; |
39 | |
40 | Building Stem |
41 | |
42 | This script will ask you various questions in order to properly |
43 | configure, build and install Stem on your system. Whenever a question |
44 | is asked, the default answer will be shown inside [brackets]. |
45 | Pressing enter will accept the default answer. If a choice needs to be |
46 | made from a list of values, that list will be inside (parentheses). |
47 | |
48 | If you have already configured Stem in a previous build, you can put |
49 | use_defaults=1 on the Build command line and you won't be prompted for |
50 | any answers and the previous settings will be used. |
51 | |
52 | If you want to force a new build, run Build clean. |
53 | |
54 | ---------------------------------------------------------------------------- |
55 | |
56 | EOT |
57 | |
58 | print <<'EOT'; |
59 | |
60 | Stem comes with a utility called 'run_stem' which takes care of things |
61 | like initalizing Stem with a configuration file and controlling it's |
62 | operation via various parameters you can pass in as environment |
63 | variables or command line arguments. |
64 | |
65 | Stem configuration files are used to create and initialize Stem Cells |
66 | (objects). run_stem can search a path list for config files, so you |
67 | can set that list of directories here. |
68 | |
69 | Note that you can easily override this path with either a shell environment |
70 | variable or on the command line of run_stem. See the documentation on |
71 | run_stem for how so do this. |
72 | |
73 | The last directory in the list is where the standard and demo Stem |
74 | configuration files will be installed. |
75 | |
76 | Please enter a list of directory paths separated by ':'. |
77 | |
78 | EOT |
79 | |
80 | my $conf_path = $build->prompt( |
81 | "What directories do you want Stem to search for configuration files?\n", |
82 | '.:~/.stem/conf:/usr/local/stem/conf' |
83 | ); |
84 | $build->config_data(conf_path => $conf_path); |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | =begin comment |
92 | |
93 | print "\n\nChecking to see if you have a good C compiler...\n\n" ; |
94 | if ( $build->have_c_compiler() ) { |
95 | print <<'EOT'; |
96 | |
97 | |
98 | ssfe (Split Screen Front End) is a compiled program optionally used by |
99 | the Stem demonstration scripts that provides a full screen interface |
100 | with command line editing and history. It is not required to run Stem |
101 | but it makes the demonstrations easier to work with and they look much |
102 | nicer. To use ssfe add the '-s' option when you run any demonstration |
103 | script. You can also use ssfe for your own programs. Install ssfe in |
104 | some place in your $PATH ($conf->{'bin_path'} is where Stem executables |
105 | are being installed) so it can be used by the demo scripts. The ssfe |
106 | install script will do this for you or you can do it manually after |
107 | building it. |
108 | |
109 | EOT |
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 | |
126 | print <<'EOT'; |
127 | |
128 | Stem comes with a variety of demos to show how to get started and do some |
129 | basic things. |
130 | |
131 | EOT |
132 | my $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 ) ; |
135 | if ( $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 | |
166 | telnet was not found on this system. you can't run the demo programs |
167 | without telnet. Make sure you enter a valid path to telnet or some other |
168 | terminal emulator. |
169 | |
170 | NOTE: If you don't have an telnet, you can still run the demo scripts |
171 | by hand. Run a *_demo script and see what telnet commands it |
172 | issues. The run those telnet commands using your telnet or another |
173 | similar program. |
174 | |
175 | EOT |
176 | $telnet_path = $build->prompt( |
177 | "Enter the path to telnet " |
178 | . "(or another compatible telnet client)", |
179 | '/usr/bin/telnet' |
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 | |
191 | xterm was not found on this system. you can't run the demo programs |
192 | without xterm. Make sure you enter a valid path to xterm or some other |
193 | terminal emulator. |
194 | |
195 | NOTE: If you don't have an xterm, you can still run the demo scripts |
196 | by hand. Run a *_demo script and see what commands it issues. Take the |
197 | part after the -e and run that command in its own terminal window. |
198 | |
199 | EOT |
200 | $xterm_path = $build->prompt( |
201 | "Enter the path to xterm " |
202 | . "(or another compatible terminal emulator)", |
203 | '/usr/bin/xterm' |
204 | ) ; |
205 | } |
206 | $build->config_data( xterm_path => $xterm_path ) ; |
207 | |
208 | } |
209 | |
210 | |
211 | |
212 | my $script_dest = $build->install_destination('script') ; |
213 | my $run_stem_path = File::Spec->catfile( $script_dest, 'run_stem' ) ; |
214 | $build->config_data( run_stem_path => $run_stem_path ) ; |
215 | |
216 | |
217 | |
218 | |
219 | my $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 | |
237 | exit ; |
b3407611 |
238 | |
239 | 1 ; |