configure.ac 134 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884
  1. # Configure.ac script for Libgcrypt
  2. # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006,
  3. # 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
  4. # Copyright (C) 2012-2024 g10 Code GmbH
  5. #
  6. # This file is part of Libgcrypt.
  7. #
  8. # Libgcrypt is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU Lesser General Public License as
  10. # published by the Free Software Foundation; either version 2.1 of
  11. # the License, or (at your option) any later version.
  12. #
  13. # Libgcrypt is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Lesser General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Lesser General Public
  19. # License along with this program; if not, see <http://www.gnu.org/licenses/>.
  20. # (Process this file with autoconf to produce a configure script.)
  21. AC_REVISION($Revision$)
  22. AC_PREREQ([2.69])
  23. min_automake_version="1.14"
  24. # To build a release you need to create a tag with the version number
  25. # (git tag -s libgcrypt-n.m.k) and run "./autogen.sh --force". Please
  26. # bump the version number immediately after the release and do another
  27. # commit and push so that the git magic is able to work. See below
  28. # for the LT versions.
  29. m4_define([mym4_package],[libgcrypt])
  30. m4_define([mym4_major], [1])
  31. m4_define([mym4_minor], [11])
  32. m4_define([mym4_micro], [0])
  33. # Below is m4 magic to extract and compute the git revision number,
  34. # the decimalized short revision number, a beta version string and a
  35. # flag indicating a development version (mym4_isbeta). Note that the
  36. # m4 processing is done by autoconf and not during the configure run.
  37. m4_define([mym4_verslist], m4_split(m4_esyscmd([./autogen.sh --find-version] \
  38. mym4_package mym4_major mym4_minor mym4_micro),[:]))
  39. m4_define([mym4_isbeta], m4_argn(2, mym4_verslist))
  40. m4_define([mym4_version], m4_argn(4, mym4_verslist))
  41. m4_define([mym4_revision], m4_argn(7, mym4_verslist))
  42. m4_define([mym4_revision_dec], m4_argn(8, mym4_verslist))
  43. m4_esyscmd([echo ]mym4_version[>VERSION])
  44. AC_INIT([mym4_package],[mym4_version],[https://bugs.gnupg.org])
  45. # LT Version numbers, remember to change them just *before* a release.
  46. # (Code changed: REVISION++)
  47. # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
  48. # (Interfaces added: AGE++)
  49. # (Interfaces removed: AGE=0)
  50. #
  51. # (Interfaces removed: CURRENT++, AGE=0, REVISION=0)
  52. # (Interfaces added: CURRENT++, AGE++, REVISION=0)
  53. # (No interfaces changed: REVISION++)
  54. LIBGCRYPT_LT_CURRENT=25
  55. LIBGCRYPT_LT_AGE=5
  56. LIBGCRYPT_LT_REVISION=0
  57. ################################################
  58. AC_SUBST(LIBGCRYPT_LT_CURRENT)
  59. AC_SUBST(LIBGCRYPT_LT_AGE)
  60. AC_SUBST(LIBGCRYPT_LT_REVISION)
  61. # If the API is changed in an incompatible way: increment the next counter.
  62. #
  63. # 1.6: ABI and API change but the change is to most users irrelevant
  64. # and thus the API version number has not been incremented.
  65. LIBGCRYPT_CONFIG_API_VERSION=1
  66. # If you change the required gpg-error version, please remove
  67. # unnecessary error code defines in src/gcrypt-int.h.
  68. NEED_GPG_ERROR_VERSION=1.49
  69. AC_CONFIG_AUX_DIR([build-aux])
  70. AC_CONFIG_SRCDIR([src/libgcrypt.vers])
  71. AM_INIT_AUTOMAKE([serial-tests dist-bzip2])
  72. AC_CONFIG_HEADERS([config.h])
  73. AC_CONFIG_MACRO_DIR([m4])
  74. AC_CONFIG_LIBOBJ_DIR([compat])
  75. AC_CANONICAL_HOST
  76. AM_MAINTAINER_MODE
  77. AM_SILENT_RULES
  78. AC_USE_SYSTEM_EXTENSIONS
  79. AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
  80. AH_TOP([
  81. #ifndef _GCRYPT_CONFIG_H_INCLUDED
  82. #define _GCRYPT_CONFIG_H_INCLUDED
  83. /* Enable gpg-error's strerror macro for W32CE. */
  84. #define GPG_ERR_ENABLE_ERRNO_MACROS 1
  85. ])
  86. AH_BOTTOM([
  87. #define _GCRYPT_IN_LIBGCRYPT 1
  88. /* Add .note.gnu.property section for Intel CET in assembler sources
  89. when CET is enabled. */
  90. #if defined(__ASSEMBLER__) && defined(__CET__)
  91. # include <cet.h>
  92. #endif
  93. /* If the configure check for endianness has been disabled, get it from
  94. OS macros. This is intended for making fat binary builds on OS X. */
  95. #ifdef DISABLED_ENDIAN_CHECK
  96. # if defined(__BIG_ENDIAN__)
  97. # define WORDS_BIGENDIAN 1
  98. # elif defined(__LITTLE_ENDIAN__)
  99. # undef WORDS_BIGENDIAN
  100. # else
  101. # error "No endianness found"
  102. # endif
  103. #endif /*DISABLED_ENDIAN_CHECK*/
  104. /* We basically use the original Camellia source. Make sure the symbols
  105. properly prefixed. */
  106. #define CAMELLIA_EXT_SYM_PREFIX _gcry_
  107. #endif /*_GCRYPT_CONFIG_H_INCLUDED*/
  108. ])
  109. AH_VERBATIM([_REENTRANT],
  110. [/* To allow the use of Libgcrypt in multithreaded programs we have to use
  111. special features from the library. */
  112. #ifndef _REENTRANT
  113. # define _REENTRANT 1
  114. #endif
  115. ])
  116. ######################
  117. ## Basic checks. ### (we need some results later on (e.g. $GCC)
  118. ######################
  119. AC_PROG_MAKE_SET
  120. missing_dir=`cd $ac_aux_dir && pwd`
  121. AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
  122. AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
  123. AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
  124. AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
  125. # AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
  126. AC_PROG_CC
  127. AC_PROG_CPP
  128. AM_PROG_CC_C_O
  129. AM_PROG_AS
  130. AC_SEARCH_LIBS([strerror],[cposix])
  131. AC_PROG_INSTALL
  132. AC_PROG_AWK
  133. AC_PROG_FGREP
  134. # Taken from mpfr-4.0.1, then modified for LDADD_FOR_TESTS_KLUDGE
  135. dnl Under Linux, make sure that the old dtags are used if LD_LIBRARY_PATH
  136. dnl is defined. The issue is that with the new dtags, LD_LIBRARY_PATH has
  137. dnl the precedence over the run path, so that if a compatible MPFR library
  138. dnl is installed in some directory from $LD_LIBRARY_PATH, then the tested
  139. dnl MPFR library will be this library instead of the MPFR library from the
  140. dnl build tree. Other OS with the same issue might be added later.
  141. dnl
  142. dnl References:
  143. dnl https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859732
  144. dnl http://lists.gnu.org/archive/html/libtool/2017-05/msg00000.html
  145. dnl
  146. dnl We need to check whether --disable-new-dtags is supported as alternate
  147. dnl linkers may be used (e.g., with tcc: CC=tcc LD=tcc).
  148. dnl
  149. case $host in
  150. *-*-linux*)
  151. if test -n "$LD_LIBRARY_PATH"; then
  152. saved_LDFLAGS="$LDFLAGS"
  153. LDADD_FOR_TESTS_KLUDGE="-Wl,--disable-new-dtags"
  154. LDFLAGS="$LDFLAGS $LDADD_FOR_TESTS_KLUDGE"
  155. AC_MSG_CHECKING(whether --disable-new-dtags is supported by the linker)
  156. AC_LINK_IFELSE([AC_LANG_SOURCE([[
  157. int main (void) { return 0; }
  158. ]])],
  159. [AC_MSG_RESULT(yes (use it since LD_LIBRARY_PATH is set))],
  160. [AC_MSG_RESULT(no)
  161. LDADD_FOR_TESTS_KLUDGE=""
  162. ])
  163. LDFLAGS="$saved_LDFLAGS"
  164. fi
  165. ;;
  166. esac
  167. AC_SUBST([LDADD_FOR_TESTS_KLUDGE])
  168. VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" mym4_major \
  169. mym4_minor mym4_micro)
  170. AC_SUBST(VERSION_NUMBER)
  171. # We need to compile and run a program on the build machine.
  172. AX_CC_FOR_BUILD
  173. LT_PREREQ([2.2.6])
  174. LT_INIT([win32-dll disable-static])
  175. LT_LANG([Windows Resource])
  176. ##########################
  177. ## General definitions. ##
  178. ##########################
  179. # Used by libgcrypt-config
  180. LIBGCRYPT_CONFIG_LIBS="-lgcrypt"
  181. LIBGCRYPT_CONFIG_CFLAGS=""
  182. LIBGCRYPT_CONFIG_HOST="$host"
  183. # Definitions for symmetric ciphers.
  184. available_ciphers="arcfour blowfish cast5 des aes twofish serpent rfc2268 seed"
  185. available_ciphers="$available_ciphers camellia idea salsa20 gost28147 chacha20"
  186. available_ciphers="$available_ciphers sm4 aria"
  187. enabled_ciphers=""
  188. # Definitions for public-key ciphers.
  189. available_pubkey_ciphers="dsa elgamal rsa ecc"
  190. enabled_pubkey_ciphers=""
  191. # Definitions for message digests.
  192. available_digests="crc gostr3411-94 md2 md4 md5 rmd160 sha1 sha256 sha512"
  193. available_digests="$available_digests sha3 tiger whirlpool stribog blake2"
  194. available_digests="$available_digests sm3"
  195. enabled_digests=""
  196. # Definitions for kdfs (optional ones)
  197. available_kdfs="s2k pkdf2 scrypt"
  198. enabled_kdfs=""
  199. # Definitions for random modules.
  200. available_random_modules="getentropy linux egd unix"
  201. auto_random_modules="$available_random_modules"
  202. # Supported thread backends.
  203. LIBGCRYPT_THREAD_MODULES=""
  204. # Other definitions.
  205. have_w32_system=no
  206. have_w32ce_system=no
  207. have_pthread=no
  208. # Setup some stuff depending on host.
  209. case "${host}" in
  210. *-*-mingw32*)
  211. ac_cv_have_dev_random=no
  212. have_w32_system=yes
  213. case "${host}" in
  214. *-mingw32ce*)
  215. have_w32ce_system=yes
  216. available_random_modules="w32ce"
  217. ;;
  218. *)
  219. available_random_modules="w32"
  220. ;;
  221. esac
  222. AC_DEFINE(USE_ONLY_8DOT3,1,
  223. [set this to limit filenames to the 8.3 format])
  224. AC_DEFINE(HAVE_DRIVE_LETTERS,1,
  225. [defined if we must run on a stupid file system])
  226. AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
  227. [defined if we run on some of the PCDOS like systems
  228. (DOS, Windoze. OS/2) with special properties like
  229. no file modes])
  230. ;;
  231. i?86-emx-os2 | i?86-*-os2*emx)
  232. # OS/2 with the EMX environment
  233. ac_cv_have_dev_random=no
  234. AC_DEFINE(HAVE_DRIVE_LETTERS)
  235. AC_DEFINE(HAVE_DOSISH_SYSTEM)
  236. ;;
  237. i?86-*-msdosdjgpp*)
  238. # DOS with the DJGPP environment
  239. ac_cv_have_dev_random=no
  240. AC_DEFINE(HAVE_DRIVE_LETTERS)
  241. AC_DEFINE(HAVE_DOSISH_SYSTEM)
  242. ;;
  243. *-*-hpux*)
  244. if test -z "$GCC" ; then
  245. CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
  246. fi
  247. ;;
  248. *-dec-osf4*)
  249. if test -z "$GCC" ; then
  250. # Suppress all warnings
  251. # to get rid of the unsigned/signed char mismatch warnings.
  252. CFLAGS="$CFLAGS -w"
  253. fi
  254. ;;
  255. m68k-atari-mint)
  256. ;;
  257. *-apple-darwin*)
  258. AC_DEFINE(_DARWIN_C_SOURCE, 1,
  259. Expose all libc features (__DARWIN_C_FULL).)
  260. AC_DEFINE(USE_POSIX_SPAWN_FOR_TESTS, 1,
  261. [defined if we use posix_spawn in test program])
  262. AC_CHECK_HEADERS(spawn.h)
  263. ;;
  264. *)
  265. ;;
  266. esac
  267. if test "$have_w32_system" = yes; then
  268. AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
  269. if test "$have_w32ce_system" = yes; then
  270. AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
  271. fi
  272. fi
  273. AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
  274. AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
  275. # A printable OS Name is sometimes useful.
  276. case "${host}" in
  277. *-*-mingw32ce*)
  278. PRINTABLE_OS_NAME="W32CE"
  279. ;;
  280. *-*-mingw32*)
  281. PRINTABLE_OS_NAME="W32"
  282. ;;
  283. i?86-emx-os2 | i?86-*-os2*emx )
  284. PRINTABLE_OS_NAME="OS/2"
  285. ;;
  286. i?86-*-msdosdjgpp*)
  287. PRINTABLE_OS_NAME="MSDOS/DJGPP"
  288. ;;
  289. *-linux*)
  290. PRINTABLE_OS_NAME="GNU/Linux"
  291. ;;
  292. *)
  293. PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
  294. ;;
  295. esac
  296. NAME_OF_DEV_RANDOM="/dev/random"
  297. NAME_OF_DEV_URANDOM="/dev/urandom"
  298. AC_ARG_ENABLE(endian-check,
  299. AS_HELP_STRING([--disable-endian-check],
  300. [disable the endian check and trust the OS provided macros]),
  301. endiancheck=$enableval,endiancheck=yes)
  302. if test x"$endiancheck" = xyes ; then
  303. AC_C_BIGENDIAN
  304. else
  305. AC_DEFINE(DISABLED_ENDIAN_CHECK,1,[configure did not test for endianness])
  306. fi
  307. AC_CHECK_SIZEOF(unsigned short, 2)
  308. AC_CHECK_SIZEOF(unsigned int, 4)
  309. AC_CHECK_SIZEOF(unsigned long, 4)
  310. AC_CHECK_SIZEOF(unsigned long long, 0)
  311. AC_CHECK_SIZEOF(unsigned __int128, 0)
  312. AC_CHECK_SIZEOF(void *, 0)
  313. AC_TYPE_UINTPTR_T
  314. if test "$ac_cv_sizeof_unsigned_short" = "0" \
  315. || test "$ac_cv_sizeof_unsigned_int" = "0" \
  316. || test "$ac_cv_sizeof_unsigned_long" = "0"; then
  317. AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
  318. fi
  319. # Ensure that we have UINT64_C before we bother to check for uint64_t
  320. AC_CACHE_CHECK([for UINT64_C],[gnupg_cv_uint64_c_works],
  321. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <inttypes.h>]],
  322. [[uint64_t foo=UINT64_C(42);]])],
  323. gnupg_cv_uint64_c_works=yes,gnupg_cv_uint64_c_works=no))
  324. if test "$gnupg_cv_uint64_c_works" = "yes" ; then
  325. AC_CHECK_SIZEOF(uint64_t)
  326. fi
  327. # Do we have any 64-bit data types?
  328. if test "$ac_cv_sizeof_unsigned_int" != "8" \
  329. && test "$ac_cv_sizeof_unsigned_long" != "8" \
  330. && test "$ac_cv_sizeof_unsigned_long_long" != "8" \
  331. && test "$ac_cv_sizeof_uint64_t" != "8"; then
  332. AC_MSG_ERROR([[
  333. ***
  334. *** No 64-bit integer type available.
  335. *** It is not possible to build Libgcrypt on this platform.
  336. ***]])
  337. fi
  338. # If not specified otherwise, all available algorithms will be
  339. # included.
  340. default_ciphers="$available_ciphers"
  341. default_pubkey_ciphers="$available_pubkey_ciphers"
  342. default_digests="$available_digests"
  343. default_kdfs="$available_kdfs"
  344. # Blacklist MD2 by default
  345. default_digests=`echo $default_digests | sed -e 's/md2//g'`
  346. # Substitutions to set generated files in a Emacs buffer to read-only.
  347. AC_SUBST(emacs_local_vars_begin, ['Local Variables:'])
  348. AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t'])
  349. AC_SUBST(emacs_local_vars_end, ['End:'])
  350. ############################
  351. ## Command line switches. ##
  352. ############################
  353. # Implementation of the --enable-ciphers switch.
  354. AC_ARG_ENABLE(ciphers,
  355. AS_HELP_STRING([--enable-ciphers=ciphers],
  356. [select the symmetric ciphers to include]),
  357. [enabled_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
  358. [enabled_ciphers=""])
  359. if test "x$enabled_ciphers" = "x" \
  360. -o "$enabled_ciphers" = "yes" \
  361. -o "$enabled_ciphers" = "no"; then
  362. enabled_ciphers=$default_ciphers
  363. fi
  364. AC_MSG_CHECKING([which symmetric ciphers to include])
  365. for cipher in $enabled_ciphers; do
  366. LIST_MEMBER($cipher, $available_ciphers)
  367. if test "$found" = "0"; then
  368. AC_MSG_ERROR([unsupported cipher "$cipher" specified])
  369. fi
  370. done
  371. AC_MSG_RESULT([$enabled_ciphers])
  372. # Implementation of the --enable-pubkey-ciphers switch.
  373. AC_ARG_ENABLE(pubkey-ciphers,
  374. AS_HELP_STRING([--enable-pubkey-ciphers=ciphers],
  375. [select the public-key ciphers to include]),
  376. [enabled_pubkey_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
  377. [enabled_pubkey_ciphers=""])
  378. if test "x$enabled_pubkey_ciphers" = "x" \
  379. -o "$enabled_pubkey_ciphers" = "yes" \
  380. -o "$enabled_pubkey_ciphers" = "no"; then
  381. enabled_pubkey_ciphers=$default_pubkey_ciphers
  382. fi
  383. AC_MSG_CHECKING([which public-key ciphers to include])
  384. for cipher in $enabled_pubkey_ciphers; do
  385. LIST_MEMBER($cipher, $available_pubkey_ciphers)
  386. if test "$found" = "0"; then
  387. AC_MSG_ERROR([unsupported public-key cipher specified])
  388. fi
  389. done
  390. AC_MSG_RESULT([$enabled_pubkey_ciphers])
  391. # Implementation of the --enable-digests switch.
  392. AC_ARG_ENABLE(digests,
  393. AS_HELP_STRING([--enable-digests=digests],
  394. [select the message digests to include]),
  395. [enabled_digests=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
  396. [enabled_digests=""])
  397. if test "x$enabled_digests" = "x" \
  398. -o "$enabled_digests" = "yes" \
  399. -o "$enabled_digests" = "no"; then
  400. enabled_digests=$default_digests
  401. fi
  402. AC_MSG_CHECKING([which message digests to include])
  403. for digest in $enabled_digests; do
  404. LIST_MEMBER($digest, $available_digests)
  405. if test "$found" = "0"; then
  406. AC_MSG_ERROR([unsupported message digest specified])
  407. fi
  408. done
  409. AC_MSG_RESULT([$enabled_digests])
  410. # Implementation of the --enable-kdfs switch.
  411. AC_ARG_ENABLE(kdfs,
  412. AS_HELP_STRING([--enable-kfds=kdfs],
  413. [select the KDFs to include]),
  414. [enabled_kdfs=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`],
  415. [enabled_kdfs=""])
  416. if test "x$enabled_kdfs" = "x" \
  417. -o "$enabled_kdfs" = "yes" \
  418. -o "$enabled_kdfs" = "no"; then
  419. enabled_kdfs=$default_kdfs
  420. fi
  421. AC_MSG_CHECKING([which key derivation functions to include])
  422. for kdf in $enabled_kdfs; do
  423. LIST_MEMBER($kdf, $available_kdfs)
  424. if test "$found" = "0"; then
  425. AC_MSG_ERROR([unsupported key derivation function specified])
  426. fi
  427. done
  428. AC_MSG_RESULT([$enabled_kdfs])
  429. # Implementation of the --enable-random switch.
  430. AC_ARG_ENABLE(random,
  431. AS_HELP_STRING([--enable-random=name],
  432. [select which random number generator to use]),
  433. [random=`echo $enableval | tr '[A-Z]' '[a-z]'`],
  434. [])
  435. if test "x$random" = "x" -o "$random" = "yes" -o "$random" = "no"; then
  436. random=default
  437. fi
  438. AC_MSG_CHECKING([which random module to use])
  439. if test "$random" != "default" -a "$random" != "auto"; then
  440. LIST_MEMBER($random, $available_random_modules)
  441. if test "$found" = "0"; then
  442. AC_MSG_ERROR([unsupported random module specified])
  443. fi
  444. fi
  445. AC_MSG_RESULT($random)
  446. # Implementation of the --disable-dev-random switch.
  447. AC_MSG_CHECKING([whether use of /dev/random is requested])
  448. AC_ARG_ENABLE(dev-random,
  449. [ --disable-dev-random disable the use of dev random],
  450. try_dev_random=$enableval, try_dev_random=yes)
  451. AC_MSG_RESULT($try_dev_random)
  452. # Implementation of the --with-egd-socket switch.
  453. AC_ARG_WITH(egd-socket,
  454. [ --with-egd-socket=NAME Use NAME for the EGD socket)],
  455. egd_socket_name="$withval", egd_socket_name="" )
  456. AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, "$egd_socket_name",
  457. [Define if you don't want the default EGD socket name.
  458. For details see cipher/rndegd.c])
  459. # Implementation of --disable-asm.
  460. AC_MSG_CHECKING([whether MPI and cipher assembler modules are requested])
  461. AC_ARG_ENABLE([asm],
  462. AS_HELP_STRING([--disable-asm],
  463. [Disable MPI and cipher assembler modules]),
  464. [try_asm_modules=$enableval],
  465. [try_asm_modules=yes])
  466. AC_MSG_RESULT($try_asm_modules)
  467. if test "$try_asm_modules" != yes ; then
  468. AC_DEFINE(ASM_DISABLED,1,[Defined if --disable-asm was used to configure])
  469. fi
  470. # Implementation of the --enable-large-data-tests switch.
  471. AC_MSG_CHECKING([whether to run large data tests])
  472. AC_ARG_ENABLE(large-data-tests,
  473. AS_HELP_STRING([--enable-large-data-tests],
  474. [Enable the real long ruinning large data tests]),
  475. large_data_tests=$enableval,large_data_tests=no)
  476. AC_MSG_RESULT($large_data_tests)
  477. AC_SUBST(RUN_LARGE_DATA_TESTS, $large_data_tests)
  478. # Implementation of --enable-force-soft-hwfeatures
  479. AC_MSG_CHECKING([whether 'soft' HW feature bits are forced on])
  480. AC_ARG_ENABLE([force-soft-hwfeatures],
  481. AS_HELP_STRING([--enable-force-soft-hwfeatures],
  482. [Enable forcing 'soft' HW feature bits on]),
  483. [force_soft_hwfeatures=$enableval],
  484. [force_soft_hwfeatures=no])
  485. AC_MSG_RESULT($force_soft_hwfeatures)
  486. # Implementation of the --with-capabilities switch.
  487. # Check whether we want to use Linux capabilities
  488. AC_MSG_CHECKING([whether use of capabilities is requested])
  489. AC_ARG_WITH(capabilities,
  490. AS_HELP_STRING([--with-capabilities],
  491. [Use linux capabilities [default=no]]),
  492. [use_capabilities="$withval"],[use_capabilities=no])
  493. AC_MSG_RESULT($use_capabilities)
  494. # Implementation of the --enable-hmac-binary-check.
  495. AC_MSG_CHECKING([whether a HMAC binary check is requested])
  496. AC_ARG_ENABLE(hmac-binary-check,
  497. AS_HELP_STRING([--enable-hmac-binary-check],
  498. [Enable library integrity check]),
  499. [use_hmac_binary_check="$enableval"],
  500. [use_hmac_binary_check=no])
  501. AC_MSG_RESULT($use_hmac_binary_check)
  502. if test "$use_hmac_binary_check" = no ; then
  503. DEF_HMAC_BINARY_CHECK=''
  504. else
  505. AC_DEFINE(ENABLE_HMAC_BINARY_CHECK,1,
  506. [Define to support an HMAC based integrity check])
  507. AC_CHECK_TOOL(OBJCOPY, [objcopy])
  508. AC_CHECK_TOOL(READELF, [readelf])
  509. if test "$use_hmac_binary_check" != yes ; then
  510. DEF_HMAC_BINARY_CHECK=-DKEY_FOR_BINARY_CHECK="'\"$use_hmac_binary_check\"'"
  511. fi
  512. fi
  513. AM_CONDITIONAL(USE_HMAC_BINARY_CHECK, test "x$use_hmac_binary_check" != xno)
  514. AC_SUBST(DEF_HMAC_BINARY_CHECK)
  515. # Implementation of the --with-fips-module-version.
  516. AC_ARG_WITH(fips-module-version,
  517. AS_HELP_STRING([--with-fips-module-version=VERSION],
  518. [Specify the FIPS module version for the build]),
  519. fips_module_version="$withval", fips_module_version="" )
  520. AC_DEFINE_UNQUOTED(FIPS_MODULE_VERSION, "$fips_module_version",
  521. [Define FIPS module version for certification])
  522. # Implementation of the --disable-jent-support switch.
  523. AC_MSG_CHECKING([whether jitter entropy support is requested])
  524. AC_ARG_ENABLE(jent-support,
  525. AS_HELP_STRING([--disable-jent-support],
  526. [Disable support for the Jitter entropy collector]),
  527. jentsupport=$enableval,jentsupport=yes)
  528. AC_MSG_RESULT($jentsupport)
  529. # Implementation of the --disable-padlock-support switch.
  530. AC_MSG_CHECKING([whether padlock support is requested])
  531. AC_ARG_ENABLE(padlock-support,
  532. AS_HELP_STRING([--disable-padlock-support],
  533. [Disable support for the PadLock Engine of VIA processors]),
  534. padlocksupport=$enableval,padlocksupport=yes)
  535. AC_MSG_RESULT($padlocksupport)
  536. # Implementation of the --disable-aesni-support switch.
  537. AC_MSG_CHECKING([whether AESNI support is requested])
  538. AC_ARG_ENABLE(aesni-support,
  539. AS_HELP_STRING([--disable-aesni-support],
  540. [Disable support for the Intel AES-NI instructions]),
  541. aesnisupport=$enableval,aesnisupport=yes)
  542. AC_MSG_RESULT($aesnisupport)
  543. # Implementation of the --disable-shaext-support switch.
  544. AC_MSG_CHECKING([whether SHAEXT support is requested])
  545. AC_ARG_ENABLE(shaext-support,
  546. AS_HELP_STRING([--disable-shaext-support],
  547. [Disable support for the Intel SHAEXT instructions]),
  548. shaextsupport=$enableval,shaextsupport=yes)
  549. AC_MSG_RESULT($shaextsupport)
  550. # Implementation of the --disable-pclmul-support switch.
  551. AC_MSG_CHECKING([whether PCLMUL support is requested])
  552. AC_ARG_ENABLE(pclmul-support,
  553. AS_HELP_STRING([--disable-pclmul-support],
  554. [Disable support for the Intel PCLMUL instructions]),
  555. pclmulsupport=$enableval,pclmulsupport=yes)
  556. AC_MSG_RESULT($pclmulsupport)
  557. # Implementation of the --disable-sse41-support switch.
  558. AC_MSG_CHECKING([whether SSE4.1 support is requested])
  559. AC_ARG_ENABLE(sse41-support,
  560. AS_HELP_STRING([--disable-sse41-support],
  561. [Disable support for the Intel SSE4.1 instructions]),
  562. sse41support=$enableval,sse41support=yes)
  563. AC_MSG_RESULT($sse41support)
  564. # Implementation of the --disable-drng-support switch.
  565. AC_MSG_CHECKING([whether DRNG support is requested])
  566. AC_ARG_ENABLE(drng-support,
  567. AS_HELP_STRING([--disable-drng-support],
  568. [Disable support for the Intel DRNG (RDRAND instruction)]),
  569. drngsupport=$enableval,drngsupport=yes)
  570. AC_MSG_RESULT($drngsupport)
  571. # Implementation of the --disable-avx-support switch.
  572. AC_MSG_CHECKING([whether AVX support is requested])
  573. AC_ARG_ENABLE(avx-support,
  574. AS_HELP_STRING([--disable-avx-support],
  575. [Disable support for the Intel AVX instructions]),
  576. avxsupport=$enableval,avxsupport=yes)
  577. AC_MSG_RESULT($avxsupport)
  578. # Implementation of the --disable-avx2-support switch.
  579. AC_MSG_CHECKING([whether AVX2 support is requested])
  580. AC_ARG_ENABLE(avx2-support,
  581. AS_HELP_STRING([--disable-avx2-support],
  582. [Disable support for the Intel AVX2 instructions]),
  583. avx2support=$enableval,avx2support=yes)
  584. AC_MSG_RESULT($avx2support)
  585. # Implementation of the --disable-avx512-support switch.
  586. AC_MSG_CHECKING([whether AVX512 support is requested])
  587. AC_ARG_ENABLE(avx512-support,
  588. AS_HELP_STRING([--disable-avx512-support],
  589. [Disable support for the Intel AVX512 instructions]),
  590. avx512support=$enableval,avx512support=yes)
  591. AC_MSG_RESULT($avx512support)
  592. # Implementation of the --disable-gfni-support switch.
  593. AC_MSG_CHECKING([whether GFNI support is requested])
  594. AC_ARG_ENABLE(gfni-support,
  595. AS_HELP_STRING([--disable-gfni-support],
  596. [Disable support for the Intel GFNI instructions]),
  597. gfnisupport=$enableval,gfnisupport=yes)
  598. AC_MSG_RESULT($gfnisupport)
  599. # Implementation of the --disable-neon-support switch.
  600. AC_MSG_CHECKING([whether NEON support is requested])
  601. AC_ARG_ENABLE(neon-support,
  602. AS_HELP_STRING([--disable-neon-support],
  603. [Disable support for the ARM NEON instructions]),
  604. neonsupport=$enableval,neonsupport=yes)
  605. AC_MSG_RESULT($neonsupport)
  606. # Implementation of the --disable-arm-crypto-support switch.
  607. AC_MSG_CHECKING([whether ARMv8 Crypto Extension support is requested])
  608. AC_ARG_ENABLE(arm-crypto-support,
  609. AS_HELP_STRING([--disable-arm-crypto-support],
  610. [Disable support for the ARMv8 Crypto Extension instructions]),
  611. armcryptosupport=$enableval,armcryptosupport=yes)
  612. AC_MSG_RESULT($armcryptosupport)
  613. # Implementation of the --disable-sve-support switch.
  614. AC_MSG_CHECKING([whether SVE support is requested])
  615. AC_ARG_ENABLE(sve-support,
  616. AS_HELP_STRING([--disable-sve-support],
  617. [Disable support for the ARMv8 SVE instructions]),
  618. svesupport=$enableval,svesupport=yes)
  619. AC_MSG_RESULT($svesupport)
  620. # Implementation of the --disable-sve2-support switch.
  621. AC_MSG_CHECKING([whether SVE2 support is requested])
  622. AC_ARG_ENABLE(sve2-support,
  623. AS_HELP_STRING([--disable-sve2-support],
  624. [Disable support for the ARMv9 SVE2 instructions]),
  625. sve2support=$enableval,sve2support=yes)
  626. AC_MSG_RESULT($sve2support)
  627. # Implementation of the --disable-ppc-crypto-support switch.
  628. AC_MSG_CHECKING([whether PPC crypto support is requested])
  629. AC_ARG_ENABLE(ppc-crypto-support,
  630. AS_HELP_STRING([--disable-ppc-crypto-support],
  631. [Disable support for the PPC crypto instructions introduced in POWER 8 (PowerISA 2.07)]),
  632. ppccryptosupport=$enableval,ppccryptosupport=yes)
  633. AC_MSG_RESULT($ppccryptosupport)
  634. # Implementation of the --disable-O-flag-munging switch.
  635. AC_MSG_CHECKING([whether a -O flag munging is requested])
  636. AC_ARG_ENABLE([O-flag-munging],
  637. AS_HELP_STRING([--disable-O-flag-munging],
  638. [Disable modification of the cc -O flag]),
  639. [enable_o_flag_munging=$enableval],
  640. [enable_o_flag_munging=yes])
  641. AC_MSG_RESULT($enable_o_flag_munging)
  642. AM_CONDITIONAL(ENABLE_O_FLAG_MUNGING, test "$enable_o_flag_munging" = "yes")
  643. # Implementation of the --disable-instrumentation-munging switch.
  644. AC_MSG_CHECKING([whether a instrumentation (-fprofile, -fsanitize) munging is requested])
  645. AC_ARG_ENABLE([instrumentation-munging],
  646. AS_HELP_STRING([--disable-instrumentation-munging],
  647. [Disable modification of the cc instrumentation options]),
  648. [enable_instrumentation_munging=$enableval],
  649. [enable_instrumentation_munging=yes])
  650. AC_MSG_RESULT($enable_instrumentation_munging)
  651. AM_CONDITIONAL(ENABLE_INSTRUMENTATION_MUNGING,
  652. test "$enable_instrumentation_munging" = "yes")
  653. # Implementation of the --disable-amd64-as-feature-detection switch.
  654. AC_MSG_CHECKING([whether to enable AMD64 as(1) feature detection])
  655. AC_ARG_ENABLE(amd64-as-feature-detection,
  656. AS_HELP_STRING([--disable-amd64-as-feature-detection],
  657. [Disable the auto-detection of AMD64 as(1) features]),
  658. amd64_as_feature_detection=$enableval,
  659. amd64_as_feature_detection=yes)
  660. AC_MSG_RESULT($amd64_as_feature_detection)
  661. AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
  662. [A human readable text with the name of the OS])
  663. # For some systems we know that we have ld_version scripts.
  664. # Use it then as default.
  665. have_ld_version_script=no
  666. case "${host}" in
  667. *-*-linux*)
  668. have_ld_version_script=yes
  669. ;;
  670. *-*-gnu*)
  671. have_ld_version_script=yes
  672. ;;
  673. esac
  674. AC_ARG_ENABLE([ld-version-script],
  675. AS_HELP_STRING([--enable-ld-version-script],
  676. [enable/disable use of linker version script.
  677. (default is system dependent)]),
  678. [have_ld_version_script=$enableval],
  679. [ : ] )
  680. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  681. AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM",
  682. [defined to the name of the strong random device])
  683. AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM",
  684. [defined to the name of the weaker random device])
  685. #
  686. # Specify how we support our local modification of libtool for Windows
  687. # 64-bit. Options are:
  688. #
  689. # (1) apply: when appying patch fails, it results failure of entire build
  690. # (2) never: never apply the patch (no try)
  691. # (3) try: use patched if it goes well, use original if fails
  692. #
  693. AC_ARG_WITH([libtool-modification],
  694. AS_HELP_STRING([--with-libtool-modification=apply|never|try],
  695. [how to handle libtool modification (default=never)]),
  696. build_libtool_modification=$withval,
  697. build_libtool_modification=never)
  698. #
  699. # Apply a patch (locally maintained one of ours) to libtool
  700. #
  701. case $host in
  702. x86_64-*mingw32*)
  703. AC_CONFIG_COMMANDS([libtool-patch],[[
  704. if test "$build_selection" = never; then
  705. echo "patch not applied"
  706. elif (mv -f libtool libtool.orig; \
  707. sed -f $srcdir/build-aux/libtool-patch.sed libtool.orig >libtool); then
  708. echo "applied successfully"
  709. elif test "$build_selection" = try; then
  710. mv -f libtool.orig libtool
  711. echo "patch failed, thus, using original"
  712. else
  713. echo "patch failed"
  714. as_fn_exit 1
  715. fi
  716. ]],[build_selection=$build_libtool_modification])
  717. ;;
  718. *)
  719. ;;
  720. esac
  721. ###############################
  722. #### Checks for libraries. ####
  723. ###############################
  724. #
  725. # gpg-error is required.
  726. #
  727. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
  728. if test "x$GPG_ERROR_LIBS" = "x"; then
  729. AC_MSG_ERROR([libgpg-error is needed.
  730. See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .])
  731. fi
  732. AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT,
  733. [The default error source for libgcrypt.])
  734. AM_CONDITIONAL(USE_GPGRT_CONFIG, [test -n "$GPGRT_CONFIG" \
  735. -a "$ac_cv_path_GPG_ERROR_CONFIG" = no])
  736. #
  737. # Check whether pthreads is available
  738. #
  739. if test "$have_w32_system" != yes; then
  740. AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
  741. if test "$have_pthread" = yes; then
  742. AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.])
  743. fi
  744. fi
  745. # Solaris needs -lsocket and -lnsl. Unisys system includes
  746. # gethostbyname in libsocket but needs libnsl for socket.
  747. AC_SEARCH_LIBS(setsockopt, [socket], ,
  748. [AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
  749. AC_SEARCH_LIBS(setsockopt, [nsl])
  750. ##################################
  751. #### Checks for header files. ####
  752. ##################################
  753. AC_CHECK_HEADERS(unistd.h sys/auxv.h sys/random.h sys/sysctl.h)
  754. ##########################################
  755. #### Checks for typedefs, structures, ####
  756. #### and compiler characteristics. ####
  757. ##########################################
  758. AC_C_CONST
  759. AC_C_INLINE
  760. AC_TYPE_SIZE_T
  761. AC_TYPE_PID_T
  762. AC_CHECK_TYPES([byte, ushort, u16, u32, u64])
  763. #
  764. # Check for __builtin_bswap32 intrinsic.
  765. #
  766. AC_CACHE_CHECK(for __builtin_bswap32,
  767. [gcry_cv_have_builtin_bswap32],
  768. [gcry_cv_have_builtin_bswap32=no
  769. AC_LINK_IFELSE([AC_LANG_PROGRAM([],
  770. [int x = 0; int y = __builtin_bswap32(x); return y;])],
  771. [gcry_cv_have_builtin_bswap32=yes])])
  772. if test "$gcry_cv_have_builtin_bswap32" = "yes" ; then
  773. AC_DEFINE(HAVE_BUILTIN_BSWAP32,1,
  774. [Defined if compiler has '__builtin_bswap32' intrinsic])
  775. fi
  776. #
  777. # Check for __builtin_bswap64 intrinsic.
  778. #
  779. AC_CACHE_CHECK(for __builtin_bswap64,
  780. [gcry_cv_have_builtin_bswap64],
  781. [gcry_cv_have_builtin_bswap64=no
  782. AC_LINK_IFELSE([AC_LANG_PROGRAM([],
  783. [long long x = 0; long long y = __builtin_bswap64(x); return y;])],
  784. [gcry_cv_have_builtin_bswap64=yes])])
  785. if test "$gcry_cv_have_builtin_bswap64" = "yes" ; then
  786. AC_DEFINE(HAVE_BUILTIN_BSWAP64,1,
  787. [Defined if compiler has '__builtin_bswap64' intrinsic])
  788. fi
  789. #
  790. # Check for __builtin_ctz intrinsic.
  791. #
  792. AC_CACHE_CHECK(for __builtin_ctz,
  793. [gcry_cv_have_builtin_ctz],
  794. [gcry_cv_have_builtin_ctz=no
  795. AC_LINK_IFELSE([AC_LANG_PROGRAM([],
  796. [unsigned int x = 0; int y = __builtin_ctz(x); return y;])],
  797. [gcry_cv_have_builtin_ctz=yes])])
  798. if test "$gcry_cv_have_builtin_ctz" = "yes" ; then
  799. AC_DEFINE(HAVE_BUILTIN_CTZ, 1,
  800. [Defined if compiler has '__builtin_ctz' intrinsic])
  801. fi
  802. #
  803. # Check for __builtin_ctzl intrinsic.
  804. #
  805. AC_CACHE_CHECK(for __builtin_ctzl,
  806. [gcry_cv_have_builtin_ctzl],
  807. [gcry_cv_have_builtin_ctzl=no
  808. AC_LINK_IFELSE([AC_LANG_PROGRAM([],
  809. [unsigned long x = 0; long y = __builtin_ctzl(x); return y;])],
  810. [gcry_cv_have_builtin_ctzl=yes])])
  811. if test "$gcry_cv_have_builtin_ctzl" = "yes" ; then
  812. AC_DEFINE(HAVE_BUILTIN_CTZL, 1,
  813. [Defined if compiler has '__builtin_ctzl' intrinsic])
  814. fi
  815. #
  816. # Check for __builtin_clz intrinsic.
  817. #
  818. AC_CACHE_CHECK(for __builtin_clz,
  819. [gcry_cv_have_builtin_clz],
  820. [gcry_cv_have_builtin_clz=no
  821. AC_LINK_IFELSE([AC_LANG_PROGRAM([],
  822. [unsigned int x = 0; int y = __builtin_clz(x); return y;])],
  823. [gcry_cv_have_builtin_clz=yes])])
  824. if test "$gcry_cv_have_builtin_clz" = "yes" ; then
  825. AC_DEFINE(HAVE_BUILTIN_CLZ, 1,
  826. [Defined if compiler has '__builtin_clz' intrinsic])
  827. fi
  828. #
  829. # Check for __builtin_clzl intrinsic.
  830. #
  831. AC_CACHE_CHECK(for __builtin_clzl,
  832. [gcry_cv_have_builtin_clzl],
  833. [gcry_cv_have_builtin_clzl=no
  834. AC_LINK_IFELSE([AC_LANG_PROGRAM([],
  835. [unsigned long x = 0; long y = __builtin_clzl(x); return y;])],
  836. [gcry_cv_have_builtin_clzl=yes])])
  837. if test "$gcry_cv_have_builtin_clzl" = "yes" ; then
  838. AC_DEFINE(HAVE_BUILTIN_CLZL, 1,
  839. [Defined if compiler has '__builtin_clzl' intrinsic])
  840. fi
  841. #
  842. # Check for __sync_synchronize intrinsic.
  843. #
  844. AC_CACHE_CHECK(for __sync_synchronize,
  845. [gcry_cv_have_sync_synchronize],
  846. [gcry_cv_have_sync_synchronize=no
  847. AC_LINK_IFELSE([AC_LANG_PROGRAM([],
  848. [__sync_synchronize(); return 0;])],
  849. [gcry_cv_have_sync_synchronize=yes])])
  850. if test "$gcry_cv_have_sync_synchronize" = "yes" ; then
  851. AC_DEFINE(HAVE_SYNC_SYNCHRONIZE, 1,
  852. [Defined if compiler has '__sync_synchronize' intrinsic])
  853. fi
  854. #
  855. # Check for VLA support (variable length arrays).
  856. #
  857. AC_CACHE_CHECK(whether the variable length arrays are supported,
  858. [gcry_cv_have_vla],
  859. [gcry_cv_have_vla=no
  860. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  861. [[void f1(char *, int);
  862. char foo(int i) {
  863. char b[(i < 0 ? 0 : i) + 1];
  864. f1(b, sizeof b); return b[0];}]])],
  865. [gcry_cv_have_vla=yes])])
  866. if test "$gcry_cv_have_vla" = "yes" ; then
  867. AC_DEFINE(HAVE_VLA,1, [Defined if variable length arrays are supported])
  868. fi
  869. #
  870. # Check for ELF visibility support.
  871. #
  872. AC_CACHE_CHECK(whether the visibility attribute is supported,
  873. gcry_cv_visibility_attribute,
  874. [gcry_cv_visibility_attribute=no
  875. AC_LANG_CONFTEST([AC_LANG_SOURCE(
  876. [[int foo __attribute__ ((visibility ("hidden"))) = 1;
  877. int bar __attribute__ ((visibility ("protected"))) = 1;
  878. ]])])
  879. if ${CC-cc} -Werror -S conftest.c -o conftest.s \
  880. 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
  881. if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
  882. if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
  883. gcry_cv_visibility_attribute=yes
  884. fi
  885. fi
  886. fi
  887. ])
  888. if test "$gcry_cv_visibility_attribute" = "yes"; then
  889. AC_CACHE_CHECK(for broken visibility attribute,
  890. gcry_cv_broken_visibility_attribute,
  891. [gcry_cv_broken_visibility_attribute=yes
  892. AC_LANG_CONFTEST([AC_LANG_SOURCE(
  893. [[int foo (int x);
  894. int bar (int x) __asm__ ("foo")
  895. __attribute__ ((visibility ("hidden")));
  896. int bar (int x) { return x; }
  897. ]])])
  898. if ${CC-cc} -Werror -S conftest.c -o conftest.s \
  899. 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
  900. if grep '\.hidden@<:@ _@:>@foo' conftest.s >/dev/null 2>&1;
  901. then
  902. gcry_cv_broken_visibility_attribute=no
  903. fi
  904. fi
  905. ])
  906. fi
  907. if test "$gcry_cv_visibility_attribute" = "yes"; then
  908. AC_CACHE_CHECK(for broken alias attribute,
  909. gcry_cv_broken_alias_attribute,
  910. [gcry_cv_broken_alias_attribute=yes
  911. AC_LANG_CONFTEST([AC_LANG_SOURCE(
  912. [[extern int foo (int x) __asm ("xyzzy");
  913. int bar (int x) { return x; }
  914. extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
  915. extern int dfoo;
  916. extern __typeof (dfoo) dfoo __asm ("abccb");
  917. int dfoo = 1;
  918. ]])])
  919. if ${CC-cc} -Werror -S conftest.c -o conftest.s \
  920. 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
  921. if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
  922. grep 'abccb' conftest.s >/dev/null 2>&1; then
  923. gcry_cv_broken_alias_attribute=no
  924. fi
  925. fi
  926. ])
  927. fi
  928. if test "$gcry_cv_visibility_attribute" = "yes"; then
  929. AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
  930. gcry_cv_gcc_has_f_visibility,
  931. [gcry_cv_gcc_has_f_visibility=no
  932. _gcc_cflags_save=$CFLAGS
  933. CFLAGS="-fvisibility=hidden"
  934. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
  935. gcry_cv_gcc_has_f_visibility=yes)
  936. CFLAGS=$_gcc_cflags_save;
  937. ])
  938. fi
  939. if test "$gcry_cv_visibility_attribute" = "yes" \
  940. && test "$gcry_cv_broken_visibility_attribute" != "yes" \
  941. && test "$gcry_cv_broken_alias_attribute" != "yes" \
  942. && test "$gcry_cv_gcc_has_f_visibility" = "yes"
  943. then
  944. AC_DEFINE(GCRY_USE_VISIBILITY, 1,
  945. [Define to use the GNU C visibility attribute.])
  946. CFLAGS="$CFLAGS -fvisibility=hidden"
  947. fi
  948. # Following attribute tests depend on warnings to cause compile to fail,
  949. # so set -Werror temporarily.
  950. _gcc_cflags_save=$CFLAGS
  951. CFLAGS="$CFLAGS -Werror"
  952. #
  953. # Check whether the compiler supports the GCC style aligned attribute
  954. #
  955. AC_CACHE_CHECK([whether the GCC style aligned attribute is supported],
  956. [gcry_cv_gcc_attribute_aligned],
  957. [gcry_cv_gcc_attribute_aligned=no
  958. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  959. [[struct { int a; } foo __attribute__ ((aligned (16)));]])],
  960. [gcry_cv_gcc_attribute_aligned=yes])])
  961. if test "$gcry_cv_gcc_attribute_aligned" = "yes" ; then
  962. AC_DEFINE(HAVE_GCC_ATTRIBUTE_ALIGNED,1,
  963. [Defined if a GCC style "__attribute__ ((aligned (n))" is supported])
  964. fi
  965. #
  966. # Check whether the compiler supports the GCC style packed attribute
  967. #
  968. AC_CACHE_CHECK([whether the GCC style packed attribute is supported],
  969. [gcry_cv_gcc_attribute_packed],
  970. [gcry_cv_gcc_attribute_packed=no
  971. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  972. [[struct foolong_s { long b; } __attribute__ ((packed));
  973. struct foo_s { char a; struct foolong_s b; }
  974. __attribute__ ((packed));
  975. enum bar {
  976. FOO = 1 / (sizeof(struct foo_s) == (sizeof(char) + sizeof(long))),
  977. };]])],
  978. [gcry_cv_gcc_attribute_packed=yes])])
  979. if test "$gcry_cv_gcc_attribute_packed" = "yes" ; then
  980. AC_DEFINE(HAVE_GCC_ATTRIBUTE_PACKED,1,
  981. [Defined if a GCC style "__attribute__ ((packed))" is supported])
  982. fi
  983. #
  984. # Check whether the compiler supports the GCC style may_alias attribute
  985. #
  986. AC_CACHE_CHECK([whether the GCC style may_alias attribute is supported],
  987. [gcry_cv_gcc_attribute_may_alias],
  988. [gcry_cv_gcc_attribute_may_alias=no
  989. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  990. [[typedef struct foo_s { int a; }
  991. __attribute__ ((may_alias)) foo_t;]])],
  992. [gcry_cv_gcc_attribute_may_alias=yes])])
  993. if test "$gcry_cv_gcc_attribute_may_alias" = "yes" ; then
  994. AC_DEFINE(HAVE_GCC_ATTRIBUTE_MAY_ALIAS,1,
  995. [Defined if a GCC style "__attribute__ ((may_alias))" is supported])
  996. fi
  997. # Restore flags.
  998. CFLAGS=$_gcc_cflags_save;
  999. #
  1000. # Check whether the compiler supports 'asm' or '__asm__' keyword for
  1001. # assembler blocks.
  1002. #
  1003. AC_CACHE_CHECK([whether 'asm' assembler keyword is supported],
  1004. [gcry_cv_have_asm],
  1005. [gcry_cv_have_asm=no
  1006. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1007. [[void a(void) { asm("":::"memory"); }]])],
  1008. [gcry_cv_have_asm=yes])])
  1009. AC_CACHE_CHECK([whether '__asm__' assembler keyword is supported],
  1010. [gcry_cv_have___asm__],
  1011. [gcry_cv_have___asm__=no
  1012. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1013. [[void a(void) { __asm__("":::"memory"); }]])],
  1014. [gcry_cv_have___asm__=yes])])
  1015. if test "$gcry_cv_have_asm" = "no" ; then
  1016. if test "$gcry_cv_have___asm__" = "yes" ; then
  1017. AC_DEFINE(asm,__asm__,
  1018. [Define to supported assembler block keyword, if plain 'asm' was not
  1019. supported])
  1020. fi
  1021. fi
  1022. #
  1023. # Check whether the compiler supports inline assembly memory barrier.
  1024. #
  1025. if test "$gcry_cv_have_asm" = "no" ; then
  1026. if test "$gcry_cv_have___asm__" = "yes" ; then
  1027. AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
  1028. [gcry_cv_have_asm_volatile_memory],
  1029. [gcry_cv_have_asm_volatile_memory=no
  1030. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1031. [[void a(int x)
  1032. {
  1033. __asm__ volatile("":::"memory");
  1034. __asm__ volatile("":"+r"(x)::"memory");
  1035. }]])],
  1036. [gcry_cv_have_asm_volatile_memory=yes])])
  1037. fi
  1038. else
  1039. AC_CACHE_CHECK([whether inline assembly memory barrier is supported],
  1040. [gcry_cv_have_asm_volatile_memory],
  1041. [gcry_cv_have_asm_volatile_memory=no
  1042. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1043. [[void a(int x)
  1044. {
  1045. asm volatile("":::"memory");
  1046. asm volatile("":"+r"(x)::"memory"); }]])],
  1047. [gcry_cv_have_asm_volatile_memory=yes])])
  1048. fi
  1049. if test "$gcry_cv_have_asm_volatile_memory" = "yes" ; then
  1050. AC_DEFINE(HAVE_GCC_ASM_VOLATILE_MEMORY,1,
  1051. [Define if inline asm memory barrier is supported])
  1052. fi
  1053. #
  1054. # Check whether GCC assembler supports features needed for our ARM
  1055. # implementations. This needs to be done before setting up the
  1056. # assembler stuff.
  1057. #
  1058. AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations],
  1059. [gcry_cv_gcc_arm_platform_as_ok],
  1060. [if test "$try_asm_modules" != "yes" ; then
  1061. gcry_cv_gcc_arm_platform_as_ok="n/a"
  1062. else
  1063. gcry_cv_gcc_arm_platform_as_ok=no
  1064. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1065. [[__asm__(
  1066. /* Test if assembler supports UAL syntax. */
  1067. ".syntax unified\n\t"
  1068. ".arm\n\t" /* our assembly code is in ARM mode */
  1069. ".text\n\t"
  1070. /* Following causes error if assembler ignored '.syntax unified'. */
  1071. "asmfunc:\n\t"
  1072. "add r0, r0, r4, ror #12;\n\t"
  1073. /* Test if '.type' and '.size' are supported. */
  1074. ".size asmfunc,.-asmfunc;\n\t"
  1075. ".type asmfunc,%function;\n\t"
  1076. );
  1077. void asmfunc(void);]], [ asmfunc(); ] )],
  1078. [gcry_cv_gcc_arm_platform_as_ok=yes])
  1079. fi])
  1080. if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then
  1081. AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1,
  1082. [Defined if underlying assembler is compatible with ARM assembly implementations])
  1083. fi
  1084. #
  1085. # Check whether GCC assembler supports features needed for our ARMv8/Aarch64
  1086. # implementations. This needs to be done before setting up the
  1087. # assembler stuff.
  1088. #
  1089. AC_CACHE_CHECK([whether GCC assembler is compatible for ARMv8/Aarch64 assembly implementations],
  1090. [gcry_cv_gcc_aarch64_platform_as_ok],
  1091. [if test "$try_asm_modules" != "yes" ; then
  1092. gcry_cv_gcc_aarch64_platform_as_ok="n/a"
  1093. else
  1094. gcry_cv_gcc_aarch64_platform_as_ok=no
  1095. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1096. [[__asm__(
  1097. ".text\n\t"
  1098. "asmfunc:\n\t"
  1099. "eor x0, x0, x30, ror #12;\n\t"
  1100. "add x0, x0, x30, asr #12;\n\t"
  1101. "eor v0.16b, v0.16b, v31.16b;\n\t"
  1102. );
  1103. void asmfunc(void);]], [ asmfunc(); ] )],
  1104. [gcry_cv_gcc_aarch64_platform_as_ok=yes])
  1105. fi])
  1106. if test "$gcry_cv_gcc_aarch64_platform_as_ok" = "yes" ; then
  1107. AC_DEFINE(HAVE_COMPATIBLE_GCC_AARCH64_PLATFORM_AS,1,
  1108. [Defined if underlying assembler is compatible with ARMv8/Aarch64 assembly implementations])
  1109. fi
  1110. #
  1111. # Check whether GCC assembler supports for CFI directives.
  1112. #
  1113. AC_CACHE_CHECK([whether GCC assembler supports for CFI directives],
  1114. [gcry_cv_gcc_asm_cfi_directives],
  1115. [gcry_cv_gcc_asm_cfi_directives=no
  1116. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1117. [[__asm__(
  1118. ".text\n\t"
  1119. "ac_test:\n\t"
  1120. ".cfi_startproc\n\t"
  1121. ".cfi_remember_state\n\t"
  1122. ".cfi_adjust_cfa_offset 8\n\t"
  1123. ".cfi_rel_offset 0, 8\n\t"
  1124. ".cfi_def_cfa_register 1\n\t"
  1125. ".cfi_register 2, 3\n\t"
  1126. ".cfi_restore 2\n\t"
  1127. ".cfi_escape 0x0f, 0x02, 0x11, 0x00\n\t"
  1128. ".cfi_restore_state\n\t"
  1129. ".long 0\n\t"
  1130. ".cfi_endproc\n\t"
  1131. );]])],
  1132. [gcry_cv_gcc_asm_cfi_directives=yes])])
  1133. if test "$gcry_cv_gcc_asm_cfi_directives" = "yes" ; then
  1134. AC_DEFINE(HAVE_GCC_ASM_CFI_DIRECTIVES,1,
  1135. [Defined if underlying assembler supports for CFI directives])
  1136. fi
  1137. #
  1138. # Check whether GCC assembler supports for ELF directives.
  1139. #
  1140. AC_CACHE_CHECK([whether GCC assembler supports for ELF directives],
  1141. [gcry_cv_gcc_asm_elf_directives],
  1142. [gcry_cv_gcc_asm_elf_directives=no
  1143. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1144. [[__asm__(
  1145. /* Test if ELF directives '.type' and '.size' are supported. */
  1146. ".text\n\t"
  1147. "asmfunc:\n\t"
  1148. ".size asmfunc,.-asmfunc;\n\t"
  1149. ".type asmfunc,STT_FUNC;\n\t"
  1150. );]])],
  1151. [gcry_cv_gcc_asm_elf_directives=yes])])
  1152. if test "$gcry_cv_gcc_asm_elf_directives" = "yes" ; then
  1153. AC_DEFINE(HAVE_GCC_ASM_ELF_DIRECTIVES,1,
  1154. [Defined if underlying assembler supports for ELF directives])
  1155. fi
  1156. #
  1157. # Check whether underscores in symbols are required. This needs to be
  1158. # done before setting up the assembler stuff.
  1159. #
  1160. GNUPG_SYS_SYMBOL_UNDERSCORE()
  1161. #################################
  1162. #### ####
  1163. #### Setup assembler stuff. ####
  1164. #### Define mpi_cpu_arch. ####
  1165. #### ####
  1166. #################################
  1167. AC_ARG_ENABLE(mpi-path,
  1168. AS_HELP_STRING([--enable-mpi-path=EXTRA_PATH],
  1169. [prepend EXTRA_PATH to list of CPU specific optimizations]),
  1170. mpi_extra_path="$enableval",mpi_extra_path="")
  1171. AC_MSG_CHECKING(architecture and mpi assembler functions)
  1172. if test -f $srcdir/mpi/config.links ; then
  1173. . $srcdir/mpi/config.links
  1174. AC_CONFIG_LINKS("$mpi_ln_list")
  1175. ac_cv_mpi_sflags="$mpi_sflags"
  1176. AC_MSG_RESULT($mpi_cpu_arch)
  1177. else
  1178. AC_MSG_RESULT(failed)
  1179. AC_MSG_ERROR([mpi/config.links missing!])
  1180. fi
  1181. MPI_SFLAGS="$ac_cv_mpi_sflags"
  1182. AC_SUBST(MPI_SFLAGS)
  1183. AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes)
  1184. AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes)
  1185. AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes)
  1186. AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes)
  1187. AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes)
  1188. AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes)
  1189. AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes)
  1190. AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes)
  1191. AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes)
  1192. AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes)
  1193. AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes)
  1194. AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes)
  1195. AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes)
  1196. AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes)
  1197. AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes)
  1198. AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes)
  1199. AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes)
  1200. AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes)
  1201. # Reset non applicable feature flags.
  1202. if test "$mpi_cpu_arch" != "x86" ; then
  1203. aesnisupport="n/a"
  1204. shaextsupport="n/a"
  1205. pclmulsupport="n/a"
  1206. sse41support="n/a"
  1207. avxsupport="n/a"
  1208. avx2support="n/a"
  1209. avx512support="n/a"
  1210. gfnisupport="n/a"
  1211. padlocksupport="n/a"
  1212. drngsupport="n/a"
  1213. fi
  1214. if test "$mpi_cpu_arch" != "arm" ; then
  1215. if test "$mpi_cpu_arch" != "aarch64" ; then
  1216. neonsupport="n/a"
  1217. armcryptosupport="n/a"
  1218. svesupport="n/a"
  1219. sve2support="n/a"
  1220. fi
  1221. fi
  1222. if test "$mpi_cpu_arch" != "ppc"; then
  1223. ppccryptosupport="n/a"
  1224. fi
  1225. #############################################
  1226. #### ####
  1227. #### Platform specific compiler checks. ####
  1228. #### ####
  1229. #############################################
  1230. # Following tests depend on warnings to cause compile to fail, so set -Werror
  1231. # temporarily.
  1232. _gcc_cflags_save=$CFLAGS
  1233. CFLAGS="$CFLAGS -Werror"
  1234. #
  1235. # Check whether compiler supports 'optimize' function attribute
  1236. #
  1237. AC_CACHE_CHECK([whether compiler supports 'optimize' function attribute],
  1238. [gcry_cv_gcc_attribute_optimize],
  1239. [gcry_cv_gcc_attribute_optimize=no
  1240. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1241. [[int __attribute__ ((optimize("-O2"))) fn(int i){return i;}]])],
  1242. [gcry_cv_gcc_attribute_optimize=yes])])
  1243. if test "$gcry_cv_gcc_attribute_optimize" = "yes" ; then
  1244. AC_DEFINE(HAVE_GCC_ATTRIBUTE_OPTIMIZE,1,
  1245. [Defined if compiler supports "__attribute__ ((optimize))" function attribute])
  1246. fi
  1247. #
  1248. # Check whether compiler supports 'ms_abi' function attribute.
  1249. #
  1250. AC_CACHE_CHECK([whether compiler supports 'ms_abi' function attribute],
  1251. [gcry_cv_gcc_attribute_ms_abi],
  1252. [gcry_cv_gcc_attribute_ms_abi=no
  1253. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1254. [[int __attribute__ ((ms_abi)) proto(int);]])],
  1255. [gcry_cv_gcc_attribute_ms_abi=yes])])
  1256. if test "$gcry_cv_gcc_attribute_ms_abi" = "yes" ; then
  1257. AC_DEFINE(HAVE_GCC_ATTRIBUTE_MS_ABI,1,
  1258. [Defined if compiler supports "__attribute__ ((ms_abi))" function attribute])
  1259. fi
  1260. #
  1261. # Check whether compiler supports 'sysv_abi' function attribute.
  1262. #
  1263. AC_CACHE_CHECK([whether compiler supports 'sysv_abi' function attribute],
  1264. [gcry_cv_gcc_attribute_sysv_abi],
  1265. [gcry_cv_gcc_attribute_sysv_abi=no
  1266. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1267. [[int __attribute__ ((sysv_abi)) proto(int);]])],
  1268. [gcry_cv_gcc_attribute_sysv_abi=yes])])
  1269. if test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" ; then
  1270. AC_DEFINE(HAVE_GCC_ATTRIBUTE_SYSV_ABI,1,
  1271. [Defined if compiler supports "__attribute__ ((sysv_abi))" function attribute])
  1272. fi
  1273. #
  1274. # Check whether default calling convention is 'ms_abi'.
  1275. #
  1276. if test "$gcry_cv_gcc_attribute_ms_abi" = "yes" ; then
  1277. AC_CACHE_CHECK([whether default calling convention is 'ms_abi'],
  1278. [gcry_cv_gcc_default_abi_is_ms_abi],
  1279. [gcry_cv_gcc_default_abi_is_ms_abi=no
  1280. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1281. [[void *test(void) {
  1282. void *(*def_func)(void) = test;
  1283. void *__attribute__((ms_abi))(*msabi_func)(void);
  1284. /* warning on SysV abi targets, passes on Windows based targets */
  1285. msabi_func = def_func;
  1286. return msabi_func;
  1287. }]])],
  1288. [gcry_cv_gcc_default_abi_is_ms_abi=yes])])
  1289. if test "$gcry_cv_gcc_default_abi_is_ms_abi" = "yes" ; then
  1290. AC_DEFINE(HAVE_GCC_DEFAULT_ABI_IS_MS_ABI,1,
  1291. [Defined if default calling convention is 'ms_abi'])
  1292. fi
  1293. fi
  1294. #
  1295. # Check whether default calling convention is 'sysv_abi'.
  1296. #
  1297. if test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" ; then
  1298. AC_CACHE_CHECK([whether default calling convention is 'sysv_abi'],
  1299. [gcry_cv_gcc_default_abi_is_sysv_abi],
  1300. [gcry_cv_gcc_default_abi_is_sysv_abi=no
  1301. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1302. [[void *test(void) {
  1303. void *(*def_func)(void) = test;
  1304. void *__attribute__((sysv_abi))(*sysvabi_func)(void);
  1305. /* warning on MS ABI targets, passes on SysV ABI targets */
  1306. sysvabi_func = def_func;
  1307. return sysvabi_func;
  1308. }]])],
  1309. [gcry_cv_gcc_default_abi_is_sysv_abi=yes])])
  1310. if test "$gcry_cv_gcc_default_abi_is_sysv_abi" = "yes" ; then
  1311. AC_DEFINE(HAVE_GCC_DEFAULT_ABI_IS_SYSV_ABI,1,
  1312. [Defined if default calling convention is 'sysv_abi'])
  1313. fi
  1314. fi
  1315. # Restore flags.
  1316. CFLAGS=$_gcc_cflags_save;
  1317. #
  1318. # Check whether GCC inline assembler supports SSSE3 instructions
  1319. # This is required for the AES-NI instructions.
  1320. #
  1321. AC_CACHE_CHECK([whether GCC inline assembler supports SSSE3 instructions],
  1322. [gcry_cv_gcc_inline_asm_ssse3],
  1323. [if test "$mpi_cpu_arch" != "x86" ||
  1324. test "$try_asm_modules" != "yes" ; then
  1325. gcry_cv_gcc_inline_asm_ssse3="n/a"
  1326. else
  1327. gcry_cv_gcc_inline_asm_ssse3=no
  1328. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1329. [[static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
  1330. { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
  1331. void a(void) {
  1332. __asm__("pshufb %[mask], %%xmm2\n\t"::[mask]"m"(*be_mask):);
  1333. }]], [ a(); ] )],
  1334. [gcry_cv_gcc_inline_asm_ssse3=yes])
  1335. fi])
  1336. if test "$gcry_cv_gcc_inline_asm_ssse3" = "yes" ; then
  1337. AC_DEFINE(HAVE_GCC_INLINE_ASM_SSSE3,1,
  1338. [Defined if inline assembler supports SSSE3 instructions])
  1339. fi
  1340. #
  1341. # Check whether GCC inline assembler supports PCLMUL instructions.
  1342. #
  1343. AC_CACHE_CHECK([whether GCC inline assembler supports PCLMUL instructions],
  1344. [gcry_cv_gcc_inline_asm_pclmul],
  1345. [if test "$mpi_cpu_arch" != "x86" ||
  1346. test "$try_asm_modules" != "yes" ; then
  1347. gcry_cv_gcc_inline_asm_pclmul="n/a"
  1348. else
  1349. gcry_cv_gcc_inline_asm_pclmul=no
  1350. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1351. [[void a(void) {
  1352. __asm__("pclmulqdq \$0, %%xmm1, %%xmm3\n\t":::"cc");
  1353. }]], [ a(); ] )],
  1354. [gcry_cv_gcc_inline_asm_pclmul=yes])
  1355. fi])
  1356. if test "$gcry_cv_gcc_inline_asm_pclmul" = "yes" ; then
  1357. AC_DEFINE(HAVE_GCC_INLINE_ASM_PCLMUL,1,
  1358. [Defined if inline assembler supports PCLMUL instructions])
  1359. fi
  1360. #
  1361. # Check whether GCC inline assembler supports SHA Extensions instructions.
  1362. #
  1363. AC_CACHE_CHECK([whether GCC inline assembler supports SHA Extensions instructions],
  1364. [gcry_cv_gcc_inline_asm_shaext],
  1365. [if test "$mpi_cpu_arch" != "x86" ||
  1366. test "$try_asm_modules" != "yes" ; then
  1367. gcry_cv_gcc_inline_asm_shaext="n/a"
  1368. else
  1369. gcry_cv_gcc_inline_asm_shaext=no
  1370. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1371. [[void a(void) {
  1372. __asm__("sha1rnds4 \$0, %%xmm1, %%xmm3\n\t":::"cc");
  1373. __asm__("sha1nexte %%xmm1, %%xmm3\n\t":::"cc");
  1374. __asm__("sha1msg1 %%xmm1, %%xmm3\n\t":::"cc");
  1375. __asm__("sha1msg2 %%xmm1, %%xmm3\n\t":::"cc");
  1376. __asm__("sha256rnds2 %%xmm0, %%xmm1, %%xmm3\n\t":::"cc");
  1377. __asm__("sha256msg1 %%xmm1, %%xmm3\n\t":::"cc");
  1378. __asm__("sha256msg2 %%xmm1, %%xmm3\n\t":::"cc");
  1379. }]], [ a(); ] )],
  1380. [gcry_cv_gcc_inline_asm_shaext=yes])
  1381. fi])
  1382. if test "$gcry_cv_gcc_inline_asm_shaext" = "yes" ; then
  1383. AC_DEFINE(HAVE_GCC_INLINE_ASM_SHAEXT,1,
  1384. [Defined if inline assembler supports SHA Extensions instructions])
  1385. fi
  1386. #
  1387. # Check whether GCC inline assembler supports SSE4.1 instructions.
  1388. #
  1389. AC_CACHE_CHECK([whether GCC inline assembler supports SSE4.1 instructions],
  1390. [gcry_cv_gcc_inline_asm_sse41],
  1391. [if test "$mpi_cpu_arch" != "x86" ||
  1392. test "$try_asm_modules" != "yes" ; then
  1393. gcry_cv_gcc_inline_asm_sse41="n/a"
  1394. else
  1395. gcry_cv_gcc_inline_asm_sse41=no
  1396. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1397. [[void a(void) {
  1398. int i;
  1399. __asm__("pextrd \$2, %%xmm0, %[out]\n\t" : [out] "=m" (i));
  1400. }]], [ a(); ] )],
  1401. [gcry_cv_gcc_inline_asm_sse41=yes])
  1402. fi])
  1403. if test "$gcry_cv_gcc_inline_asm_sse41" = "yes" ; then
  1404. AC_DEFINE(HAVE_GCC_INLINE_ASM_SSE41,1,
  1405. [Defined if inline assembler supports SSE4.1 instructions])
  1406. fi
  1407. #
  1408. # Check whether GCC inline assembler supports AVX instructions
  1409. #
  1410. AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions],
  1411. [gcry_cv_gcc_inline_asm_avx],
  1412. [if test "$mpi_cpu_arch" != "x86" ||
  1413. test "$try_asm_modules" != "yes" ; then
  1414. gcry_cv_gcc_inline_asm_avx="n/a"
  1415. else
  1416. gcry_cv_gcc_inline_asm_avx=no
  1417. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1418. [[void a(void) {
  1419. __asm__("xgetbv; vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):);
  1420. }]], [ a(); ] )],
  1421. [gcry_cv_gcc_inline_asm_avx=yes])
  1422. fi])
  1423. if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then
  1424. AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX,1,
  1425. [Defined if inline assembler supports AVX instructions])
  1426. fi
  1427. #
  1428. # Check whether GCC inline assembler supports AVX2 instructions
  1429. #
  1430. AC_CACHE_CHECK([whether GCC inline assembler supports AVX2 instructions],
  1431. [gcry_cv_gcc_inline_asm_avx2],
  1432. [if test "$mpi_cpu_arch" != "x86" ||
  1433. test "$try_asm_modules" != "yes" ; then
  1434. gcry_cv_gcc_inline_asm_avx2="n/a"
  1435. else
  1436. gcry_cv_gcc_inline_asm_avx2=no
  1437. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1438. [[void a(void) {
  1439. __asm__("xgetbv; vpbroadcastb %%xmm7,%%ymm1\n\t":::"cc");
  1440. }]], [ a(); ] )],
  1441. [gcry_cv_gcc_inline_asm_avx2=yes])
  1442. fi])
  1443. if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then
  1444. AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX2,1,
  1445. [Defined if inline assembler supports AVX2 instructions])
  1446. fi
  1447. #
  1448. # Check whether GCC inline assembler supports AVX512 instructions
  1449. #
  1450. AC_CACHE_CHECK([whether GCC inline assembler supports AVX512 instructions],
  1451. [gcry_cv_gcc_inline_asm_avx512],
  1452. [if test "$mpi_cpu_arch" != "x86" ||
  1453. test "$try_asm_modules" != "yes" ; then
  1454. gcry_cv_gcc_inline_asm_avx512="n/a"
  1455. else
  1456. gcry_cv_gcc_inline_asm_avx512=no
  1457. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1458. [[void a(void) {
  1459. __asm__("xgetbv; vpopcntq %%zmm7, %%zmm1%{%%k1%}%{z%};\n\t":::"cc");
  1460. __asm__("vpexpandb %%zmm3, %%zmm1;\n\t":::"cc");
  1461. __asm__("vpxorq %%xmm7, %%xmm7, %%xmm7;\n\t":::"cc");
  1462. __asm__("vpxorq %%ymm7, %%ymm7, %%ymm7;\n\t":::"cc");
  1463. __asm__("vpxorq (%%eax)%{1to8%}, %%zmm7, %%zmm7;\n\t":::"cc");
  1464. }]], [ a(); ] )],
  1465. [gcry_cv_gcc_inline_asm_avx512=yes])
  1466. fi])
  1467. if test "$gcry_cv_gcc_inline_asm_avx512" = "yes" ; then
  1468. AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX512,1,
  1469. [Defined if inline assembler supports AVX512 instructions])
  1470. fi
  1471. #
  1472. # Check whether GCC inline assembler supports VAES and VPCLMUL instructions
  1473. #
  1474. AC_CACHE_CHECK([whether GCC inline assembler supports VAES and VPCLMUL instructions],
  1475. [gcry_cv_gcc_inline_asm_vaes_vpclmul],
  1476. [if test "$mpi_cpu_arch" != "x86" ||
  1477. test "$try_asm_modules" != "yes" ; then
  1478. gcry_cv_gcc_inline_asm_vaes_vpclmul="n/a"
  1479. else
  1480. gcry_cv_gcc_inline_asm_vaes_vpclmul=no
  1481. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1482. [[void a(void) {
  1483. __asm__("vaesenclast %%ymm7,%%ymm7,%%ymm1\n\t":::"cc");/*256-bit*/
  1484. __asm__("vaesenclast %%zmm7,%%zmm7,%%zmm1\n\t":::"cc");/*512-bit*/
  1485. __asm__("vpclmulqdq \$0,%%ymm7,%%ymm7,%%ymm1\n\t":::"cc");/*256-bit*/
  1486. __asm__("vpclmulqdq \$0,%%zmm7,%%zmm7,%%zmm1\n\t":::"cc");/*512-bit*/
  1487. }]], [ a(); ] )],
  1488. [gcry_cv_gcc_inline_asm_vaes_vpclmul=yes])
  1489. fi])
  1490. if test "$gcry_cv_gcc_inline_asm_vaes_vpclmul" = "yes" ; then
  1491. AC_DEFINE(HAVE_GCC_INLINE_ASM_VAES_VPCLMUL,1,
  1492. [Defined if inline assembler supports VAES and VPCLMUL instructions])
  1493. fi
  1494. #
  1495. # Check whether GCC inline assembler supports GFNI instructions
  1496. #
  1497. AC_CACHE_CHECK([whether GCC inline assembler supports GFNI instructions],
  1498. [gcry_cv_gcc_inline_asm_gfni],
  1499. [if test "$mpi_cpu_arch" != "x86" ||
  1500. test "$try_asm_modules" != "yes" ; then
  1501. gcry_cv_gcc_inline_asm_gfni="n/a"
  1502. else
  1503. gcry_cv_gcc_inline_asm_gfni=no
  1504. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1505. [[void a(void) {
  1506. __asm__("gf2p8affineqb \$123, %%xmm0, %%xmm0;\n\t":::"cc"); /* SSE */
  1507. __asm__("vgf2p8affineinvqb \$234, %%ymm1, %%ymm1, %%ymm1;\n\t":::"cc"); /* AVX */
  1508. __asm__("vgf2p8mulb (%%eax), %%zmm2, %%zmm2;\n\t":::"cc"); /* AVX512 */
  1509. }]], [ a(); ] )],
  1510. [gcry_cv_gcc_inline_asm_gfni=yes])
  1511. fi])
  1512. if test "$gcry_cv_gcc_inline_asm_gfni" = "yes" ; then
  1513. AC_DEFINE(HAVE_GCC_INLINE_ASM_GFNI,1,
  1514. [Defined if inline assembler supports GFNI instructions])
  1515. fi
  1516. #
  1517. # Check whether GCC inline assembler supports BMI2 instructions
  1518. #
  1519. AC_CACHE_CHECK([whether GCC inline assembler supports BMI2 instructions],
  1520. [gcry_cv_gcc_inline_asm_bmi2],
  1521. [if test "$mpi_cpu_arch" != "x86" ||
  1522. test "$try_asm_modules" != "yes" ; then
  1523. gcry_cv_gcc_inline_asm_bmi2="n/a"
  1524. else
  1525. gcry_cv_gcc_inline_asm_bmi2=no
  1526. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1527. [[unsigned int a(unsigned int x, unsigned int y) {
  1528. unsigned int tmp1, tmp2;
  1529. asm ("rorxl %2, %1, %0"
  1530. : "=r" (tmp1)
  1531. : "rm0" (x), "J" (32 - ((23) & 31)));
  1532. asm ("andnl %2, %1, %0"
  1533. : "=r" (tmp2)
  1534. : "r0" (x), "rm" (y));
  1535. return tmp1 + tmp2;
  1536. }]], [ a(1, 2); ] )],
  1537. [gcry_cv_gcc_inline_asm_bmi2=yes])
  1538. fi])
  1539. if test "$gcry_cv_gcc_inline_asm_bmi2" = "yes" ; then
  1540. AC_DEFINE(HAVE_GCC_INLINE_ASM_BMI2,1,
  1541. [Defined if inline assembler supports BMI2 instructions])
  1542. fi
  1543. #
  1544. # Check whether compiler supports x86/AVX512 intrinsics
  1545. #
  1546. _gcc_cflags_save=$CFLAGS
  1547. CFLAGS="$CFLAGS -mavx512f"
  1548. AC_CACHE_CHECK([whether compiler supports x86/AVX512 intrinsics],
  1549. [gcry_cv_cc_x86_avx512_intrinsics],
  1550. [if test "$mpi_cpu_arch" != "x86" ||
  1551. test "$try_asm_modules" != "yes" ; then
  1552. gcry_cv_cc_x86_avx512_intrinsics="n/a"
  1553. else
  1554. gcry_cv_cc_x86_avx512_intrinsics=no
  1555. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1556. [[#include <immintrin.h>
  1557. __m512i fn(void *in, __m128i y)
  1558. {
  1559. __m512i x;
  1560. x = _mm512_loadu_epi32 (in); /* check the GCC bug 90980. */
  1561. x = _mm512_maskz_loadu_epi32(_cvtu32_mask16(0xfff0), in)
  1562. ^ _mm512_castsi128_si512(y);
  1563. asm volatile ("vinserti32x4 \$3, %0, %%zmm6, %%zmm6;\n\t"
  1564. "vpxord %%zmm6, %%zmm6, %%zmm6"
  1565. ::"x"(y),"r"(in):"memory","xmm6");
  1566. return x;
  1567. }
  1568. ]])],
  1569. [gcry_cv_cc_x86_avx512_intrinsics=yes])
  1570. fi])
  1571. if test "$gcry_cv_cc_x86_avx512_intrinsics" = "yes" ; then
  1572. AC_DEFINE(HAVE_COMPATIBLE_CC_X86_AVX512_INTRINSICS,1,
  1573. [Defined if underlying compiler supports x86/AVX512 intrinsics])
  1574. fi
  1575. AM_CONDITIONAL(ENABLE_X86_AVX512_INTRINSICS_EXTRA_CFLAGS,
  1576. test "$gcry_cv_cc_x86_avx512_intrinsics" = "yes")
  1577. # Restore flags.
  1578. CFLAGS=$_gcc_cflags_save;
  1579. #
  1580. # Check whether GCC assembler needs "-Wa,--divide" to correctly handle
  1581. # constant division
  1582. #
  1583. if test $amd64_as_feature_detection = yes; then
  1584. AC_CACHE_CHECK([whether GCC assembler handles division correctly],
  1585. [gcry_cv_gcc_as_const_division_ok],
  1586. [gcry_cv_gcc_as_const_division_ok=no
  1587. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1588. [[__asm__(".text\n\tfn:\n\t xorl \$(123456789/12345678), %ebp;\n\t");
  1589. void fn(void);]],
  1590. [fn();])],
  1591. [gcry_cv_gcc_as_const_division_ok=yes])])
  1592. if test "$gcry_cv_gcc_as_const_division_ok" = "no" ; then
  1593. #
  1594. # Add '-Wa,--divide' to CPPFLAGS and try check again.
  1595. #
  1596. _gcc_cppflags_save="$CPPFLAGS"
  1597. CPPFLAGS="$CPPFLAGS -Wa,--divide"
  1598. AC_CACHE_CHECK([whether GCC assembler handles division correctly with "-Wa,--divide"],
  1599. [gcry_cv_gcc_as_const_division_with_wadivide_ok],
  1600. [gcry_cv_gcc_as_const_division_with_wadivide_ok=no
  1601. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1602. [[__asm__(".text\n\tfn:\n\t xorl \$(123456789/12345678), %ebp;\n\t");
  1603. void fn(void);]],
  1604. [fn();])],
  1605. [gcry_cv_gcc_as_const_division_with_wadivide_ok=yes])])
  1606. if test "$gcry_cv_gcc_as_const_division_with_wadivide_ok" = "no" ; then
  1607. # '-Wa,--divide' did not work, restore old flags.
  1608. CPPFLAGS="$_gcc_cppflags_save"
  1609. fi
  1610. fi
  1611. fi
  1612. #
  1613. # Check whether GCC assembler supports features needed for our i386/amd64
  1614. # implementations
  1615. #
  1616. if test $amd64_as_feature_detection = yes; then
  1617. AC_CACHE_CHECK([whether GCC assembler is compatible for i386/amd64 assembly implementations],
  1618. [gcry_cv_gcc_x86_platform_as_ok],
  1619. [if test "$mpi_cpu_arch" != "x86" ||
  1620. test "$try_asm_modules" != "yes" ; then
  1621. gcry_cv_gcc_x86_platform_as_ok="n/a"
  1622. else
  1623. gcry_cv_gcc_x86_platform_as_ok=no
  1624. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1625. [[__asm__(
  1626. /* Test if '.type' and '.size' are supported. */
  1627. /* These work only on ELF targets. */
  1628. ".text\n\t"
  1629. "asmfunc:\n\t"
  1630. ".size asmfunc,.-asmfunc;\n\t"
  1631. ".type asmfunc,@function;\n\t"
  1632. /* Test if assembler allows use of '/' for constant division
  1633. * (Solaris/x86 issue). If previous constant division check
  1634. * and "-Wa,--divide" workaround failed, this causes assembly
  1635. * to be disable on this machine. */
  1636. "xorl \$(123456789/12345678), %ebp;\n\t"
  1637. );
  1638. void asmfunc(void);]], [ asmfunc(); ])],
  1639. [gcry_cv_gcc_x86_platform_as_ok=yes])
  1640. fi])
  1641. if test "$gcry_cv_gcc_x86_platform_as_ok" = "yes" &&
  1642. test "$ac_cv_sizeof_unsigned_long" = "8"; then
  1643. AC_DEFINE(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS,1,
  1644. [Defined if underlying assembler is compatible with amd64 assembly implementations])
  1645. fi
  1646. if test "$gcry_cv_gcc_x86_platform_as_ok" = "yes" &&
  1647. test "$ac_cv_sizeof_unsigned_long" = "4"; then
  1648. AC_DEFINE(HAVE_COMPATIBLE_GCC_I386_PLATFORM_AS,1,
  1649. [Defined if underlying assembler is compatible with i386 assembly implementations])
  1650. fi
  1651. if test "$gcry_cv_gcc_x86_platform_as_ok" = "no" &&
  1652. test "$gcry_cv_gcc_attribute_sysv_abi" = "yes" &&
  1653. test "$gcry_cv_gcc_default_abi_is_ms_abi" = "yes"; then
  1654. AC_CACHE_CHECK([whether GCC assembler is compatible for WIN64 assembly implementations],
  1655. [gcry_cv_gcc_win64_platform_as_ok],
  1656. [gcry_cv_gcc_win64_platform_as_ok=no
  1657. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1658. [[__asm__(
  1659. ".text\n\t"
  1660. ".globl asmfunc\n\t"
  1661. "asmfunc:\n\t"
  1662. "xorq \$(1234), %rbp;\n\t"
  1663. );
  1664. void asmfunc(void);]], [ asmfunc(); ])],
  1665. [gcry_cv_gcc_win64_platform_as_ok=yes])])
  1666. if test "$gcry_cv_gcc_win64_platform_as_ok" = "yes" ; then
  1667. AC_DEFINE(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS,1,
  1668. [Defined if underlying assembler is compatible with WIN64 assembly implementations])
  1669. fi
  1670. fi
  1671. if test "$gcry_cv_gcc_x86_platform_as_ok" = "no" &&
  1672. test "$ac_cv_sizeof_unsigned_long" = "4"; then
  1673. AC_CACHE_CHECK([whether GCC assembler is compatible for WIN32 assembly implementations],
  1674. [gcry_cv_gcc_win32_platform_as_ok],
  1675. [gcry_cv_gcc_win32_platform_as_ok=no
  1676. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1677. [[__asm__(
  1678. ".text\n\t"
  1679. ".globl _asmfunc\n\t"
  1680. "_asmfunc:\n\t"
  1681. "xorl \$(1234), %ebp;\n\t"
  1682. );
  1683. void asmfunc(void);]], [ asmfunc(); ])],
  1684. [gcry_cv_gcc_win32_platform_as_ok=yes])])
  1685. if test "$gcry_cv_gcc_win32_platform_as_ok" = "yes" ; then
  1686. AC_DEFINE(HAVE_COMPATIBLE_GCC_WIN32_PLATFORM_AS,1,
  1687. [Defined if underlying assembler is compatible with WIN32 assembly implementations])
  1688. fi
  1689. fi
  1690. fi
  1691. #
  1692. # Check whether GCC assembler supports features needed for assembly
  1693. # implementations that use Intel syntax
  1694. #
  1695. AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly implementations],
  1696. [gcry_cv_gcc_platform_as_ok_for_intel_syntax],
  1697. [if test "$mpi_cpu_arch" != "x86" ||
  1698. test "$try_asm_modules" != "yes" ; then
  1699. gcry_cv_gcc_platform_as_ok_for_intel_syntax="n/a"
  1700. else
  1701. gcry_cv_gcc_platform_as_ok_for_intel_syntax=no
  1702. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1703. [[__asm__(
  1704. ".intel_syntax noprefix\n\t"
  1705. ".text\n\t"
  1706. "actest:\n\t"
  1707. "pxor xmm1, xmm7;\n\t"
  1708. "vperm2i128 ymm2, ymm3, ymm0, 1;\n\t"
  1709. "add eax, ebp;\n\t"
  1710. "rorx eax, ebp, 1;\n\t"
  1711. "sub eax, [esp + 4];\n\t"
  1712. "add dword ptr [esp + eax], 0b10101;\n\t"
  1713. ".att_syntax prefix\n\t"
  1714. );
  1715. void actest(void);]], [ actest(); ])],
  1716. [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes])
  1717. fi])
  1718. if test "$gcry_cv_gcc_platform_as_ok_for_intel_syntax" = "yes" ; then
  1719. AC_DEFINE(HAVE_INTEL_SYNTAX_PLATFORM_AS,1,
  1720. [Defined if underlying assembler is compatible with Intel syntax assembly implementations])
  1721. fi
  1722. #
  1723. # Check whether compiler is configured for ARMv6 or newer architecture
  1724. #
  1725. AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture],
  1726. [gcry_cv_cc_arm_arch_is_v6],
  1727. [if test "$mpi_cpu_arch" != "arm" ||
  1728. test "$try_asm_modules" != "yes" ; then
  1729. gcry_cv_cc_arm_arch_is_v6="n/a"
  1730. else
  1731. gcry_cv_cc_arm_arch_is_v6=no
  1732. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  1733. [[
  1734. #if defined(__arm__) && \
  1735. ((defined(__ARM_ARCH) && __ARM_ARCH >= 6) \
  1736. || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
  1737. || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
  1738. || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) \
  1739. || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
  1740. || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
  1741. || defined(__ARM_ARCH_7EM__))
  1742. /* empty */
  1743. #else
  1744. /* fail compile if not ARMv6. */
  1745. not_armv6 not_armv6 = (not_armv6)not_armv6;
  1746. #endif
  1747. ]])],
  1748. [gcry_cv_cc_arm_arch_is_v6=yes])
  1749. fi])
  1750. if test "$gcry_cv_cc_arm_arch_is_v6" = "yes" ; then
  1751. AC_DEFINE(HAVE_ARM_ARCH_V6,1,
  1752. [Defined if ARM architecture is v6 or newer])
  1753. fi
  1754. #
  1755. # Check whether GCC inline assembler supports NEON instructions
  1756. #
  1757. AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions],
  1758. [gcry_cv_gcc_inline_asm_neon],
  1759. [if test "$mpi_cpu_arch" != "arm" ||
  1760. test "$try_asm_modules" != "yes" ; then
  1761. gcry_cv_gcc_inline_asm_neon="n/a"
  1762. else
  1763. gcry_cv_gcc_inline_asm_neon=no
  1764. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1765. [[__asm__(
  1766. ".syntax unified\n\t"
  1767. ".arm\n\t"
  1768. ".fpu neon\n\t"
  1769. ".text\n\t"
  1770. "testfn:\n\t"
  1771. "vld1.64 {q0-q1}, [r0]!;\n\t"
  1772. "vrev64.8 q0, q3;\n\t"
  1773. "vadd.u64 q0, q1;\n\t"
  1774. "vadd.s64 d3, d2, d3;\n\t"
  1775. );
  1776. void testfn(void);
  1777. ]], [ testfn(); ])],
  1778. [gcry_cv_gcc_inline_asm_neon=yes])
  1779. fi])
  1780. if test "$gcry_cv_gcc_inline_asm_neon" = "yes" ; then
  1781. AC_DEFINE(HAVE_GCC_INLINE_ASM_NEON,1,
  1782. [Defined if inline assembler supports NEON instructions])
  1783. fi
  1784. #
  1785. # Check whether GCC inline assembler supports AArch32 Crypto Extension instructions
  1786. #
  1787. AC_CACHE_CHECK([whether GCC inline assembler supports AArch32 Crypto Extension instructions],
  1788. [gcry_cv_gcc_inline_asm_aarch32_crypto],
  1789. [if test "$mpi_cpu_arch" != "arm" ||
  1790. test "$try_asm_modules" != "yes" ; then
  1791. gcry_cv_gcc_inline_asm_aarch32_crypto="n/a"
  1792. else
  1793. gcry_cv_gcc_inline_asm_aarch32_crypto=no
  1794. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1795. [[__asm__(
  1796. ".syntax unified\n\t"
  1797. ".arch armv8-a\n\t"
  1798. ".arm\n\t"
  1799. ".fpu crypto-neon-fp-armv8\n\t"
  1800. ".text\n\t"
  1801. "testfn:\n\t"
  1802. "sha1h.32 q0, q0;\n\t"
  1803. "sha1c.32 q0, q0, q0;\n\t"
  1804. "sha1p.32 q0, q0, q0;\n\t"
  1805. "sha1su0.32 q0, q0, q0;\n\t"
  1806. "sha1su1.32 q0, q0;\n\t"
  1807. "sha256h.32 q0, q0, q0;\n\t"
  1808. "sha256h2.32 q0, q0, q0;\n\t"
  1809. "sha1p.32 q0, q0, q0;\n\t"
  1810. "sha256su0.32 q0, q0;\n\t"
  1811. "sha256su1.32 q0, q0, q15;\n\t"
  1812. "aese.8 q0, q0;\n\t"
  1813. "aesd.8 q0, q0;\n\t"
  1814. "aesmc.8 q0, q0;\n\t"
  1815. "aesimc.8 q0, q0;\n\t"
  1816. "vmull.p64 q0, d0, d0;\n\t"
  1817. );
  1818. void testfn(void);
  1819. ]], [ testfn(); ])],
  1820. [gcry_cv_gcc_inline_asm_aarch32_crypto=yes])
  1821. fi])
  1822. if test "$gcry_cv_gcc_inline_asm_aarch32_crypto" = "yes" ; then
  1823. AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH32_CRYPTO,1,
  1824. [Defined if inline assembler supports AArch32 Crypto Extension instructions])
  1825. fi
  1826. #
  1827. # Check whether GCC inline assembler supports AArch64 NEON instructions
  1828. #
  1829. AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 NEON instructions],
  1830. [gcry_cv_gcc_inline_asm_aarch64_neon],
  1831. [if test "$mpi_cpu_arch" != "aarch64" ||
  1832. test "$try_asm_modules" != "yes" ; then
  1833. gcry_cv_gcc_inline_asm_aarch64_neon="n/a"
  1834. else
  1835. gcry_cv_gcc_inline_asm_aarch64_neon=no
  1836. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1837. [[__asm__(
  1838. ".cpu generic+simd\n\t"
  1839. ".text\n\t"
  1840. "testfn:\n\t"
  1841. "mov w0, \#42;\n\t"
  1842. "dup v0.8b, w0;\n\t"
  1843. "ld4 {v0.8b,v1.8b,v2.8b,v3.8b},[x0],\#32;\n\t"
  1844. );
  1845. void testfn(void);
  1846. ]], [ testfn(); ])],
  1847. [gcry_cv_gcc_inline_asm_aarch64_neon=yes])
  1848. fi])
  1849. if test "$gcry_cv_gcc_inline_asm_aarch64_neon" = "yes" ; then
  1850. AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_NEON,1,
  1851. [Defined if inline assembler supports AArch64 NEON instructions])
  1852. fi
  1853. #
  1854. # Check whether GCC inline assembler supports AArch64 Crypto Extension instructions
  1855. #
  1856. AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 Crypto Extension instructions],
  1857. [gcry_cv_gcc_inline_asm_aarch64_crypto],
  1858. [if test "$mpi_cpu_arch" != "aarch64" ||
  1859. test "$try_asm_modules" != "yes" ; then
  1860. gcry_cv_gcc_inline_asm_aarch64_crypto="n/a"
  1861. else
  1862. gcry_cv_gcc_inline_asm_aarch64_crypto=no
  1863. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1864. [[__asm__(
  1865. ".cpu generic+simd+crypto\n\t"
  1866. ".text\n\t"
  1867. "testfn:\n\t"
  1868. "mov w0, \#42;\n\t"
  1869. "dup v0.8b, w0;\n\t"
  1870. "ld4 {v0.8b,v1.8b,v2.8b,v3.8b},[x0],\#32;\n\t"
  1871. "sha1h s0, s0;\n\t"
  1872. "sha1c q0, s0, v0.4s;\n\t"
  1873. "sha1p q0, s0, v0.4s;\n\t"
  1874. "sha1su0 v0.4s, v0.4s, v0.4s;\n\t"
  1875. "sha1su1 v0.4s, v0.4s;\n\t"
  1876. "sha256h q0, q0, v0.4s;\n\t"
  1877. "sha256h2 q0, q0, v0.4s;\n\t"
  1878. "sha1p q0, s0, v0.4s;\n\t"
  1879. "sha256su0 v0.4s, v0.4s;\n\t"
  1880. "sha256su1 v0.4s, v0.4s, v31.4s;\n\t"
  1881. "aese v0.16b, v0.16b;\n\t"
  1882. "aesd v0.16b, v0.16b;\n\t"
  1883. "aesmc v0.16b, v0.16b;\n\t"
  1884. "aesimc v0.16b, v0.16b;\n\t"
  1885. "pmull v0.1q, v0.1d, v31.1d;\n\t"
  1886. "pmull2 v0.1q, v0.2d, v31.2d;\n\t"
  1887. );
  1888. void testfn(void);
  1889. ]], [ testfn(); ])],
  1890. [gcry_cv_gcc_inline_asm_aarch64_crypto=yes])
  1891. fi])
  1892. if test "$gcry_cv_gcc_inline_asm_aarch64_crypto" = "yes" ; then
  1893. AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_CRYPTO,1,
  1894. [Defined if inline assembler supports AArch64 Crypto Extension instructions])
  1895. fi
  1896. #
  1897. # Check whether GCC inline assembler supports AArch64 SVE instructions
  1898. #
  1899. AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 SVE instructions],
  1900. [gcry_cv_gcc_inline_asm_aarch64_sve],
  1901. [if test "$mpi_cpu_arch" != "aarch64" ||
  1902. test "$try_asm_modules" != "yes" ; then
  1903. gcry_cv_gcc_inline_asm_aarch64_sve="n/a"
  1904. else
  1905. gcry_cv_gcc_inline_asm_aarch64_sve=no
  1906. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1907. [[__asm__(
  1908. ".cpu generic+simd+sve\n\t"
  1909. ".text\n\t"
  1910. "testfn:\n\t"
  1911. "mov x0, \#60;\n\t"
  1912. "whilelo p0.s, xzr, x0;\n\t"
  1913. "mov z0.s, p0/z, \#55;\n\t"
  1914. "ld1b {z0.b}, p0/z, [x1];\n\t"
  1915. );
  1916. void testfn(void);
  1917. ]], [ testfn(); ])],
  1918. [gcry_cv_gcc_inline_asm_aarch64_sve=yes])
  1919. fi])
  1920. if test "$gcry_cv_gcc_inline_asm_aarch64_sve" = "yes" ; then
  1921. AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_SVE,1,
  1922. [Defined if inline assembler supports AArch64 SVE instructions])
  1923. fi
  1924. #
  1925. # Check whether GCC inline assembler supports AArch64 SVE2 instructions
  1926. #
  1927. AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 SVE2 instructions],
  1928. [gcry_cv_gcc_inline_asm_aarch64_sve2],
  1929. [if test "$mpi_cpu_arch" != "aarch64" ||
  1930. test "$try_asm_modules" != "yes" ; then
  1931. gcry_cv_gcc_inline_asm_aarch64_sve2="n/a"
  1932. else
  1933. gcry_cv_gcc_inline_asm_aarch64_sve2=no
  1934. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1935. [[__asm__(
  1936. ".cpu generic+simd+sve2\n\t"
  1937. ".text\n\t"
  1938. "testfn:\n\t"
  1939. ";\n\t"
  1940. "eor3 z0.d, z0.d, z1.d, z2.d;\n\t"
  1941. "ext z8.b, {z20.b, z21.b}, \#3;\n\t"
  1942. "adclt z0.d, z1.d, z2.d;\n\t"
  1943. "tbl z0.b, {z8.b, z9.b}, z1.b;\n\t"
  1944. "addhnb z16.s, z17.d, z18.d;\n\t"
  1945. "mov z0.s, p0/z, \#55;\n\t"
  1946. "ld1b {z0.b}, p0/z, [x1];\n\t"
  1947. );
  1948. void testfn(void);
  1949. ]], [ testfn(); ])],
  1950. [gcry_cv_gcc_inline_asm_aarch64_sve2=yes])
  1951. fi])
  1952. if test "$gcry_cv_gcc_inline_asm_aarch64_sve2" = "yes" ; then
  1953. AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_SVE2,1,
  1954. [Defined if inline assembler supports AArch64 SVE2 instructions])
  1955. fi
  1956. #
  1957. # Check whether GCC inline assembler supports AArch64 SHA3/SHA512/SM3/SM4 instructions
  1958. #
  1959. AC_CACHE_CHECK([whether GCC inline assembler supports AArch64 SHA3/SHA512/SM3/SM4 instructions],
  1960. [gcry_cv_gcc_inline_asm_aarch64_sha3_sha512_sm3_sm4],
  1961. [if test "$mpi_cpu_arch" != "aarch64" ||
  1962. test "$try_asm_modules" != "yes" ; then
  1963. gcry_cv_gcc_inline_asm_aarch64_sha3_sha512_sm3_sm4="n/a"
  1964. else
  1965. gcry_cv_gcc_inline_asm_aarch64_sha3_sha512_sm3_sm4=no
  1966. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1967. [[__asm__(
  1968. ".arch armv8.2-a+sha3+sm4\n\t"
  1969. ".text\n\t"
  1970. "testfn:\n\t"
  1971. /* Test for SHA512 instructions */
  1972. "sha512h q0, q0, v0.2d;\n\t"
  1973. "sha512h2 q0, q0, v0.2d;\n\t"
  1974. "sha512su0 v0.2d, v0.2d;\n\t"
  1975. "sha512su1 v0.2d, v0.2d, v31.2d;\n\t"
  1976. /* Test for SHA3 instructions */
  1977. "bcax v0.16b, v1.16b, v2.16b, v3.16b;\n\t"
  1978. "eor3 v0.16b, v1.16b, v2.16b, v3.16b;\n\t"
  1979. "rax1 v0.2d, v1.2d, v2.2d;\n\t"
  1980. "xar v0.2d, v1.2d, v2.2d, \#1;\n\t"
  1981. /* Test for SM3 instructions */
  1982. "sm3partw1 v0.4s, v1.4s, v2.4s;\n\t"
  1983. "sm3partw2 v0.4s, v1.4s, v2.4s;\n\t"
  1984. "sm3ss1 v0.4s, v1.4s, v2.4s, v3.4s;\n\t"
  1985. "sm3tt1a v0.4s, v1.4s, v2.s[0];\n\t"
  1986. "sm3tt1b v0.4s, v1.4s, v2.s[0];\n\t"
  1987. "sm3tt2a v0.4s, v1.4s, v2.s[0];\n\t"
  1988. "sm3tt2b v0.4s, v1.4s, v2.s[0];\n\t"
  1989. /* Test for SM4 instructions */
  1990. "sm4e v0.4s, v1.4s;\n\t"
  1991. "sm4ekey v0.4s, v1.4s, v2.4s;\n\t"
  1992. );
  1993. void testfn(void);
  1994. ]], [ testfn(); ])],
  1995. [gcry_cv_gcc_inline_asm_aarch64_sha3_sha512_sm3_sm4=yes])
  1996. fi])
  1997. if test "$gcry_cv_gcc_inline_asm_aarch64_sha3_sha512_sm3_sm4" = "yes" ; then
  1998. AC_DEFINE(HAVE_GCC_INLINE_ASM_AARCH64_SHA3_SHA512_SM3_SM4,1,
  1999. [Defined if inline assembler supports AArch64 SHA3/SHA512/SM3/SM4 instructions])
  2000. fi
  2001. #
  2002. # Check whether compiler supports AArch64/NEON/crypto intrinsics
  2003. #
  2004. AC_CACHE_CHECK([whether compiler supports AArch64/NEON/crypto intrinsics],
  2005. [gcry_cv_cc_aarch64_neon_intrinsics],
  2006. [if test "$mpi_cpu_arch" != "aarch64" ||
  2007. test "$try_asm_modules" != "yes" ; then
  2008. gcry_cv_cc_aarch64_neon_intrinsics="n/a"
  2009. else
  2010. gcry_cv_cc_aarch64_neon_intrinsics=no
  2011. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  2012. [[#include <arm_neon.h>
  2013. #define __m128i uint64x2_t
  2014. #define vpsrldq128(s, a, o) \
  2015. ({ uint64x2_t __tmp = { 0, 0 }; \
  2016. o = (__m128i)vextq_u8((uint8x16_t)a, \
  2017. (uint8x16_t)__tmp, (s) & 15); })
  2018. #define vaesenclast128(a, b, o) \
  2019. (o = (__m128i)vaeseq_u8((uint8x16_t)b, (uint8x16_t)a))
  2020. #define memory_barrier_with_vec(a) __asm__("" : "+w"(a) :: "memory")
  2021. static inline __attribute__((always_inline)) __m128i
  2022. fn2(__m128i a)
  2023. {
  2024. vpsrldq128(2, a, a);
  2025. return a;
  2026. }
  2027. __m128i fn(__m128i in)
  2028. {
  2029. __m128i x;
  2030. memory_barrier_with_vec(in);
  2031. x = fn2(in);
  2032. memory_barrier_with_vec(x);
  2033. vaesenclast128(in, x, in);
  2034. memory_barrier_with_vec(in);
  2035. return in;
  2036. }
  2037. ]])],
  2038. [gcry_cv_cc_aarch64_neon_intrinsics=yes])
  2039. fi])
  2040. if test "$gcry_cv_cc_aarch64_neon_intrinsics" = "yes" ; then
  2041. AC_DEFINE(HAVE_COMPATIBLE_CC_AARCH64_NEON_INTRINSICS,1,
  2042. [Defined if underlying compiler supports AArch64/NEON/crypto intrinsics])
  2043. fi
  2044. _gcc_cflags_save=$CFLAGS
  2045. CFLAGS="$CFLAGS -O2 -march=armv8-a+crypto"
  2046. if test "$gcry_cv_cc_aarch64_neon_intrinsics" = "no" &&
  2047. test "$mpi_cpu_arch" = "aarch64" &&
  2048. test "$try_asm_modules" = "yes" ; then
  2049. AC_CACHE_CHECK([whether compiler supports AArch64/NEON/crypto intrinsics with extra GCC flags],
  2050. [gcry_cv_cc_aarch64_neon_intrinsics_cflags],
  2051. [gcry_cv_cc_aarch64_neon_intrinsics_cflags=no
  2052. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  2053. [[#include <arm_neon.h>
  2054. #define __m128i uint64x2_t
  2055. #define vpsrldq128(s, a, o) \
  2056. ({ uint64x2_t __tmp = { 0, 0 }; \
  2057. o = (__m128i)vextq_u8((uint8x16_t)a, \
  2058. (uint8x16_t)__tmp, (s) & 15); })
  2059. #define vaesenclast128(a, b, o) \
  2060. (o = (__m128i)vaeseq_u8((uint8x16_t)b, (uint8x16_t)a))
  2061. #define memory_barrier_with_vec(a) __asm__("" : "+w"(a) :: "memory")
  2062. static inline __attribute__((always_inline)) __m128i
  2063. fn2(__m128i a)
  2064. {
  2065. vpsrldq128(2, a, a);
  2066. return a;
  2067. }
  2068. __m128i fn(__m128i in)
  2069. {
  2070. __m128i x;
  2071. memory_barrier_with_vec(in);
  2072. x = fn2(in);
  2073. memory_barrier_with_vec(x);
  2074. vaesenclast128(in, x, in);
  2075. memory_barrier_with_vec(in);
  2076. return in;
  2077. }
  2078. ]])],
  2079. [gcry_cv_cc_aarch64_neon_intrinsics_cflags=yes])])
  2080. if test "$gcry_cv_cc_aarch64_neon_intrinsics_cflags" = "yes" ; then
  2081. AC_DEFINE(HAVE_COMPATIBLE_CC_AARCH64_NEON_INTRINSICS,1,
  2082. [Defined if underlying compiler supports AArch64/NEON/crypto intrinsics])
  2083. AC_DEFINE(HAVE_COMPATIBLE_CC_AARCH64_NEON_INTRINSICS_WITH_CFLAGS,1,
  2084. [Defined if underlying compiler supports AArch64/NEON/crypto intrinsics with extra GCC flags])
  2085. fi
  2086. fi
  2087. AM_CONDITIONAL(ENABLE_AARCH64_NEON_INTRINSICS_EXTRA_CFLAGS,
  2088. test "$gcry_cv_cc_aarch64_neon_intrinsics_cflags" = "yes")
  2089. # Restore flags.
  2090. CFLAGS=$_gcc_cflags_save;
  2091. #
  2092. # Check whether compiler supports PowerPC AltiVec/VSX intrinsics
  2093. #
  2094. AC_CACHE_CHECK([whether compiler supports PowerPC AltiVec/VSX/crypto intrinsics],
  2095. [gcry_cv_cc_ppc_altivec],
  2096. [if test "$mpi_cpu_arch" != "ppc" ||
  2097. test "$try_asm_modules" != "yes" ; then
  2098. gcry_cv_cc_ppc_altivec="n/a"
  2099. else
  2100. gcry_cv_cc_ppc_altivec=no
  2101. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  2102. [[#include <altivec.h>
  2103. typedef vector unsigned char block;
  2104. typedef vector unsigned int vecu32;
  2105. static inline __attribute__((always_inline)) vecu32
  2106. vec_sld_u32(vecu32 a, vecu32 b, unsigned int idx)
  2107. {
  2108. return vec_sld (a, b, (4 * idx) & 15);
  2109. }
  2110. block fn(block in)
  2111. {
  2112. block t = vec_perm (in, in, vec_vsx_ld (0, (unsigned char*)0));
  2113. vecu32 y = vec_vsx_ld (0, (unsigned int*)0);
  2114. y = vec_sld_u32 (y, y, 3);
  2115. return vec_cipher_be (t, in) ^ (block)y;
  2116. }
  2117. ]])],
  2118. [gcry_cv_cc_ppc_altivec=yes])
  2119. fi])
  2120. if test "$gcry_cv_cc_ppc_altivec" = "yes" ; then
  2121. AC_DEFINE(HAVE_COMPATIBLE_CC_PPC_ALTIVEC,1,
  2122. [Defined if underlying compiler supports PowerPC AltiVec/VSX/crypto intrinsics])
  2123. fi
  2124. _gcc_cflags_save=$CFLAGS
  2125. CFLAGS="$CFLAGS -O2 -maltivec -mvsx -mcrypto"
  2126. if test "$gcry_cv_cc_ppc_altivec" = "no" &&
  2127. test "$mpi_cpu_arch" = "ppc" &&
  2128. test "$try_asm_modules" = "yes" ; then
  2129. AC_CACHE_CHECK([whether compiler supports PowerPC AltiVec/VSX/crypto intrinsics with extra GCC flags],
  2130. [gcry_cv_cc_ppc_altivec_cflags],
  2131. [gcry_cv_cc_ppc_altivec_cflags=no
  2132. AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  2133. [[#include <altivec.h>
  2134. typedef vector unsigned char block;
  2135. typedef vector unsigned int vecu32;
  2136. static inline __attribute__((always_inline)) vecu32
  2137. vec_sld_u32(vecu32 a, vecu32 b, unsigned int idx)
  2138. {
  2139. return vec_sld (a, b, (4 * idx) & 15);
  2140. }
  2141. block fn(block in)
  2142. {
  2143. block t = vec_perm (in, in, vec_vsx_ld (0, (unsigned char*)0));
  2144. vecu32 y = vec_vsx_ld (0, (unsigned int*)0);
  2145. y = vec_sld_u32 (y, y, 3);
  2146. return vec_cipher_be (t, in) ^ (block)y;
  2147. }
  2148. ]])],
  2149. [gcry_cv_cc_ppc_altivec_cflags=yes])])
  2150. if test "$gcry_cv_cc_ppc_altivec_cflags" = "yes" ; then
  2151. AC_DEFINE(HAVE_COMPATIBLE_CC_PPC_ALTIVEC,1,
  2152. [Defined if underlying compiler supports PowerPC AltiVec/VSX/crypto intrinsics])
  2153. AC_DEFINE(HAVE_COMPATIBLE_CC_PPC_ALTIVEC_WITH_CFLAGS,1,
  2154. [Defined if underlying compiler supports PowerPC AltiVec/VSX/crypto intrinsics with extra GCC flags])
  2155. fi
  2156. fi
  2157. AM_CONDITIONAL(ENABLE_PPC_VCRYPTO_EXTRA_CFLAGS,
  2158. test "$gcry_cv_cc_ppc_altivec_cflags" = "yes")
  2159. # Restore flags.
  2160. CFLAGS=$_gcc_cflags_save;
  2161. #
  2162. # Check whether GCC inline assembler supports PowerPC AltiVec/VSX/crypto instructions
  2163. #
  2164. AC_CACHE_CHECK([whether GCC inline assembler supports PowerPC AltiVec/VSX/crypto instructions],
  2165. [gcry_cv_gcc_inline_asm_ppc_altivec],
  2166. [if test "$mpi_cpu_arch" != "ppc" ||
  2167. test "$try_asm_modules" != "yes" ; then
  2168. gcry_cv_gcc_inline_asm_ppc_altivec="n/a"
  2169. else
  2170. gcry_cv_gcc_inline_asm_ppc_altivec=no
  2171. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  2172. [[__asm__(".globl testfn;\n"
  2173. ".text\n\t"
  2174. "testfn:\n"
  2175. "stvx %v31,%r12,%r0;\n"
  2176. "lvx %v20,%r12,%r0;\n"
  2177. "vcipher %v0, %v1, %v22;\n"
  2178. "lxvw4x %vs32, %r0, %r1;\n"
  2179. "vadduwm %v0, %v1, %v22;\n"
  2180. "vshasigmaw %v0, %v1, 0, 15;\n"
  2181. "vshasigmad %v0, %v1, 0, 15;\n"
  2182. "vpmsumd %v11, %v11, %v11;\n"
  2183. );
  2184. void testfn(void);
  2185. ]], [ testfn(); ] )],
  2186. [gcry_cv_gcc_inline_asm_ppc_altivec=yes])
  2187. fi])
  2188. if test "$gcry_cv_gcc_inline_asm_ppc_altivec" = "yes" ; then
  2189. AC_DEFINE(HAVE_GCC_INLINE_ASM_PPC_ALTIVEC,1,
  2190. [Defined if inline assembler supports PowerPC AltiVec/VSX/crypto instructions])
  2191. fi
  2192. #
  2193. # Check whether GCC inline assembler supports PowerISA 3.00 instructions
  2194. #
  2195. AC_CACHE_CHECK([whether GCC inline assembler supports PowerISA 3.00 instructions],
  2196. [gcry_cv_gcc_inline_asm_ppc_arch_3_00],
  2197. [if test "$mpi_cpu_arch" != "ppc" ||
  2198. test "$try_asm_modules" != "yes" ; then
  2199. gcry_cv_gcc_inline_asm_ppc_arch_3_00="n/a"
  2200. else
  2201. gcry_cv_gcc_inline_asm_ppc_arch_3_00=no
  2202. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  2203. [[__asm__(".text\n\t"
  2204. ".globl testfn;\n"
  2205. "testfn:\n"
  2206. "stxvb16x %r1,%v12,%v30;\n"
  2207. );
  2208. void testfn(void);
  2209. ]], [ testfn(); ])],
  2210. [gcry_cv_gcc_inline_asm_ppc_arch_3_00=yes])
  2211. fi])
  2212. if test "$gcry_cv_gcc_inline_asm_ppc_arch_3_00" = "yes" ; then
  2213. AC_DEFINE(HAVE_GCC_INLINE_ASM_PPC_ARCH_3_00,1,
  2214. [Defined if inline assembler supports PowerISA 3.00 instructions])
  2215. fi
  2216. #
  2217. # Check whether compiler supports GCC PowerPC target attributes
  2218. #
  2219. AC_CACHE_CHECK([whether compiler supports GCC PowerPC target attributes],
  2220. [gcry_cv_gcc_attribute_ppc_target],
  2221. [if test "$mpi_cpu_arch" != "ppc" ; then
  2222. gcry_cv_gcc_attribute_ppc_target="n/a"
  2223. else
  2224. gcry_cv_gcc_attribute_ppc_target=no
  2225. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  2226. [[void __attribute__((always_inline)) inline aifn(void) {}
  2227. void __attribute__((target("cpu=power8"))) testfn8(void) {aifn();}
  2228. void __attribute__((target("cpu=power9"))) testfn9(void)
  2229. { testfn8(); aifn(); }
  2230. ]], [ testfn9(); aifn(); ])],
  2231. [gcry_cv_gcc_attribute_ppc_target=yes])
  2232. fi])
  2233. if test "$gcry_cv_gcc_attribute_ppc_target" = "yes" ; then
  2234. AC_DEFINE(HAVE_GCC_ATTRIBUTE_PPC_TARGET,1,
  2235. [Defined if compiler supports GCC PowerPC target attributes])
  2236. fi
  2237. #
  2238. # Check whether compiler supports clang PowerPC target attributes
  2239. #
  2240. AC_CACHE_CHECK([whether compiler supports clang PowerPC target attributes],
  2241. [gcry_cv_clang_attribute_ppc_target],
  2242. [if test "$mpi_cpu_arch" != "ppc" ; then
  2243. gcry_cv_clang_attribute_ppc_target="n/a"
  2244. else
  2245. gcry_cv_clang_attribute_ppc_target=no
  2246. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  2247. [[void __attribute__((always_inline)) inline aifn(void) {}
  2248. void __attribute__((target("arch=pwr8"))) testfn8(void) {aifn();}
  2249. void __attribute__((target("arch=pwr9"))) testfn9(void)
  2250. { testfn8(); aifn(); }
  2251. ]], [ testfn9(); aifn(); ])],
  2252. [gcry_cv_clang_attribute_ppc_target=yes])
  2253. fi])
  2254. if test "$gcry_cv_clang_attribute_ppc_target" = "yes" ; then
  2255. AC_DEFINE(HAVE_CLANG_ATTRIBUTE_PPC_TARGET,1,
  2256. [Defined if compiler supports clang PowerPC target attributes])
  2257. fi
  2258. #
  2259. # Check whether GCC inline assembler supports zSeries instructions
  2260. #
  2261. AC_CACHE_CHECK([whether GCC inline assembler supports zSeries instructions],
  2262. [gcry_cv_gcc_inline_asm_s390x],
  2263. [if test "$mpi_cpu_arch" != "s390x" ||
  2264. test "$try_asm_modules" != "yes" ; then
  2265. gcry_cv_gcc_inline_asm_s390x="n/a"
  2266. else
  2267. gcry_cv_gcc_inline_asm_s390x=no
  2268. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  2269. [[typedef unsigned int u128_t __attribute__ ((mode (TI)));
  2270. unsigned int testfunc(unsigned int x, void *y, unsigned int z)
  2271. {
  2272. unsigned long fac[8];
  2273. register unsigned long reg0 asm("0") = 0;
  2274. register unsigned long reg1 asm("1") = x;
  2275. u128_t r1 = ((u128_t)(unsigned long)y << 64) | (unsigned long)z;
  2276. u128_t r2 = 0;
  2277. u128_t r3 = 0;
  2278. asm volatile (".insn rre,0xb92e << 16, %[r1], %[r2]\n\t"
  2279. : [r1] "+a" (r1), [r2] "+a" (r2)
  2280. : "r" (reg0), "r" (reg1)
  2281. : "cc", "memory");
  2282. asm volatile (".insn rrf,0xb929 << 16, %[r1], %[r2], %[r3], 0\n\t"
  2283. : [r1] "+a" (r1), [r2] "+a" (r2), [r3] "+a" (r3)
  2284. : "r" (reg0), "r" (reg1)
  2285. : "cc", "memory");
  2286. reg0 = 8 - 1;
  2287. asm ("stfle %1\n\t"
  2288. : "+d" (reg0), "=Q" (fac[0])
  2289. :
  2290. : "cc", "memory");
  2291. asm volatile ("mvc 0(16, %0), 0(%1)\n\t"
  2292. :
  2293. : "a" (y), "a" (fac)
  2294. : "memory");
  2295. asm volatile ("xc 0(16, %0), 0(%0)\n\t"
  2296. :
  2297. : "a" (fac)
  2298. : "memory");
  2299. asm volatile ("risbgn %%r11, %%r11, 0, 129, 0\n\t"
  2300. :
  2301. :
  2302. : "memory", "r11");
  2303. asm volatile ("algrk %%r14, %%r14, %%r14\n\t"
  2304. :
  2305. :
  2306. : "memory", "r14");
  2307. return (unsigned int)r1 ^ reg0;
  2308. }
  2309. ]] , [ testfunc(0, 0, 0); ])],
  2310. [gcry_cv_gcc_inline_asm_s390x=yes])
  2311. fi])
  2312. if test "$gcry_cv_gcc_inline_asm_s390x" = "yes" ; then
  2313. AC_DEFINE(HAVE_GCC_INLINE_ASM_S390X,1,
  2314. [Defined if inline assembler supports zSeries instructions])
  2315. fi
  2316. #
  2317. # Check whether GCC inline assembler supports zSeries vector instructions
  2318. #
  2319. AC_CACHE_CHECK([whether GCC inline assembler supports zSeries vector instructions],
  2320. [gcry_cv_gcc_inline_asm_s390x_vx],
  2321. [if test "$mpi_cpu_arch" != "s390x" ||
  2322. test "$try_asm_modules" != "yes" ; then
  2323. gcry_cv_gcc_inline_asm_s390x_vx="n/a"
  2324. else
  2325. gcry_cv_gcc_inline_asm_s390x_vx=no
  2326. if test "$gcry_cv_gcc_inline_asm_s390x" = "yes" ; then
  2327. AC_LINK_IFELSE([AC_LANG_PROGRAM(
  2328. [[void testfunc(void)
  2329. {
  2330. asm volatile (".machine \"z13+vx\"\n\t"
  2331. "vx %%v0, %%v1, %%v31\n\t"
  2332. "verllf %%v11, %%v11, (16)(0)\n\t"
  2333. :
  2334. :
  2335. : "memory");
  2336. }
  2337. ]], [ testfunc(); ])],
  2338. [gcry_cv_gcc_inline_asm_s390x_vx=yes])
  2339. fi
  2340. fi])
  2341. if test "$gcry_cv_gcc_inline_asm_s390x_vx" = "yes" ; then
  2342. AC_DEFINE(HAVE_GCC_INLINE_ASM_S390X_VX,1,
  2343. [Defined if inline assembler supports zSeries vector instructions])
  2344. fi
  2345. #######################################
  2346. #### Checks for library functions. ####
  2347. #######################################
  2348. AC_FUNC_VPRINTF
  2349. # We have replacements for these in src/missing-string.c
  2350. AC_CHECK_FUNCS(stpcpy strcasecmp)
  2351. # We have replacements for these in src/g10lib.h
  2352. AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
  2353. # Other checks
  2354. AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4)
  2355. AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog)
  2356. AC_CHECK_FUNCS(syscall fcntl ftruncate flockfile getauxval elf_aux_info)
  2357. AC_CHECK_FUNCS(explicit_bzero explicit_memset getentropy sysctlbyname)
  2358. GNUPG_CHECK_MLOCK
  2359. #
  2360. # Replacement functions.
  2361. #
  2362. AC_REPLACE_FUNCS([getpid clock])
  2363. #
  2364. # Check whether it is necessary to link against libdl.
  2365. #
  2366. DL_LIBS=""
  2367. if test "$use_hmac_binary_check" != no ; then
  2368. _gcry_save_libs="$LIBS"
  2369. LIBS=""
  2370. AC_SEARCH_LIBS(dlopen, c dl,,,)
  2371. DL_LIBS=$LIBS
  2372. LIBS="$_gcry_save_libs"
  2373. fi
  2374. AC_SUBST(DL_LIBS)
  2375. #
  2376. # Check whether we can use Linux capabilities as requested.
  2377. #
  2378. if test "$use_capabilities" = "yes" ; then
  2379. use_capabilities=no
  2380. AC_CHECK_HEADERS(sys/capability.h)
  2381. if test "$ac_cv_header_sys_capability_h" = "yes" ; then
  2382. AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
  2383. if test "$ac_cv_lib_cap_cap_init" = "yes"; then
  2384. AC_DEFINE(USE_CAPABILITIES,1,
  2385. [define if capabilities should be used])
  2386. LIBS="$LIBS -lcap"
  2387. use_capabilities=yes
  2388. fi
  2389. fi
  2390. if test "$use_capabilities" = "no" ; then
  2391. AC_MSG_WARN([[
  2392. ***
  2393. *** The use of capabilities on this system is not possible.
  2394. *** You need a recent Linux kernel and some patches:
  2395. *** fcaps-2.2.9-990610.patch (kernel patch for 2.2.9)
  2396. *** fcap-module-990613.tar.gz (kernel module)
  2397. *** libcap-1.92.tar.gz (user mode library and utilities)
  2398. *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
  2399. *** set (filesystems menu). Be warned: This code is *really* ALPHA.
  2400. ***]])
  2401. fi
  2402. fi
  2403. # Check whether a random device is available.
  2404. if test "$try_dev_random" = yes ; then
  2405. AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
  2406. [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
  2407. ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
  2408. if test "$ac_cv_have_dev_random" = yes; then
  2409. AC_DEFINE(HAVE_DEV_RANDOM,1,
  2410. [defined if the system supports a random device] )
  2411. fi
  2412. else
  2413. AC_MSG_CHECKING(for random device)
  2414. ac_cv_have_dev_random=no
  2415. AC_MSG_RESULT(has been disabled)
  2416. fi
  2417. # Figure out the random modules for this configuration.
  2418. if test "$random" = "default"; then
  2419. # Select default value.
  2420. if test "$ac_cv_func_getentropy" = yes; then
  2421. random_modules="getentropy"
  2422. elif test "$ac_cv_have_dev_random" = yes; then
  2423. # Try Linuxish random device.
  2424. random_modules="linux"
  2425. else
  2426. case "${host}" in
  2427. *-*-mingw32ce*)
  2428. # WindowsCE random device.
  2429. random_modules="w32ce"
  2430. ;;
  2431. *-*-mingw32*|*-*-cygwin*)
  2432. # Windows random device.
  2433. random_modules="w32"
  2434. ;;
  2435. *)
  2436. # Build everything, allow to select at runtime.
  2437. random_modules="$auto_random_modules"
  2438. ;;
  2439. esac
  2440. fi
  2441. else
  2442. if test "$random" = "auto"; then
  2443. # Build everything, allow to select at runtime.
  2444. random_modules="$auto_random_modules"
  2445. else
  2446. random_modules="$random"
  2447. fi
  2448. fi
  2449. #
  2450. # Other defines
  2451. #
  2452. if test mym4_isgit = "yes"; then
  2453. AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
  2454. [Defined if this is not a regular release])
  2455. fi
  2456. AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
  2457. # This is handy for debugging so the compiler doesn't rearrange
  2458. # things and eliminate variables.
  2459. AC_ARG_ENABLE(optimization,
  2460. AS_HELP_STRING([--disable-optimization],
  2461. [disable compiler optimization]),
  2462. [if test $enableval = no ; then
  2463. CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
  2464. fi])
  2465. AC_MSG_NOTICE([checking for cc features])
  2466. # CFLAGS mangling when using gcc.
  2467. if test "$GCC" = yes; then
  2468. AC_MSG_CHECKING([if gcc supports -fno-delete-null-pointer-checks])
  2469. _gcc_cflags_save=$CFLAGS
  2470. CFLAGS="-fno-delete-null-pointer-checks"
  2471. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
  2472. AC_MSG_RESULT($_gcc_wopt)
  2473. CFLAGS=$_gcc_cflags_save;
  2474. if test x"$_gcc_wopt" = xyes ; then
  2475. CFLAGS="$CFLAGS -fno-delete-null-pointer-checks"
  2476. fi
  2477. CFLAGS="$CFLAGS -Wall"
  2478. if test "$USE_MAINTAINER_MODE" = "yes"; then
  2479. CFLAGS="$CFLAGS -Wcast-align -Wshadow -Wstrict-prototypes"
  2480. CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
  2481. # If -Wno-missing-field-initializers is supported we can enable a
  2482. # a bunch of really useful warnings.
  2483. AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
  2484. _gcc_cflags_save=$CFLAGS
  2485. CFLAGS="-Wno-missing-field-initializers"
  2486. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
  2487. AC_MSG_RESULT($_gcc_wopt)
  2488. CFLAGS=$_gcc_cflags_save;
  2489. if test x"$_gcc_wopt" = xyes ; then
  2490. CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
  2491. CFLAGS="$CFLAGS -Wwrite-strings"
  2492. CFLAGS="$CFLAGS -Wdeclaration-after-statement"
  2493. CFLAGS="$CFLAGS -Wno-missing-field-initializers"
  2494. CFLAGS="$CFLAGS -Wno-sign-compare"
  2495. fi
  2496. AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
  2497. _gcc_cflags_save=$CFLAGS
  2498. CFLAGS="-Wpointer-arith"
  2499. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
  2500. AC_MSG_RESULT($_gcc_wopt)
  2501. CFLAGS=$_gcc_cflags_save;
  2502. if test x"$_gcc_wopt" = xyes ; then
  2503. CFLAGS="$CFLAGS -Wpointer-arith"
  2504. fi
  2505. fi
  2506. fi
  2507. # Check whether as(1) supports a noeexecstack feature. This test
  2508. # includes an override option.
  2509. CL_AS_NOEXECSTACK
  2510. AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
  2511. AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
  2512. AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
  2513. AC_SUBST(LIBGCRYPT_CONFIG_HOST)
  2514. AC_SUBST(LIBGCRYPT_THREAD_MODULES)
  2515. AC_CONFIG_COMMANDS([gcrypt-conf],[[
  2516. chmod +x src/libgcrypt-config
  2517. ]],[[
  2518. prefix=$prefix
  2519. exec_prefix=$exec_prefix
  2520. libdir=$libdir
  2521. datadir=$datadir
  2522. DATADIRNAME=$DATADIRNAME
  2523. ]])
  2524. #####################
  2525. #### Conclusion. ####
  2526. #####################
  2527. # Check that requested feature can actually be used and define
  2528. # ENABLE_foo_SUPPORT macros.
  2529. if test x"$aesnisupport" = xyes ; then
  2530. if test "$gcry_cv_gcc_inline_asm_ssse3" != "yes" ; then
  2531. aesnisupport="no (unsupported by compiler)"
  2532. fi
  2533. fi
  2534. if test x"$shaextsupport" = xyes ; then
  2535. if test "$gcry_cv_gcc_inline_asm_shaext" != "yes" ; then
  2536. shaextsupport="no (unsupported by compiler)"
  2537. fi
  2538. fi
  2539. if test x"$pclmulsupport" = xyes ; then
  2540. if test "$gcry_cv_gcc_inline_asm_pclmul" != "yes" ; then
  2541. pclmulsupport="no (unsupported by compiler)"
  2542. fi
  2543. fi
  2544. if test x"$sse41support" = xyes ; then
  2545. if test "$gcry_cv_gcc_inline_asm_sse41" != "yes" ; then
  2546. sse41support="no (unsupported by compiler)"
  2547. fi
  2548. fi
  2549. if test x"$avxsupport" = xyes ; then
  2550. if test "$gcry_cv_gcc_inline_asm_avx" != "yes" ; then
  2551. avxsupport="no (unsupported by compiler)"
  2552. fi
  2553. fi
  2554. if test x"$avx2support" = xyes ; then
  2555. if test "$gcry_cv_gcc_inline_asm_avx2" != "yes" ; then
  2556. avx2support="no (unsupported by compiler)"
  2557. fi
  2558. fi
  2559. if test x"$avx512support" = xyes ; then
  2560. if test "$gcry_cv_gcc_inline_asm_avx512" != "yes" ; then
  2561. avx512support="no (unsupported by compiler)"
  2562. fi
  2563. fi
  2564. if test x"$gfnisupport" = xyes ; then
  2565. if test "$gcry_cv_gcc_inline_asm_gfni" != "yes" ; then
  2566. gfnisupport="no (unsupported by compiler)"
  2567. fi
  2568. fi
  2569. if test x"$neonsupport" = xyes ; then
  2570. if test "$gcry_cv_gcc_inline_asm_neon" != "yes" ; then
  2571. if test "$gcry_cv_gcc_inline_asm_aarch64_neon" != "yes" ; then
  2572. neonsupport="no (unsupported by compiler)"
  2573. fi
  2574. fi
  2575. fi
  2576. if test x"$armcryptosupport" = xyes ; then
  2577. if test "$gcry_cv_gcc_inline_asm_aarch32_crypto" != "yes" ; then
  2578. if test "$gcry_cv_gcc_inline_asm_aarch64_crypto" != "yes" ; then
  2579. armcryptosupport="no (unsupported by compiler)"
  2580. fi
  2581. fi
  2582. fi
  2583. if test x"$svesupport" = xyes ; then
  2584. if test "$gcry_cv_gcc_inline_asm_sve" != "yes" ; then
  2585. if test "$gcry_cv_gcc_inline_asm_aarch64_sve" != "yes" ; then
  2586. svesupport="no (unsupported by compiler)"
  2587. fi
  2588. fi
  2589. fi
  2590. if test x"$sve2support" = xyes ; then
  2591. if test "$gcry_cv_gcc_inline_asm_sve2" != "yes" ; then
  2592. if test "$gcry_cv_gcc_inline_asm_aarch64_sve2" != "yes" ; then
  2593. sve2support="no (unsupported by compiler)"
  2594. fi
  2595. fi
  2596. fi
  2597. if test x"$aesnisupport" = xyes ; then
  2598. AC_DEFINE(ENABLE_AESNI_SUPPORT, 1,
  2599. [Enable support for Intel AES-NI instructions.])
  2600. fi
  2601. if test x"$shaextsupport" = xyes ; then
  2602. AC_DEFINE(ENABLE_SHAEXT_SUPPORT, 1,
  2603. [Enable support for Intel SHAEXT instructions.])
  2604. fi
  2605. if test x"$pclmulsupport" = xyes ; then
  2606. AC_DEFINE(ENABLE_PCLMUL_SUPPORT, 1,
  2607. [Enable support for Intel PCLMUL instructions.])
  2608. fi
  2609. if test x"$sse41support" = xyes ; then
  2610. AC_DEFINE(ENABLE_SSE41_SUPPORT, 1,
  2611. [Enable support for Intel SSE4.1 instructions.])
  2612. fi
  2613. if test x"$avxsupport" = xyes ; then
  2614. AC_DEFINE(ENABLE_AVX_SUPPORT,1,
  2615. [Enable support for Intel AVX instructions.])
  2616. fi
  2617. if test x"$avx2support" = xyes ; then
  2618. AC_DEFINE(ENABLE_AVX2_SUPPORT,1,
  2619. [Enable support for Intel AVX2 instructions.])
  2620. fi
  2621. if test x"$avx512support" = xyes ; then
  2622. AC_DEFINE(ENABLE_AVX512_SUPPORT,1,
  2623. [Enable support for Intel AVX512 instructions.])
  2624. fi
  2625. if test x"$gfnisupport" = xyes ; then
  2626. AC_DEFINE(ENABLE_GFNI_SUPPORT,1,
  2627. [Enable support for Intel GFNI instructions.])
  2628. fi
  2629. if test x"$neonsupport" = xyes ; then
  2630. AC_DEFINE(ENABLE_NEON_SUPPORT,1,
  2631. [Enable support for ARM NEON instructions.])
  2632. fi
  2633. if test x"$armcryptosupport" = xyes ; then
  2634. AC_DEFINE(ENABLE_ARM_CRYPTO_SUPPORT,1,
  2635. [Enable support for ARMv8 Crypto Extension instructions.])
  2636. fi
  2637. if test x"$svesupport" = xyes ; then
  2638. AC_DEFINE(ENABLE_SVE_SUPPORT,1,
  2639. [Enable support for ARMv8 SVE instructions.])
  2640. fi
  2641. if test x"$sve2support" = xyes ; then
  2642. AC_DEFINE(ENABLE_SVE2_SUPPORT,1,
  2643. [Enable support for ARMv9 SVE2 instructions.])
  2644. fi
  2645. if test x"$ppccryptosupport" = xyes ; then
  2646. AC_DEFINE(ENABLE_PPC_CRYPTO_SUPPORT,1,
  2647. [Enable support for POWER 8 (PowerISA 2.07) crypto extension.])
  2648. fi
  2649. if test x"$jentsupport" = xyes ; then
  2650. AC_DEFINE(ENABLE_JENT_SUPPORT, 1,
  2651. [Enable support for the jitter entropy collector.])
  2652. fi
  2653. if test x"$padlocksupport" = xyes ; then
  2654. AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1,
  2655. [Enable support for the PadLock engine.])
  2656. fi
  2657. if test x"$drngsupport" = xyes ; then
  2658. AC_DEFINE(ENABLE_DRNG_SUPPORT, 1,
  2659. [Enable support for Intel DRNG (RDRAND instruction).])
  2660. fi
  2661. if test x"$force_soft_hwfeatures" = xyes ; then
  2662. AC_DEFINE(ENABLE_FORCE_SOFT_HWFEATURES, 1,
  2663. [Enable forcing 'soft' HW feature bits on (for testing).])
  2664. fi
  2665. # Define conditional sources and config.h symbols depending on the
  2666. # selected ciphers, pubkey-ciphers, digests, kdfs, and random modules.
  2667. LIST_MEMBER(arcfour, $enabled_ciphers)
  2668. if test "$found" = "1"; then
  2669. GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
  2670. AC_DEFINE(USE_ARCFOUR, 1, [Defined if this module should be included])
  2671. case "${host}" in
  2672. x86_64-*-*)
  2673. # Build with the assembly implementation
  2674. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS arcfour-amd64.lo"
  2675. ;;
  2676. esac
  2677. fi
  2678. LIST_MEMBER(blowfish, $enabled_ciphers)
  2679. if test "$found" = "1" ; then
  2680. GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
  2681. AC_DEFINE(USE_BLOWFISH, 1, [Defined if this module should be included])
  2682. case "${host}" in
  2683. x86_64-*-*)
  2684. # Build with the assembly implementation
  2685. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS blowfish-amd64.lo"
  2686. ;;
  2687. arm*-*-*)
  2688. # Build with the assembly implementation
  2689. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS blowfish-arm.lo"
  2690. ;;
  2691. esac
  2692. fi
  2693. LIST_MEMBER(cast5, $enabled_ciphers)
  2694. if test "$found" = "1" ; then
  2695. GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
  2696. AC_DEFINE(USE_CAST5, 1, [Defined if this module should be included])
  2697. case "${host}" in
  2698. x86_64-*-*)
  2699. # Build with the assembly implementation
  2700. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS cast5-amd64.lo"
  2701. ;;
  2702. arm*-*-*)
  2703. # Build with the assembly implementation
  2704. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS cast5-arm.lo"
  2705. ;;
  2706. esac
  2707. fi
  2708. LIST_MEMBER(des, $enabled_ciphers)
  2709. if test "$found" = "1" ; then
  2710. GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
  2711. AC_DEFINE(USE_DES, 1, [Defined if this module should be included])
  2712. case "${host}" in
  2713. x86_64-*-*)
  2714. # Build with the assembly implementation
  2715. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS des-amd64.lo"
  2716. ;;
  2717. esac
  2718. fi
  2719. LIST_MEMBER(aes, $enabled_ciphers)
  2720. if test "$found" = "1" ; then
  2721. GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
  2722. AC_DEFINE(USE_AES, 1, [Defined if this module should be included])
  2723. case "${host}" in
  2724. x86_64-*-*)
  2725. # Build with the assembly implementation
  2726. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-amd64.lo"
  2727. # Build with the SSSE3 implementation
  2728. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ssse3-amd64.lo"
  2729. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ssse3-amd64-asm.lo"
  2730. # Build with the VAES/AVX2 implementation
  2731. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-vaes.lo"
  2732. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-vaes-avx2-amd64.lo"
  2733. ;;
  2734. arm*-*-*)
  2735. # Build with the assembly implementation
  2736. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-arm.lo"
  2737. # Build with the ARMv8/AArch32 CE implementation
  2738. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-armv8-ce.lo"
  2739. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-armv8-aarch32-ce.lo"
  2740. ;;
  2741. aarch64-*-*)
  2742. # Build with the assembly implementation
  2743. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-aarch64.lo"
  2744. # Build with the ARMv8/AArch64 CE implementation
  2745. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-armv8-ce.lo"
  2746. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-armv8-aarch64-ce.lo"
  2747. ;;
  2748. powerpc64le-*-*)
  2749. # Build with the crypto extension implementation
  2750. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ppc.lo"
  2751. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ppc9le.lo"
  2752. if test "$gcry_cv_gcc_inline_asm_ppc_altivec" = "yes" &&
  2753. test "$gcry_cv_gcc_inline_asm_ppc_arch_3_00" = "yes" ; then
  2754. # Build with AES-GCM bulk implementation for P10
  2755. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-gcm-p10le.lo"
  2756. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-p10le.lo"
  2757. fi
  2758. ;;
  2759. powerpc64-*-*)
  2760. # Big-Endian.
  2761. # Build with the crypto extension implementation
  2762. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ppc.lo"
  2763. ;;
  2764. powerpc-*-*)
  2765. # Big-Endian.
  2766. # Build with the crypto extension implementation
  2767. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-ppc.lo"
  2768. ;;
  2769. s390x-*-*)
  2770. # Big-Endian.
  2771. # Build with the crypto extension implementation
  2772. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-s390x.lo"
  2773. ;;
  2774. esac
  2775. case "$mpi_cpu_arch" in
  2776. x86)
  2777. # Build with the AES-NI implementation
  2778. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-aesni.lo"
  2779. # Build with the Padlock implementation
  2780. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-padlock.lo"
  2781. # Build with the VAES/AVX2 implementation
  2782. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-vaes-i386.lo"
  2783. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS rijndael-vaes-avx2-i386.lo"
  2784. ;;
  2785. esac
  2786. fi
  2787. LIST_MEMBER(twofish, $enabled_ciphers)
  2788. if test "$found" = "1" ; then
  2789. GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
  2790. AC_DEFINE(USE_TWOFISH, 1, [Defined if this module should be included])
  2791. case "${host}" in
  2792. x86_64-*-*)
  2793. # Build with the assembly implementation
  2794. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS twofish-amd64.lo"
  2795. if test x"$avx2support" = xyes ; then
  2796. # Build with the AVX2 implementation
  2797. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS twofish-avx2-amd64.lo"
  2798. fi
  2799. ;;
  2800. arm*-*-*)
  2801. # Build with the assembly implementation
  2802. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS twofish-arm.lo"
  2803. ;;
  2804. aarch64-*-*)
  2805. # Build with the assembly implementation
  2806. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS twofish-aarch64.lo"
  2807. ;;
  2808. esac
  2809. fi
  2810. LIST_MEMBER(serpent, $enabled_ciphers)
  2811. if test "$found" = "1" ; then
  2812. GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
  2813. AC_DEFINE(USE_SERPENT, 1, [Defined if this module should be included])
  2814. case "${host}" in
  2815. x86_64-*-*)
  2816. # Build with the SSE2 implementation
  2817. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS serpent-sse2-amd64.lo"
  2818. ;;
  2819. esac
  2820. if test x"$avx2support" = xyes ; then
  2821. # Build with the AVX2 implementation
  2822. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS serpent-avx2-amd64.lo"
  2823. fi
  2824. if test x"$avx512support" = xyes ; then
  2825. # Build with the AVX512 implementation
  2826. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS serpent-avx512-x86.lo"
  2827. fi
  2828. if test x"$neonsupport" = xyes ; then
  2829. # Build with the NEON implementation
  2830. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS serpent-armv7-neon.lo"
  2831. fi
  2832. fi
  2833. LIST_MEMBER(rfc2268, $enabled_ciphers)
  2834. if test "$found" = "1" ; then
  2835. GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
  2836. AC_DEFINE(USE_RFC2268, 1, [Defined if this module should be included])
  2837. fi
  2838. LIST_MEMBER(seed, $enabled_ciphers)
  2839. if test "$found" = "1" ; then
  2840. GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo"
  2841. AC_DEFINE(USE_SEED, 1, [Defined if this module should be included])
  2842. fi
  2843. LIST_MEMBER(camellia, $enabled_ciphers)
  2844. if test "$found" = "1" ; then
  2845. GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo"
  2846. AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included])
  2847. case "${host}" in
  2848. arm*-*-*)
  2849. # Build with the assembly implementation
  2850. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-arm.lo"
  2851. ;;
  2852. aarch64-*-*)
  2853. # Build with the assembly implementation
  2854. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-aarch64.lo"
  2855. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-aarch64-ce.lo"
  2856. ;;
  2857. powerpc64le-*-*)
  2858. # Build with the POWER vector implementations
  2859. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-ppc8le.lo"
  2860. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-ppc9le.lo"
  2861. ;;
  2862. esac
  2863. if test x"$avxsupport" = xyes ; then
  2864. if test x"$aesnisupport" = xyes ; then
  2865. # Build with the AES-NI/AVX implementation
  2866. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-aesni-avx-amd64.lo"
  2867. fi
  2868. fi
  2869. if test x"$avx2support" = xyes ; then
  2870. if test x"$aesnisupport" = xyes ; then
  2871. # Build with the AES-NI/AVX2 implementation
  2872. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-aesni-avx2-amd64.lo"
  2873. # Build with the VAES/AVX2 implementation
  2874. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-vaes-avx2-amd64.lo"
  2875. # Build with the GFNI/AVX2 implementation
  2876. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-gfni-avx2-amd64.lo"
  2877. # Build with the GFNI/AVX512 implementation
  2878. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS camellia-gfni-avx512-amd64.lo"
  2879. fi
  2880. fi
  2881. fi
  2882. LIST_MEMBER(idea, $enabled_ciphers)
  2883. if test "$found" = "1" ; then
  2884. GCRYPT_CIPHERS="$GCRYPT_CIPHERS idea.lo"
  2885. AC_DEFINE(USE_IDEA, 1, [Defined if this module should be included])
  2886. fi
  2887. LIST_MEMBER(salsa20, $enabled_ciphers)
  2888. if test "$found" = "1" ; then
  2889. GCRYPT_CIPHERS="$GCRYPT_CIPHERS salsa20.lo"
  2890. AC_DEFINE(USE_SALSA20, 1, [Defined if this module should be included])
  2891. case "${host}" in
  2892. x86_64-*-*)
  2893. # Build with the assembly implementation
  2894. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS salsa20-amd64.lo"
  2895. ;;
  2896. esac
  2897. if test x"$neonsupport" = xyes ; then
  2898. # Build with the NEON implementation
  2899. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS salsa20-armv7-neon.lo"
  2900. fi
  2901. fi
  2902. LIST_MEMBER(gost28147, $enabled_ciphers)
  2903. if test "$found" = "1" ; then
  2904. GCRYPT_CIPHERS="$GCRYPT_CIPHERS gost28147.lo"
  2905. AC_DEFINE(USE_GOST28147, 1, [Defined if this module should be included])
  2906. fi
  2907. LIST_MEMBER(chacha20, $enabled_ciphers)
  2908. if test "$found" = "1" ; then
  2909. GCRYPT_CIPHERS="$GCRYPT_CIPHERS chacha20.lo"
  2910. AC_DEFINE(USE_CHACHA20, 1, [Defined if this module should be included])
  2911. case "${host}" in
  2912. x86_64-*-*)
  2913. # Build with the assembly implementation
  2914. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-amd64-ssse3.lo"
  2915. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-amd64-avx2.lo"
  2916. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-amd64-avx512.lo"
  2917. ;;
  2918. aarch64-*-*)
  2919. # Build with the assembly implementation
  2920. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-aarch64.lo"
  2921. ;;
  2922. powerpc64le-*-*)
  2923. # Build with the ppc8 vector implementation
  2924. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-ppc.lo"
  2925. # Build with the assembly implementation
  2926. if test "$gcry_cv_gcc_inline_asm_ppc_altivec" = "yes" &&
  2927. test "$gcry_cv_gcc_inline_asm_ppc_arch_3_00" = "yes" ; then
  2928. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-p10le-8x.lo"
  2929. fi
  2930. ;;
  2931. powerpc64-*-*)
  2932. # Build with the ppc8 vector implementation
  2933. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-ppc.lo"
  2934. ;;
  2935. powerpc-*-*)
  2936. # Build with the ppc8 vector implementation
  2937. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-ppc.lo"
  2938. ;;
  2939. s390x-*-*)
  2940. # Build with the s390x/zSeries vector implementation
  2941. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-s390x.lo"
  2942. ;;
  2943. esac
  2944. if test x"$neonsupport" = xyes ; then
  2945. # Build with the NEON implementation
  2946. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS chacha20-armv7-neon.lo"
  2947. fi
  2948. fi
  2949. LIST_MEMBER(sm4, $enabled_ciphers)
  2950. if test "$found" = "1" ; then
  2951. GCRYPT_CIPHERS="$GCRYPT_CIPHERS sm4.lo"
  2952. AC_DEFINE(USE_SM4, 1, [Defined if this module should be included])
  2953. case "${host}" in
  2954. x86_64-*-*)
  2955. # Build with the assembly implementation
  2956. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-aesni-avx-amd64.lo"
  2957. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-aesni-avx2-amd64.lo"
  2958. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-gfni-avx2-amd64.lo"
  2959. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-gfni-avx512-amd64.lo"
  2960. ;;
  2961. aarch64-*-*)
  2962. # Build with the assembly implementation
  2963. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-aarch64.lo"
  2964. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-armv8-aarch64-ce.lo"
  2965. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-armv9-aarch64-sve-ce.lo"
  2966. ;;
  2967. powerpc64le-*-*)
  2968. # Build with the ppc64le vector implementation
  2969. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS sm4-ppc.lo"
  2970. ;;
  2971. esac
  2972. fi
  2973. LIST_MEMBER(aria, $enabled_ciphers)
  2974. if test "$found" = "1" ; then
  2975. GCRYPT_CIPHERS="$GCRYPT_CIPHERS aria.lo"
  2976. AC_DEFINE(USE_ARIA, 1, [Defined if this module should be included])
  2977. case "${host}" in
  2978. x86_64-*-*)
  2979. # Build with the assembly implementation
  2980. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS aria-aesni-avx-amd64.lo"
  2981. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS aria-aesni-avx2-amd64.lo"
  2982. GCRYPT_ASM_CIPHERS="$GCRYPT_ASM_CIPHERS aria-gfni-avx512-amd64.lo"
  2983. ;;
  2984. esac
  2985. fi
  2986. LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
  2987. AM_CONDITIONAL(USE_DSA, [test "$found" = "1"])
  2988. if test "$found" = "1" ; then
  2989. GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
  2990. AC_DEFINE(USE_DSA, 1, [Defined if this module should be included])
  2991. fi
  2992. LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
  2993. AM_CONDITIONAL(USE_RSA, [test "$found" = "1"])
  2994. if test "$found" = "1" ; then
  2995. GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
  2996. AC_DEFINE(USE_RSA, 1, [Defined if this module should be included])
  2997. fi
  2998. LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
  2999. AM_CONDITIONAL(USE_ELGAMAL, [test "$found" = "1"])
  3000. if test "$found" = "1" ; then
  3001. GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
  3002. AC_DEFINE(USE_ELGAMAL, 1, [Defined if this module should be included])
  3003. fi
  3004. LIST_MEMBER(ecc, $enabled_pubkey_ciphers)
  3005. AM_CONDITIONAL(USE_ECC, [test "$found" = "1"])
  3006. if test "$found" = "1" ; then
  3007. GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS \
  3008. ecc.lo ecc-curves.lo ecc-misc.lo \
  3009. ecc-ecdh.lo ecc-ecdsa.lo ecc-eddsa.lo ecc-gost.lo \
  3010. ecc-sm2.lo"
  3011. AC_DEFINE(USE_ECC, 1, [Defined if this module should be included])
  3012. fi
  3013. LIST_MEMBER(crc, $enabled_digests)
  3014. if test "$found" = "1" ; then
  3015. GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
  3016. AC_DEFINE(USE_CRC, 1, [Defined if this module should be included])
  3017. case "${host}" in
  3018. i?86-*-* | x86_64-*-*)
  3019. # Build with the assembly implementation
  3020. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-intel-pclmul.lo"
  3021. ;;
  3022. aarch64-*-*)
  3023. # Build with the assembly implementation
  3024. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-armv8-ce.lo"
  3025. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-armv8-aarch64-ce.lo"
  3026. ;;
  3027. powerpc64le-*-*)
  3028. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-ppc.lo"
  3029. ;;
  3030. powerpc64-*-*)
  3031. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-ppc.lo"
  3032. ;;
  3033. powerpc-*-*)
  3034. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS crc-ppc.lo"
  3035. ;;
  3036. esac
  3037. fi
  3038. LIST_MEMBER(gostr3411-94, $enabled_digests)
  3039. if test "$found" = "1" ; then
  3040. # GOST R 34.11-94 internally uses GOST 28147-89
  3041. LIST_MEMBER(gost28147, $enabled_ciphers)
  3042. if test "$found" = "1" ; then
  3043. GCRYPT_DIGESTS="$GCRYPT_DIGESTS gostr3411-94.lo"
  3044. AC_DEFINE(USE_GOST_R_3411_94, 1, [Defined if this module should be included])
  3045. fi
  3046. fi
  3047. LIST_MEMBER(stribog, $enabled_digests)
  3048. if test "$found" = "1" ; then
  3049. GCRYPT_DIGESTS="$GCRYPT_DIGESTS stribog.lo"
  3050. AC_DEFINE(USE_GOST_R_3411_12, 1, [Defined if this module should be included])
  3051. fi
  3052. LIST_MEMBER(md2, $enabled_digests)
  3053. if test "$found" = "1" ; then
  3054. GCRYPT_DIGESTS="$GCRYPT_DIGESTS md2.lo"
  3055. AC_DEFINE(USE_MD2, 1, [Defined if this module should be included])
  3056. fi
  3057. LIST_MEMBER(md4, $enabled_digests)
  3058. if test "$found" = "1" ; then
  3059. GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
  3060. AC_DEFINE(USE_MD4, 1, [Defined if this module should be included])
  3061. fi
  3062. LIST_MEMBER(md5, $enabled_digests)
  3063. if test "$found" = "1" ; then
  3064. GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
  3065. AC_DEFINE(USE_MD5, 1, [Defined if this module should be included])
  3066. fi
  3067. LIST_MEMBER(rmd160, $enabled_digests)
  3068. if test "$found" = "1" ; then
  3069. GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo"
  3070. AC_DEFINE(USE_RMD160, 1, [Defined if this module should be included])
  3071. fi
  3072. LIST_MEMBER(sha256, $enabled_digests)
  3073. if test "$found" = "1" ; then
  3074. GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
  3075. AC_DEFINE(USE_SHA256, 1, [Defined if this module should be included])
  3076. case "${host}" in
  3077. x86_64-*-*)
  3078. # Build with the assembly implementation
  3079. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-ssse3-amd64.lo"
  3080. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-avx-amd64.lo"
  3081. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-avx2-bmi2-amd64.lo"
  3082. ;;
  3083. arm*-*-*)
  3084. # Build with the assembly implementation
  3085. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-armv8-aarch32-ce.lo"
  3086. ;;
  3087. aarch64-*-*)
  3088. # Build with the assembly implementation
  3089. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-armv8-aarch64-ce.lo"
  3090. ;;
  3091. powerpc64le-*-*)
  3092. # Build with the crypto extension implementation
  3093. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-ppc.lo"
  3094. ;;
  3095. powerpc64-*-*)
  3096. # Big-Endian.
  3097. # Build with the crypto extension implementation
  3098. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-ppc.lo"
  3099. ;;
  3100. powerpc-*-*)
  3101. # Big-Endian.
  3102. # Build with the crypto extension implementation
  3103. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-ppc.lo"
  3104. esac
  3105. case "$mpi_cpu_arch" in
  3106. x86)
  3107. # Build with the SHAEXT implementation
  3108. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha256-intel-shaext.lo"
  3109. ;;
  3110. esac
  3111. fi
  3112. LIST_MEMBER(sha512, $enabled_digests)
  3113. if test "$found" = "1" ; then
  3114. GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
  3115. AC_DEFINE(USE_SHA512, 1, [Defined if this module should be included])
  3116. case "${host}" in
  3117. x86_64-*-*)
  3118. # Build with the assembly implementation
  3119. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ssse3-amd64.lo"
  3120. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-avx-amd64.lo"
  3121. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-avx2-bmi2-amd64.lo"
  3122. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-avx512-amd64.lo"
  3123. ;;
  3124. i?86-*-*)
  3125. # Build with the assembly implementation
  3126. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ssse3-i386.lo"
  3127. ;;
  3128. arm*-*-*)
  3129. # Build with the assembly implementation
  3130. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-arm.lo"
  3131. ;;
  3132. aarch64-*-*)
  3133. # Build with the assembly implementation
  3134. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-armv8-aarch64-ce.lo"
  3135. ;;
  3136. powerpc64le-*-*)
  3137. # Build with the crypto extension implementation
  3138. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ppc.lo"
  3139. ;;
  3140. powerpc64-*-*)
  3141. # Big-Endian.
  3142. # Build with the crypto extension implementation
  3143. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ppc.lo"
  3144. ;;
  3145. powerpc-*-*)
  3146. # Big-Endian.
  3147. # Build with the crypto extension implementation
  3148. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-ppc.lo"
  3149. esac
  3150. if test x"$neonsupport" = xyes ; then
  3151. # Build with the NEON implementation
  3152. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha512-armv7-neon.lo"
  3153. fi
  3154. fi
  3155. LIST_MEMBER(sha3, $enabled_digests)
  3156. if test "$found" = "1" ; then
  3157. GCRYPT_DIGESTS="$GCRYPT_DIGESTS keccak.lo"
  3158. AC_DEFINE(USE_SHA3, 1, [Defined if this module should be included])
  3159. case "${host}" in
  3160. x86_64-*-*)
  3161. # Build with the assembly implementation
  3162. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS keccak-amd64-avx512.lo"
  3163. ;;
  3164. esac
  3165. if test x"$neonsupport" = xyes ; then
  3166. # Build with the NEON implementation
  3167. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS keccak-armv7-neon.lo"
  3168. fi
  3169. fi
  3170. LIST_MEMBER(tiger, $enabled_digests)
  3171. if test "$found" = "1" ; then
  3172. GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
  3173. AC_DEFINE(USE_TIGER, 1, [Defined if this module should be included])
  3174. fi
  3175. LIST_MEMBER(whirlpool, $enabled_digests)
  3176. if test "$found" = "1" ; then
  3177. GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
  3178. AC_DEFINE(USE_WHIRLPOOL, 1, [Defined if this module should be included])
  3179. case "${host}" in
  3180. x86_64-*-*)
  3181. # Build with the assembly implementation
  3182. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS whirlpool-sse2-amd64.lo"
  3183. ;;
  3184. esac
  3185. fi
  3186. LIST_MEMBER(blake2, $enabled_digests)
  3187. if test "$found" = "1" ; then
  3188. GCRYPT_DIGESTS="$GCRYPT_DIGESTS blake2.lo"
  3189. AC_DEFINE(USE_BLAKE2, 1, [Defined if this module should be included])
  3190. case "${host}" in
  3191. x86_64-*-*)
  3192. # Build with the assembly implementation
  3193. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS blake2b-amd64-avx2.lo"
  3194. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS blake2b-amd64-avx512.lo"
  3195. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS blake2s-amd64-avx.lo"
  3196. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS blake2s-amd64-avx512.lo"
  3197. ;;
  3198. esac
  3199. fi
  3200. LIST_MEMBER(sm3, $enabled_digests)
  3201. if test "$found" = "1" ; then
  3202. GCRYPT_DIGESTS="$GCRYPT_DIGESTS sm3.lo"
  3203. AC_DEFINE(USE_SM3, 1, [Defined if this module should be included])
  3204. case "${host}" in
  3205. x86_64-*-*)
  3206. # Build with the assembly implementation
  3207. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sm3-avx-bmi2-amd64.lo"
  3208. ;;
  3209. aarch64-*-*)
  3210. # Build with the assembly implementation
  3211. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sm3-aarch64.lo"
  3212. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sm3-armv8-aarch64-ce.lo"
  3213. ;;
  3214. esac
  3215. fi
  3216. # SHA-1 needs to be included always for example because it is used by
  3217. # random-csprng.c.
  3218. GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1.lo"
  3219. AC_DEFINE(USE_SHA1, 1, [Defined if this module should be included])
  3220. case "${host}" in
  3221. x86_64-*-*)
  3222. # Build with the assembly implementation
  3223. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-ssse3-amd64.lo"
  3224. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-avx-amd64.lo"
  3225. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-avx-bmi2-amd64.lo"
  3226. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-avx2-bmi2-amd64.lo"
  3227. ;;
  3228. arm*-*-*)
  3229. # Build with the assembly implementation
  3230. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-armv7-neon.lo"
  3231. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-armv8-aarch32-ce.lo"
  3232. ;;
  3233. aarch64-*-*)
  3234. # Build with the assembly implementation
  3235. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-armv8-aarch64-ce.lo"
  3236. ;;
  3237. esac
  3238. case "$mpi_cpu_arch" in
  3239. x86)
  3240. # Build with the SHAEXT implementation
  3241. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS sha1-intel-shaext.lo"
  3242. ;;
  3243. esac
  3244. # Arch specific GCM implementations
  3245. case "${host}" in
  3246. i?86-*-* | x86_64-*-*)
  3247. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-intel-pclmul.lo"
  3248. ;;
  3249. arm*-*-*)
  3250. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-armv7-neon.lo"
  3251. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-armv8-aarch32-ce.lo"
  3252. ;;
  3253. aarch64-*-*)
  3254. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-armv8-aarch64-ce.lo"
  3255. ;;
  3256. powerpc64le-*-* | powerpc64-*-* | powerpc-*-*)
  3257. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS cipher-gcm-ppc.lo"
  3258. ;;
  3259. esac
  3260. # Arch specific MAC implementations
  3261. case "${host}" in
  3262. s390x-*-*)
  3263. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS poly1305-s390x.lo"
  3264. ;;
  3265. x86_64-*-*)
  3266. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS poly1305-amd64-avx512.lo"
  3267. ;;
  3268. powerpc64le-*-*)
  3269. # Build with the assembly implementation
  3270. if test "$gcry_cv_gcc_inline_asm_ppc_altivec" = "yes" &&
  3271. test "$gcry_cv_gcc_inline_asm_ppc_arch_3_00" = "yes" ; then
  3272. GCRYPT_ASM_DIGESTS="$GCRYPT_ASM_DIGESTS poly1305-p10le.lo"
  3273. fi
  3274. ;;
  3275. esac
  3276. LIST_MEMBER(scrypt, $enabled_kdfs)
  3277. if test "$found" = "1" ; then
  3278. GCRYPT_KDFS="$GCRYPT_KDFS scrypt.lo"
  3279. AC_DEFINE(USE_SCRYPT, 1, [Defined if this module should be included])
  3280. fi
  3281. LIST_MEMBER(getentropy, $random_modules)
  3282. if test "$found" = "1" ; then
  3283. GCRYPT_RANDOM="$GCRYPT_RANDOM rndgetentropy.lo"
  3284. AC_DEFINE(USE_RNDGETENTROPY, 1, [Defined if the getentropy RNG should be used.])
  3285. fi
  3286. LIST_MEMBER(linux, $random_modules)
  3287. if test "$found" = "1" ; then
  3288. GCRYPT_RANDOM="$GCRYPT_RANDOM rndoldlinux.lo"
  3289. AC_DEFINE(USE_RNDOLDLINUX, 1, [Defined if the /dev/random RNG should be used.])
  3290. fi
  3291. LIST_MEMBER(unix, $random_modules)
  3292. if test "$found" = "1" ; then
  3293. GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
  3294. AC_DEFINE(USE_RNDUNIX, 1, [Defined if the default Unix RNG should be used.])
  3295. fi
  3296. LIST_MEMBER(egd, $random_modules)
  3297. if test "$found" = "1" ; then
  3298. GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
  3299. AC_DEFINE(USE_RNDEGD, 1, [Defined if the EGD based RNG should be used.])
  3300. fi
  3301. LIST_MEMBER(w32, $random_modules)
  3302. if test "$found" = "1" ; then
  3303. GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
  3304. AC_DEFINE(USE_RNDW32, 1,
  3305. [Defined if the Windows specific RNG should be used.])
  3306. fi
  3307. LIST_MEMBER(w32ce, $random_modules)
  3308. if test "$found" = "1" ; then
  3309. GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32ce.lo"
  3310. AC_DEFINE(USE_RNDW32CE, 1,
  3311. [Defined if the WindowsCE specific RNG should be used.])
  3312. fi
  3313. if test "$try_asm_modules" = yes ; then
  3314. # Build with assembly implementations
  3315. GCRYPT_CIPHERS="$GCRYPT_CIPHERS $GCRYPT_ASM_CIPHERS"
  3316. GCRYPT_DIGESTS="$GCRYPT_DIGESTS $GCRYPT_ASM_DIGESTS"
  3317. fi
  3318. AC_SUBST([GCRYPT_CIPHERS])
  3319. AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
  3320. AC_SUBST([GCRYPT_DIGESTS])
  3321. AC_SUBST([GCRYPT_KDFS])
  3322. AC_SUBST([GCRYPT_RANDOM])
  3323. AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
  3324. AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
  3325. AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
  3326. # For printing the configuration we need a colon separated list of
  3327. # algorithm names.
  3328. tmp=`echo "$enabled_ciphers" | tr ' ' : `
  3329. AC_DEFINE_UNQUOTED(LIBGCRYPT_CIPHERS, "$tmp",
  3330. [List of available cipher algorithms])
  3331. tmp=`echo "$enabled_pubkey_ciphers" | tr ' ' : `
  3332. AC_DEFINE_UNQUOTED(LIBGCRYPT_PUBKEY_CIPHERS, "$tmp",
  3333. [List of available public key cipher algorithms])
  3334. tmp=`echo "$enabled_digests" | tr ' ' : `
  3335. AC_DEFINE_UNQUOTED(LIBGCRYPT_DIGESTS, "$tmp",
  3336. [List of available digest algorithms])
  3337. tmp=`echo "$enabled_kdfs" | tr ' ' : `
  3338. AC_DEFINE_UNQUOTED(LIBGCRYPT_KDFS, "$tmp",
  3339. [List of available KDF algorithms])
  3340. #
  3341. # Define conditional sources depending on the used hardware platform.
  3342. # Note that all possible modules must also be listed in
  3343. # src/Makefile.am (EXTRA_libgcrypt_la_SOURCES).
  3344. #
  3345. GCRYPT_HWF_MODULES=
  3346. case "$mpi_cpu_arch" in
  3347. x86)
  3348. AC_DEFINE(HAVE_CPU_ARCH_X86, 1, [Defined for the x86 platforms])
  3349. GCRYPT_HWF_MODULES="libgcrypt_la-hwf-x86.lo"
  3350. ;;
  3351. alpha)
  3352. AC_DEFINE(HAVE_CPU_ARCH_ALPHA, 1, [Defined for Alpha platforms])
  3353. ;;
  3354. sparc)
  3355. AC_DEFINE(HAVE_CPU_ARCH_SPARC, 1, [Defined for SPARC platforms])
  3356. ;;
  3357. mips)
  3358. AC_DEFINE(HAVE_CPU_ARCH_MIPS, 1, [Defined for MIPS platforms])
  3359. ;;
  3360. m68k)
  3361. AC_DEFINE(HAVE_CPU_ARCH_M68K, 1, [Defined for M68k platforms])
  3362. ;;
  3363. ppc)
  3364. AC_DEFINE(HAVE_CPU_ARCH_PPC, 1, [Defined for PPC platforms])
  3365. GCRYPT_HWF_MODULES="libgcrypt_la-hwf-ppc.lo"
  3366. ;;
  3367. arm)
  3368. AC_DEFINE(HAVE_CPU_ARCH_ARM, 1, [Defined for ARM platforms])
  3369. GCRYPT_HWF_MODULES="libgcrypt_la-hwf-arm.lo"
  3370. ;;
  3371. aarch64)
  3372. AC_DEFINE(HAVE_CPU_ARCH_ARM, 1, [Defined for ARM AArch64 platforms])
  3373. GCRYPT_HWF_MODULES="libgcrypt_la-hwf-arm.lo"
  3374. ;;
  3375. s390x)
  3376. AC_DEFINE(HAVE_CPU_ARCH_S390X, 1, [Defined for s390x/zSeries platforms])
  3377. GCRYPT_HWF_MODULES="libgcrypt_la-hwf-s390x.lo"
  3378. ;;
  3379. esac
  3380. AC_SUBST([GCRYPT_HWF_MODULES])
  3381. #
  3382. # Option to disable building of doc file
  3383. #
  3384. build_doc=yes
  3385. AC_ARG_ENABLE([doc], AS_HELP_STRING([--disable-doc],
  3386. [do not build the documentation]),
  3387. build_doc=$enableval, build_doc=yes)
  3388. AM_CONDITIONAL([BUILD_DOC], [test "x$build_doc" != xno])
  3389. #
  3390. # Provide information about the build.
  3391. #
  3392. BUILD_REVISION="mym4_revision"
  3393. AC_SUBST(BUILD_REVISION)
  3394. AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
  3395. [GIT commit id revision used to build this package])
  3396. changequote(,)dnl
  3397. BUILD_VERSION=`echo "$PACKAGE_VERSION" | sed 's/\([0-9.]*\).*/\1./'`
  3398. changequote([,])dnl
  3399. BUILD_VERSION="${BUILD_VERSION}mym4_revision_dec"
  3400. BUILD_FILEVERSION=`echo "${BUILD_VERSION}" | tr . ,`
  3401. AC_SUBST(BUILD_VERSION)
  3402. AC_SUBST(BUILD_FILEVERSION)
  3403. AC_ARG_ENABLE([build-timestamp],
  3404. AS_HELP_STRING([--enable-build-timestamp],
  3405. [set an explicit build timestamp for reproducibility.
  3406. (default is the current time in ISO-8601 format)]),
  3407. [if test "$enableval" = "yes"; then
  3408. BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
  3409. else
  3410. BUILD_TIMESTAMP="$enableval"
  3411. fi],
  3412. [BUILD_TIMESTAMP="<none>"])
  3413. AC_SUBST(BUILD_TIMESTAMP)
  3414. AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
  3415. [The time this package was configured for a build])
  3416. # And create the files.
  3417. AC_CONFIG_FILES([
  3418. Makefile
  3419. m4/Makefile
  3420. compat/Makefile
  3421. mpi/Makefile
  3422. cipher/Makefile
  3423. random/Makefile
  3424. doc/Makefile
  3425. src/Makefile
  3426. src/gcrypt.h
  3427. src/libgcrypt-config
  3428. src/libgcrypt.pc
  3429. src/versioninfo.rc
  3430. tests/Makefile
  3431. ])
  3432. AC_CONFIG_FILES([tests/hashtest-6g], [chmod +x tests/hashtest-6g])
  3433. AC_CONFIG_FILES([tests/hashtest-256g], [chmod +x tests/hashtest-256g])
  3434. AC_CONFIG_FILES([tests/basic-disable-all-hwf], [chmod +x tests/basic-disable-all-hwf])
  3435. AC_OUTPUT
  3436. detection_module="${GCRYPT_HWF_MODULES%.lo}"
  3437. test -n "$detection_module" || detection_module="none"
  3438. # Give some feedback
  3439. GCRY_MSG_SHOW([],[])
  3440. GCRY_MSG_SHOW([Libgcrypt],[v${VERSION} has been configured as follows:])
  3441. GCRY_MSG_SHOW([],[])
  3442. GCRY_MSG_SHOW([Platform: ],[$PRINTABLE_OS_NAME ($host)])
  3443. GCRY_MSG_SHOW([Hardware detection module:],[$detection_module])
  3444. GCRY_MSG_WRAP([Enabled cipher algorithms:],[$enabled_ciphers])
  3445. GCRY_MSG_WRAP([Enabled digest algorithms:],[$enabled_digests])
  3446. GCRY_MSG_WRAP([Enabled kdf algorithms: ],[$enabled_kdfs])
  3447. GCRY_MSG_WRAP([Enabled pubkey algorithms:],[$enabled_pubkey_ciphers])
  3448. GCRY_MSG_SHOW([Random number generator: ],[$random])
  3449. GCRY_MSG_SHOW([Try using jitter entropy: ],[$jentsupport])
  3450. GCRY_MSG_SHOW([Using linux capabilities: ],[$use_capabilities])
  3451. GCRY_MSG_SHOW([FIPS module version: ],[$fips_module_version])
  3452. GCRY_MSG_SHOW([Try using Padlock crypto: ],[$padlocksupport])
  3453. GCRY_MSG_SHOW([Try using AES-NI crypto: ],[$aesnisupport])
  3454. GCRY_MSG_SHOW([Try using Intel SHAEXT: ],[$shaextsupport])
  3455. GCRY_MSG_SHOW([Try using Intel PCLMUL: ],[$pclmulsupport])
  3456. GCRY_MSG_SHOW([Try using Intel SSE4.1: ],[$sse41support])
  3457. GCRY_MSG_SHOW([Try using DRNG (RDRAND): ],[$drngsupport])
  3458. GCRY_MSG_SHOW([Try using Intel AVX: ],[$avxsupport])
  3459. GCRY_MSG_SHOW([Try using Intel AVX2: ],[$avx2support])
  3460. GCRY_MSG_SHOW([Try using Intel AVX512: ],[$avx512support])
  3461. GCRY_MSG_SHOW([Try using Intel GFNI: ],[$gfnisupport])
  3462. GCRY_MSG_SHOW([Try using ARM NEON: ],[$neonsupport])
  3463. GCRY_MSG_SHOW([Try using ARMv8 crypto: ],[$armcryptosupport])
  3464. GCRY_MSG_SHOW([Try using ARMv8 SVE: ],[$svesupport])
  3465. GCRY_MSG_SHOW([Try using ARMv9 SVE2: ],[$sve2support])
  3466. GCRY_MSG_SHOW([Try using PPC crypto: ],[$ppccryptosupport])
  3467. GCRY_MSG_SHOW([],[])
  3468. if test "x${gpg_config_script_warn}" != x; then
  3469. cat <<G10EOF
  3470. Mismatches between the target platform and the to
  3471. be used libraries have been been detected for:
  3472. ${gpg_config_script_warn}
  3473. Please check above for warning messages.
  3474. G10EOF
  3475. fi
  3476. if test "$gcry_cv_gcc_attribute_aligned" != "yes" ; then
  3477. cat <<G10EOF
  3478. Please note that your compiler does not support the GCC style
  3479. aligned attribute. Using this software may evoke bus errors.
  3480. G10EOF
  3481. fi