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