This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove spurious LINT: directives
[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
4c42341b 4?RCS:
959f3c4c
JH
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
959f3c4c
JH
73: see how we will look up host name
74echo " "
75call=''
76@if HAS_GETHOSTNAME
77if set gethostname val -f d_gethname; eval $csym; $val; then
78 echo 'gethostname() found.' >&4
79 d_gethname="$define"
80 call=gethostname
81fi
82@end
83@if HAS_UNAME
84if set uname val -f d_uname; eval $csym; $val; then
85 if ./xenix; then
86 $cat <<'EOM'
87uname() was found, but you're running xenix, and older versions of xenix
88have a broken uname(). If you don't really know whether your xenix is old
89enough to have a broken system call, use the default answer.
90
91EOM
92 dflt=y
93 case "$d_uname" in
94 "$define") dflt=n;;
95 esac
96 rp='Is your uname() broken?'
97 . ./myread
98 case "$ans" in
99 n*) d_uname="$define"; call=uname;;
100 esac
101 else
102 echo 'uname() found.' >&4
103 d_uname="$define"
104 case "$call" in
105 '') call=uname ;;
106 esac
107 fi
108fi
109@end
110case "$d_gethname" in
111'') d_gethname="$undef";;
112esac
113case "$d_uname" in
114'') d_uname="$undef";;
115esac
116@if PHOSTNAME || MYHOSTNAME
117case "$d_uname$d_gethname" in
118*define*)
119 dflt=n
120 cat <<EOM
4c42341b 121
959f3c4c
JH
122Every now and then someone has a $call() that lies about the hostname
123but can't be fixed for political or economic reasons. If you wish, I can
124@if MYHOSTNAME && PHOSTNAME
125pretend $call() isn't there and maybe compile in the hostname or
126compute it from the '$phostname' command at run-time.
127@elsif MYHOSTNAME
128pretend $call() isn't there and maybe compile in the hostname.
129@elsif PHOSTNAME
130pretend $call() isn't there and maybe compute hostname at run-time
131thanks to the '$phostname' command.
132@elsif WHOAMI
133get the hostname from whomai.h (provided you have one).
134@else
135simply ignore your host name and use someting like "noname" instead.
136@end
137
138EOM
139 rp="Shall I ignore $call() from now on?"
140 . ./myread
141 case "$ans" in
142 y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
143 esac;;
144esac
145@end
146@if PHOSTNAME || aphostname
147?X: Compute the full path name for the command
148case "$phostname" in
149'') aphostname='';;
150*) case "$aphostname" in
151 /*) ;;
152 *) set X $phostname
153 shift
154 file=$1
155 shift
156 file=`./loc $file $file $pth`
157 aphostname=`echo $file $*`
158 ;;
159 esac
160 ;;
161esac
162@end
163@if PHOSTNAME && MYHOSTNAME
164case "$d_uname$d_gethname" in
165*define*) ;;
166*)
167 case "$phostname" in
168 '') ;;
169 *)
170 $cat <<EOT
171
172There is no gethostname() or uname() on this system. You have two
173possibilities at this point:
174
1751) You can have your host name ($myhostname) compiled into $package, which
176 lets $package start up faster, but makes your binaries non-portable, or
1772) you can have $package use a
4c42341b 178
959f3c4c
JH
179 popen("$aphostname","r")
180
181 which will start slower but be more portable.
182
183@ if WHOAMI
184Option 1 will give you the option of using whoami.h if you have one.
185@ end
186If you want option 2 but with a different command, you can edit config.sh at
187the end of this shell script.
188
189EOT
190 case "$d_phostname" in
191 "$define") dflt=n;;
192 "$undef") dflt=y;;
193 '')
194 case "$d_portable" in
195 "$define") dflt=n ;;
196 *) dflt=y ;;
197 esac;;
198 esac
199 rp="Do you want your host name compiled in?"
200 . ./myread
201 case "$ans" in
202 n*) d_phostname="$define" ;;
203 *) aphostname=''; d_phostname="$undef";;
204 esac;;
205 esac
206 case "$aphostname" in
207 '')
208@ if WHOAMI
209 case "$i_whoami" in
210 "$define")
211 dflt=y
212 $cat <<EOM
4c42341b 213
959f3c4c
JH
214No hostname function--you can either use the whoami.h file, which has this line:
215
216 `grep sysname $usrinc/whoami.h`
217
218or you can have the name we came up with earlier ($myhostname) hardwired in.
219EOM
220 rp="Use whoami.h to get hostname?"
221 . ./myread
222 case "$ans" in
223 n*) i_whoami="$undef";;
224 esac
225 ;;
226 "$undef")
227 $cat <<EOM
228No hostname function and no whoami.h -- hardwiring "$myhostname".
229EOM
230 ;;
231 esac;;
232@ else
233 echo 'No hostname function -- hardwiring "'$myhostname'".' >&4;;
234@ end
235 esac;;
236esac
237@elsif PHOSTNAME
238case "$d_uname$d_gethname" in
239*define*) ;;
240*)
241 case "$phostname" in
242 '')
243@ if WHOAMI
244 case "$i_whoami" in
245 "$define")
246 $cat <<EOM
247
248No hostname function--we'll use the whoami.h file, which has this line:
249
250 `grep sysname $usrinc/whoami.h`
251
252EOM
253 ;;
254 *) echo "There will be no way for $package to get your hostname." >&4;;
255 esac;;
256@ else
257 echo "There will be no way for $package to get your hostname." >&4;;
258@ end
259 *)
260 echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
261 ;;
262 esac;;
263esac
264@elsif MYHOSTNAME
265case "$d_uname$d_gethname" in
266*define*) ;;
267*)
268@ if WHOAMI
269 case "$i_whoami" in
270 "$define")
271 dflt=y
272 $cat <<EOM
4c42341b 273
959f3c4c
JH
274No hostname function--you can either use the whoami.h file, which has this line:
275
276 `grep sysname $usrinc/whoami.h`
277
278or you can have the name we came up with earlier ($myhostname) hardwired in.
279EOM
280 rp="Use whoami.h to get hostname?"
281 . ./myread
282 case "$ans" in
283 n*) i_whoami="$undef";;
284 esac
285 ;;
286 "$undef")
287 echo 'No whoami.h--hardwiring "'$myhostname'".' >&4;;
288 esac;;
289@ else
290 echo 'Hardwiring "'$myhostname'".' >&4;;
291@ end
292esac
293@end
294case "$d_phostname" in
295'') d_phostname="$undef";;
296esac
297