configure.ac 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348
  1. # -*- autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
  4. #
  5. # This configure.ac is free software; the author
  6. # gives unlimited permission to copy and/or distribute it,
  7. # with or without modifications, as long as this notice is preserved.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  11. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12. # PARTICULAR PURPOSE.
  13. dnl This configure script is complicated, because GRUB needs to deal
  14. dnl with three potentially different types:
  15. dnl
  16. dnl build -- the environment for building GRUB
  17. dnl host -- the environment for running utilities
  18. dnl target -- the environment for running GRUB
  19. dnl
  20. dnl In addition, GRUB needs to deal with a platform specification
  21. dnl which specifies the system running GRUB, such as firmware.
  22. dnl This is necessary because the target type in autoconf does not
  23. dnl describe such a system very well.
  24. dnl
  25. dnl The current strategy is to use variables with no prefix (such as
  26. dnl CC, CFLAGS, etc.) for the host and target type, variables with
  27. dnl prefix "BUILD_" (such as BUILD_CC, BUILD_CFLAGS, etc.) for the
  28. dnl build type, variables with prefix "HOST_" (such as HOST_CC,
  29. dnl HOST_CFLAGS, etc.) for the host type and variables with the prefix
  30. dnl "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for
  31. dnl the target type. See INSTALL for full list of variables and
  32. dnl description of the relationships between them.
  33. AC_INIT([GRUB],[2.13],[bug-grub@gnu.org])
  34. AS_CASE(["$ERROR_PLATFORM_NOT_SUPPORT_SSP"],
  35. [n | no | nO | N | No | NO], [ERROR_PLATFORM_NOT_SUPPORT_SSP=no],
  36. [ERROR_PLATFORM_NOT_SUPPORT_SSP=yes])
  37. # We don't want -g -O2 by default in CFLAGS
  38. : ${CFLAGS=""}
  39. AC_USE_SYSTEM_EXTENSIONS
  40. AC_CONFIG_AUX_DIR([build-aux])
  41. # Checks for build, host and target systems.
  42. AC_CANONICAL_BUILD
  43. AC_CANONICAL_HOST
  44. save_program_prefix="${program_prefix}"
  45. AC_CANONICAL_TARGET
  46. program_prefix="${save_program_prefix}"
  47. AM_INIT_AUTOMAKE([1.11])
  48. AC_PREREQ(2.64)
  49. AC_CONFIG_SRCDIR([include/grub/dl.h])
  50. AC_CONFIG_HEADERS([config-util.h])
  51. # Explicitly check for pkg-config early on, since otherwise conditional
  52. # calls are problematic.
  53. PKG_PROG_PKG_CONFIG
  54. # Program name transformations
  55. AC_ARG_PROGRAM
  56. grub_TRANSFORM([grub-bios-setup])
  57. grub_TRANSFORM([grub-editenv])
  58. grub_TRANSFORM([grub-install])
  59. grub_TRANSFORM([grub-mkconfig])
  60. grub_TRANSFORM([grub-mkfont])
  61. grub_TRANSFORM([grub-mkimage])
  62. grub_TRANSFORM([grub-glue-efi])
  63. grub_TRANSFORM([grub-mklayout])
  64. grub_TRANSFORM([grub-mkpasswd-pbkdf2])
  65. grub_TRANSFORM([grub-mkrelpath])
  66. grub_TRANSFORM([grub-mkrescue])
  67. grub_TRANSFORM([grub-probe])
  68. grub_TRANSFORM([grub-reboot])
  69. grub_TRANSFORM([grub-script-check])
  70. grub_TRANSFORM([grub-set-default])
  71. grub_TRANSFORM([grub-sparc64-setup])
  72. grub_TRANSFORM([grub-render-label])
  73. grub_TRANSFORM([grub-file])
  74. # Allow HOST_CC to override CC.
  75. if test "x$HOST_CC" != x; then
  76. CC=$HOST_CC
  77. fi
  78. # Optimization flag. Allow user to override.
  79. if test "x$TARGET_CFLAGS" = x; then
  80. TARGET_CFLAGS=-Os
  81. fi
  82. # Enable support for "restrict" keyword and other
  83. # features from gnu99 C language standard.
  84. BUILD_CFLAGS="-std=gnu99 -fno-common $BUILD_CFLAGS"
  85. HOST_CFLAGS="-std=gnu99 -fno-common $HOST_CFLAGS"
  86. TARGET_CFLAGS="-std=gnu99 -fno-common $TARGET_CFLAGS"
  87. # Default HOST_CPPFLAGS
  88. HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
  89. HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
  90. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
  91. case "$target_cpu" in
  92. i[[3456]]86) target_cpu=i386 ;;
  93. amd64) target_cpu=x86_64 ;;
  94. sparc) target_cpu=sparc64 ;;
  95. mipsel|mips64el)
  96. target_cpu=mipsel
  97. machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"
  98. ;;
  99. mips|mips64)
  100. target_cpu=mips
  101. machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"
  102. ;;
  103. arm*) target_cpu=arm ;;
  104. aarch64*) target_cpu=arm64 ;;
  105. loongarch64) target_cpu=loongarch64 ;;
  106. riscv32*) target_cpu=riscv32 ;;
  107. riscv64*) target_cpu=riscv64 ;;
  108. esac
  109. # Specify the platform (such as firmware).
  110. AC_ARG_WITH([platform],
  111. AS_HELP_STRING([--with-platform=PLATFORM],
  112. [select the host platform [[guessed]]]))
  113. # Guess the platform if not specified.
  114. if test "x$with_platform" = x; then
  115. case "$target_cpu"-"$target_vendor" in
  116. i386-apple) platform=efi ;;
  117. i386-*) platform=pc ;;
  118. x86_64-apple) platform=efi ;;
  119. x86_64-*) platform=pc ;;
  120. powerpc-*) platform=ieee1275 ;;
  121. powerpc64-*) platform=ieee1275 ;;
  122. powerpc64le-*) platform=ieee1275 ;;
  123. sparc64-*) platform=ieee1275 ;;
  124. mipsel-*) platform=loongson ;;
  125. mips-*) platform=arc ;;
  126. ia64-*) platform=efi ;;
  127. arm-*) platform=uboot ;;
  128. arm64-*) platform=efi ;;
  129. loongarch64-*) platform=efi;;
  130. riscv32-*) platform=efi ;;
  131. riscv64-*) platform=efi ;;
  132. *)
  133. AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities])
  134. platform=none
  135. ;;
  136. esac
  137. else
  138. platform="$with_platform"
  139. fi
  140. case "$target_cpu"-"$platform" in
  141. x86_64-efi) ;;
  142. x86_64-emu) ;;
  143. x86_64-xen) ;;
  144. x86_64-none) ;;
  145. x86_64-*) target_cpu=i386 ;;
  146. powerpc64-ieee1275) target_cpu=powerpc ;;
  147. powerpc64le-ieee1275) target_cpu=powerpc ;;
  148. esac
  149. # Check if the platform is supported, make final adjustments.
  150. case "$target_cpu"-"$platform" in
  151. i386-efi) ;;
  152. x86_64-efi) ;;
  153. i386-xen) ;;
  154. i386-xen_pvh) ;;
  155. x86_64-xen) ;;
  156. i386-pc) ;;
  157. i386-multiboot) ;;
  158. i386-coreboot) ;;
  159. i386-linuxbios) platform=coreboot ;;
  160. i386-ieee1275) ;;
  161. i386-qemu) ;;
  162. powerpc-ieee1275) ;;
  163. sparc64-ieee1275) ;;
  164. ia64-efi) ;;
  165. mips-qemu_mips) ;;
  166. mips-qemu-mips) platform=qemu_mips;;
  167. mips-arc) ;;
  168. mipsel-arc) ;;
  169. mipsel-qemu_mips) ;;
  170. mipsel-qemu-mips) platform=qemu_mips;;
  171. mipsel-yeeloong) platform=loongson ;;
  172. mipsel-fuloong) platform=loongson ;;
  173. mipsel-loongson) ;;
  174. arm-uboot) ;;
  175. arm-coreboot) ;;
  176. arm-efi) ;;
  177. arm64-efi) ;;
  178. loongarch64-efi) ;;
  179. riscv32-efi) ;;
  180. riscv64-efi) ;;
  181. *-emu) ;;
  182. *-none) ;;
  183. *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
  184. esac
  185. if test x$platform != xemu ; then
  186. case "$target_cpu" in
  187. i386 | powerpc) target_m32=1 ;;
  188. x86_64 | sparc64) target_m64=1 ;;
  189. esac
  190. fi
  191. if test x"$target_cpu-$platform" = xsparc64-emu ; then
  192. target_m64=1
  193. fi
  194. case "$target_os" in
  195. windows* | mingw32*) target_os=cygwin ;;
  196. esac
  197. # This normalizes the names, and creates a new variable ("host_kernel")
  198. # while at it, since the mapping is not always 1:1 (e.g. different OSes
  199. # using the same kernel type).
  200. case "$host_os" in
  201. gnu*) host_kernel=hurd ;;
  202. linux*) host_kernel=linux ;;
  203. freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
  204. netbsd*) host_kernel=netbsd ;;
  205. solaris*) host_kernel=illumos ;;
  206. darwin*) host_kernel=xnu ;;
  207. cygwin | windows* | mingw32*) host_kernel=windows ;;
  208. esac
  209. case "$host_os" in
  210. cygwin) have_exec=y ;;
  211. windows* | mingw32*) have_exec=n ;;
  212. aros*) have_exec=n ;;
  213. *) have_exec=y;;
  214. esac
  215. case "$platform" in
  216. coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
  217. multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
  218. efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
  219. xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
  220. xen_pvh) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN_PVH=1" ;;
  221. ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
  222. uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
  223. qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
  224. pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
  225. emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
  226. loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;;
  227. qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;;
  228. arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
  229. esac
  230. if test x${target_cpu} = xmipsel ; then
  231. machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
  232. else
  233. machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
  234. fi
  235. case "${target_cpu}-$platform" in
  236. mips-arc)
  237. TARGET_LINK_ADDR=0x88200000
  238. TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
  239. ;;
  240. mipsel-arc)
  241. TARGET_LINK_ADDR=0x80700000
  242. TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
  243. ;;
  244. mips*-qemu_mips | mips*-loongson)
  245. TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
  246. ;;
  247. esac
  248. AC_SUBST(TARGET_LINK_ADDR)
  249. AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
  250. TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
  251. AC_SUBST(host_cpu)
  252. AC_SUBST(host_os)
  253. AC_SUBST(host_kernel)
  254. AC_SUBST(target_cpu)
  255. AC_SUBST(platform)
  256. # Define default variables
  257. have_with_bootdir=n
  258. AC_ARG_WITH([bootdir],
  259. AS_HELP_STRING([--with-bootdir=DIR],
  260. [set the name of /boot directory [[guessed]]]),
  261. [have_with_bootdir=y],
  262. [have_with_bootdir=n])
  263. if test x$have_with_bootdir = xy; then
  264. bootdirname="$with_bootdir"
  265. else
  266. case "$host_os" in
  267. netbsd* | openbsd*)
  268. # Because /boot is used for the boot block in NetBSD and OpenBSD,
  269. bootdirname='' ;;
  270. *) bootdirname='boot' ;;
  271. esac
  272. fi
  273. AC_SUBST(bootdirname)
  274. AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
  275. [Default boot directory name])
  276. AC_ARG_WITH([grubdir],
  277. AS_HELP_STRING([--with-grubdir=DIR],
  278. [set the name of grub directory [[guessed]]]),
  279. [grubdirname="$with_grubdir"],
  280. [grubdirname="$PACKAGE"])
  281. AC_SUBST(grubdirname)
  282. AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
  283. [Default grub directory name])
  284. #
  285. # Checks for build programs.
  286. #
  287. # Although cmp is listed in the GNU Coding Standards as a command which
  288. # can used directly, OpenBSD lacks cmp in the default installation.
  289. AC_CHECK_PROGS([CMP], [cmp])
  290. if test "x$CMP" = x; then
  291. AC_MSG_ERROR([cmp is not found])
  292. fi
  293. AC_CHECK_PROGS([YACC], [bison])
  294. if test "x$YACC" = x; then
  295. AC_MSG_ERROR([bison is not found])
  296. fi
  297. AC_PROG_RANLIB
  298. AC_PROG_INSTALL
  299. AC_PROG_AWK
  300. AC_PROG_LEX([noyywrap])
  301. AC_PROG_YACC
  302. AC_PROG_MAKE_SET
  303. AC_PROG_MKDIR_P
  304. AC_PROG_LN_S
  305. if test "x$LEX" = "x:"; then
  306. AC_MSG_ERROR([flex is not found])
  307. else
  308. version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
  309. if test -n "$version" -a "$version" -ge 20535; then
  310. :
  311. else
  312. AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
  313. fi
  314. fi
  315. # These are not a "must".
  316. AC_PATH_PROGS(MAKEINFO, makeinfo true)
  317. #
  318. # Checks for host programs.
  319. #
  320. AC_PROG_CC
  321. gl_EARLY
  322. AC_PROG_CXX
  323. AM_PROG_CC_C_O
  324. AM_PROG_AS
  325. AM_PATH_PYTHON([2.6])
  326. # Must be GCC.
  327. test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
  328. AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
  329. AM_GNU_GETTEXT([external])
  330. AM_GNU_GETTEXT_VERSION([0.18.3])
  331. AC_SYS_LARGEFILE
  332. PLATFORMS_PCI=" $(PYTHONPATH="${srcdir}" $PYTHON -c 'import gentpl; print(" ".join(gentpl.GROUPS[["pci"]]))') "
  333. if test x"${PLATFORMS_PCI##* ${target_cpu}_${platform} *}" = x ; then
  334. have_pci=y
  335. fi
  336. # Identify characteristics of the host architecture.
  337. unset ac_cv_c_bigendian
  338. if test x"$target_cpu-$platform" = xsparc64-emu ; then
  339. CFLAGS="$CFLAGS -m64"
  340. HOST_CFLAGS="$HOST_CFLAGS -m64"
  341. fi
  342. CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
  343. HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
  344. AC_C_BIGENDIAN
  345. AC_CHECK_SIZEOF(void *)
  346. AC_CHECK_SIZEOF(long)
  347. case "$host_os" in
  348. cygwin | windows* | mingw32*)
  349. HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
  350. CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
  351. AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
  352. ;;
  353. esac
  354. case "$host_os" in
  355. cygwin | windows* | mingw32* | aros*)
  356. ;;
  357. *)
  358. AC_CHECK_SIZEOF(off_t)
  359. if test x"$ac_cv_sizeof_off_t" != x8 ; then
  360. AC_CHECK_SIZEOF(off64_t)
  361. test x"$ac_cv_sizeof_off64_t" = x8 || AC_MSG_ERROR([Large file support is required])
  362. fi;;
  363. esac
  364. if test x$USE_NLS = xno; then
  365. HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
  366. fi
  367. if test "x$cross_compiling" = xyes; then
  368. AC_MSG_WARN([cannot generate manual pages while cross compiling])
  369. else
  370. AC_PATH_PROG(HELP2MAN, help2man)
  371. fi
  372. # Check for functions and headers.
  373. AC_CHECK_FUNCS(posix_memalign memalign getextmntent atexit)
  374. AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
  375. # glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation
  376. # warning which causes compilation failure later with -Werror. So use -Werror here
  377. # as well to force proper sys/sysmacros.h detection. Used in include/grub/osdep/major.h.
  378. SAVED_CFLAGS="$CFLAGS"
  379. CFLAGS="$HOST_CFLAGS -Werror"
  380. AC_HEADER_MAJOR
  381. CFLAGS="$SAVED_CFLAGS"
  382. AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
  383. #include <sys/param.h>
  384. #include <sys/mount.h>])
  385. AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
  386. #include <sys/param.h>
  387. #include <sys/mount.h>])
  388. # For opendisk() and getrawpartition() on NetBSD.
  389. # Used in util/deviceiter.c and in util/hostdisk.c.
  390. AC_CHECK_HEADER([util.h], [
  391. AC_CHECK_LIB([util], [opendisk], [
  392. LIBUTIL="-lutil"
  393. AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
  394. ])
  395. AC_CHECK_LIB([util], [getrawpartition], [
  396. LIBUTIL="-lutil"
  397. AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
  398. ])
  399. ])
  400. AC_SUBST([LIBUTIL])
  401. AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
  402. SAVED_CFLAGS="$CFLAGS"
  403. CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
  404. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
  405. int va_arg_func (int fixed, va_list args);]], [[]])],
  406. [grub_cv_host_cc_wtrampolines=yes],
  407. [grub_cv_host_cc_wtrampolines=no])
  408. CFLAGS="$SAVED_CFLAGS"
  409. ])
  410. if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
  411. HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
  412. fi
  413. #
  414. # Check for host and build compilers.
  415. #
  416. HOST_CC=$CC
  417. AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
  418. test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
  419. BUILD_CPP="$BUILD_CC -E"
  420. case "$build_os" in
  421. haiku*) BUILD_LIBM= ;;
  422. *) BUILD_LIBM=-lm ;;
  423. esac
  424. dnl FIXME proper test seems to require too deep dive into Autoconf internals.
  425. dnl For now just list known platforms that we support.
  426. case "$build_os" in
  427. cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;;
  428. *) BUILD_EXEEXT= ;;
  429. esac
  430. AC_SUBST(BUILD_EXEEXT)
  431. # In some build environments like termux /bin/sh is not a valid
  432. # shebang. Use $SHELL instead if it's executable and /bin/sh isn't
  433. BUILD_SHEBANG=/bin/sh
  434. for she in /bin/sh "$SHELL"; do
  435. if test -x "$she" ; then
  436. BUILD_SHEBANG="$she"
  437. fi
  438. done
  439. AC_SUBST(BUILD_SHEBANG)
  440. # For gnulib.
  441. gl_INIT
  442. WARN_FLAGS="-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes"
  443. EXTRA_WARN_FLAGS="-Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2"
  444. HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
  445. AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
  446. SAVED_CFLAGS="$CFLAGS"
  447. grub_cv_cc_w_extra_flags=
  448. for x in $EXTRA_WARN_FLAGS; do
  449. CFLAGS="$HOST_CFLAGS $x -Werror"
  450. AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
  451. if test x$flag = x1 ; then
  452. grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
  453. fi
  454. done
  455. CFLAGS="$SAVED_CFLAGS"
  456. ])
  457. HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
  458. #
  459. # Check for target programs.
  460. #
  461. # Find tools for the target.
  462. if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
  463. tmp_ac_tool_prefix="$ac_tool_prefix"
  464. ac_tool_prefix=$target_alias-
  465. AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
  466. [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
  467. AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
  468. AC_CHECK_TOOL(TARGET_STRIP, strip)
  469. AC_CHECK_TOOL(TARGET_NM, nm)
  470. AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
  471. ac_tool_prefix="$tmp_ac_tool_prefix"
  472. else
  473. if test "x$TARGET_CC" = x; then
  474. TARGET_CC=$CC
  475. fi
  476. AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
  477. AC_CHECK_TOOL(TARGET_STRIP, strip)
  478. AC_CHECK_TOOL(TARGET_NM, nm)
  479. AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
  480. fi
  481. AC_SUBST(HOST_CC)
  482. AC_SUBST(BUILD_CC)
  483. AC_SUBST(BUILD_CFLAGS)
  484. AC_SUBST(BUILD_CPPFLAGS)
  485. AC_SUBST(BUILD_LDFLAGS)
  486. AC_SUBST(TARGET_CC)
  487. AC_SUBST(TARGET_NM)
  488. AC_SUBST(TARGET_RANLIB)
  489. AC_SUBST(TARGET_STRIP)
  490. AC_SUBST(TARGET_OBJCOPY)
  491. # Test the C compiler for the target environment.
  492. tmp_CC="$CC"
  493. tmp_CFLAGS="$CFLAGS"
  494. tmp_LDFLAGS="$LDFLAGS"
  495. tmp_CPPFLAGS="$CPPFLAGS"
  496. tmp_LIBS="$LIBS"
  497. CC="$TARGET_CC"
  498. CFLAGS="$TARGET_CFLAGS"
  499. CPPFLAGS="$TARGET_CPPFLAGS"
  500. LDFLAGS="$TARGET_LDFLAGS"
  501. LIBS=""
  502. if test "x$target_m32" = x1; then
  503. # Force 32-bit mode.
  504. TARGET_CFLAGS="$TARGET_CFLAGS -m32"
  505. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
  506. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
  507. TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
  508. TARGET_MODULE_FORMAT="elf32"
  509. fi
  510. if test "x$target_m64" = x1; then
  511. # Force 64-bit mode.
  512. TARGET_CFLAGS="$TARGET_CFLAGS -m64"
  513. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
  514. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
  515. TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
  516. TARGET_MODULE_FORMAT="elf64"
  517. fi
  518. # debug flags.
  519. TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
  520. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
  521. if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
  522. TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
  523. fi
  524. TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
  525. AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
  526. LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
  527. grub_cv_target_cc_w_extra_flags=
  528. for x in $EXTRA_WARN_FLAGS; do
  529. CFLAGS="$TARGET_CFLAGS $x -Werror"
  530. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  531. asm (".globl start; start:");
  532. void __main (void);
  533. void __main (void) {}
  534. int main (void);
  535. ]], [[]])], [flag=1], [flag=0])
  536. if test x$flag = x1 ; then
  537. grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
  538. fi
  539. done
  540. ])
  541. TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
  542. AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
  543. [
  544. CFLAGS="$TARGET_CFLAGS"
  545. AC_COMPILE_IFELSE(
  546. [AC_LANG_PROGRAM([], [[
  547. #ifdef __clang__
  548. #error "is clang"
  549. #endif
  550. ]])],
  551. [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
  552. if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
  553. AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
  554. grub_cv_target_cc_big_endian=no
  555. for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
  556. "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
  557. "-EB" "-mbig-endian"; do
  558. if test x"$grub_cv_target_cc_big_endian" != xno ; then
  559. break
  560. fi
  561. CFLAGS="$TARGET_CFLAGS $cand -Werror"
  562. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  563. #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
  564. #error still little endian
  565. #endif
  566. asm (".globl start; start:");
  567. asm (".globl _start; _start:");
  568. asm (".globl __start; __start:");
  569. void __main (void);
  570. void __main (void) {}
  571. int main (void);
  572. ]], [[]])],
  573. [grub_cv_target_cc_big_endian="$cand"], [])
  574. done
  575. ])
  576. if test x"$grub_cv_target_cc_big_endian" = xno ; then
  577. AC_MSG_ERROR([could not force big-endian])
  578. fi
  579. skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
  580. TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
  581. TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
  582. TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
  583. TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
  584. elif test x$target_cpu = xmipsel; then
  585. AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
  586. grub_cv_target_cc_little_endian=no
  587. for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
  588. "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
  589. "-EL"; do
  590. if test x"$grub_cv_target_cc_little_endian" != xno ; then
  591. break
  592. fi
  593. CFLAGS="$TARGET_CFLAGS $cand -Werror"
  594. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  595. #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
  596. #error still big endian
  597. #endif
  598. asm (".globl start; start:");
  599. asm (".globl _start; _start:");
  600. asm (".globl __start; __start:");
  601. void __main (void);
  602. void __main (void) {}
  603. int main (void);
  604. ]], [[]])],
  605. [grub_cv_target_cc_little_endian="$cand"], [])
  606. done
  607. ])
  608. if test x"$grub_cv_target_cc_little_endian" = xno ; then
  609. AC_MSG_ERROR([could not force little-endian])
  610. fi
  611. skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
  612. TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
  613. TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
  614. TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
  615. TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
  616. fi
  617. # GRUB code is N32-compliant but it's experimental and we would prefer to
  618. # avoid having too much variety when it doesn't result in any real improvement.
  619. # Moreover N64 isn't supported.
  620. if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
  621. AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
  622. grub_cv_target_cc_mips_o32_abi=no
  623. for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
  624. if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
  625. break
  626. fi
  627. CFLAGS="$TARGET_CFLAGS $arg -Werror"
  628. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  629. #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
  630. #error not o32 ABI
  631. #endif
  632. asm (".globl start; start:");
  633. asm (".globl _start; _start:");
  634. asm (".globl __start; __start:");
  635. void __main (void);
  636. void __main (void) {}
  637. int main (void);
  638. ]], [[]])],
  639. [grub_cv_target_cc_mips_o32_abi="$arg"], [])
  640. done
  641. ])
  642. if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
  643. AC_MSG_ERROR([could not force MIPS o32 ABI])
  644. fi
  645. TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
  646. TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
  647. fi
  648. AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
  649. test_program=
  650. case "x$target_cpu-$platform" in
  651. xmips-* | xmipsel-*)
  652. test_program=mips
  653. ;;
  654. xi386-pc)
  655. test_program=i386-pc
  656. ;;
  657. xi386-* | xx86_64-*)
  658. test_program=i386
  659. ;;
  660. xpowerpc-* | xsparc64-* | xarm-*)
  661. test_program=$target_cpu
  662. ;;
  663. esac
  664. if test x"$test_program" = x ; then
  665. grub_cv_cc_target_asm_compile=
  666. else
  667. found=no
  668. for arg in "" "-no-integrated-as"; do
  669. cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
  670. echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
  671. if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
  672. grub_cv_cc_target_asm_compile="$arg"
  673. found=yes
  674. break
  675. fi
  676. done
  677. if test x"$found" = xno ; then
  678. AC_MSG_ERROR([could not compile assembly])
  679. fi
  680. fi
  681. ])
  682. TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
  683. if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
  684. TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
  685. fi
  686. if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
  687. TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
  688. fi
  689. # on mips redirect cache flushing function to non-existant one.
  690. if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
  691. AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
  692. CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
  693. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  694. [grub_cv_cc_mflush_func=yes],
  695. [grub_cv_cc_mflush_func=no])
  696. ])
  697. if test "x$grub_cv_cc_mflush_func" = xyes; then
  698. TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
  699. fi
  700. AC_CACHE_CHECK([whether -mno-gpopt works], [grub_cv_cc_mno_gpopt], [
  701. CFLAGS="$TARGET_CFLAGS -mno-gpopt -Werror"
  702. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  703. [grub_cv_cc_mno_gpopt=yes],
  704. [grub_cv_cc_mno_gpopt=no])
  705. ])
  706. if test "x$grub_cv_cc_mno_gpopt" = xyes; then
  707. TARGET_CFLAGS="$TARGET_CFLAGS -mno-gpopt"
  708. fi
  709. fi
  710. # Force no alignment to save space on i386.
  711. if test "x$target_cpu" = xi386; then
  712. TARGET_CFLAGS="$TARGET_CFLAGS -falign-functions=1"
  713. AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
  714. CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
  715. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  716. [grub_cv_cc_falign_loop=yes],
  717. [grub_cv_cc_falign_loop=no])
  718. ])
  719. if test "x$grub_cv_cc_falign_loop" = xyes; then
  720. TARGET_CFLAGS="$TARGET_CFLAGS -falign-loops=1"
  721. fi
  722. AC_CACHE_CHECK([whether -falign-jumps works], [grub_cv_cc_falign_jumps], [
  723. CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -Werror"
  724. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  725. [grub_cv_cc_falign_jumps=yes],
  726. [grub_cv_cc_falign_jumps=no])
  727. ])
  728. if test "x$grub_cv_cc_falign_jumps" = xyes; then
  729. TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1"
  730. fi
  731. fi
  732. AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
  733. CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
  734. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  735. [grub_cv_cc_freg_struct_return=yes],
  736. [grub_cv_cc_freg_struct_return=no])
  737. ])
  738. if test "x$grub_cv_cc_freg_struct_return" = xyes; then
  739. TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
  740. fi
  741. if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
  742. # Some toolchains enable these features by default, but they need
  743. # registers that aren't set up properly in GRUB.
  744. TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
  745. fi
  746. if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ); then
  747. AC_CACHE_CHECK([whether -Wa,-mx86-used-note works], [grub_cv_cc_mx86_used_note], [
  748. CFLAGS="$TARGET_CFLAGS -Wa,-mx86-used-note=no -Werror"
  749. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  750. [grub_cv_cc_mx86_used_note=yes],
  751. [grub_cv_cc_mx86_used_note=no])
  752. ])
  753. if test "x$grub_cv_cc_mx86_used_note" = xyes; then
  754. TARGET_CFLAGS="$TARGET_CFLAGS -Wa,-mx86-used-note=no"
  755. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mx86-used-note=no"
  756. fi
  757. fi
  758. if test "x$target_cpu" = xloongarch64; then
  759. AC_CACHE_CHECK([whether _mno_explicit_relocs works], [grub_cv_cc_mno_explicit_relocs], [
  760. CFLAGS="$TARGET_CFLAGS -mno-explicit-relocs -Werror"
  761. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  762. [grub_cv_cc_mno_explicit_relocs=yes],
  763. [grub_cv_cc_mno_explicit_relocs=no])
  764. ])
  765. if test "x$grub_cv_cc_mno_explicit_relocs" = xyes; then
  766. TARGET_CFLAGS="$TARGET_CFLAGS -mno-explicit-relocs -fno-plt"
  767. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -mno-explicit-relocs -fno-plt"
  768. fi
  769. AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
  770. grub_cv_target_cc_mno_relax=no
  771. for cand in "-mno-relax" "-Wa,-mno-relax"; do
  772. if test x"$grub_cv_target_cc_mno_relax" != xno ; then
  773. break
  774. fi
  775. CFLAGS="$TARGET_CFLAGS $cand -Werror"
  776. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  777. asm (".globl start; start:");
  778. void __main (void);
  779. void __main (void) {}
  780. int main (void);
  781. ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
  782. done
  783. ])
  784. CFLAGS="$TARGET_CFLAGS"
  785. if test x"$grub_cv_target_cc_mno_relax" != xno ; then
  786. TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_relax"
  787. TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mno_relax"
  788. fi
  789. TARGET_CFLAGS="$TARGET_CFLAGS -Wa,-mla-global-with-abs"
  790. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mla-global-with-abs"
  791. fi
  792. # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
  793. # that floats are a good fit to run instead of what's written in the code.
  794. # Given that floating point unit is disabled (if present to begin with)
  795. # when GRUB is running which may result in various hard crashes.
  796. if test x"$platform" != xemu ; then
  797. AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
  798. grub_cv_target_cc_soft_float=no
  799. if test "x$target_cpu" = xarm64; then
  800. CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
  801. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  802. [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
  803. fi
  804. if test "x$target_cpu" = xriscv32; then
  805. CFLAGS="$TARGET_CFLAGS -march=rv32imac -mabi=ilp32 -Werror"
  806. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  807. [grub_cv_target_cc_soft_float="-march=rv32imac -mabi=ilp32"], [])
  808. # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
  809. CFLAGS="$TARGET_CFLAGS -march=rv32imac_zicsr_zifencei -mabi=ilp32 -Werror"
  810. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  811. [grub_cv_target_cc_soft_float="-march=rv32imac_zicsr_zifencei -mabi=ilp32"], [])
  812. fi
  813. if test "x$target_cpu" = xriscv64; then
  814. CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror"
  815. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  816. [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], [])
  817. # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
  818. CFLAGS="$TARGET_CFLAGS -march=rv64imac_zicsr_zifencei -mabi=lp64 -Werror"
  819. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  820. [grub_cv_target_cc_soft_float="-march=rv64imac_zicsr_zifencei -mabi=lp64"], [])
  821. fi
  822. if test "x$target_cpu" = xia64; then
  823. CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
  824. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  825. [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
  826. fi
  827. if test "x$target_cpu" = xsh4; then
  828. CFLAGS="$TARGET_CFLAGS -m4-nofpu -Werror"
  829. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  830. [grub_cv_target_cc_soft_float="-m4-nofpu"], [])
  831. fi
  832. for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
  833. "-Xclang -msoft-float -Xclang -no-implicit-float" \
  834. "-Xclang -msoft-float" "-msoft-float"; do
  835. if test x"$grub_cv_target_cc_soft_float" != xno ; then
  836. break
  837. fi
  838. CFLAGS="$TARGET_CFLAGS $cand -Werror"
  839. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  840. [grub_cv_target_cc_soft_float="$cand"], [])
  841. done
  842. ])
  843. if test x"$grub_cv_target_cc_soft_float" = xno ; then
  844. AC_MSG_ERROR([could not force soft-float])
  845. fi
  846. case x"$grub_cv_target_cc_soft_float" in
  847. x*"-Xclang"*)
  848. # A trick so that clang doesn't see it on link stаge
  849. TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
  850. ;;
  851. *)
  852. TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
  853. ;;
  854. esac
  855. TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
  856. fi
  857. if test x"$target_cpu" = xsparc64 ; then
  858. AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
  859. grub_cv_target_cc_mno_app_regs=no
  860. for cand in "-mllvm -sparc-reserve-app-registers" \
  861. "-mno-app-regs"; do
  862. if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
  863. break
  864. fi
  865. CFLAGS="$TARGET_CFLAGS $cand -Werror"
  866. CPPFLAGS="$TARGET_CPPFLAGS"
  867. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  868. [grub_cv_target_cc_mno_app_regs="$cand"], [])
  869. done
  870. ])
  871. if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
  872. AC_MSG_ERROR([could not reserve application registers])
  873. fi
  874. if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
  875. # A trick so that clang doesn't see it on link stаge
  876. TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
  877. else
  878. TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
  879. fi
  880. AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
  881. grub_cv_target_cc_mno_relax=no
  882. for cand in "-mno-relax" "-Wl,--no-relax"; do
  883. if test x"$grub_cv_target_cc_mno_relax" != xno ; then
  884. break
  885. fi
  886. LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
  887. CFLAGS="$TARGET_CFLAGS -Werror"
  888. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  889. asm (".globl start; start:");
  890. void __main (void);
  891. void __main (void) {}
  892. int main (void);
  893. ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
  894. done
  895. ])
  896. LDFLAGS="$TARGET_LDFLAGS"
  897. CFLAGS="$TARGET_CFLAGS"
  898. if test x"$grub_cv_target_cc_mno_relax" = xno ; then
  899. AC_MSG_ERROR([could not find no-relax options])
  900. fi
  901. TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
  902. fi
  903. # The backtrace module relies on frame pointers and the default optimization
  904. # level, -Os, omits them. Make sure they are enabled.
  905. AC_CACHE_CHECK([whether -fno-omit-frame-pointer works], [grub_cv_cc_fno_omit_frame_pointer], [
  906. CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer"
  907. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  908. [grub_cv_cc_fno_omit_frame_pointer=yes],
  909. [grub_cv_cc_fno_omit_frame_pointer=no])
  910. ])
  911. if test "x$grub_cv_cc_fno_omit_frame_pointer" = xyes; then
  912. TARGET_CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer"
  913. fi
  914. # By default, GCC 4.4 generates .eh_frame sections containing unwind
  915. # information in some cases where it previously did not. GRUB doesn't need
  916. # these and they just use up vital space. Restore the old compiler
  917. # behaviour.
  918. AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
  919. CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
  920. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  921. [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
  922. [grub_cv_cc_fno_dwarf2_cfi_asm=no])
  923. ])
  924. if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
  925. TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
  926. fi
  927. if test x"$target_os" = xcygwin; then
  928. AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
  929. CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
  930. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  931. [grub_cv_cc_no_reorder_functions=yes],
  932. [grub_cv_cc_no_reorder_functions=no])
  933. ])
  934. fi
  935. if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
  936. TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
  937. fi
  938. AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [
  939. CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
  940. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  941. [grub_cv_cc_mno_stack_arg_probe=yes],
  942. [grub_cv_cc_mno_stack_arg_probe=no])
  943. ])
  944. if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then
  945. TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
  946. fi
  947. # By default, GCC 4.6 generates .eh_frame sections containing unwind
  948. # information in some cases where it previously did not. GRUB doesn't need
  949. # these and they just use up vital space. Restore the old compiler
  950. # behaviour.
  951. AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
  952. CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
  953. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  954. [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
  955. [grub_cv_cc_fno_asynchronous_unwind_tables=no])
  956. ])
  957. if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
  958. TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
  959. fi
  960. AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
  961. CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
  962. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  963. [grub_cv_cc_fno_unwind_tables=yes],
  964. [grub_cv_cc_fno_unwind_tables=no])
  965. ])
  966. if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then
  967. TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
  968. fi
  969. # Do not generate .ident sections.
  970. AC_CACHE_CHECK([whether -fno-ident works], [grub_cv_cc_fno_ident], [
  971. CFLAGS="$TARGET_CFLAGS -fno-ident"
  972. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  973. [grub_cv_cc_fno_ident=yes],
  974. [grub_cv_cc_fno_ident=no])
  975. ])
  976. if test "x$grub_cv_cc_fno_ident" = xyes; then
  977. TARGET_CFLAGS="$TARGET_CFLAGS -fno-ident"
  978. fi
  979. CFLAGS="$TARGET_CFLAGS"
  980. if test x"$platform" = xemu ; then
  981. TARGET_OBJ2ELF=
  982. grub_cv_target_cc_link_format=
  983. case "$host_os" in
  984. *darwin* | *mac*)
  985. grub_cv_target_cc_link_format="-arch,${target_cpu}"
  986. TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
  987. ;;
  988. *windows* | *cygwin* | *mingw*)
  989. if test x${target_cpu} = xi386 ; then
  990. grub_cv_target_cc_link_format=-mi386pe
  991. TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
  992. fi
  993. if test x${target_cpu} = xx86_64 ; then
  994. grub_cv_target_cc_link_format=-mi386pep
  995. TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
  996. fi
  997. TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
  998. ;;
  999. esac
  1000. elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
  1001. AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
  1002. grub_cv_target_cc_link_format=unknown
  1003. for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do
  1004. if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then
  1005. continue
  1006. fi
  1007. if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then
  1008. continue
  1009. fi
  1010. CFLAGS="$TARGET_CFLAGS"
  1011. LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
  1012. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1013. asm (".globl start; start:");
  1014. asm (".globl _start; _start:");
  1015. asm (".globl __start; __start:");
  1016. void __main (void);
  1017. void __main (void) {}
  1018. ]], [[]])], [flag=1], [flag=0])
  1019. if test x"$flag" = x1; then
  1020. grub_cv_target_cc_link_format="$format"
  1021. break
  1022. fi
  1023. done])
  1024. if test x"$grub_cv_target_cc_link_format" = xunknown; then
  1025. AC_MSG_ERROR([no suitable link format found])
  1026. fi
  1027. TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
  1028. if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
  1029. TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
  1030. fi
  1031. if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
  1032. TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
  1033. fi
  1034. fi
  1035. if test x$grub_cv_target_cc_link_format = x-arch,i386 || test x$grub_cv_target_cc_link_format = x-arch,x86_64; then
  1036. TARGET_APPLE_LINKER=1
  1037. AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
  1038. if test "x$TARGET_OBJCONV" = x ; then
  1039. AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
  1040. fi
  1041. if test "x$TARGET_OBJCONV" = x ; then
  1042. AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
  1043. fi
  1044. TARGET_IMG_LDSCRIPT=
  1045. TARGET_IMG_CFLAGS="-static"
  1046. TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
  1047. TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
  1048. TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
  1049. TARGET_LDFLAGS_OLDMAGIC=""
  1050. elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then
  1051. TARGET_APPLE_LINKER=0
  1052. TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
  1053. TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/i386-cygwin-img-ld.sc"
  1054. TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
  1055. TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/i386-cygwin-img-ld.sc"
  1056. TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
  1057. TARGET_IMG_CFLAGS=
  1058. else
  1059. TARGET_APPLE_LINKER=0
  1060. TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
  1061. TARGET_IMG_LDSCRIPT=
  1062. TARGET_IMG_LDFLAGS='-Wl,-N'
  1063. TARGET_IMG_LDFLAGS_AC='-Wl,-N'
  1064. TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
  1065. TARGET_IMG_CFLAGS=
  1066. fi
  1067. CFLAGS="$TARGET_CFLAGS"
  1068. AC_ARG_ENABLE([efiemu],
  1069. [AS_HELP_STRING([--enable-efiemu],
  1070. [build and install the efiemu runtimes (default=guessed)])])
  1071. if test x"$enable_efiemu" = xno ; then
  1072. efiemu_excuse="explicitly disabled"
  1073. fi
  1074. if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
  1075. efiemu_excuse="not available on cygwin"
  1076. fi
  1077. if test x"$target_cpu" != xi386 ; then
  1078. efiemu_excuse="only available on i386"
  1079. fi
  1080. if test x"$platform" = xefi ; then
  1081. efiemu_excuse="not available on efi"
  1082. fi
  1083. if test x"$efiemu_excuse" = x ; then
  1084. AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
  1085. CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
  1086. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  1087. [grub_cv_cc_efiemu=yes],
  1088. [grub_cv_cc_efiemu=no])
  1089. ])
  1090. if test x$grub_cv_cc_efiemu = xno; then
  1091. efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
  1092. fi
  1093. fi
  1094. if test x"$efiemu_excuse" = x ; then
  1095. AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
  1096. grub_cv_target_cc_efiemu64_link_format=unknown
  1097. for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
  1098. CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
  1099. LDFLAGS="-m64 -Wl,$format -nostdlib -static"
  1100. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1101. asm (".globl start; start:");
  1102. asm (".globl _start; _start:");
  1103. asm (".globl __start; __start:");
  1104. void __main (void);
  1105. void __main (void) {}
  1106. ]], [[]])], [flag=1], [flag=0])
  1107. if test x"$flag" = x1; then
  1108. grub_cv_target_cc_efiemu64_link_format="$format"
  1109. break
  1110. fi
  1111. done])
  1112. if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
  1113. efiemu_excuse="no suitable link format for efiemu64 found"
  1114. else
  1115. EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
  1116. fi
  1117. fi
  1118. if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
  1119. AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
  1120. fi
  1121. if test x"$efiemu_excuse" = x ; then
  1122. enable_efiemu=yes
  1123. else
  1124. enable_efiemu=no
  1125. fi
  1126. AC_SUBST([enable_efiemu])
  1127. AC_SUBST([EFIEMU64_LINK_FORMAT])
  1128. CFLAGS="$TARGET_CFLAGS"
  1129. AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
  1130. LDFLAGS="$TARGET_LDFLAGS"
  1131. if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64 ; then
  1132. # Use large model to support 4G memory
  1133. AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
  1134. CFLAGS="$TARGET_CFLAGS -mcmodel=large"
  1135. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  1136. [grub_cv_cc_mcmodel=yes],
  1137. [grub_cv_cc_mcmodel=no])
  1138. ])
  1139. if test "x$grub_cv_cc_mcmodel" = xyes; then
  1140. TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
  1141. elif test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64; then
  1142. TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
  1143. fi
  1144. fi
  1145. if test "$target_cpu"-"$platform" = x86_64-efi; then
  1146. # EFI writes to stack below %rsp, we must not use the red zone
  1147. AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
  1148. CFLAGS="$TARGET_CFLAGS -mno-red-zone"
  1149. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  1150. [grub_cv_cc_no_red_zone=yes],
  1151. [grub_cv_cc_no_red_zone=no])
  1152. ])
  1153. if test "x$grub_cv_cc_no_red_zone" = xno; then
  1154. AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
  1155. fi
  1156. TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
  1157. fi
  1158. if test "x$target_cpu" = xarm; then
  1159. AC_CACHE_CHECK([for options to disable movt and movw], grub_cv_target_cc_mno_movt, [
  1160. grub_cv_target_cc_mno_movt=no
  1161. for cand in "-mno-movt" \
  1162. "-mllvm -arm-use-movt=0" \
  1163. "-mword-relocations"; do
  1164. if test x"$grub_cv_target_cc_mno_movt" != xno ; then
  1165. break
  1166. fi
  1167. CFLAGS="$TARGET_CFLAGS $cand -Werror"
  1168. CPPFLAGS="$TARGET_CPPFLAGS"
  1169. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  1170. [grub_cv_target_cc_mno_movt="$cand"], [])
  1171. done
  1172. ])
  1173. if test x"$grub_cv_target_cc_mno_movt" != xno ; then
  1174. # A trick so that clang doesn't see it on link stage
  1175. TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt"
  1176. fi
  1177. AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [
  1178. CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror"
  1179. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  1180. [grub_cv_cc_mthumb_interwork=yes],
  1181. [grub_cv_cc_mthumb_interwork=no])
  1182. ])
  1183. if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
  1184. TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
  1185. # Clang defaults to thumb interworking
  1186. elif test "x$grub_cv_cc_target_clang" = xno ; then
  1187. AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
  1188. fi
  1189. fi
  1190. AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
  1191. CFLAGS="$TARGET_CFLAGS -Qn -Qunused-arguments -Werror"
  1192. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  1193. [grub_cv_target_cc_qn=yes],
  1194. [grub_cv_target_cc_qn=no])])
  1195. if test "x$grub_cv_target_cc_qn" = xyes; then
  1196. TARGET_CFLAGS="$TARGET_CFLAGS -Qn -Qunused-arguments"
  1197. fi
  1198. #
  1199. # Compiler features.
  1200. #
  1201. CFLAGS="$TARGET_CFLAGS"
  1202. # Position independent executable.
  1203. grub_CHECK_PIE
  1204. grub_CHECK_NO_PIE
  1205. grub_CHECK_NO_PIE_ONEWORD
  1206. grub_CHECK_LINK_PIE
  1207. [# Need that, because some distributions ship compilers that include
  1208. # `-fPIE' or '-fpie' and '-pie' in the default specs.
  1209. if [ x"$pie_possible" = xyes ]; then
  1210. TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
  1211. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -fno-PIE -fno-pie"
  1212. fi
  1213. if [ x"$link_nopie_needed" = xyes ] || [ x"$pie_possible" = xyes ]; then
  1214. if [ x"$nopie_possible" = xyes ]; then
  1215. TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
  1216. fi
  1217. if [ x"$nopie_oneword_possible" = xyes ]; then
  1218. TARGET_LDFLAGS="$TARGET_LDFLAGS -nopie"
  1219. fi
  1220. fi]
  1221. CFLAGS="$TARGET_CFLAGS"
  1222. LDFLAGS="$TARGET_LDFLAGS"
  1223. # Position independent executable.
  1224. grub_CHECK_PIC
  1225. [# On most platforms we don't want PIC as it only makes relocations harder
  1226. # and code less efficient. On mips we want to have one got table per module
  1227. # and reload $gp in every function.
  1228. # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
  1229. # However with clang we need PIC for this reloading to happen.
  1230. # With arm64 we need relocations that are in some way representable in
  1231. # PE as we need to support arm64-efi. Without -fPIC clang generates
  1232. # movk's which aren't representable.
  1233. # Since default varies across dictributions use either -fPIC or -fno-PIC
  1234. # explicitly.
  1235. if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel || test x$target_cpu = xarm64 ) && test "x$grub_cv_cc_target_clang" = xyes ; then
  1236. TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
  1237. elif [ x"$pic_possible" = xyes ]; then
  1238. TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
  1239. fi]
  1240. CFLAGS="$TARGET_CFLAGS"
  1241. # Stack smashing protector.
  1242. grub_CHECK_STACK_PROTECTOR
  1243. AC_ARG_ENABLE([stack-protector],
  1244. AS_HELP_STRING([--enable-stack-protector],
  1245. [enable the stack protector]),
  1246. [],
  1247. [enable_stack_protector=no])
  1248. if test "x$enable_stack_protector" = xno; then
  1249. if test "x$ssp_possible" = xyes; then
  1250. # Need that, because some distributions ship compilers that include
  1251. # `-fstack-protector' in the default specs.
  1252. TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
  1253. fi
  1254. elif test "x$platform" != xefi; then
  1255. if test "$ERROR_PLATFORM_NOT_SUPPORT_SSP" = "yes"; then
  1256. AC_MSG_ERROR([--enable-stack-protector is only supported on EFI platforms])
  1257. else
  1258. AC_MSG_WARN([--enable-stack-protector is only supported on EFI platforms])
  1259. fi
  1260. enable_stack_protector=no
  1261. elif test "x$ssp_global_possible" != xyes; then
  1262. AC_MSG_ERROR([--enable-stack-protector is not supported (compiler doesn't support -mstack-protector-guard=global)])
  1263. else
  1264. TARGET_CFLAGS="$TARGET_CFLAGS -mstack-protector-guard=global"
  1265. if test "x$enable_stack_protector" = xyes; then
  1266. if test "x$ssp_possible" != xyes; then
  1267. AC_MSG_ERROR([--enable-stack-protector is not supported (compiler doesn't support -fstack-protector)])
  1268. fi
  1269. TARGET_CFLAGS="$TARGET_CFLAGS -fstack-protector"
  1270. elif test "x$enable_stack_protector" = xstrong; then
  1271. if test "x$ssp_strong_possible" != xyes; then
  1272. AC_MSG_ERROR([--enable-stack-protector=strong is not supported (compiler doesn't support -fstack-protector-strong)])
  1273. fi
  1274. TARGET_CFLAGS="$TARGET_CFLAGS -fstack-protector-strong"
  1275. else
  1276. # Note, -fstack-protector-all requires that the protector is disabled for
  1277. # functions that appear in the call stack when the canary is initialized.
  1278. AC_MSG_ERROR([invalid value $enable_stack_protector for --enable-stack-protector])
  1279. fi
  1280. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DGRUB_STACK_PROTECTOR=1"
  1281. if test -n "$SOURCE_DATE_EPOCH"; then
  1282. GRUB_STACK_PROTECTOR_INIT="0x00f2b7e2$(printf "%x" "$SOURCE_DATE_EPOCH" | sed 's/.*\(........\)$/\1/')"
  1283. elif test -r /dev/urandom; then
  1284. # Generate the 8 byte stack protector canary at build time if /dev/urandom
  1285. # is able to be read. The first byte should be NUL to filter out string
  1286. # buffer overflow attacks.
  1287. GRUB_STACK_PROTECTOR_INIT="$($PYTHON -c 'import codecs; rf=open("/dev/urandom", "rb"); print("0x00"+codecs.encode(rf.read(7), "hex").decode("ascii"))')"
  1288. else
  1289. # Some hosts may not have a urandom, e.g. Windows, so use statically
  1290. # generated random bytes
  1291. GRUB_STACK_PROTECTOR_INIT="0x00f2b7e2f193b25c"
  1292. fi
  1293. if test x"$target_m32" = x1 ; then
  1294. # Make sure that the canary default value is 24-bits by only using the
  1295. # lower 3 bytes on 32 bit systems. This allows the upper byte to be NUL
  1296. # to filter out string buffer overflow attacks.
  1297. GRUB_STACK_PROTECTOR_INIT="0x00$(echo "$GRUB_STACK_PROTECTOR_INIT" | sed 's/.*\(......\)$/\1/')"
  1298. fi
  1299. AC_SUBST([GRUB_STACK_PROTECTOR_INIT])
  1300. fi
  1301. CFLAGS="$TARGET_CFLAGS"
  1302. grub_CHECK_STACK_ARG_PROBE
  1303. # Cygwin's GCC uses alloca() to probe the stackframe on static
  1304. # stack allocations above some threshold.
  1305. if test x"$sap_possible" = xyes; then
  1306. TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
  1307. fi
  1308. CFLAGS="$TARGET_CFLAGS"
  1309. # -mno-unaligned-access -mstrict-align
  1310. if test "$target_cpu" = arm; then
  1311. AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
  1312. grub_cv_target_cc_strict_align=
  1313. for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
  1314. CFLAGS="$TARGET_CFLAGS $arg -Werror"
  1315. LDFLAGS="$TARGET_LDFLAGS"
  1316. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
  1317. if test x"$flag" = x1; then
  1318. grub_cv_target_cc_strict_align="$arg"
  1319. break
  1320. fi
  1321. done])
  1322. TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
  1323. if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
  1324. TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
  1325. fi
  1326. AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
  1327. [CFLAGS="$TARGET_CFLAGS"
  1328. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
  1329. #ifdef __ARM_FEATURE_UNALIGNED
  1330. #error "unaligned"
  1331. #endif
  1332. ]])],
  1333. [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
  1334. if test x$grub_cv_cc_target_emits_unaligned = xyes; then
  1335. AC_MSG_ERROR([compiler generates unaligned accesses])
  1336. fi
  1337. fi
  1338. # Set them to their new values for the tests below.
  1339. CC="$TARGET_CC"
  1340. CPPFLAGS="$TARGET_CPPFLAGS"
  1341. # Check for libgcc symbols
  1342. if test x"$platform" = xemu; then
  1343. CFLAGS="$TARGET_CFLAGS -Wno-error"
  1344. AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __clzdi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms)
  1345. fi
  1346. if test "x$TARGET_APPLE_LINKER" = x1 ; then
  1347. CFLAGS="$TARGET_CFLAGS -nostdlib -static"
  1348. else
  1349. CFLAGS="$TARGET_CFLAGS -nostdlib"
  1350. fi
  1351. LIBS=""
  1352. # Defined in acinclude.m4.
  1353. grub_ASM_USCORE
  1354. grub_PROG_TARGET_CC
  1355. if test "x$TARGET_APPLE_LINKER" != x1 ; then
  1356. grub_PROG_OBJCOPY_ABSOLUTE
  1357. fi
  1358. grub_PROG_LD_BUILD_ID_NONE
  1359. if test "x$target_cpu" = xi386; then
  1360. if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
  1361. if test ! -z "$TARGET_IMG_LDSCRIPT"; then
  1362. # Check symbols provided by linker script.
  1363. CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000"
  1364. fi
  1365. grub_CHECK_BSS_START_SYMBOL
  1366. grub_CHECK_END_SYMBOL
  1367. fi
  1368. CFLAGS="$TARGET_CFLAGS"
  1369. fi
  1370. grub_PROG_NM_WORKS
  1371. grub_PROG_NM_MINUS_P
  1372. grub_PROG_NM_DEFINED_ONLY
  1373. AC_SUBST(TARGET_NMFLAGS_MINUS_P)
  1374. AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
  1375. if test "$platform" != emu; then
  1376. AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
  1377. SAVED_CPPFLAGS="$CPPFLAGS"
  1378. CPPFLAGS="$TARGET_CPPFLAGS -nostdlib -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
  1379. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
  1380. #include <stddef.h>
  1381. int va_arg_func (int fixed, va_list args);]], [[]])],
  1382. [grub_cv_cc_isystem=yes],
  1383. [grub_cv_cc_isystem=no])
  1384. CPPFLAGS="$SAVED_CPPFLAGS"
  1385. ])
  1386. if test x"$grub_cv_cc_isystem" = xyes ; then
  1387. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
  1388. fi
  1389. fi
  1390. AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
  1391. CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
  1392. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
  1393. int va_arg_func (int fixed, va_list args);]], [[]])],
  1394. [grub_cv_cc_wtrampolines=yes],
  1395. [grub_cv_cc_wtrampolines=no])
  1396. ])
  1397. if test x"$grub_cv_cc_wtrampolines" = xyes ; then
  1398. TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
  1399. fi
  1400. # Restore the flags.
  1401. CC="$tmp_CC"
  1402. CFLAGS="$tmp_CFLAGS"
  1403. CPPFLAGS="$tmp_CPPFLAGS"
  1404. LDFLAGS="$tmp_LDFLAGS"
  1405. LIBS="$tmp_LIBS"
  1406. #
  1407. # Check for options.
  1408. #
  1409. # Memory manager debugging.
  1410. AC_ARG_ENABLE([mm-debug],
  1411. AS_HELP_STRING([--enable-mm-debug],
  1412. [include memory manager debugging]))
  1413. if test x$enable_mm_debug = xyes; then
  1414. MM_DEBUG=1
  1415. else
  1416. MM_DEBUG=0
  1417. fi
  1418. AC_SUBST([MM_DEBUG])
  1419. AM_CONDITIONAL([COND_MM_DEBUG], [test x$MM_DEBUG = x1])
  1420. AC_ARG_ENABLE([cache-stats],
  1421. AS_HELP_STRING([--enable-cache-stats],
  1422. [enable disk cache statistics collection]))
  1423. if test x$enable_cache_stats = xyes; then
  1424. DISK_CACHE_STATS=1
  1425. else
  1426. DISK_CACHE_STATS=0
  1427. fi
  1428. AC_SUBST([DISK_CACHE_STATS])
  1429. AC_ARG_ENABLE([boot-time],
  1430. AS_HELP_STRING([--enable-boot-time],
  1431. [enable boot time statistics collection]))
  1432. if test x$enable_boot_time = xyes; then
  1433. BOOT_TIME_STATS=1
  1434. else
  1435. BOOT_TIME_STATS=0
  1436. fi
  1437. AC_SUBST([BOOT_TIME_STATS])
  1438. AC_ARG_ENABLE([grub-emu-sdl2],
  1439. [AS_HELP_STRING([--enable-grub-emu-sdl2],
  1440. [build and install the `grub-emu' debugging utility with SDL2 support (default=guessed)])])
  1441. AC_ARG_ENABLE([grub-emu-sdl],
  1442. [AS_HELP_STRING([--enable-grub-emu-sdl],
  1443. [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
  1444. AC_ARG_ENABLE([grub-emu-pci],
  1445. [AS_HELP_STRING([--enable-grub-emu-pci],
  1446. [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
  1447. if test "$platform" = emu; then
  1448. if test x"$enable_grub_emu_sdl2" = xno ; then
  1449. grub_emu_sdl2_excuse="explicitly disabled"
  1450. fi
  1451. [if [ x"$grub_emu_sdl2_excuse" = x ]; then
  1452. # Check for libSDL libraries.]
  1453. PKG_CHECK_MODULES([SDL2], [sdl2], [
  1454. AC_DEFINE([HAVE_SDL2], [1], [Define to 1 if you have SDL2 library.])
  1455. AC_SUBST(HAVE_SDL2)],
  1456. [grub_emu_sdl2_excuse="libSDL2 libraries are required to build \`grub-emu' with SDL2 support"])
  1457. [fi]
  1458. if test x"$enable_grub_emu_sdl2" = xyes && test x"$grub_emu_sdl2_excuse" != x ; then
  1459. AC_MSG_ERROR([SDL2 support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl2_excuse)])
  1460. fi
  1461. if test x"$grub_emu_sdl2_excuse" = x ; then
  1462. enable_grub_emu_sdl2=yes
  1463. else
  1464. enable_grub_emu_sdl2=no
  1465. fi
  1466. if test x"$enable_grub_emu_sdl2" = xyes ; then
  1467. grub_emu_sdl_excuse="disabled by sdl2"
  1468. fi
  1469. if test x"$enable_grub_emu_sdl" = xno ; then
  1470. grub_emu_sdl_excuse="explicitly disabled"
  1471. fi
  1472. [if [ x"$grub_emu_sdl_excuse" = x ]; then
  1473. # Check for libSDL libraries.]
  1474. AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
  1475. [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
  1476. AC_SUBST([LIBSDL])
  1477. [fi]
  1478. [if [ x"$grub_emu_sdl_excuse" = x ]; then
  1479. # Check for headers.]
  1480. AC_CHECK_HEADERS([SDL/SDL.h], [],
  1481. [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
  1482. [fi]
  1483. if test x"$enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
  1484. AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
  1485. fi
  1486. if test x"$grub_emu_sdl_excuse" = x ; then
  1487. enable_grub_emu_sdl=yes
  1488. else
  1489. enable_grub_emu_sdl=no
  1490. fi
  1491. if test x"$enable_grub_emu_pci" != xyes ; then
  1492. grub_emu_pci_excuse="not enabled"
  1493. fi
  1494. [if [ x"$grub_emu_pci_excuse" = x ]; then
  1495. # Check for libpci libraries.]
  1496. AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
  1497. [grub_emu_pci_excuse=["need libpciaccess library"]])
  1498. AC_SUBST([LIBPCIACCESS])
  1499. [fi]
  1500. [if [ x"$grub_emu_pci_excuse" = x ]; then
  1501. # Check for headers.]
  1502. AC_CHECK_HEADERS([pciaccess.h], [],
  1503. [grub_emu_pci_excuse=["need libpciaccess headers"]])
  1504. [fi]
  1505. if test x"$grub_emu_pci_excuse" = x ; then
  1506. enable_grub_emu_pci=yes
  1507. else
  1508. enable_grub_emu_pci=no
  1509. fi
  1510. AC_SUBST([enable_grub_emu_sdl2])
  1511. AC_SUBST([enable_grub_emu_sdl])
  1512. AC_SUBST([enable_grub_emu_pci])
  1513. else
  1514. # Ignore --enable-emu-* if platform is not emu
  1515. enable_grub_emu_sdl2=no
  1516. enable_grub_emu_sdl=no
  1517. enable_grub_emu_pci=no
  1518. fi
  1519. AC_ARG_ENABLE([grub-mkfont],
  1520. [AS_HELP_STRING([--enable-grub-mkfont],
  1521. [build and install the `grub-mkfont' utility (default=guessed)])])
  1522. if test x"$enable_grub_mkfont" = xno ; then
  1523. grub_mkfont_excuse="explicitly disabled"
  1524. fi
  1525. unset ac_cv_header_ft2build_h
  1526. if test x"$grub_mkfont_excuse" = x ; then
  1527. # Check for freetype libraries.
  1528. PKG_CHECK_MODULES([FREETYPE], [freetype2], [
  1529. SAVED_CPPFLAGS="$CPPFLAGS"
  1530. SAVED_LIBS="$LIBS"
  1531. CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
  1532. LIBS="$LIBS $FREETYPE_LIBS"
  1533. AC_CHECK_HEADERS([ft2build.h], [],
  1534. [grub_mkfont_excuse=["need freetype2 headers"]])
  1535. AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
  1536. [grub_mkfont_excuse=["freetype2 library unusable"]])
  1537. CPPFLAGS="$SAVED_CPPFLAGS"
  1538. LIBS="$SAVED_LIBS"
  1539. ], [grub_mkfont_excuse=["need freetype2 library"]])
  1540. if test x"$grub_mkfont_excuse" = x && test x"$host_kernel" = xnetbsd ; then
  1541. FREETYPE_LIBS="$FREETYPE_LIBS -Wl,-R,/usr/pkg/lib" ;
  1542. fi
  1543. fi
  1544. if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
  1545. AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)])
  1546. fi
  1547. if test x"$grub_mkfont_excuse" = x ; then
  1548. enable_grub_mkfont=yes
  1549. else
  1550. enable_grub_mkfont=no
  1551. fi
  1552. AC_SUBST([enable_grub_mkfont])
  1553. SAVED_CC="$CC"
  1554. SAVED_CPP="$CPP"
  1555. SAVED_CFLAGS="$CFLAGS"
  1556. SAVED_CPPFLAGS="$CPPFLAGS"
  1557. SAVED_LDFLAGS="$LDFLAGS"
  1558. CC="$BUILD_CC"
  1559. CPP="$BUILD_CPP"
  1560. CFLAGS="$BUILD_CFLAGS"
  1561. CPPFLAGS="$BUILD_CPPFLAGS"
  1562. LDFLAGS="$BUILD_LDFLAGS"
  1563. unset ac_cv_c_bigendian
  1564. unset ac_cv_header_ft2build_h
  1565. AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
  1566. AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
  1567. AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
  1568. if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
  1569. AC_MSG_ERROR([couldnt determine build endianness])
  1570. fi
  1571. AC_SUBST([BUILD_SIZEOF_LONG])
  1572. AC_SUBST([BUILD_SIZEOF_VOID_P])
  1573. AC_SUBST([BUILD_WORDS_BIGENDIAN])
  1574. if test x"$grub_build_mkfont_excuse" = x ; then
  1575. # Check for freetype libraries.
  1576. SAVED_PKG_CONFIG="$PKG_CONFIG"
  1577. test -z "$BUILD_PKG_CONFIG" || PKG_CONFIG="$BUILD_PKG_CONFIG"
  1578. PKG_CHECK_MODULES([BUILD_FREETYPE], [freetype2], [
  1579. SAVED_CPPFLAGS_2="$CPPFLAGS"
  1580. SAVED_LIBS="$LIBS"
  1581. CPPFLAGS="$CPPFLAGS $BUILD_FREETYPE_CFLAGS"
  1582. LIBS="$LIBS $BUILD_FREETYPE_LIBS"
  1583. AC_CHECK_HEADERS([ft2build.h], [],
  1584. [grub_build_mkfont_excuse=["need freetype2 headers"]])
  1585. AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
  1586. [grub_build_mkfont_excuse=["freetype2 library unusable"]])
  1587. LIBS="$SAVED_LIBS"
  1588. CPPFLAGS="$SAVED_CPPFLAGS_2"
  1589. ], [grub_build_mkfont_excuse=["need freetype2 library"]])
  1590. if test x"$grub_build_mkfont_excuse" = x ; then
  1591. case x"$build_os" in
  1592. xnetbsd*) BUILD_FREETYPE_LIBS="$BUILD_FREETYPE_LIBS -Wl,-R,/usr/pkg/lib" ;;
  1593. esac
  1594. fi
  1595. PKG_CONFIG="$SAVED_PKG_CONFIG"
  1596. fi
  1597. if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
  1598. AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)])
  1599. fi
  1600. if test x"$grub_build_mkfont_excuse" = x ; then
  1601. enable_build_grub_mkfont=yes
  1602. else
  1603. enable_build_grub_mkfont=no
  1604. fi
  1605. if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
  1606. if test x"$grub_build_mkfont_excuse" = x ; then
  1607. AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont])
  1608. else
  1609. AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)])
  1610. fi
  1611. fi
  1612. CC="$SAVED_CC"
  1613. CPP="$SAVED_CPP"
  1614. CFLAGS="$SAVED_CFLAGS"
  1615. CPPFLAGS="$SAVED_CPPFLAGS"
  1616. LDFLAGS="$SAVED_LDFLAGS"
  1617. starfield_excuse=
  1618. AC_ARG_ENABLE([grub-themes],
  1619. [AS_HELP_STRING([--enable-grub-themes],
  1620. [build and install GRUB themes (default=guessed)])])
  1621. if test x"$enable_grub_themes" = xno ; then
  1622. starfield_excuse="explicitly disabled"
  1623. fi
  1624. if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
  1625. starfield_excuse="No build-time grub-mkfont"
  1626. fi
  1627. AC_ARG_WITH([dejavufont],
  1628. AS_HELP_STRING([--with-dejavufont=FILE],
  1629. [set the DejeVu source [[guessed]]]))
  1630. if test "x$with_dejavufont" = x; then
  1631. # search in well-known directories
  1632. if test x"$starfield_excuse" = x; then
  1633. for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
  1634. for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype /usr/pkg/share/fonts/X11/TTF /usr/local/share/fonts/dejavu /usr/X11R6/lib/X11/fonts/TTF /usr/share/fonts/dejavu-sans-fonts /usr/share/fonts/truetype/dejavu; do
  1635. if test -f "$dir/DejaVuSans.$ext"; then
  1636. DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
  1637. break 2
  1638. fi
  1639. done
  1640. done
  1641. if test "x$DJVU_FONT_SOURCE" = x; then
  1642. starfield_excuse="No DejaVu found"
  1643. fi
  1644. fi
  1645. else
  1646. DJVU_FONT_SOURCE="$with_dejavufont"
  1647. fi
  1648. if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
  1649. AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)])
  1650. fi
  1651. AC_SUBST([DJVU_FONT_SOURCE])
  1652. AC_ARG_WITH([unifont],
  1653. AS_HELP_STRING([--with-unifont=FILE],
  1654. [set the unifont source [[guessed]]]))
  1655. if test "x$with_unifont" = x; then
  1656. # search in well-known directories
  1657. for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz otf otf.gz; do
  1658. for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc /usr/pkg/share/fonts/X11/misc /usr/local/share/fonts/gnu-unifont /usr/local/share/fonts/unifont; do
  1659. if test -f "$dir/unifont.$ext"; then
  1660. md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
  1661. # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
  1662. if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
  1663. continue
  1664. fi
  1665. FONT_SOURCE="$dir/unifont.$ext"
  1666. break 2
  1667. fi
  1668. done
  1669. done
  1670. else
  1671. FONT_SOURCE="$with_unifont"
  1672. fi
  1673. if test x"$enable_build_grub_mkfont" = xno ; then
  1674. FONT_SOURCE=
  1675. fi
  1676. if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
  1677. if test x"$grub_build_mkfont_excuse" = x ; then
  1678. AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont])
  1679. else
  1680. AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
  1681. fi
  1682. fi
  1683. AC_SUBST([FONT_SOURCE])
  1684. if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
  1685. grub_build_mkfont_excuse="no fonts"
  1686. fi
  1687. AC_ARG_ENABLE([grub-mount],
  1688. [AS_HELP_STRING([--enable-grub-mount],
  1689. [build and install the `grub-mount' utility (default=guessed)])])
  1690. if test x"$enable_grub_mount" = xno ; then
  1691. grub_mount_excuse="explicitly disabled"
  1692. fi
  1693. if test x"$grub_mount_excuse" = x ; then
  1694. PKG_CHECK_MODULES([FUSE], [fuse3], [FUSE_CFLAGS="$FUSE_CFLAGS -DFUSE_USE_VERSION=32"], [
  1695. PKG_CHECK_MODULES([FUSE], [fuse], [FUSE_CFLAGS="$FUSE_CFLAGS -DFUSE_USE_VERSION=26"], [
  1696. grub_mount_excuse="need fuse or fuse3 libraries"
  1697. ])
  1698. ])
  1699. fi
  1700. if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
  1701. AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)])
  1702. fi
  1703. if test x"$grub_mount_excuse" = x ; then
  1704. enable_grub_mount=yes
  1705. else
  1706. enable_grub_mount=no
  1707. fi
  1708. AC_SUBST([enable_grub_mount])
  1709. AC_ARG_ENABLE([device-mapper],
  1710. [AS_HELP_STRING([--enable-device-mapper],
  1711. [enable Linux device-mapper support (default=guessed)])])
  1712. if test x"$enable_device_mapper" = xno ; then
  1713. device_mapper_excuse="explicitly disabled"
  1714. fi
  1715. if test x"$device_mapper_excuse" = x ; then
  1716. # Check for device-mapper header.
  1717. AC_CHECK_HEADER([libdevmapper.h], [],
  1718. [device_mapper_excuse="need libdevmapper header"])
  1719. fi
  1720. if test x"$device_mapper_excuse" = x ; then
  1721. # Check for device-mapper library.
  1722. AC_CHECK_LIB([devmapper], [dm_task_create], [],
  1723. [device_mapper_excuse="need devmapper library"])
  1724. fi
  1725. if test x"$device_mapper_excuse" = x ; then
  1726. # Check for device-mapper library.
  1727. AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
  1728. [],
  1729. [device_mapper_excuse="need devmapper library"])
  1730. fi
  1731. if test x"$device_mapper_excuse" = x ; then
  1732. LIBDEVMAPPER="-ldevmapper"
  1733. AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
  1734. [Define to 1 if you have the devmapper library.])
  1735. fi
  1736. AC_SUBST([LIBDEVMAPPER])
  1737. LIBGEOM=
  1738. if test x$host_kernel = xkfreebsd; then
  1739. AC_CHECK_LIB([geom], [geom_gettree], [],
  1740. [AC_MSG_ERROR([Your platform requires libgeom])])
  1741. LIBGEOM="-lgeom"
  1742. fi
  1743. AC_SUBST([LIBGEOM])
  1744. AC_ARG_ENABLE([liblzma],
  1745. [AS_HELP_STRING([--enable-liblzma],
  1746. [enable liblzma integration (default=guessed)])])
  1747. if test x"$enable_liblzma" = xno ; then
  1748. liblzma_excuse="explicitly disabled"
  1749. fi
  1750. if test x"$liblzma_excuse" = x ; then
  1751. AC_CHECK_LIB([lzma], [lzma_code],
  1752. [],[liblzma_excuse="need lzma library"])
  1753. fi
  1754. if test x"$liblzma_excuse" = x ; then
  1755. AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
  1756. fi
  1757. if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
  1758. AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)])
  1759. fi
  1760. if test x"$liblzma_excuse" = x ; then
  1761. LIBLZMA="-llzma"
  1762. AC_DEFINE([USE_LIBLZMA], [1],
  1763. [Define to 1 if you have the LZMA library.])
  1764. fi
  1765. AC_SUBST([LIBLZMA])
  1766. AC_ARG_ENABLE([libzfs],
  1767. [AS_HELP_STRING([--enable-libzfs],
  1768. [enable libzfs integration (default=guessed)])])
  1769. if test x"$enable_libzfs" = xno ; then
  1770. libzfs_excuse="explicitly disabled"
  1771. fi
  1772. if test x"$libzfs_excuse" = x ; then
  1773. # Only check for system headers if libzfs support has not been disabled.
  1774. AC_CHECK_HEADERS(libzfs.h libnvpair.h)
  1775. fi
  1776. if test x"$libzfs_excuse" = x ; then
  1777. AC_CHECK_LIB([zfs], [libzfs_init],
  1778. [],
  1779. [libzfs_excuse="need zfs library"])
  1780. fi
  1781. if test x"$libzfs_excuse" = x ; then
  1782. AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
  1783. [have_normal_nvpair=yes],
  1784. [have_normal_nvpair=no])
  1785. if test x"$have_normal_nvpair" = xno ; then
  1786. AC_CHECK_LIB([nvpair], [opensolaris_nvlist_lookup_string],
  1787. [have_prefixed_nvpair=yes],
  1788. [have_prefixed_nvpair=no])
  1789. if test x"$have_prefixed_nvpair" = xyes ; then
  1790. AC_DEFINE([GRUB_UTIL_NVPAIR_IS_PREFIXED], [1],
  1791. [Define to 1 if libnvpair symbols are prefixed with opensolaris_.])
  1792. else
  1793. libzfs_excuse="need nvpair library"
  1794. fi
  1795. fi
  1796. fi
  1797. if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
  1798. AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)])
  1799. fi
  1800. if test x"$libzfs_excuse" = x ; then
  1801. # We need both libzfs and libnvpair for a successful build.
  1802. LIBZFS="-lzfs"
  1803. LIBNVPAIR="-lnvpair"
  1804. AC_DEFINE([USE_LIBZFS], [1],
  1805. [Define to 1 if ZFS library should be used.])
  1806. fi
  1807. AC_SUBST([LIBZFS])
  1808. AC_SUBST([LIBNVPAIR])
  1809. LIBS=""
  1810. AC_SUBST([FONT_SOURCE])
  1811. AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
  1812. [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
  1813. AC_SUBST(HAVE_ASM_USCORE)
  1814. AC_SUBST(BSS_START_SYMBOL)
  1815. AC_SUBST(END_SYMBOL)
  1816. AC_SUBST(PACKAGE)
  1817. AC_SUBST(VERSION)
  1818. AC_ARG_ENABLE([werror],
  1819. [AS_HELP_STRING([--disable-werror],
  1820. [do not use -Werror when building GRUB])])
  1821. if test x"$enable_werror" != xno ; then
  1822. TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
  1823. HOST_CFLAGS="$HOST_CFLAGS -Werror"
  1824. if test "x$grub_cv_cc_target_clang" = xyes; then
  1825. TARGET_CFLAGS="$TARGET_CFLAGS -Wno-error=vla"
  1826. HOST_CFLAGS="$HOST_CFLAGS -Wno-error=vla"
  1827. fi
  1828. fi
  1829. TARGET_CPP="$TARGET_CC -E"
  1830. TARGET_CCAS=$TARGET_CC
  1831. # Includes which include make-time substitutions. They must come last
  1832. # as to avoid executing top_builddir in shell.
  1833. HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
  1834. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
  1835. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
  1836. GRUB_TARGET_CPU="${target_cpu}"
  1837. GRUB_PLATFORM="${platform}"
  1838. AC_SUBST(GRUB_TARGET_CPU)
  1839. AC_SUBST(GRUB_PLATFORM)
  1840. AC_SUBST(TARGET_OBJCONV)
  1841. AC_SUBST(TARGET_CPP)
  1842. AC_SUBST(TARGET_CCAS)
  1843. AC_SUBST(TARGET_OBJ2ELF)
  1844. AC_SUBST(TARGET_MODULE_FORMAT)
  1845. AC_SUBST(TARGET_CC_VERSION)
  1846. AC_SUBST(TARGET_CFLAGS)
  1847. AC_SUBST(TARGET_LDFLAGS)
  1848. AC_SUBST(TARGET_CPPFLAGS)
  1849. AC_SUBST(TARGET_CCASFLAGS)
  1850. AC_SUBST(TARGET_IMG_LDFLAGS)
  1851. AC_SUBST(TARGET_IMG_CFLAGS)
  1852. AC_SUBST(TARGET_IMG_BASE_LDOPT)
  1853. AC_SUBST(TARGET_APPLE_LINKER)
  1854. AC_SUBST(HOST_CFLAGS)
  1855. AC_SUBST(HOST_LDFLAGS)
  1856. AC_SUBST(HOST_CPPFLAGS)
  1857. AC_SUBST(HOST_CCASFLAGS)
  1858. AC_SUBST(BUILD_LIBM)
  1859. #
  1860. # Automake conditionals
  1861. #
  1862. AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
  1863. AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
  1864. AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
  1865. AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
  1866. AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot])
  1867. AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
  1868. AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
  1869. AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
  1870. AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
  1871. AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
  1872. AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
  1873. AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
  1874. AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
  1875. AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
  1876. AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
  1877. AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
  1878. AM_CONDITIONAL([COND_i386_xen_pvh], [test x$target_cpu = xi386 -a x$platform = xxen_pvh])
  1879. AM_CONDITIONAL([COND_loongarch64], [test x$target_cpu = xloongarch64])
  1880. AM_CONDITIONAL([COND_loongarch64_efi], [test x$target_cpu = xloongarch64 -a x$platform = xefi])
  1881. AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
  1882. AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
  1883. AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
  1884. AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
  1885. AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
  1886. AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
  1887. AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
  1888. AM_CONDITIONAL([COND_riscv32], [test x$target_cpu = xriscv32 ])
  1889. AM_CONDITIONAL([COND_riscv64], [test x$target_cpu = xriscv64 ])
  1890. AM_CONDITIONAL([COND_riscv32_efi], [test x$target_cpu = xriscv32 -a x$platform = xefi])
  1891. AM_CONDITIONAL([COND_riscv64_efi], [test x$target_cpu = xriscv64 -a x$platform = xefi])
  1892. AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
  1893. AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
  1894. AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
  1895. AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
  1896. AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
  1897. AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
  1898. AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
  1899. AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
  1900. AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
  1901. AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
  1902. AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
  1903. AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
  1904. AM_CONDITIONAL([COND_GRUB_EMU_SDL2], [test x$enable_grub_emu_sdl2 = xyes])
  1905. AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
  1906. AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
  1907. AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
  1908. AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
  1909. AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
  1910. if test x$FONT_SOURCE != x ; then
  1911. HAVE_FONT_SOURCE=1
  1912. else
  1913. HAVE_FONT_SOURCE=0
  1914. fi
  1915. AC_SUBST(HAVE_FONT_SOURCE)
  1916. AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
  1917. AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
  1918. AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
  1919. AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
  1920. AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
  1921. AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
  1922. AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
  1923. AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
  1924. AM_CONDITIONAL([COND_HAVE_PCI], [test "x$have_pci" = xy])
  1925. test "x$prefix" = xNONE && prefix="$ac_default_prefix"
  1926. test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
  1927. datarootdir="$(eval echo "$datarootdir")"
  1928. grub_libdir="$(eval echo "$libdir")"
  1929. grub_localedir="$(eval echo "$localedir")"
  1930. grub_datadir="$(eval echo "$datadir")"
  1931. grub_sysconfdir="$(eval echo "$sysconfdir")"
  1932. AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
  1933. AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
  1934. AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
  1935. AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
  1936. # Output files.
  1937. if test "$platform" != none; then
  1938. cpudir="${target_cpu}"
  1939. if test x${cpudir} = xmipsel; then
  1940. cpudir=mips;
  1941. fi
  1942. grub_CHECK_LINK_DIR
  1943. if test x"$link_dir" = xyes ; then
  1944. AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
  1945. if test "$platform" != emu ; then
  1946. AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
  1947. fi
  1948. else
  1949. mkdir -p include/grub 2>/dev/null
  1950. rm -rf include/grub/cpu
  1951. cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
  1952. if test "$platform" != emu ; then
  1953. rm -rf include/grub/machine
  1954. cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
  1955. fi
  1956. fi
  1957. else
  1958. # Just enough to stop the compiler failing with -I$(srcdir)/include.
  1959. mkdir -p include 2>/dev/null
  1960. rm -rf include/grub/cpu include/grub/machine
  1961. fi
  1962. AC_CONFIG_FILES([Makefile])
  1963. AC_CONFIG_FILES([grub-core/Makefile])
  1964. AC_CONFIG_FILES([grub-core/lib/gnulib/Makefile])
  1965. AC_CONFIG_FILES([po/Makefile.in])
  1966. AC_CONFIG_FILES([docs/Makefile])
  1967. AC_CONFIG_FILES([util/bash-completion.d/Makefile])
  1968. AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
  1969. AC_CONFIG_FILES([config.h])
  1970. AC_OUTPUT
  1971. [
  1972. echo "*******************************************************"
  1973. echo GRUB2 will be compiled with following components:
  1974. echo Platform: "$target_cpu"-"$platform"
  1975. if [ x"$platform" = xemu ]; then
  1976. if [ x"$grub_emu_sdl2_excuse" = x ]; then
  1977. echo SDL2 support for grub-emu: Yes
  1978. else
  1979. echo SDL2 support for grub-emu: No "($grub_emu_sdl2_excuse)"
  1980. fi
  1981. if [ x"$grub_emu_sdl_excuse" = x ]; then
  1982. echo SDL support for grub-emu: Yes
  1983. else
  1984. echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
  1985. fi
  1986. if [ x"$grub_emu_pci_excuse" = x ]; then
  1987. echo PCI support for grub-emu: Yes
  1988. else
  1989. echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
  1990. fi
  1991. fi
  1992. if test x"$device_mapper_excuse" = x ; then
  1993. echo With devmapper support: Yes
  1994. else
  1995. echo With devmapper support: No "($device_mapper_excuse)"
  1996. fi
  1997. if [ x"$enable_mm_debug" = xyes ]; then
  1998. echo With memory debugging: Yes
  1999. else
  2000. echo With memory debugging: No
  2001. fi
  2002. if [ x"$enable_cache_stats" = xyes ]; then
  2003. echo With disk cache statistics: Yes
  2004. else
  2005. echo With disk cache statistics: No
  2006. fi
  2007. if [ x"$enable_boot_time" = xyes ]; then
  2008. echo With boot time statistics: Yes
  2009. else
  2010. echo With boot time statistics: No
  2011. fi
  2012. if [ x"$efiemu_excuse" = x ]; then
  2013. echo efiemu runtime: Yes
  2014. else
  2015. echo efiemu runtime: No "($efiemu_excuse)"
  2016. fi
  2017. if [ x"$grub_mkfont_excuse" = x ]; then
  2018. echo grub-mkfont: Yes
  2019. else
  2020. echo grub-mkfont: No "($grub_mkfont_excuse)"
  2021. fi
  2022. if [ x"$grub_mount_excuse" = x ]; then
  2023. echo grub-mount: Yes
  2024. else
  2025. echo grub-mount: No "($grub_mount_excuse)"
  2026. fi
  2027. if [ x"$starfield_excuse" = x ]; then
  2028. echo starfield theme: Yes
  2029. echo With DejaVuSans font from $DJVU_FONT_SOURCE
  2030. else
  2031. echo starfield theme: No "($starfield_excuse)"
  2032. fi
  2033. if [ x"$libzfs_excuse" = x ]; then
  2034. echo With libzfs support: Yes
  2035. else
  2036. echo With libzfs support: No "($libzfs_excuse)"
  2037. fi
  2038. if [ x"$grub_build_mkfont_excuse" = x ]; then
  2039. echo Build-time grub-mkfont: Yes
  2040. if test "x$FONT_SOURCE" = x ; then
  2041. echo "Without unifont"
  2042. else
  2043. echo "With unifont from $FONT_SOURCE"
  2044. fi
  2045. else
  2046. echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
  2047. echo "Without unifont (no build-time grub-mkfont)"
  2048. fi
  2049. if test x"$liblzma_excuse" != x ; then
  2050. echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
  2051. else
  2052. echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
  2053. fi
  2054. if test "x$enable_stack_protector" != xno; then
  2055. echo "With stack smashing protector: Yes"
  2056. else
  2057. echo "With stack smashing protector: No"
  2058. fi
  2059. echo "*******************************************************"
  2060. ]