/* doc/configuration (in Emacs -*-outline-*- format). */Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.This file is part of the GNU MP Library.The GNU MP Library is free software; you can redistribute it and/or modifyit under the terms of the GNU Lesser General Public License as published bythe Free Software Foundation; either version 3 of the License, or (at youroption) any later version.The GNU MP Library is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITYor FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General PublicLicense for more details.You should have received a copy of the GNU Lesser General Public Licensealong with the GNU MP Library. If not, see http://www.gnu.org/licenses/.* Adding a new file** Adding a top-level filei) Add it to libgmp_la_SOURCES in Makefile.am.ii) If libmp.la needs it (usually doesn't), then add it tolibmp_la_SOURCES too.** Adding a subdirectory fileFor instance for mpz,i) Add file.c to libmpz_la_SOURCES in mpz/Makefile.am.ii) Add mpz/file$U.lo to MPZ_OBJECTS in the top-level Makefile.amiii) If for some reason libmp.la needs it (usually doesn't) then addmpz/file$U.lo to libmp_la_DEPENDENCIES in the top-levelMakefile.am too.The same applies to mpf, mpq, scanf and printf.** Adding an mpn fileThe way we build libmpn (in the `mpn' subdirectory) is quite special.Currently only mpn/mp_bases.c is truely generic and included in everyconfiguration. All other files are linked at build time into the mpnbuild directory from one of the CPU specific sub-directories, or fromthe mpn/generic directory.There are four types of mpn source files..asm Assembly code preprocessed with m4.S Assembly code preprocessed with cpp.s Assembly code not preprocessed at all.c C codeThere are two types of .asm files.i) ``Normal'' files containing one function, though possibly withmore than one entry point.ii) Multi-function files that generate one of a set of functionsaccording to build options.To add a new implementation of an existing function,i) Put it in the appropriate CPU-specific mpn subdirectory, it'll bedetected and used.ii) Any entrypoints tested by HAVE_NATIVE_func in other code musthave PROLOGUE(func) for configure to grep. This is normal for.asm or .S files, but for .c files a dummy comment like thefollowing will be needed./*PROLOGUE(func)*/To add a new implementation using a multi-function file, in additiondo the following,i) Use a MULFUNC_PROLOGUE(func1 func2 ...) in the .asm, declaringall the functions implemented, including carry-in variants.If there's a separate PROLOGUE(func) for each possible function(but this is usually not the case), then MULFUNC_PROLOGUE isn'tnecessary.To add a new style of multi-function file, in addition do thefollowing,i) Add to the GMP_MULFUNC_CHOICES "case" statement in configure.inwhich lists each multi-function filename and what function filesit can provide.To add a completely new mpn function file, do the following,i) Ensure the filename is a valid C identifier, due to the-DOPERATION_$* used to support multi-function files. This means"-" can't be used (but "_" can).ii) Add it to configure.in under one of the followinga) `gmp_mpn_functions' if it exists for every target. Thismeans there must be a C version in mpn/generic. (Eg. mul_1)b) `gmp_mpn_functions_optional' if it's a standard function, butdoesn't need to exist for every target. Code wanting to usethis will test HAVE_NATIVE_func to see if it's available.(Eg. copyi)c) `extra_functions' for some targets, if it's a specialfunction that only ever needs to exist for certain targets.Code wanting to use it can test either HAVE_NATIVE_func orHAVE_HOST_CPU_foo, as desired.iii) If HAVE_NATIVE_func is going to be used, then add a #undef tothe AH_VERBATIM([HAVE_NATIVE] block in configure.in.iv) Add file.c to nodist_libdummy_la_SOURCES in mpn/Makefile.am (inorder to get an ansi2knr rule). If the file is only inassembler then this step is unnecessary, but do it anyway so asnot to forget if later a .c version is added.v) If the function can be provided by a multi-function file, thenadd to the "case" statement in configure.in which lists eachmulti-function filename and what function files it can provide.** Adding a test programi) Tests to be run early in the testing can be added to the main"tests" sub-directory.ii) Tests for mpn, mpz, mpq and mpf can be added under thecorresponding tests subdirectory.iii) Generic tests for late in the testing can be added to"tests/misc". printf and scanf tests currently live there too.iv) Random number function tests can be added to "tests/rand". Thatdirectory has some development-time programs too.v) C++ test programs can be added to "tests/cxx". A line like thefollowing must be added for each, since by default automake looksfor a .c file.t_foo_SOURCES = t-foo.ccIn all cases the name of the program should be added to check_PROGRAMSin the Makefile.am. TESTS is equal to check_PROGRAMS, so all thoseprograms get run."tests/devel" has a number of programs which are only for developmentpurposes and are not for use in "make check". These should be listedin EXTRA_PROGRAMS to get Makefile rules created, but they're neverbuilt or run unless an explicit "make someprog" is used.* Adding a new CPUIn general it's policy to use proper names for each CPU typesupported. If two CPUs are quite similar and perhaps don't have anyactual differences in GMP then they're still given separate names, forexample alphaev67 and alphaev68.Canonical names:i) Decide the canonical CPU names GMP will accept.ii) Add these to the config.sub wrapper if configfsf.sub doesn'talready accept them.iii) Document the names in gmp.texi.Aliases (optional):i) Any aliases can be added to the config.sub wrapper, unlessconfigfsf.sub already does the right thing with them.ii) Leave configure.in and everywhere else using only the canonicalnames. Aliases shouldn't appear anywhere except config.sub.iii) Document in gmp.texi, if desired. Usually this isn't a goodidea, better encourage users to know just the canonicalnames.Configure:i) Add patterns to configure.in for the new CPU names. Include thefollowing (see configure.in for the variables to set up),a) ABI choices (if any).b) Compiler choices.c) mpn path for CPU specific code.d) Good default CFLAGS for each likely compiler.d) Any special tests necessary on the compiler or assemblercapabilities.ii) M4 macros to be shared by asm files in a CPU family are byconvention in a foo-defs.m4 like mpn/x86/x86-defs.m4. They'relikely to use settings from config.m4 generated by configure.Fat binaries:i) In configure.in, add CPU specific directory(s) to fat_path.ii) In mpn/<cpu>/fat.c, identify the CPU at runtime and use suitableCPUVEC_SETUP_subdir macros to select the function pointers for it.iii) For the x86s, add to the "$tmp_prefix" setups in configure.inwhich abbreviates subdirectory names to fit an 8.3 filesystem.(No need to restrict to 8.3, just ensure uniqueness whentruncated.)* The configure system** Installing toolsThe current versions of automake, autoconf and libtool in use can bechecked in the ChangeLog. Look for "Update to ...". Patches may havebeen applied, look for "Regenerate ...".The GMP build system is in places somewhat dependent on the internalsof the build tools. Obviously that's avoided as much as possible, butwhere it can't it creates a problem when upgrading or attempting touse different tools versions.** Updating gmpThe following files need to be updated when going to a new version ofthe build tools. Unfortunately the tools generally don't identifywhen an out-of-date version is present.aclocal.m4 is updated by running "aclocal". (Only needed for a newautomake or libtool.)INSTALL.autoconf can be copied from INSTALL in autoconf.ltmain.sh comes from libtool. Remove it and run "libtoolize --copy",or just copy the file by hand.ansi2knr.c, ansi2knr.1, install-sh and doc/mdate-sh come from automakeand can be updated by copying or by removing and running "automake--add-missing --copy".texinfo.tex can be updated from ftp.gnu.org. Check it still workswith "make gmp.dvi", "make gmp.ps" and "make gmp.pdf".configfsf.guess and configfsf.sub can be updated from ftp.gnu.org (orfrom the "config" cvs module at subversions.gnu.org). The gmpconfig.guess and config.sub wrappers are supposed to make such anupdate fairly painless.depcomp from automake is not needed because configure.in specifiesautomake with "no-dependencies".** How it worksDuring development:Input files Tool Output files---------------------------------------------------------aclocal$prefix/share/aclocal*/*.m4 ----------------> aclocal.m4configure.in \ autoconfaclocal.m4 / -----------------------------> configure*/Makefile.am \ automakeconfigure.in | ----------------------------> Makefile.inaclocal.m4 /configure.in \ autoheaderaclocal.m4 / -----------------------------> config.inAt build time:Input files Tool Output files--------------------------------------------*/Makefile.in \ configure / */Makefileconfig.in | -------------> | config.hgmp-h.in | | config.m4mp-h.in / | gmp.h| mp.h\ fat.h (fat binary build only)When configured with --enable-maintainer-mode the Makefiles includerules to re-run the necessary tools if the input files are changed.This can end up running a lot more things than are really necessary.If a build tree is in too much of a mess for those rules to workproperly then a bootstrap can be done from the source directory withaclocalautoconfautomakeautoheaderThe autom4te.cache directory is created by autoconf to save some workin subsequent automake or autoheader runs. It's recreatedautomatically if removed, it doesn't get distributed.** C++ configurationIt's intended that the contents of libgmp.la won't vary according towhether --enable-cxx is selected. This means that if C++ sharedlibraries don't work properly then a shared+static with --disable-cxxcan be done for the C parts, then a static-only with --enable-cxx toget libgmpxx.libgmpxx.la uses some internals from libgmp.la, in order to share codebetween C and C++. It's intended that libgmpxx can only be expectedto work with libgmp from the same version of GMP. If some of theshared internals change their interface, then it's proposed to renamethem, for instance __gmp_doprint2 or the like, so as to provoke linkerrors rather than mysterious failures from a mismatch.* Development setups** General--disable-shared will make builds go much faster, though of courseshared or shared+static should be tested too.--enable-mpbsd grabs various bits of mpz, which might need to beadjusted if things in those routines are changed. Building mpbsd allthe time doesn't cost much.--prefix to a dummy directory followed by "make install" will showwhat's installed."make check" acts on the libgmp just built, and will ignore any other/usr/lib/libgmp, or at least it should do. Libtool does various hairythings to ensure it hits the just-built library.** Long long limb testingOn systems where gcc supports long long, but a limb is normally just along, the following can be used to force long long for testingpurposes. It will probably run quite slowly../configure --host=none ABI=longlong** Function argument conversionsWhen using gcc, configuring with something like./configure CFLAGS="-g -Wall -Wconversion -Wno-sign-compare"can show where function parameters are being converted due to havingfunction prototypes available, which won't happen in a K&R compiler.Doing this in combination with the long long limb setups above isgood.Conversions between int and long aren't warned about by gcc whenthey're the same size, which is unfortunate because casts should beused in such cases, for the benefit of K&R compilers with int!=longand where the difference matters in function calls.** K&R supportFunction definitions must be in the GNU stylized form to work. Seethe ansi2knr.1 man page (included in the GMP sources).__GMP_PROTO is used for function prototypes, other ANSI / K&Rdifferences are conditionalized in various places.Proper testing of the K&R support requires a compiler which gives anerror for ANSI-isms. Configuring with --host=none is a good idea, totest all the generic C code.When using an ANSI compiler, the ansi2knr setups can be partiallytested with./configure am_cv_prog_cc_stdc=no ac_cv_prog_cc_stdc=noThis will test the use of $U and the like in the makefiles, but notmuch else.Forcing the cache variables can be used with a compiler like HP Cwhich is K&R by default but to which configure normally adds ANSI modeflags. This then should be a good full K&R test.* Other Notes** Compatibilitycompat.c is the home of functions retained for binary compatibility,but now done by other means (like a macro).struct __mpz_struct etc - this must be retained for C++ compatibility.C++ applications defining functions taking mpz_t etc parameterswill get this in the mangled name because C++ "sees though" thetypedef mpz_t to the underlying struct.Incidentally, this probably means for C++ that our mp.h is notcompatible with an original BSD mp.h, since we use struct__mpz_struct for MINT in ours. Maybe we could change to whateverthe original did, but it seems unlikely anyone would be using C++with mp.h.__gmpn - note that glibc defines some __mpn symbols, old versions ofsome mpn routines, which it uses for floating point printfs.Local variables:mode: outlinefill-column: 70End:/* eof doc/configuration */