151c586b8Smrg/* doc/configuration (in Emacs -*-outline-*- format). */ 251c586b8Smrg 3*ce543368SmrgCopyright 2000-2004 Free Software Foundation, Inc. 451c586b8Smrg 551c586b8SmrgThis file is part of the GNU MP Library. 651c586b8Smrg 751c586b8SmrgThe GNU MP Library is free software; you can redistribute it and/or modify 8*ce543368Smrgit under the terms of either: 9*ce543368Smrg 10*ce543368Smrg * the GNU Lesser General Public License as published by the Free 11*ce543368Smrg Software Foundation; either version 3 of the License, or (at your 1251c586b8Smrg option) any later version. 1351c586b8Smrg 14*ce543368Smrgor 15*ce543368Smrg 16*ce543368Smrg * the GNU General Public License as published by the Free Software 17*ce543368Smrg Foundation; either version 2 of the License, or (at your option) any 18*ce543368Smrg later version. 19*ce543368Smrg 20*ce543368Smrgor both in parallel, as here. 21*ce543368Smrg 2251c586b8SmrgThe GNU MP Library is distributed in the hope that it will be useful, but 2351c586b8SmrgWITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 24*ce543368Smrgor FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25*ce543368Smrgfor more details. 2651c586b8Smrg 27*ce543368SmrgYou should have received copies of the GNU General Public License and the 28*ce543368SmrgGNU Lesser General Public License along with the GNU MP Library. If not, 29*ce543368Smrgsee https://www.gnu.org/licenses/. 3051c586b8Smrg 3151c586b8Smrg 3251c586b8Smrg 3351c586b8Smrg* Adding a new file 3451c586b8Smrg 3551c586b8Smrg** Adding a top-level file 3651c586b8Smrg 3751c586b8Smrg i) Add it to libgmp_la_SOURCES in Makefile.am. 3851c586b8Smrg 3951c586b8Smrg ii) If libmp.la needs it (usually doesn't), then add it to 4051c586b8Smrg libmp_la_SOURCES too. 4151c586b8Smrg 4251c586b8Smrg** Adding a subdirectory file 4351c586b8Smrg 4451c586b8SmrgFor instance for mpz, 4551c586b8Smrg 4651c586b8Smrg i) Add file.c to libmpz_la_SOURCES in mpz/Makefile.am. 4751c586b8Smrg 4851c586b8Smrg ii) Add mpz/file$U.lo to MPZ_OBJECTS in the top-level Makefile.am 4951c586b8Smrg 5051c586b8Smrg iii) If for some reason libmp.la needs it (usually doesn't) then add 5151c586b8Smrg mpz/file$U.lo to libmp_la_DEPENDENCIES in the top-level 5251c586b8Smrg Makefile.am too. 5351c586b8Smrg 5451c586b8SmrgThe same applies to mpf, mpq, scanf and printf. 5551c586b8Smrg 5651c586b8Smrg** Adding an mpn file 5751c586b8Smrg 5851c586b8SmrgThe way we build libmpn (in the `mpn' subdirectory) is quite special. 5951c586b8Smrg 60*ce543368SmrgCurrently only mpn/mp_bases.c is truly generic and included in every 6151c586b8Smrgconfiguration. All other files are linked at build time into the mpn 6251c586b8Smrgbuild directory from one of the CPU specific sub-directories, or from 6351c586b8Smrgthe mpn/generic directory. 6451c586b8Smrg 6551c586b8SmrgThere are four types of mpn source files. 6651c586b8Smrg 6751c586b8Smrg .asm Assembly code preprocessed with m4 6851c586b8Smrg .S Assembly code preprocessed with cpp 6951c586b8Smrg .s Assembly code not preprocessed at all 7051c586b8Smrg .c C code 7151c586b8Smrg 7251c586b8SmrgThere are two types of .asm files. 7351c586b8Smrg 7451c586b8Smrg i) ``Normal'' files containing one function, though possibly with 7551c586b8Smrg more than one entry point. 7651c586b8Smrg 7751c586b8Smrg ii) Multi-function files that generate one of a set of functions 7851c586b8Smrg according to build options. 7951c586b8Smrg 8051c586b8SmrgTo add a new implementation of an existing function, 8151c586b8Smrg 8251c586b8Smrg i) Put it in the appropriate CPU-specific mpn subdirectory, it'll be 8351c586b8Smrg detected and used. 8451c586b8Smrg 8551c586b8Smrg ii) Any entrypoints tested by HAVE_NATIVE_func in other code must 8651c586b8Smrg have PROLOGUE(func) for configure to grep. This is normal for 8751c586b8Smrg .asm or .S files, but for .c files a dummy comment like the 8851c586b8Smrg following will be needed. 8951c586b8Smrg 9051c586b8Smrg /* 9151c586b8Smrg PROLOGUE(func) 9251c586b8Smrg */ 9351c586b8Smrg 9451c586b8SmrgTo add a new implementation using a multi-function file, in addition 9551c586b8Smrgdo the following, 9651c586b8Smrg 9751c586b8Smrg i) Use a MULFUNC_PROLOGUE(func1 func2 ...) in the .asm, declaring 9851c586b8Smrg all the functions implemented, including carry-in variants. 9951c586b8Smrg 10051c586b8Smrg If there's a separate PROLOGUE(func) for each possible function 10151c586b8Smrg (but this is usually not the case), then MULFUNC_PROLOGUE isn't 10251c586b8Smrg necessary. 10351c586b8Smrg 10451c586b8SmrgTo add a new style of multi-function file, in addition do the 10551c586b8Smrgfollowing, 10651c586b8Smrg 10751c586b8Smrg i) Add to the GMP_MULFUNC_CHOICES "case" statement in configure.in 10851c586b8Smrg which lists each multi-function filename and what function files 10951c586b8Smrg it can provide. 11051c586b8Smrg 11151c586b8SmrgTo add a completely new mpn function file, do the following, 11251c586b8Smrg 11351c586b8Smrg i) Ensure the filename is a valid C identifier, due to the 11451c586b8Smrg -DOPERATION_$* used to support multi-function files. This means 11551c586b8Smrg "-" can't be used (but "_" can). 11651c586b8Smrg 11751c586b8Smrg ii) Add it to configure.in under one of the following 11851c586b8Smrg 11951c586b8Smrg a) `gmp_mpn_functions' if it exists for every target. This 12051c586b8Smrg means there must be a C version in mpn/generic. (Eg. mul_1) 12151c586b8Smrg 12251c586b8Smrg b) `gmp_mpn_functions_optional' if it's a standard function, but 12351c586b8Smrg doesn't need to exist for every target. Code wanting to use 12451c586b8Smrg this will test HAVE_NATIVE_func to see if it's available. 12551c586b8Smrg (Eg. copyi) 12651c586b8Smrg 12751c586b8Smrg c) `extra_functions' for some targets, if it's a special 12851c586b8Smrg function that only ever needs to exist for certain targets. 12951c586b8Smrg Code wanting to use it can test either HAVE_NATIVE_func or 13051c586b8Smrg HAVE_HOST_CPU_foo, as desired. 13151c586b8Smrg 13251c586b8Smrg iii) If HAVE_NATIVE_func is going to be used, then add a #undef to 13351c586b8Smrg the AH_VERBATIM([HAVE_NATIVE] block in configure.in. 13451c586b8Smrg 135dab47db4Smrg iv) If the function can be provided by a multi-function file, then 13651c586b8Smrg add to the "case" statement in configure.in which lists each 13751c586b8Smrg multi-function filename and what function files it can provide. 13851c586b8Smrg 13951c586b8Smrg 14051c586b8Smrg** Adding a test program 14151c586b8Smrg 14251c586b8Smrg i) Tests to be run early in the testing can be added to the main 14351c586b8Smrg "tests" sub-directory. 14451c586b8Smrg 14551c586b8Smrg ii) Tests for mpn, mpz, mpq and mpf can be added under the 14651c586b8Smrg corresponding tests subdirectory. 14751c586b8Smrg 14851c586b8Smrg iii) Generic tests for late in the testing can be added to 14951c586b8Smrg "tests/misc". printf and scanf tests currently live there too. 15051c586b8Smrg 15151c586b8Smrg iv) Random number function tests can be added to "tests/rand". That 15251c586b8Smrg directory has some development-time programs too. 15351c586b8Smrg 15451c586b8Smrg v) C++ test programs can be added to "tests/cxx". A line like the 15551c586b8Smrg following must be added for each, since by default automake looks 15651c586b8Smrg for a .c file. 15751c586b8Smrg 15851c586b8Smrg t_foo_SOURCES = t-foo.cc 15951c586b8Smrg 16051c586b8SmrgIn all cases the name of the program should be added to check_PROGRAMS 16151c586b8Smrgin the Makefile.am. TESTS is equal to check_PROGRAMS, so all those 16251c586b8Smrgprograms get run. 16351c586b8Smrg 16451c586b8Smrg"tests/devel" has a number of programs which are only for development 16551c586b8Smrgpurposes and are not for use in "make check". These should be listed 16651c586b8Smrgin EXTRA_PROGRAMS to get Makefile rules created, but they're never 16751c586b8Smrgbuilt or run unless an explicit "make someprog" is used. 16851c586b8Smrg 16951c586b8Smrg 17051c586b8Smrg* Adding a new CPU 17151c586b8Smrg 17251c586b8SmrgIn general it's policy to use proper names for each CPU type 17351c586b8Smrgsupported. If two CPUs are quite similar and perhaps don't have any 17451c586b8Smrgactual differences in GMP then they're still given separate names, for 17551c586b8Smrgexample alphaev67 and alphaev68. 17651c586b8Smrg 17751c586b8SmrgCanonical names: 17851c586b8Smrg 17951c586b8Smrg i) Decide the canonical CPU names GMP will accept. 18051c586b8Smrg 18151c586b8Smrg ii) Add these to the config.sub wrapper if configfsf.sub doesn't 18251c586b8Smrg already accept them. 18351c586b8Smrg 18451c586b8Smrg iii) Document the names in gmp.texi. 18551c586b8Smrg 18651c586b8SmrgAliases (optional): 18751c586b8Smrg 18851c586b8Smrg i) Any aliases can be added to the config.sub wrapper, unless 18951c586b8Smrg configfsf.sub already does the right thing with them. 19051c586b8Smrg 19151c586b8Smrg ii) Leave configure.in and everywhere else using only the canonical 19251c586b8Smrg names. Aliases shouldn't appear anywhere except config.sub. 19351c586b8Smrg 19451c586b8Smrg iii) Document in gmp.texi, if desired. Usually this isn't a good 19551c586b8Smrg idea, better encourage users to know just the canonical 19651c586b8Smrg names. 19751c586b8Smrg 19851c586b8SmrgConfigure: 19951c586b8Smrg 20051c586b8Smrg i) Add patterns to configure.in for the new CPU names. Include the 20151c586b8Smrg following (see configure.in for the variables to set up), 20251c586b8Smrg 20351c586b8Smrg a) ABI choices (if any). 20451c586b8Smrg b) Compiler choices. 20551c586b8Smrg c) mpn path for CPU specific code. 20651c586b8Smrg d) Good default CFLAGS for each likely compiler. 20751c586b8Smrg d) Any special tests necessary on the compiler or assembler 20851c586b8Smrg capabilities. 20951c586b8Smrg 21051c586b8Smrg ii) M4 macros to be shared by asm files in a CPU family are by 21151c586b8Smrg convention in a foo-defs.m4 like mpn/x86/x86-defs.m4. They're 21251c586b8Smrg likely to use settings from config.m4 generated by configure. 21351c586b8Smrg 21451c586b8SmrgFat binaries: 21551c586b8Smrg 21651c586b8Smrg i) In configure.in, add CPU specific directory(s) to fat_path. 21751c586b8Smrg 21851c586b8Smrg ii) In mpn/<cpu>/fat.c, identify the CPU at runtime and use suitable 21951c586b8Smrg CPUVEC_SETUP_subdir macros to select the function pointers for it. 22051c586b8Smrg 22151c586b8Smrg iii) For the x86s, add to the "$tmp_prefix" setups in configure.in 22251c586b8Smrg which abbreviates subdirectory names to fit an 8.3 filesystem. 22351c586b8Smrg (No need to restrict to 8.3, just ensure uniqueness when 22451c586b8Smrg truncated.) 22551c586b8Smrg 22651c586b8Smrg 22751c586b8Smrg* The configure system 22851c586b8Smrg 22951c586b8Smrg** Installing tools 23051c586b8Smrg 23151c586b8SmrgThe current versions of automake, autoconf and libtool in use can be 23251c586b8Smrgchecked in the ChangeLog. Look for "Update to ...". Patches may have 23351c586b8Smrgbeen applied, look for "Regenerate ...". 23451c586b8Smrg 23551c586b8SmrgThe GMP build system is in places somewhat dependent on the internals 23651c586b8Smrgof the build tools. Obviously that's avoided as much as possible, but 23751c586b8Smrgwhere it can't it creates a problem when upgrading or attempting to 23851c586b8Smrguse different tools versions. 23951c586b8Smrg 24051c586b8Smrg** Updating gmp 24151c586b8Smrg 24251c586b8SmrgThe following files need to be updated when going to a new version of 24351c586b8Smrgthe build tools. Unfortunately the tools generally don't identify 24451c586b8Smrgwhen an out-of-date version is present. 24551c586b8Smrg 24651c586b8Smrgaclocal.m4 is updated by running "aclocal". (Only needed for a new 24751c586b8Smrgautomake or libtool.) 24851c586b8Smrg 24951c586b8SmrgINSTALL.autoconf can be copied from INSTALL in autoconf. 25051c586b8Smrg 25151c586b8Smrgltmain.sh comes from libtool. Remove it and run "libtoolize --copy", 25251c586b8Smrgor just copy the file by hand. 25351c586b8Smrg 25451c586b8Smrgtexinfo.tex can be updated from ftp.gnu.org. Check it still works 25551c586b8Smrgwith "make gmp.dvi", "make gmp.ps" and "make gmp.pdf". 25651c586b8Smrg 25751c586b8Smrgconfigfsf.guess and configfsf.sub can be updated from ftp.gnu.org (or 25851c586b8Smrgfrom the "config" cvs module at subversions.gnu.org). The gmp 25951c586b8Smrgconfig.guess and config.sub wrappers are supposed to make such an 26051c586b8Smrgupdate fairly painless. 26151c586b8Smrg 26251c586b8Smrgdepcomp from automake is not needed because configure.in specifies 26351c586b8Smrgautomake with "no-dependencies". 26451c586b8Smrg 26551c586b8Smrg** How it works 26651c586b8Smrg 26751c586b8SmrgDuring development: 26851c586b8Smrg 26951c586b8Smrg Input files Tool Output files 27051c586b8Smrg --------------------------------------------------------- 27151c586b8Smrg 27251c586b8Smrg aclocal 27351c586b8Smrg $prefix/share/aclocal*/*.m4 ----------------> aclocal.m4 27451c586b8Smrg 27551c586b8Smrg 27651c586b8Smrg configure.in \ autoconf 27751c586b8Smrg aclocal.m4 / -----------------------------> configure 27851c586b8Smrg 27951c586b8Smrg 28051c586b8Smrg */Makefile.am \ automake 28151c586b8Smrg configure.in | ----------------------------> Makefile.in 28251c586b8Smrg aclocal.m4 / 28351c586b8Smrg 28451c586b8Smrg configure.in \ autoheader 28551c586b8Smrg aclocal.m4 / -----------------------------> config.in 28651c586b8Smrg 28751c586b8SmrgAt build time: 28851c586b8Smrg 28951c586b8Smrg Input files Tool Output files 29051c586b8Smrg -------------------------------------------- 29151c586b8Smrg 29251c586b8Smrg */Makefile.in \ configure / */Makefile 29351c586b8Smrg config.in | -------------> | config.h 294*ce543368Smrg gmp-h.in / | config.m4 295*ce543368Smrg | gmp.h 29651c586b8Smrg \ fat.h (fat binary build only) 29751c586b8Smrg 29851c586b8SmrgWhen configured with --enable-maintainer-mode the Makefiles include 29951c586b8Smrgrules to re-run the necessary tools if the input files are changed. 30051c586b8SmrgThis can end up running a lot more things than are really necessary. 30151c586b8Smrg 30251c586b8SmrgIf a build tree is in too much of a mess for those rules to work 30351c586b8Smrgproperly then a bootstrap can be done from the source directory with 30451c586b8Smrg 30551c586b8Smrg aclocal 30651c586b8Smrg autoconf 30751c586b8Smrg automake 30851c586b8Smrg autoheader 30951c586b8Smrg 31051c586b8SmrgThe autom4te.cache directory is created by autoconf to save some work 31151c586b8Smrgin subsequent automake or autoheader runs. It's recreated 31251c586b8Smrgautomatically if removed, it doesn't get distributed. 31351c586b8Smrg 31451c586b8Smrg** C++ configuration 31551c586b8Smrg 31651c586b8SmrgIt's intended that the contents of libgmp.la won't vary according to 31751c586b8Smrgwhether --enable-cxx is selected. This means that if C++ shared 31851c586b8Smrglibraries don't work properly then a shared+static with --disable-cxx 31951c586b8Smrgcan be done for the C parts, then a static-only with --enable-cxx to 32051c586b8Smrgget libgmpxx. 32151c586b8Smrg 32251c586b8Smrglibgmpxx.la uses some internals from libgmp.la, in order to share code 32351c586b8Smrgbetween C and C++. It's intended that libgmpxx can only be expected 32451c586b8Smrgto work with libgmp from the same version of GMP. If some of the 32551c586b8Smrgshared internals change their interface, then it's proposed to rename 32651c586b8Smrgthem, for instance __gmp_doprint2 or the like, so as to provoke link 32751c586b8Smrgerrors rather than mysterious failures from a mismatch. 32851c586b8Smrg 32951c586b8Smrg* Development setups 33051c586b8Smrg 33151c586b8Smrg** General 33251c586b8Smrg 33351c586b8Smrg--disable-shared will make builds go much faster, though of course 33451c586b8Smrgshared or shared+static should be tested too. 33551c586b8Smrg 33651c586b8Smrg--prefix to a dummy directory followed by "make install" will show 33751c586b8Smrgwhat's installed. 33851c586b8Smrg 33951c586b8Smrg"make check" acts on the libgmp just built, and will ignore any other 34051c586b8Smrg/usr/lib/libgmp, or at least it should do. Libtool does various hairy 34151c586b8Smrgthings to ensure it hits the just-built library. 34251c586b8Smrg 34351c586b8Smrg** Long long limb testing 34451c586b8Smrg 34551c586b8SmrgOn systems where gcc supports long long, but a limb is normally just a 34651c586b8Smrglong, the following can be used to force long long for testing 34751c586b8Smrgpurposes. It will probably run quite slowly. 34851c586b8Smrg 34951c586b8Smrg ./configure --host=none ABI=longlong 35051c586b8Smrg 35151c586b8Smrg** Function argument conversions 35251c586b8Smrg 35351c586b8SmrgWhen using gcc, configuring with something like 35451c586b8Smrg 35551c586b8Smrg ./configure CFLAGS="-g -Wall -Wconversion -Wno-sign-compare" 35651c586b8Smrg 35751c586b8Smrgcan show where function parameters are being converted due to having 35851c586b8Smrgfunction prototypes available, which won't happen in a K&R compiler. 35951c586b8SmrgDoing this in combination with the long long limb setups above is 36051c586b8Smrggood. 36151c586b8Smrg 36251c586b8SmrgConversions between int and long aren't warned about by gcc when 36351c586b8Smrgthey're the same size, which is unfortunate because casts should be 36451c586b8Smrgused in such cases, for the benefit of K&R compilers with int!=long 36551c586b8Smrgand where the difference matters in function calls. 36651c586b8Smrg 36751c586b8Smrg* Other Notes 36851c586b8Smrg 36951c586b8Smrg** Compatibility 37051c586b8Smrg 37151c586b8Smrgcompat.c is the home of functions retained for binary compatibility, 37251c586b8Smrg but now done by other means (like a macro). 37351c586b8Smrg 37451c586b8Smrgstruct __mpz_struct etc - this must be retained for C++ compatibility. 37551c586b8Smrg C++ applications defining functions taking mpz_t etc parameters 37651c586b8Smrg will get this in the mangled name because C++ "sees though" the 37751c586b8Smrg typedef mpz_t to the underlying struct. 37851c586b8Smrg 37951c586b8Smrg__gmpn - note that glibc defines some __mpn symbols, old versions of 38051c586b8Smrg some mpn routines, which it uses for floating point printfs. 38151c586b8Smrg 38251c586b8Smrg 38351c586b8Smrg 38451c586b8Smrg 38551c586b8SmrgLocal variables: 38651c586b8Smrgmode: outline 38751c586b8Smrgfill-column: 70 38851c586b8SmrgEnd: 38951c586b8Smrg/* eof doc/configuration */ 390