source: trunk/third/gmp/doc/configuration @ 18191

Revision 18191, 13.2 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18190, which included commits to RCS files with non-trunk default branches.
Line 
1/* doc/configuration (in Emacs -*-outline-*- format). */
2
3Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
4
5This file is part of the GNU MP Library.
6
7The GNU MP Library is free software; you can redistribute it and/or modify
8it under the terms of the GNU Lesser General Public License as published by
9the Free Software Foundation; either version 2.1 of the License, or (at your
10option) any later version.
11
12The GNU MP Library is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15License for more details.
16
17You should have received a copy of the GNU Lesser General Public License
18along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
19the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA.
21
22
23
24* Adding a new file
25
26** Adding a top-level file
27
28  i) Add it to libgmp_la_SOURCES in Makefile.am.
29
30  ii) If libmp.la needs it (usually doesn't), then add it to
31      libmp_la_SOURCES too.
32
33** Adding a subdirectory file
34
35For instance for mpz,
36
37  i) Add file.c to libmpz_la_SOURCES in mpz/Makefile.am.
38
39  ii) Add mpz/file$U.lo to MPZ_OBJECTS in the top-level Makefile.am
40
41  iii) If for some reason libmp.la needs it (usually doesn't) then add
42       mpz/file$U.lo to libmp_la_DEPENDENCIES in the top-level
43       Makefile.am too.
44
45The same applies to mpf, mpq, scanf and printf.
46
47** Adding an mpn file
48
49The way we build libmpn (in the `mpn' subdirectory) is quite special.
50
51Currently only mpn/mp_bases.c is truely generic and included in every
52configuration.  All other files are linked at build time into the mpn
53build directory from one of the CPU specific sub-directories, or from
54the mpn/generic directory.
55
56There are four types of mpn source files.
57
58  .asm    Assembly code preprocessed with m4
59  .S      Assembly code preprocessed with cpp
60  .s      Assembly code not preprocessed at all
61  .c      C code
62
63There are two types of .asm files.
64
65  i) ``Normal'' files containing one function, though possibly with
66     more than one entry point.
67
68  ii) Multi-function files that generate one of a set of functions
69      according to build options.
70
71To add a new implementation of an existing function,
72
73  i) Put it in the appropriate CPU-specific mpn subdirectory, it'll be
74     detected and used.
75
76  ii) Any entrypoints tested by HAVE_NATIVE_func in other code must
77      have PROLOGUE(func) for configure to grep.  This is normal for
78      .asm or .S files, but for .c files a dummy comment like the
79      following will be needed.
80
81              /*
82              PROLOGUE(func)
83              */
84
85To add a new implementation using a multi-function file, in addition
86do the following,
87
88  i) Use a MULFUNC_PROLOGUE(func1 func2 ...) in the .asm, declaring
89     all the functions implemented, including carry-in variants.
90
91     If there's a separate PROLOGUE(func) for each possible function,
92     then MULFUNC_PROLOGUE isn't necessary (but this is usually not
93     the case).
94
95To add a new style of multi-function file, in addition do the
96following,
97
98  i) Add to the "case" statement in configure.in which lists each
99     multi-function filename and what function files it can provide.
100
101To add a completely new mpn function file, do the following,
102
103  i) Ensure the filename is a valid C identifier, due to the
104     -DOPERATION_$* used to support multi-function files.  This means
105     "-" can't be used (but "_" can).
106
107  ii) Add it to configure.in under one of the following
108
109      a) `gmp_mpn_functions' if it exists for every target.  This
110         means there must be a C version in mpn/generic.  (Eg. mul_1)
111
112      b) `gmp_mpn_functions_optional' if it's a standard function, but
113         doesn't need to exist for every target.  Code wanting to use
114         this will test HAVE_NATIVE_func to see if it's available.
115         (Eg. copyi)
116
117      c) `extra_functions' for some targets, if it's a special
118         function that only ever needs to exist for certain targets.
119         Code wanting to use it can test either HAVE_NATIVE_func or
120         HAVE_HOST_CPU_foo, as desired.
121
122  iii) Add `#undef HAVE_NATIVE_func' to acconfig.h.  This is only
123       actually necessary if that define is going to be used, but for
124       consistency it's good to do it always.
125
126  iv) Add file.c to nodist_libdummy_la_SOURCES in mpn/Makefile.am (in
127      order to get an ansi2knr rule).  If the file is only in
128      assembler then this step is unnecessary, but do it anyway so as
129      not to forget if later a .c version is added.
130
131  v) If the function can be provided by a multi-function file, then
132     add to the "case" statement in configure.in which lists each
133     multi-function filename and what function files it can provide.
134
135
136** Adding a test program
137
138  i) Tests to be run early in the testing can be added to the main
139     "tests" sub-directory.
140
141  ii) Tests for mpn, mpz, mpq and mpf can be added under the
142      corresponding tests subdirectory.
143
144  iii) Generic tests for late in the testing can be added to
145       "tests/misc".  printf and scanf tests currently live there too.
146
147  iv) Random number function tests can be added to "tests/rand".  That
148      directory has some development-time programs too.
149
150  v) C++ test programs can be added to "tests/cxx".  A line like the
151     following must be added for each, since by default automake looks
152     for a .c file.
153
154             t_foo_SOURCES = t-foo.cc
155
156In all cases the name of the program should be added to check_PROGRAMS
157in the Makefile.am.  TESTS is equal to check_PROGRAMS, so all those
158programs get run.
159
160"tests/devel" has a number of programs which are only for development
161purposes and are not for use in "make check".  These should be listed
162in EXTRA_PROGRAMS to get Makefile rules created, but they're never
163built or run unless an explicit "make someprog" is used.
164
165** Macos directory
166
167The macos/configure script will automatically pick up additions to
168gmp_mpn_functions, MPZ_OBJECTS, etc, but currently test programs need
169to be added to Makefile.in manually.
170
171When modifying the top-level configure.in ensure that it doesn't upset
172the macos/configure script heuristics.
173
174
175* Adding a new CPU
176
177In general it's policy to use proper names for each CPU type
178supported.  If two CPUs are quite similar and perhaps don't have any
179actual differences in GMP then they're still given separate names, for
180example alphaev67 and alphaev68.
181
182Canonical names:
183
184  i) Decide the canonical CPU names GMP will accept.
185
186  ii) Add these to the config.sub wrapper if configfsf.sub doesn't
187      already accept them.
188
189  iii) Document the names in gmp.texi.
190
191Aliases (optional):
192
193  i) Any aliases can be added to the config.sub wrapper, unless
194     configfsf.sub already does the right thing with them.
195
196  ii) Leave configure.in and everywhere else using only the canonical
197      names.  Aliases shouldn't appear anywhere except config.sub.
198
199  iii) Document in gmp.texi, if desired.  Usually this isn't a good
200       idea, better encourage users to know just the canonical
201       names.
202
203Configure:
204
205  i) Add patterns to configure.in for the new CPU names.  Include the
206     following (see configure.in for the variables to set up),
207
208     a) ABI choices (if any).
209     b) Compiler choices.
210     c) mpn path for CPU specific code.
211     d) Good default CFLAGS for each likely compiler.
212     d) Any special tests necessary on the compiler or assembler
213        capabilities.
214
215  ii) M4 macros to be shared by asm files in a CPU family are by
216      convention in a foo-defs.m4 like mpn/x86/x86-defs.m4.  They're
217      likely to use settings from config.m4 generated by configure.
218
219
220* The configure system
221
222** Installing tools
223
224The current versions of automake, autoconf and libtool in use can be
225checked in the ChangeLog.  Look for "Update to ...".  Patches may have
226been applied, look for "Regenerate ...".
227
228The GMP build system is in places somewhat dependent on the internals
229of the build tools.  Obviously that's avoided as much as possible, but
230where it can't it creates a problem when upgrading or attempting to
231use different tools versions.
232
233** Updating gmp
234
235The following files need to be updated when going to a new version of
236the build tools.  Unfortunately the tools generally don't identify
237when an out-of-date version is present.
238
239aclocal.m4 is updated by running "aclocal -I mpfr".
240
241INSTALL.autoconf can be copied from INSTALL in autoconf.
242
243ltmain.sh comes from libtool.  Remove it and run "libtoolize --copy",
244or just copy the file by hand.
245
246ansi2knr.c, ansi2knr.1, install.sh, mdate-sh and mkinstalldirs come
247from automake and can be updated by copying or by removing and running
248"automake --add-missing --copy".
249
250texinfo.tex can be updated from ftp.gnu.org.  Check it still works
251with "make gmp.dvi" and "texi2pdf gmp.texi".
252
253configfsf.guess and configfsf.sub can be updated from ftp.gnu.org (or
254from the "config" cvs module at subversions.gnu.org).  The gmp
255config.guess and config.sub wrappers are supposed to make such an
256update fairly painless.
257
258depcomp from automake is not needed because all Makefile.am files
259specify "no-dependencies".
260
261** How it works
262
263During development:
264
265    Input files        Tool       Output files
266    ------------------------------------------
267                     aclocal
268    acinclude.m4  --------------> aclocal.m4
269
270                     autoconf
271    configure.in \ -------------> configure
272    aclocal.m4   /
273
274                     automake
275    Makefile.am  \ -------------> Makefile.in
276    configure.in /
277
278                     autoheader
279    configure.in \ -------------> config.in
280    aclocal.m4   |
281    acconfig.h   /
282
283When configured with --enable-maintainer-mode the necessary tools are
284re-run on changing the input files.  This can end up running a lot
285more things than are really necessary, but that's too bad.
286
287At build time:
288
289    Input files        Tool       Output files
290    ------------------------------------------
291
292    Makefile.in  \   configure    / Makefile
293    config.in    | -------------> | config.h
294    gmp-h.in     |                | config.m4
295    mp-h.in      /                | gmp.h
296                                  \ mp.h
297
298** C++ configuration
299
300It's intended that the contents of libgmp.la won't vary according to
301whether --enable-cxx is selected.  This means that if C++ shared
302libraries don't work properly then a shared+static with --disable-cxx
303can be done for the C parts, then a static-only with --enable-cxx to
304get libgmpxx.
305
306libgmpxx.la uses some internals from libgmp.la, in order to share code
307between C and C++.  It's intended that libgmpxx can only be expected
308to work with libgmp from the same version of GMP.  If some of the
309shared internals change their interface, then it's proposed to rename
310them, for instance __gmp_doprint2 or the like, so as to provoke link
311errors rather than mysterious failures from a mismatch.
312
313* Development setups
314
315** General
316
317--disable-shared will make builds go much faster, though of course
318shared or shared+static should be tested too.
319
320--enable-mpbsd grabs various bits of mpz, which might need to be
321adjusted if things in those routines are changed.  Building mpbsd all
322the time doesn't cost much.
323
324--prefix to a dummy directory followed by "make install" will show
325what's installed.
326
327"make check" acts on the libgmp just built, and will ignore any other
328/usr/lib/libgmp, or at least it should do.  Libtool does various hairy
329things to ensure it hits the just-built library.
330
331** Debugging
332
333A build with maximum debugging can be made with
334
335        ./configure --host=none --enable-assert --enable-alloca=debug
336
337Malloc memory leaks are always checked by the test programs.  With
338alloca=debug any TMP_ALLOC leaks will be detected too.
339--enable-alloca=malloc-reentrant also has this effect.
340
341** Long long limb testing
342
343On systems where gcc supports long long, but a limb is normally just a
344long, the following can be used to force long long for testing
345purposes.  It will probably run quite slowly.
346
347        ./configure --host=none ABI=longlong
348
349** Function argument conversions
350
351When using gcc, configuring with something like
352
353        ./configure CFLAGS="-g -Wall -Wconversion -Wno-sign-compare"
354
355can show where function parameters are being converted due to having
356function prototypes available, which won't happen in a K&R compiler.
357Doing this in combination with the long long limb setups above is
358good.
359
360Conversions between int and long aren't warned about by gcc when
361they're the same size, which is unfortunate because casts should be
362used in such cases, for the benefit of K&R compilers with int!=long
363and where the difference matters in function calls.
364
365** K&R support
366
367Function definitions must be in the GNU stylized form to work.  See
368the ansi2knr.1 man page.
369
370__GMP_PROTO is used for function prototypes, other ANSI / K&R
371differences are conditionalized in various places.
372
373Proper testing of the K&R support requires a compiler which gives an
374error for ANSI-isms.  Configuring with --host=none is a good idea, to
375test all the generic C code.
376
377When using an ANSI compiler, the ansi2knr setups can be partially
378tested with
379
380        ./configure am_cv_prog_cc_stdc=no
381
382This will test the use of $U and the like in the makefiles, but not
383much else.
384
385am_cv_prog_cc_stdc=no can be used with a compiler like HP C which is
386K&R by default but to which configure normally adds ANSI mode flags.
387This then should be a good full K&R test.
388
389
390
391Local variables:
392mode: outline
393fill-column: 70
394End:
395/* eof doc/configuration */
Note: See TracBrowser for help on using the repository browser.