Home | History | Annotate | Line # | Download | only in doc
configuration revision 1.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  mrg   iv) Add file.c to nodist_libdummy_la_SOURCES in mpn/Makefile.am (in
    125  1.1  mrg       order to get an ansi2knr rule).  If the file is only in
    126  1.1  mrg       assembler then this step is unnecessary, but do it anyway so as
    127  1.1  mrg       not to forget if later a .c version is added.
    128  1.1  mrg 
    129  1.1  mrg   v) If the function can be provided by a multi-function file, then
    130  1.1  mrg      add to the "case" statement in configure.in which lists each
    131  1.1  mrg      multi-function filename and what function files it can provide.
    132  1.1  mrg 
    133  1.1  mrg 
    134  1.1  mrg ** Adding a test program
    135  1.1  mrg 
    136  1.1  mrg   i) Tests to be run early in the testing can be added to the main
    137  1.1  mrg      "tests" sub-directory.
    138  1.1  mrg 
    139  1.1  mrg   ii) Tests for mpn, mpz, mpq and mpf can be added under the
    140  1.1  mrg       corresponding tests subdirectory.
    141  1.1  mrg 
    142  1.1  mrg   iii) Generic tests for late in the testing can be added to
    143  1.1  mrg        "tests/misc".  printf and scanf tests currently live there too.
    144  1.1  mrg 
    145  1.1  mrg   iv) Random number function tests can be added to "tests/rand".  That
    146  1.1  mrg       directory has some development-time programs too.
    147  1.1  mrg 
    148  1.1  mrg   v) C++ test programs can be added to "tests/cxx".  A line like the
    149  1.1  mrg      following must be added for each, since by default automake looks
    150  1.1  mrg      for a .c file.
    151  1.1  mrg 
    152  1.1  mrg              t_foo_SOURCES = t-foo.cc
    153  1.1  mrg 
    154  1.1  mrg In all cases the name of the program should be added to check_PROGRAMS
    155  1.1  mrg in the Makefile.am.  TESTS is equal to check_PROGRAMS, so all those
    156  1.1  mrg programs get run.
    157  1.1  mrg 
    158  1.1  mrg "tests/devel" has a number of programs which are only for development
    159  1.1  mrg purposes and are not for use in "make check".  These should be listed
    160  1.1  mrg in EXTRA_PROGRAMS to get Makefile rules created, but they're never
    161  1.1  mrg built or run unless an explicit "make someprog" is used.
    162  1.1  mrg 
    163  1.1  mrg 
    164  1.1  mrg * Adding a new CPU
    165  1.1  mrg 
    166  1.1  mrg In general it's policy to use proper names for each CPU type
    167  1.1  mrg supported.  If two CPUs are quite similar and perhaps don't have any
    168  1.1  mrg actual differences in GMP then they're still given separate names, for
    169  1.1  mrg example alphaev67 and alphaev68.
    170  1.1  mrg 
    171  1.1  mrg Canonical names:
    172  1.1  mrg 
    173  1.1  mrg   i) Decide the canonical CPU names GMP will accept.
    174  1.1  mrg 
    175  1.1  mrg   ii) Add these to the config.sub wrapper if configfsf.sub doesn't
    176  1.1  mrg       already accept them.
    177  1.1  mrg 
    178  1.1  mrg   iii) Document the names in gmp.texi.
    179  1.1  mrg 
    180  1.1  mrg Aliases (optional):
    181  1.1  mrg 
    182  1.1  mrg   i) Any aliases can be added to the config.sub wrapper, unless
    183  1.1  mrg      configfsf.sub already does the right thing with them.
    184  1.1  mrg 
    185  1.1  mrg   ii) Leave configure.in and everywhere else using only the canonical
    186  1.1  mrg       names.  Aliases shouldn't appear anywhere except config.sub.
    187  1.1  mrg 
    188  1.1  mrg   iii) Document in gmp.texi, if desired.  Usually this isn't a good
    189  1.1  mrg        idea, better encourage users to know just the canonical
    190  1.1  mrg        names.
    191  1.1  mrg 
    192  1.1  mrg Configure:
    193  1.1  mrg 
    194  1.1  mrg   i) Add patterns to configure.in for the new CPU names.  Include the
    195  1.1  mrg      following (see configure.in for the variables to set up),
    196  1.1  mrg 
    197  1.1  mrg      a) ABI choices (if any).
    198  1.1  mrg      b) Compiler choices.
    199  1.1  mrg      c) mpn path for CPU specific code.
    200  1.1  mrg      d) Good default CFLAGS for each likely compiler.
    201  1.1  mrg      d) Any special tests necessary on the compiler or assembler
    202  1.1  mrg         capabilities.
    203  1.1  mrg 
    204  1.1  mrg   ii) M4 macros to be shared by asm files in a CPU family are by
    205  1.1  mrg       convention in a foo-defs.m4 like mpn/x86/x86-defs.m4.  They're
    206  1.1  mrg       likely to use settings from config.m4 generated by configure.
    207  1.1  mrg 
    208  1.1  mrg Fat binaries:
    209  1.1  mrg 
    210  1.1  mrg   i) In configure.in, add CPU specific directory(s) to fat_path.
    211  1.1  mrg 
    212  1.1  mrg   ii) In mpn/<cpu>/fat.c, identify the CPU at runtime and use suitable
    213  1.1  mrg       CPUVEC_SETUP_subdir macros to select the function pointers for it.
    214  1.1  mrg 
    215  1.1  mrg   iii) For the x86s, add to the "$tmp_prefix" setups in configure.in
    216  1.1  mrg        which abbreviates subdirectory names to fit an 8.3 filesystem.
    217  1.1  mrg        (No need to restrict to 8.3, just ensure uniqueness when
    218  1.1  mrg        truncated.)
    219  1.1  mrg 
    220  1.1  mrg 
    221  1.1  mrg * The configure system
    222  1.1  mrg 
    223  1.1  mrg ** Installing tools
    224  1.1  mrg 
    225  1.1  mrg The current versions of automake, autoconf and libtool in use can be
    226  1.1  mrg checked in the ChangeLog.  Look for "Update to ...".  Patches may have
    227  1.1  mrg been applied, look for "Regenerate ...".
    228  1.1  mrg 
    229  1.1  mrg The GMP build system is in places somewhat dependent on the internals
    230  1.1  mrg of the build tools.  Obviously that's avoided as much as possible, but
    231  1.1  mrg where it can't it creates a problem when upgrading or attempting to
    232  1.1  mrg use different tools versions.
    233  1.1  mrg 
    234  1.1  mrg ** Updating gmp
    235  1.1  mrg 
    236  1.1  mrg The following files need to be updated when going to a new version of
    237  1.1  mrg the build tools.  Unfortunately the tools generally don't identify
    238  1.1  mrg when an out-of-date version is present.
    239  1.1  mrg 
    240  1.1  mrg aclocal.m4 is updated by running "aclocal".  (Only needed for a new
    241  1.1  mrg automake or libtool.)
    242  1.1  mrg 
    243  1.1  mrg INSTALL.autoconf can be copied from INSTALL in autoconf.
    244  1.1  mrg 
    245  1.1  mrg ltmain.sh comes from libtool.  Remove it and run "libtoolize --copy",
    246  1.1  mrg or just copy the file by hand.
    247  1.1  mrg 
    248  1.1  mrg ansi2knr.c, ansi2knr.1, install-sh and doc/mdate-sh come from automake
    249  1.1  mrg and can be updated by copying or by removing and running "automake
    250  1.1  mrg --add-missing --copy".
    251  1.1  mrg 
    252  1.1  mrg texinfo.tex can be updated from ftp.gnu.org.  Check it still works
    253  1.1  mrg with "make gmp.dvi", "make gmp.ps" and "make gmp.pdf".
    254  1.1  mrg 
    255  1.1  mrg configfsf.guess and configfsf.sub can be updated from ftp.gnu.org (or
    256  1.1  mrg from the "config" cvs module at subversions.gnu.org).  The gmp
    257  1.1  mrg config.guess and config.sub wrappers are supposed to make such an
    258  1.1  mrg update fairly painless.
    259  1.1  mrg 
    260  1.1  mrg depcomp from automake is not needed because configure.in specifies
    261  1.1  mrg automake with "no-dependencies".
    262  1.1  mrg 
    263  1.1  mrg ** How it works
    264  1.1  mrg 
    265  1.1  mrg During development:
    266  1.1  mrg 
    267  1.1  mrg     Input files                       Tool       Output files
    268  1.1  mrg     ---------------------------------------------------------
    269  1.1  mrg 
    270  1.1  mrg                                      aclocal
    271  1.1  mrg     $prefix/share/aclocal*/*.m4 ----------------> aclocal.m4
    272  1.1  mrg 
    273  1.1  mrg 
    274  1.1  mrg     configure.in \                   autoconf
    275  1.1  mrg     aclocal.m4   / -----------------------------> configure
    276  1.1  mrg 
    277  1.1  mrg 
    278  1.1  mrg     */Makefile.am \                  automake
    279  1.1  mrg     configure.in  | ----------------------------> Makefile.in
    280  1.1  mrg     aclocal.m4    /
    281  1.1  mrg 
    282  1.1  mrg     configure.in \                  autoheader
    283  1.1  mrg     aclocal.m4   / -----------------------------> config.in
    284  1.1  mrg 
    285  1.1  mrg At build time:
    286  1.1  mrg 
    287  1.1  mrg     Input files          Tool       Output files
    288  1.1  mrg     --------------------------------------------
    289  1.1  mrg 
    290  1.1  mrg     */Makefile.in  \   configure    / */Makefile
    291  1.1  mrg     config.in      | -------------> | config.h
    292  1.1  mrg     gmp-h.in       |                | config.m4
    293  1.1  mrg     mp-h.in        /                | gmp.h
    294  1.1  mrg                                     | mp.h
    295  1.1  mrg                                     \ fat.h  (fat binary build only)
    296  1.1  mrg 
    297  1.1  mrg When configured with --enable-maintainer-mode the Makefiles include
    298  1.1  mrg rules to re-run the necessary tools if the input files are changed.
    299  1.1  mrg This can end up running a lot more things than are really necessary.
    300  1.1  mrg 
    301  1.1  mrg If a build tree is in too much of a mess for those rules to work
    302  1.1  mrg properly then a bootstrap can be done from the source directory with
    303  1.1  mrg 
    304  1.1  mrg 	aclocal
    305  1.1  mrg 	autoconf
    306  1.1  mrg 	automake
    307  1.1  mrg 	autoheader
    308  1.1  mrg 
    309  1.1  mrg The autom4te.cache directory is created by autoconf to save some work
    310  1.1  mrg in subsequent automake or autoheader runs.  It's recreated
    311  1.1  mrg automatically if removed, it doesn't get distributed.
    312  1.1  mrg 
    313  1.1  mrg ** C++ configuration
    314  1.1  mrg 
    315  1.1  mrg It's intended that the contents of libgmp.la won't vary according to
    316  1.1  mrg whether --enable-cxx is selected.  This means that if C++ shared
    317  1.1  mrg libraries don't work properly then a shared+static with --disable-cxx
    318  1.1  mrg can be done for the C parts, then a static-only with --enable-cxx to
    319  1.1  mrg get libgmpxx.
    320  1.1  mrg 
    321  1.1  mrg libgmpxx.la uses some internals from libgmp.la, in order to share code
    322  1.1  mrg between C and C++.  It's intended that libgmpxx can only be expected
    323  1.1  mrg to work with libgmp from the same version of GMP.  If some of the
    324  1.1  mrg shared internals change their interface, then it's proposed to rename
    325  1.1  mrg them, for instance __gmp_doprint2 or the like, so as to provoke link
    326  1.1  mrg errors rather than mysterious failures from a mismatch.
    327  1.1  mrg 
    328  1.1  mrg * Development setups
    329  1.1  mrg 
    330  1.1  mrg ** General
    331  1.1  mrg 
    332  1.1  mrg --disable-shared will make builds go much faster, though of course
    333  1.1  mrg shared or shared+static should be tested too.
    334  1.1  mrg 
    335  1.1  mrg --enable-mpbsd grabs various bits of mpz, which might need to be
    336  1.1  mrg adjusted if things in those routines are changed.  Building mpbsd all
    337  1.1  mrg the time doesn't cost much.
    338  1.1  mrg 
    339  1.1  mrg --prefix to a dummy directory followed by "make install" will show
    340  1.1  mrg what's installed.
    341  1.1  mrg 
    342  1.1  mrg "make check" acts on the libgmp just built, and will ignore any other
    343  1.1  mrg /usr/lib/libgmp, or at least it should do.  Libtool does various hairy
    344  1.1  mrg things to ensure it hits the just-built library.
    345  1.1  mrg 
    346  1.1  mrg ** Long long limb testing
    347  1.1  mrg 
    348  1.1  mrg On systems where gcc supports long long, but a limb is normally just a
    349  1.1  mrg long, the following can be used to force long long for testing
    350  1.1  mrg purposes.  It will probably run quite slowly.
    351  1.1  mrg 
    352  1.1  mrg 	./configure --host=none ABI=longlong
    353  1.1  mrg 
    354  1.1  mrg ** Function argument conversions
    355  1.1  mrg 
    356  1.1  mrg When using gcc, configuring with something like
    357  1.1  mrg 
    358  1.1  mrg 	./configure CFLAGS="-g -Wall -Wconversion -Wno-sign-compare"
    359  1.1  mrg 
    360  1.1  mrg can show where function parameters are being converted due to having
    361  1.1  mrg function prototypes available, which won't happen in a K&R compiler.
    362  1.1  mrg Doing this in combination with the long long limb setups above is
    363  1.1  mrg good.
    364  1.1  mrg 
    365  1.1  mrg Conversions between int and long aren't warned about by gcc when
    366  1.1  mrg they're the same size, which is unfortunate because casts should be
    367  1.1  mrg used in such cases, for the benefit of K&R compilers with int!=long
    368  1.1  mrg and where the difference matters in function calls.
    369  1.1  mrg 
    370  1.1  mrg ** K&R support
    371  1.1  mrg 
    372  1.1  mrg Function definitions must be in the GNU stylized form to work.  See
    373  1.1  mrg the ansi2knr.1 man page (included in the GMP sources).
    374  1.1  mrg 
    375  1.1  mrg __GMP_PROTO is used for function prototypes, other ANSI / K&R
    376  1.1  mrg differences are conditionalized in various places.
    377  1.1  mrg 
    378  1.1  mrg Proper testing of the K&R support requires a compiler which gives an
    379  1.1  mrg error for ANSI-isms.  Configuring with --host=none is a good idea, to
    380  1.1  mrg test all the generic C code.
    381  1.1  mrg 
    382  1.1  mrg When using an ANSI compiler, the ansi2knr setups can be partially
    383  1.1  mrg tested with
    384  1.1  mrg 
    385  1.1  mrg 	./configure am_cv_prog_cc_stdc=no ac_cv_prog_cc_stdc=no
    386  1.1  mrg 
    387  1.1  mrg This will test the use of $U and the like in the makefiles, but not
    388  1.1  mrg much else.
    389  1.1  mrg 
    390  1.1  mrg Forcing the cache variables can be used with a compiler like HP C
    391  1.1  mrg which is K&R by default but to which configure normally adds ANSI mode
    392  1.1  mrg flags.  This then should be a good full K&R test.
    393  1.1  mrg 
    394  1.1  mrg * Other Notes
    395  1.1  mrg 
    396  1.1  mrg ** Compatibility
    397  1.1  mrg 
    398  1.1  mrg compat.c is the home of functions retained for binary compatibility,
    399  1.1  mrg     but now done by other means (like a macro).
    400  1.1  mrg 
    401  1.1  mrg struct __mpz_struct etc - this must be retained for C++ compatibility.
    402  1.1  mrg     C++ applications defining functions taking mpz_t etc parameters
    403  1.1  mrg     will get this in the mangled name because C++ "sees though" the
    404  1.1  mrg     typedef mpz_t to the underlying struct.
    405  1.1  mrg 
    406  1.1  mrg     Incidentally, this probably means for C++ that our mp.h is not
    407  1.1  mrg     compatible with an original BSD mp.h, since we use struct
    408  1.1  mrg     __mpz_struct for MINT in ours.  Maybe we could change to whatever
    409  1.1  mrg     the original did, but it seems unlikely anyone would be using C++
    410  1.1  mrg     with mp.h.
    411  1.1  mrg 
    412  1.1  mrg __gmpn - note that glibc defines some __mpn symbols, old versions of
    413  1.1  mrg     some mpn routines, which it uses for floating point printfs.
    414  1.1  mrg 
    415  1.1  mrg 
    416  1.1  mrg 
    417  1.1  mrg 
    418  1.1  mrg Local variables:
    419  1.1  mrg mode: outline
    420  1.1  mrg fill-column: 70
    421  1.1  mrg End:
    422  1.1  mrg /* eof doc/configuration */
    423