This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
applied new parts of suggested patch
[perl5.git] / hints / README.hints
CommitLineData
693762b4
AD
1=head1 NAME
2
3README.hints
4
5=head1 DESCRIPTION
6
a0d0e21e 7These files are used by Configure to set things which Configure either
b19cab98 8can't or doesn't guess properly. Most of these hint files have been
9tested with at least some version of perl5, but some are still left
693762b4
AD
10over from perl4.
11
12Please send any problems or suggested changes to perlbug@perl.com.
a0d0e21e 13
b19cab98 14Hint file naming convention: Each hint file name should have only
693762b4 15one '.'. (This is for portability to non-unix file systems.) Names
b19cab98 16should also fit in <= 14 characters, for portability to older SVR3
17systems. File names are of the form $osname_$osvers.sh, with all '.'
693762b4 18changed to '_', and all characters (such as '/') that don't belong in
b19cab98 19Unix filenames omitted.
a0d0e21e 20
693762b4 21For example, consider Sun OS 4.1.3. Configure determines $osname=sunos
b19cab98 22(all names are converted to lower case) and $osvers=4.1.3. Configure
23will search for an appropriate hint file in the following order:
a0d0e21e 24
b19cab98 25 sunos_4_1_3.sh
26 sunos_4_1.sh
27 sunos_4.sh
28 sunos.sh
a0d0e21e 29
b19cab98 30If you need to create a hint file, please try to use as general a name
31as possible and include minor version differences inside case or test
693762b4
AD
32statements. For example, for IRIX 6.X, we have the following hints
33files:
34
35 irix_6_0.sh
36 irix_6_1.sh
37 irix_6.sh
38
39That is, 6.0 and 6.1 have their own special hints, but 6.2, 6.3, and
40up are all handled by the same irix_6.sh. That way, we don't have to
41make a new hint file every time the IRIX O/S is upgraded.
42
43If you need to test for specific minor version differences in your
44hints file, be sure to include a default choice. (See aix.sh for one
45example.) That way, if you write a hint file for foonix 3.2, it might
46still work without any changes when foonix 3.3 is released.
b19cab98 47
48Please also comment carefully on why the different hints are needed.
49That way, a future version of Configure may be able to automatically
693762b4
AD
50detect what is needed.
51
52A glossary of config.sh variables is in the file Porting/Glossary.
53
54=head1 Hint file tricks
55
56=head2 Printing critical messages
57
58[This is still experimental]
59
60If you have a *REALLY* important message that the user ought to see at
61the end of the Configure run, you can store it in the file
62'config.msg'. At the end of the Configure run, Configure will display
63the contents of this file. Currently, the only place this is used is
64in Configure itself to warn about the need to set LD_LIBRARY_PATH if
65you are building a shared libperl.so.
66
67To use this feature, just do something like the following
68
69 $cat <<EOM | $tee -a ../config.msg >&4
70
71 This is a really important message. Be sure to read it
72 before you type 'make'.
73 EOM
74
75This message will appear on the screen as the hint file is being
76processed and again at the end of Configure.
77
78Please use this sparingly.
79
80=head2 Propagating variables to config.sh
81
82Sometimes, you want an extra variable to appear in config.sh. For
83example, if your system can't compile toke.c with the optimizer on,
84you can put
85
86 toke_cflags='optimize=""'
87
88at the beginning of a line in your hints file. Configure will then
89extract that variable and place it in your config.sh file. Later,
90while compiling toke.c, the cflags shell script will eval $toke_cflags
91and hence compile toke.c without optimization.
92
93Note that for this to work, the variable you want to propagate must
94appear in the first column of the hint file. It is extracted by
95Configure with a simple sed script, so beware that surrounding case
96statements aren't any help.
97
98By contrast, if you don't want Configure to propagate your temporary
99variable, simply indent it by a leading tab in your hint file.
100
101For example, prior to 5.002, a bug in scope.c led to perl crashing
102when compiled with -O in AIX 4.1.1. The following "obvious"
103workaround in hints/aix.sh wouldn't work as expected:
104
105 case "$osvers" in
106 4.1.1)
107 scope_cflags='optimize=""'
108 ;;
109 esac
110
111because Configure doesn't parse the surrounding 'case' statement, it
112just blindly propagates any variable that starts in the first column.
113For this particular case, that's probably harmless anyway.
114
115Three possible fixes are:
116
117=over
118
119=item 1
120
121Create an aix_4_1_1.sh hint file that contains the scope_cflags
122line and then sources the regular aix hints file for the rest of
123the information.
124
125=item 2
126
127Do the following trick:
128
129 scope_cflags='case "$osvers" in 4.1*) optimize=" ";; esac'
130
131Now when $scope_cflags is eval'd by the cflags shell script, the
132case statement is executed. Of course writing scripts to be eval'd is
133tricky, especially if there is complex quoting. Or,
134
135=item 3
136
137Write directly to Configure's temporary file UU/config.sh.
138You can do this with
139
140 case "$osvers" in
141 4.1.1)
142 echo "scope_cflags='optimize=\"\"'" >> UU/config.sh
143 scope_cflags='optimize=""'
144 ;;
145 esac
146
147Note you have to both write the definition to the temporary
148UU/config.sh file and set the variable to the appropriate value.
149
150This is sneaky, but it works. Still, if you need anything this
151complex, perhaps you should create the separate hint file for
152aix 4.1.1.
153
154=back
155
156=head2 Call-backs
157
158=over 4
159
160=item Warning
161
162All of the following is experimental and subject to change. But it
163probably won't change much. :-)
164
165=item Compiler-related flags
166
167The settings of some things, such as optimization flags, may depend on
168the particular compiler used. For example, for ISC we have the
169following:
170
171 case "$cc" in
172 *gcc*) ccflags="$ccflags -posix"
173 ldflags="$ldflags -posix"
174 ;;
175 *) ccflags="$ccflags -Xp -D_POSIX_SOURCE"
176 ldflags="$ldflags -Xp"
177 ;;
178 esac
179
180However, the hints file is processed before the user is asked which
181compiler should be used. Thus in order for these hints to be useful,
182the user must specify sh Configure -Dcc=gcc on the command line, as
183advised by the INSTALL file.
184
185For versions of perl later than 5.004_61, this problem can
186be circumvented by the use of "call-back units". That is, the hints
187file can tuck this information away into a file UU/cc.cbu. Then,
188after Configure prompts the user for the C compiler, it will load in
189and run the UU/cc.cbu "call-back" unit. See hints/solaris_2.sh for an
190example.
191
693762b4
AD
192=item Future status
193
194I hope this "call-back" scheme is simple enough to use but powerful
195enough to deal with most situations. Still, there are certainly cases
196where it's not enough. For example, for aix we actually change
197compilers if we are using threads.
198
199I'd appreciate feedback on whether this is sufficiently general to be
200helpful, or whether we ought to simply continue to require folks to
201say things like "sh Configure -Dcc=gcc -Dusethreads" on the command line.
202
203=back
b19cab98 204
205Have the appropriate amount of fun :-)
206
207 Andy Dougherty doughera@lafcol.lafayette.edu