Blame doc/configuration

Packit 5c3484
/* doc/configuration (in Emacs -*-outline-*- format). */
Packit 5c3484
Packit 5c3484
Copyright 2000-2004 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
This file is part of the GNU MP Library.
Packit 5c3484
Packit 5c3484
The GNU MP Library is free software; you can redistribute it and/or modify
Packit 5c3484
it under the terms of either:
Packit 5c3484
Packit 5c3484
  * the GNU Lesser General Public License as published by the Free
Packit 5c3484
    Software Foundation; either version 3 of the License, or (at your
Packit 5c3484
    option) any later version.
Packit 5c3484
Packit 5c3484
or
Packit 5c3484
Packit 5c3484
  * the GNU General Public License as published by the Free Software
Packit 5c3484
    Foundation; either version 2 of the License, or (at your option) any
Packit 5c3484
    later version.
Packit 5c3484
Packit 5c3484
or both in parallel, as here.
Packit 5c3484
Packit 5c3484
The GNU MP Library is distributed in the hope that it will be useful, but
Packit 5c3484
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5c3484
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 5c3484
for more details.
Packit 5c3484
Packit 5c3484
You should have received copies of the GNU General Public License and the
Packit 5c3484
GNU Lesser General Public License along with the GNU MP Library.  If not,
Packit 5c3484
see https://www.gnu.org/licenses/.
Packit 5c3484
Packit 5c3484
Packit 5c3484
Packit 5c3484
* Adding a new file
Packit 5c3484
Packit 5c3484
** Adding a top-level file
Packit 5c3484
Packit 5c3484
  i) Add it to libgmp_la_SOURCES in Makefile.am.
Packit 5c3484
Packit 5c3484
  ii) If libmp.la needs it (usually doesn't), then add it to
Packit 5c3484
      libmp_la_SOURCES too.
Packit 5c3484
Packit 5c3484
** Adding a subdirectory file
Packit 5c3484
Packit 5c3484
For instance for mpz,
Packit 5c3484
Packit 5c3484
  i) Add file.c to libmpz_la_SOURCES in mpz/Makefile.am.
Packit 5c3484
Packit 5c3484
  ii) Add mpz/file$U.lo to MPZ_OBJECTS in the top-level Makefile.am
Packit 5c3484
Packit 5c3484
  iii) If for some reason libmp.la needs it (usually doesn't) then add
Packit 5c3484
       mpz/file$U.lo to libmp_la_DEPENDENCIES in the top-level
Packit 5c3484
       Makefile.am too.
Packit 5c3484
Packit 5c3484
The same applies to mpf, mpq, scanf and printf.
Packit 5c3484
Packit 5c3484
** Adding an mpn file
Packit 5c3484
Packit 5c3484
The way we build libmpn (in the `mpn' subdirectory) is quite special.
Packit 5c3484
Packit 5c3484
Currently only mpn/mp_bases.c is truly generic and included in every
Packit 5c3484
configuration.  All other files are linked at build time into the mpn
Packit 5c3484
build directory from one of the CPU specific sub-directories, or from
Packit 5c3484
the mpn/generic directory.
Packit 5c3484
Packit 5c3484
There are four types of mpn source files.
Packit 5c3484
Packit 5c3484
  .asm	  Assembly code preprocessed with m4
Packit 5c3484
  .S	  Assembly code preprocessed with cpp
Packit 5c3484
  .s	  Assembly code not preprocessed at all
Packit 5c3484
  .c	  C code
Packit 5c3484
Packit 5c3484
There are two types of .asm files.
Packit 5c3484
Packit 5c3484
  i) ``Normal'' files containing one function, though possibly with
Packit 5c3484
     more than one entry point.
Packit 5c3484
Packit 5c3484
  ii) Multi-function files that generate one of a set of functions
Packit 5c3484
      according to build options.
Packit 5c3484
Packit 5c3484
To add a new implementation of an existing function,
Packit 5c3484
Packit 5c3484
  i) Put it in the appropriate CPU-specific mpn subdirectory, it'll be
Packit 5c3484
     detected and used.
Packit 5c3484
Packit 5c3484
  ii) Any entrypoints tested by HAVE_NATIVE_func in other code must
Packit 5c3484
      have PROLOGUE(func) for configure to grep.  This is normal for
Packit 5c3484
      .asm or .S files, but for .c files a dummy comment like the
Packit 5c3484
      following will be needed.
Packit 5c3484
Packit 5c3484
              /*
Packit 5c3484
              PROLOGUE(func)
Packit 5c3484
              */
Packit 5c3484
Packit 5c3484
To add a new implementation using a multi-function file, in addition
Packit 5c3484
do the following,
Packit 5c3484
Packit 5c3484
  i) Use a MULFUNC_PROLOGUE(func1 func2 ...) in the .asm, declaring
Packit 5c3484
     all the functions implemented, including carry-in variants.
Packit 5c3484
Packit 5c3484
     If there's a separate PROLOGUE(func) for each possible function
Packit 5c3484
     (but this is usually not the case), then MULFUNC_PROLOGUE isn't
Packit 5c3484
     necessary.
Packit 5c3484
Packit 5c3484
To add a new style of multi-function file, in addition do the
Packit 5c3484
following,
Packit 5c3484
Packit 5c3484
  i) Add to the GMP_MULFUNC_CHOICES "case" statement in configure.in
Packit 5c3484
     which lists each multi-function filename and what function files
Packit 5c3484
     it can provide.
Packit 5c3484
Packit 5c3484
To add a completely new mpn function file, do the following,
Packit 5c3484
Packit 5c3484
  i) Ensure the filename is a valid C identifier, due to the
Packit 5c3484
     -DOPERATION_$* used to support multi-function files.  This means
Packit 5c3484
     "-" can't be used (but "_" can).
Packit 5c3484
Packit 5c3484
  ii) Add it to configure.in under one of the following
Packit 5c3484
Packit 5c3484
      a) `gmp_mpn_functions' if it exists for every target.  This
Packit 5c3484
         means there must be a C version in mpn/generic.  (Eg. mul_1)
Packit 5c3484
Packit 5c3484
      b) `gmp_mpn_functions_optional' if it's a standard function, but
Packit 5c3484
         doesn't need to exist for every target.  Code wanting to use
Packit 5c3484
         this will test HAVE_NATIVE_func to see if it's available.
Packit 5c3484
         (Eg. copyi)
Packit 5c3484
Packit 5c3484
      c) `extra_functions' for some targets, if it's a special
Packit 5c3484
         function that only ever needs to exist for certain targets.
Packit 5c3484
         Code wanting to use it can test either HAVE_NATIVE_func or
Packit 5c3484
         HAVE_HOST_CPU_foo, as desired.
Packit 5c3484
Packit 5c3484
  iii) If HAVE_NATIVE_func is going to be used, then add a #undef to
Packit 5c3484
       the AH_VERBATIM([HAVE_NATIVE] block in configure.in.
Packit 5c3484
Packit 5c3484
  iv) If the function can be provided by a multi-function file, then
Packit 5c3484
      add to the "case" statement in configure.in which lists each
Packit 5c3484
      multi-function filename and what function files it can provide.
Packit 5c3484
Packit 5c3484
Packit 5c3484
** Adding a test program
Packit 5c3484
Packit 5c3484
  i) Tests to be run early in the testing can be added to the main
Packit 5c3484
     "tests" sub-directory.
Packit 5c3484
Packit 5c3484
  ii) Tests for mpn, mpz, mpq and mpf can be added under the
Packit 5c3484
      corresponding tests subdirectory.
Packit 5c3484
Packit 5c3484
  iii) Generic tests for late in the testing can be added to
Packit 5c3484
       "tests/misc".  printf and scanf tests currently live there too.
Packit 5c3484
Packit 5c3484
  iv) Random number function tests can be added to "tests/rand".  That
Packit 5c3484
      directory has some development-time programs too.
Packit 5c3484
Packit 5c3484
  v) C++ test programs can be added to "tests/cxx".  A line like the
Packit 5c3484
     following must be added for each, since by default automake looks
Packit 5c3484
     for a .c file.
Packit 5c3484
Packit 5c3484
             t_foo_SOURCES = t-foo.cc
Packit 5c3484
Packit 5c3484
In all cases the name of the program should be added to check_PROGRAMS
Packit 5c3484
in the Makefile.am.  TESTS is equal to check_PROGRAMS, so all those
Packit 5c3484
programs get run.
Packit 5c3484
Packit 5c3484
"tests/devel" has a number of programs which are only for development
Packit 5c3484
purposes and are not for use in "make check".  These should be listed
Packit 5c3484
in EXTRA_PROGRAMS to get Makefile rules created, but they're never
Packit 5c3484
built or run unless an explicit "make someprog" is used.
Packit 5c3484
Packit 5c3484
Packit 5c3484
* Adding a new CPU
Packit 5c3484
Packit 5c3484
In general it's policy to use proper names for each CPU type
Packit 5c3484
supported.  If two CPUs are quite similar and perhaps don't have any
Packit 5c3484
actual differences in GMP then they're still given separate names, for
Packit 5c3484
example alphaev67 and alphaev68.
Packit 5c3484
Packit 5c3484
Canonical names:
Packit 5c3484
Packit 5c3484
  i) Decide the canonical CPU names GMP will accept.
Packit 5c3484
Packit 5c3484
  ii) Add these to the config.sub wrapper if configfsf.sub doesn't
Packit 5c3484
      already accept them.
Packit 5c3484
Packit 5c3484
  iii) Document the names in gmp.texi.
Packit 5c3484
Packit 5c3484
Aliases (optional):
Packit 5c3484
Packit 5c3484
  i) Any aliases can be added to the config.sub wrapper, unless
Packit 5c3484
     configfsf.sub already does the right thing with them.
Packit 5c3484
Packit 5c3484
  ii) Leave configure.in and everywhere else using only the canonical
Packit 5c3484
      names.  Aliases shouldn't appear anywhere except config.sub.
Packit 5c3484
Packit 5c3484
  iii) Document in gmp.texi, if desired.  Usually this isn't a good
Packit 5c3484
       idea, better encourage users to know just the canonical
Packit 5c3484
       names.
Packit 5c3484
Packit 5c3484
Configure:
Packit 5c3484
Packit 5c3484
  i) Add patterns to configure.in for the new CPU names.  Include the
Packit 5c3484
     following (see configure.in for the variables to set up),
Packit 5c3484
Packit 5c3484
     a) ABI choices (if any).
Packit 5c3484
     b) Compiler choices.
Packit 5c3484
     c) mpn path for CPU specific code.
Packit 5c3484
     d) Good default CFLAGS for each likely compiler.
Packit 5c3484
     d) Any special tests necessary on the compiler or assembler
Packit 5c3484
        capabilities.
Packit 5c3484
Packit 5c3484
  ii) M4 macros to be shared by asm files in a CPU family are by
Packit 5c3484
      convention in a foo-defs.m4 like mpn/x86/x86-defs.m4.  They're
Packit 5c3484
      likely to use settings from config.m4 generated by configure.
Packit 5c3484
Packit 5c3484
Fat binaries:
Packit 5c3484
Packit 5c3484
  i) In configure.in, add CPU specific directory(s) to fat_path.
Packit 5c3484
Packit 5c3484
  ii) In mpn/<cpu>/fat.c, identify the CPU at runtime and use suitable
Packit 5c3484
      CPUVEC_SETUP_subdir macros to select the function pointers for it.
Packit 5c3484
Packit 5c3484
  iii) For the x86s, add to the "$tmp_prefix" setups in configure.in
Packit 5c3484
       which abbreviates subdirectory names to fit an 8.3 filesystem.
Packit 5c3484
       (No need to restrict to 8.3, just ensure uniqueness when
Packit 5c3484
       truncated.)
Packit 5c3484
Packit 5c3484
Packit 5c3484
* The configure system
Packit 5c3484
Packit 5c3484
** Installing tools
Packit 5c3484
Packit 5c3484
The current versions of automake, autoconf and libtool in use can be
Packit 5c3484
checked in the ChangeLog.  Look for "Update to ...".  Patches may have
Packit 5c3484
been applied, look for "Regenerate ...".
Packit 5c3484
Packit 5c3484
The GMP build system is in places somewhat dependent on the internals
Packit 5c3484
of the build tools.  Obviously that's avoided as much as possible, but
Packit 5c3484
where it can't it creates a problem when upgrading or attempting to
Packit 5c3484
use different tools versions.
Packit 5c3484
Packit 5c3484
** Updating gmp
Packit 5c3484
Packit 5c3484
The following files need to be updated when going to a new version of
Packit 5c3484
the build tools.  Unfortunately the tools generally don't identify
Packit 5c3484
when an out-of-date version is present.
Packit 5c3484
Packit 5c3484
aclocal.m4 is updated by running "aclocal".  (Only needed for a new
Packit 5c3484
automake or libtool.)
Packit 5c3484
Packit 5c3484
INSTALL.autoconf can be copied from INSTALL in autoconf.
Packit 5c3484
Packit 5c3484
ltmain.sh comes from libtool.  Remove it and run "libtoolize --copy",
Packit 5c3484
or just copy the file by hand.
Packit 5c3484
Packit 5c3484
texinfo.tex can be updated from ftp.gnu.org.  Check it still works
Packit 5c3484
with "make gmp.dvi", "make gmp.ps" and "make gmp.pdf".
Packit 5c3484
Packit 5c3484
configfsf.guess and configfsf.sub can be updated from ftp.gnu.org (or
Packit 5c3484
from the "config" cvs module at subversions.gnu.org).  The gmp
Packit 5c3484
config.guess and config.sub wrappers are supposed to make such an
Packit 5c3484
update fairly painless.
Packit 5c3484
Packit 5c3484
depcomp from automake is not needed because configure.in specifies
Packit 5c3484
automake with "no-dependencies".
Packit 5c3484
Packit 5c3484
** How it works
Packit 5c3484
Packit 5c3484
During development:
Packit 5c3484
Packit 5c3484
    Input files                       Tool       Output files
Packit 5c3484
    ---------------------------------------------------------
Packit 5c3484
Packit 5c3484
                                     aclocal
Packit 5c3484
    $prefix/share/aclocal*/*.m4 ----------------> aclocal.m4
Packit 5c3484
Packit 5c3484
Packit 5c3484
    configure.in \                   autoconf
Packit 5c3484
    aclocal.m4   / -----------------------------> configure
Packit 5c3484
Packit 5c3484
Packit 5c3484
    */Makefile.am \                  automake
Packit 5c3484
    configure.in  | ----------------------------> Makefile.in
Packit 5c3484
    aclocal.m4    /
Packit 5c3484
Packit 5c3484
    configure.in \                  autoheader
Packit 5c3484
    aclocal.m4   / -----------------------------> config.in
Packit 5c3484
Packit 5c3484
At build time:
Packit 5c3484
Packit 5c3484
    Input files          Tool       Output files
Packit 5c3484
    --------------------------------------------
Packit 5c3484
Packit 5c3484
    */Makefile.in  \   configure    / */Makefile
Packit 5c3484
    config.in      | -------------> | config.h
Packit 5c3484
    gmp-h.in       /                | config.m4
Packit 5c3484
                                    | gmp.h
Packit 5c3484
                                    \ fat.h  (fat binary build only)
Packit 5c3484
Packit 5c3484
When configured with --enable-maintainer-mode the Makefiles include
Packit 5c3484
rules to re-run the necessary tools if the input files are changed.
Packit 5c3484
This can end up running a lot more things than are really necessary.
Packit 5c3484
Packit 5c3484
If a build tree is in too much of a mess for those rules to work
Packit 5c3484
properly then a bootstrap can be done from the source directory with
Packit 5c3484
Packit 5c3484
	aclocal
Packit 5c3484
	autoconf
Packit 5c3484
	automake
Packit 5c3484
	autoheader
Packit 5c3484
Packit 5c3484
The autom4te.cache directory is created by autoconf to save some work
Packit 5c3484
in subsequent automake or autoheader runs.  It's recreated
Packit 5c3484
automatically if removed, it doesn't get distributed.
Packit 5c3484
Packit 5c3484
** C++ configuration
Packit 5c3484
Packit 5c3484
It's intended that the contents of libgmp.la won't vary according to
Packit 5c3484
whether --enable-cxx is selected.  This means that if C++ shared
Packit 5c3484
libraries don't work properly then a shared+static with --disable-cxx
Packit 5c3484
can be done for the C parts, then a static-only with --enable-cxx to
Packit 5c3484
get libgmpxx.
Packit 5c3484
Packit 5c3484
libgmpxx.la uses some internals from libgmp.la, in order to share code
Packit 5c3484
between C and C++.  It's intended that libgmpxx can only be expected
Packit 5c3484
to work with libgmp from the same version of GMP.  If some of the
Packit 5c3484
shared internals change their interface, then it's proposed to rename
Packit 5c3484
them, for instance __gmp_doprint2 or the like, so as to provoke link
Packit 5c3484
errors rather than mysterious failures from a mismatch.
Packit 5c3484
Packit 5c3484
* Development setups
Packit 5c3484
Packit 5c3484
** General
Packit 5c3484
Packit 5c3484
--disable-shared will make builds go much faster, though of course
Packit 5c3484
shared or shared+static should be tested too.
Packit 5c3484
Packit 5c3484
--prefix to a dummy directory followed by "make install" will show
Packit 5c3484
what's installed.
Packit 5c3484
Packit 5c3484
"make check" acts on the libgmp just built, and will ignore any other
Packit 5c3484
/usr/lib/libgmp, or at least it should do.  Libtool does various hairy
Packit 5c3484
things to ensure it hits the just-built library.
Packit 5c3484
Packit 5c3484
** Long long limb testing
Packit 5c3484
Packit 5c3484
On systems where gcc supports long long, but a limb is normally just a
Packit 5c3484
long, the following can be used to force long long for testing
Packit 5c3484
purposes.  It will probably run quite slowly.
Packit 5c3484
Packit 5c3484
	./configure --host=none ABI=longlong
Packit 5c3484
Packit 5c3484
** Function argument conversions
Packit 5c3484
Packit 5c3484
When using gcc, configuring with something like
Packit 5c3484
Packit 5c3484
	./configure CFLAGS="-g -Wall -Wconversion -Wno-sign-compare"
Packit 5c3484
Packit 5c3484
can show where function parameters are being converted due to having
Packit 5c3484
function prototypes available, which won't happen in a K&R compiler.
Packit 5c3484
Doing this in combination with the long long limb setups above is
Packit 5c3484
good.
Packit 5c3484
Packit 5c3484
Conversions between int and long aren't warned about by gcc when
Packit 5c3484
they're the same size, which is unfortunate because casts should be
Packit 5c3484
used in such cases, for the benefit of K&R compilers with int!=long
Packit 5c3484
and where the difference matters in function calls.
Packit 5c3484
Packit 5c3484
* Other Notes
Packit 5c3484
Packit 5c3484
** Compatibility
Packit 5c3484
Packit 5c3484
compat.c is the home of functions retained for binary compatibility,
Packit 5c3484
    but now done by other means (like a macro).
Packit 5c3484
Packit 5c3484
struct __mpz_struct etc - this must be retained for C++ compatibility.
Packit 5c3484
    C++ applications defining functions taking mpz_t etc parameters
Packit 5c3484
    will get this in the mangled name because C++ "sees though" the
Packit 5c3484
    typedef mpz_t to the underlying struct.
Packit 5c3484
Packit 5c3484
__gmpn - note that glibc defines some __mpn symbols, old versions of
Packit 5c3484
    some mpn routines, which it uses for floating point printfs.
Packit 5c3484
Packit 5c3484
Packit 5c3484
Packit 5c3484
Packit 5c3484
Local variables:
Packit 5c3484
mode: outline
Packit 5c3484
fill-column: 70
Packit 5c3484
End:
Packit 5c3484
/* eof doc/configuration */