This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix tab/space issue that entered in 17893. AIX.
[metaconfig.git] / U / modified / d_gethname.U
CommitLineData
959f3c4c
JH
1?RCS: $Id: d_gethname.U,v 3.0.1.1 1994/10/29 16:13:00 ram Exp $
2?RCS:
3?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4?RCS:
5?RCS: You may redistribute only under the terms of the Artistic Licence,
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
8?RCS: that same Artistic Licence; a copy of which may be found at the root
9?RCS: of the source tree for dist 3.0.
10?RCS:
11?RCS: $Log: d_gethname.U,v $
12?RCS: Revision 3.0.1.1 1994/10/29 16:13:00 ram
13?RCS: patch36: call ./xenix explicitely instead of relying on PATH
14?RCS:
15?RCS: Revision 3.0 1993/08/18 12:06:11 ram
16?RCS: Baseline for dist 3.0 netwide release.
17?RCS:
18?MAKE:d_gethname d_uname d_phostname aphostname: phostname cat \
19 myhostname package d_portable Loc libc echo n c +i_whoami +usrinc \
20 Myread Guess Oldconfig Csym
21?MAKE: -pick add $@ %<
22?S:d_gethname:
23?S: This variable conditionally defines the HAS_GETHOSTNAME symbol, which
24?S: indicates to the C program that the gethostname() routine may be
25?S: used to derive the host name.
26?S:.
27?S:d_uname:
28?S: This variable conditionally defines the HAS_UNAME symbol, which
29?S: indicates to the C program that the uname() routine may be
30?S: used to derive the host name.
31?S:.
32?S:d_phostname:
33?S: This variable conditionally defines the HAS_PHOSTNAME symbol, which
34?S: contains the shell command which, when fed to popen(), may be
35?S: used to derive the host name.
36?S:.
37?S:aphostname:
38?S: This variable contains the command which can be used to compute the
39?S: host name. The command is fully qualified by its absolute path, to make
40?S: it safe when used by a process with super-user privileges.
41?S:.
42?C:HAS_GETHOSTNAME (GETHOSTNAME):
43?C: This symbol, if defined, indicates that the C program may use the
44?C: gethostname() routine to derive the host name. See also HAS_UNAME
45?C: and PHOSTNAME.
46?C:.
47?C:HAS_UNAME (UNAME):
48?C: This symbol, if defined, indicates that the C program may use the
49?C: uname() routine to derive the host name. See also HAS_GETHOSTNAME
50?C: and PHOSTNAME.
51?C:.
52?C:PHOSTNAME:
53?C: This symbol, if defined, indicates the command to feed to the
54?C: popen() routine to derive the host name. See also HAS_GETHOSTNAME
55?C: and HAS_UNAME. Note that the command uses a fully qualified path,
56?C: so that it is safe even if used by a process with super-user
57?C: privileges.
58?C:.
59?C:HAS_PHOSTNAME:
60?C: This symbol, if defined, indicates that the C program may use the
61?C: contents of PHOSTNAME as a command to feed to the popen() routine
62?C: to derive the host name.
63?C:.
64?H:?%<:#$d_gethname HAS_GETHOSTNAME /**/
65?H:?%<:#$d_uname HAS_UNAME /**/
d088635c 66?H:?%<:#$d_phostname HAS_PHOSTNAME /**/
959f3c4c
JH
67?H:?%<:#ifdef HAS_PHOSTNAME
68?H:?%<:#define PHOSTNAME "$aphostname" /* How to get the host name */
69?H:?%<:#endif
70?H:.
71?T:file val call
72?LINT:change i_whoami
73?LINT:change PHOSTNAME
74: see how we will look up host name
75echo " "
76call=''
77@if HAS_GETHOSTNAME
78if set gethostname val -f d_gethname; eval $csym; $val; then
79 echo 'gethostname() found.' >&4
80 d_gethname="$define"
81 call=gethostname
82fi
83@end
84@if HAS_UNAME
85if set uname val -f d_uname; eval $csym; $val; then
86 if ./xenix; then
87 $cat <<'EOM'
88uname() was found, but you're running xenix, and older versions of xenix
89have a broken uname(). If you don't really know whether your xenix is old
90enough to have a broken system call, use the default answer.
91
92EOM
93 dflt=y
94 case "$d_uname" in
95 "$define") dflt=n;;
96 esac
97 rp='Is your uname() broken?'
98 . ./myread
99 case "$ans" in
100 n*) d_uname="$define"; call=uname;;
101 esac
102 else
103 echo 'uname() found.' >&4
104 d_uname="$define"
105 case "$call" in
106 '') call=uname ;;
107 esac
108 fi
109fi
110@end
111case "$d_gethname" in
112'') d_gethname="$undef";;
113esac
114case "$d_uname" in
115'') d_uname="$undef";;
116esac
117@if PHOSTNAME || MYHOSTNAME
118case "$d_uname$d_gethname" in
119*define*)
120 dflt=n
121 cat <<EOM
122
123Every now and then someone has a $call() that lies about the hostname
124but can't be fixed for political or economic reasons. If you wish, I can
125@if MYHOSTNAME && PHOSTNAME
126pretend $call() isn't there and maybe compile in the hostname or
127compute it from the '$phostname' command at run-time.
128@elsif MYHOSTNAME
129pretend $call() isn't there and maybe compile in the hostname.
130@elsif PHOSTNAME
131pretend $call() isn't there and maybe compute hostname at run-time
132thanks to the '$phostname' command.
133@elsif WHOAMI
134get the hostname from whomai.h (provided you have one).
135@else
136simply ignore your host name and use someting like "noname" instead.
137@end
138
139EOM
140 rp="Shall I ignore $call() from now on?"
141 . ./myread
142 case "$ans" in
143 y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
144 esac;;
145esac
146@end
147@if PHOSTNAME || aphostname
148?X: Compute the full path name for the command
149case "$phostname" in
150'') aphostname='';;
151*) case "$aphostname" in
152 /*) ;;
153 *) set X $phostname
154 shift
155 file=$1
156 shift
157 file=`./loc $file $file $pth`
158 aphostname=`echo $file $*`
159 ;;
160 esac
161 ;;
162esac
163@end
164@if PHOSTNAME && MYHOSTNAME
165case "$d_uname$d_gethname" in
166*define*) ;;
167*)
168 case "$phostname" in
169 '') ;;
170 *)
171 $cat <<EOT
172
173There is no gethostname() or uname() on this system. You have two
174possibilities at this point:
175
1761) You can have your host name ($myhostname) compiled into $package, which
177 lets $package start up faster, but makes your binaries non-portable, or
1782) you can have $package use a
179
180 popen("$aphostname","r")
181
182 which will start slower but be more portable.
183
184@ if WHOAMI
185Option 1 will give you the option of using whoami.h if you have one.
186@ end
187If you want option 2 but with a different command, you can edit config.sh at
188the end of this shell script.
189
190EOT
191 case "$d_phostname" in
192 "$define") dflt=n;;
193 "$undef") dflt=y;;
194 '')
195 case "$d_portable" in
196 "$define") dflt=n ;;
197 *) dflt=y ;;
198 esac;;
199 esac
200 rp="Do you want your host name compiled in?"
201 . ./myread
202 case "$ans" in
203 n*) d_phostname="$define" ;;
204 *) aphostname=''; d_phostname="$undef";;
205 esac;;
206 esac
207 case "$aphostname" in
208 '')
209@ if WHOAMI
210 case "$i_whoami" in
211 "$define")
212 dflt=y
213 $cat <<EOM
214
215No hostname function--you can either use the whoami.h file, which has this line:
216
217 `grep sysname $usrinc/whoami.h`
218
219or you can have the name we came up with earlier ($myhostname) hardwired in.
220EOM
221 rp="Use whoami.h to get hostname?"
222 . ./myread
223 case "$ans" in
224 n*) i_whoami="$undef";;
225 esac
226 ;;
227 "$undef")
228 $cat <<EOM
229No hostname function and no whoami.h -- hardwiring "$myhostname".
230EOM
231 ;;
232 esac;;
233@ else
234 echo 'No hostname function -- hardwiring "'$myhostname'".' >&4;;
235@ end
236 esac;;
237esac
238@elsif PHOSTNAME
239case "$d_uname$d_gethname" in
240*define*) ;;
241*)
242 case "$phostname" in
243 '')
244@ if WHOAMI
245 case "$i_whoami" in
246 "$define")
247 $cat <<EOM
248
249No hostname function--we'll use the whoami.h file, which has this line:
250
251 `grep sysname $usrinc/whoami.h`
252
253EOM
254 ;;
255 *) echo "There will be no way for $package to get your hostname." >&4;;
256 esac;;
257@ else
258 echo "There will be no way for $package to get your hostname." >&4;;
259@ end
260 *)
261 echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
262 ;;
263 esac;;
264esac
265@elsif MYHOSTNAME
266case "$d_uname$d_gethname" in
267*define*) ;;
268*)
269@ if WHOAMI
270 case "$i_whoami" in
271 "$define")
272 dflt=y
273 $cat <<EOM
274
275No hostname function--you can either use the whoami.h file, which has this line:
276
277 `grep sysname $usrinc/whoami.h`
278
279or you can have the name we came up with earlier ($myhostname) hardwired in.
280EOM
281 rp="Use whoami.h to get hostname?"
282 . ./myread
283 case "$ans" in
284 n*) i_whoami="$undef";;
285 esac
286 ;;
287 "$undef")
288 echo 'No whoami.h--hardwiring "'$myhostname'".' >&4;;
289 esac;;
290@ else
291 echo 'Hardwiring "'$myhostname'".' >&4;;
292@ end
293esac
294@end
295case "$d_phostname" in
296'') d_phostname="$undef";;
297esac
298