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