configure.ac 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  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 type as well as the build type,
  27. dnl because GRUB does not need to use those variables for the build
  28. dnl type, so there is no conflict. Variables with the prefix "TARGET_"
  29. dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
  30. dnl type.
  31. AC_INIT([GRUB],[2.00],[bug-grub@gnu.org])
  32. AC_CONFIG_AUX_DIR([build-aux])
  33. # We don't want -g -O2 by default in CFLAGS
  34. : ${CFLAGS=""}
  35. # Checks for host and target systems.
  36. AC_CANONICAL_HOST
  37. AC_CANONICAL_TARGET
  38. AM_INIT_AUTOMAKE()
  39. AC_PREREQ(2.60)
  40. AC_CONFIG_SRCDIR([include/grub/dl.h])
  41. AC_CONFIG_HEADER([config-util.h])
  42. # Program name transformations
  43. AC_ARG_PROGRAM
  44. # Optimization flag. Allow user to override.
  45. if test "x$TARGET_CFLAGS" = x; then
  46. TARGET_CFLAGS="$TARGET_CFLAGS -Os"
  47. fi
  48. # Default HOST_CPPFLAGS
  49. HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
  50. HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
  51. HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
  52. HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\""
  53. HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
  54. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
  55. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
  56. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
  57. case "$target_cpu" in
  58. i[[3456]]86) target_cpu=i386 ;;
  59. amd64) target_cpu=x86_64 ;;
  60. sparc) target_cpu=sparc64 ;;
  61. mipsel|mips64el)
  62. target_cpu=mipsel;
  63. machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
  64. ;;
  65. mips|mips64)
  66. target_cpu=mips;
  67. machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
  68. ;;
  69. esac
  70. # Specify the platform (such as firmware).
  71. AC_ARG_WITH([platform],
  72. AS_HELP_STRING([--with-platform=PLATFORM],
  73. [select the host platform [[guessed]]]))
  74. # Guess the platform if not specified.
  75. if test "x$with_platform" = x; then
  76. case "$target_cpu"-"$target_vendor" in
  77. i386-apple) platform=efi ;;
  78. i386-*) platform=pc ;;
  79. x86_64-apple) platform=efi ;;
  80. x86_64-*) platform=pc ;;
  81. powerpc-*) platform=ieee1275 ;;
  82. powerpc64-*) platform=ieee1275 ;;
  83. sparc64-*) platform=ieee1275 ;;
  84. mipsel-*) platform=loongson ;;
  85. mips-*) platform=arc ;;
  86. ia64-*) platform=efi ;;
  87. *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
  88. esac
  89. else
  90. platform="$with_platform"
  91. fi
  92. case "$target_cpu"-"$platform" in
  93. x86_64-efi) ;;
  94. x86_64-emu) ;;
  95. x86_64-*) target_cpu=i386 ;;
  96. powerpc64-ieee1275) target_cpu=powerpc ;;
  97. esac
  98. # Check if the platform is supported, make final adjustments.
  99. case "$target_cpu"-"$platform" in
  100. i386-efi) ;;
  101. x86_64-efi) ;;
  102. i386-pc) ;;
  103. i386-multiboot) ;;
  104. i386-coreboot) ;;
  105. i386-linuxbios) platform=coreboot ;;
  106. i386-ieee1275) ;;
  107. i386-qemu) ;;
  108. powerpc-ieee1275) ;;
  109. sparc64-ieee1275) ;;
  110. ia64-efi) ;;
  111. mips-qemu_mips) ;;
  112. mips-qemu-mips) platform=qemu_mips;;
  113. mips-arc) ;;
  114. mipsel-qemu_mips) ;;
  115. mipsel-qemu-mips) platform=qemu_mips;;
  116. mipsel-yeeloong) platform=loongson ;;
  117. mipsel-fuloong) platform=loongson ;;
  118. mipsel-loongson) ;;
  119. *-emu) ;;
  120. *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
  121. esac
  122. case "$target_cpu" in
  123. i386 | powerpc) target_m32=1 ;;
  124. x86_64 | sparc64) target_m64=1 ;;
  125. esac
  126. case "$host_os" in
  127. mingw32*) host_os=cygwin ;;
  128. esac
  129. # This normalizes the names, and creates a new variable ("host_kernel")
  130. # while at it, since the mapping is not always 1:1 (e.g. different OSes
  131. # using the same kernel type).
  132. case "$host_os" in
  133. gnu*) host_kernel=hurd ;;
  134. linux*) host_kernel=linux ;;
  135. freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
  136. netbsd*) host_kernel=netbsd ;;
  137. solaris*) host_kernel=illumos ;;
  138. darwin*) host_kernel=xnu ;;
  139. cygwin) host_kernel=windows ;;
  140. esac
  141. case "$platform" in
  142. coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
  143. multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
  144. efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
  145. ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
  146. qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
  147. pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
  148. emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
  149. loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
  150. qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
  151. arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
  152. esac
  153. case "$target_cpu" in
  154. mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
  155. sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
  156. esac
  157. if test x${target_cpu} = xmipsel ; then
  158. machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
  159. else
  160. machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,` -DGRUB_TARGET_CPU_`echo ${target_cpu} | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`=1"
  161. fi
  162. TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
  163. AC_SUBST(host_cpu)
  164. AC_SUBST(host_os)
  165. AC_SUBST(host_kernel)
  166. AC_SUBST(target_cpu)
  167. AC_SUBST(platform)
  168. # Define default variables
  169. have_with_bootdir=n
  170. AC_ARG_WITH([bootdir],
  171. AS_HELP_STRING([--with-bootdir=DIR],
  172. [set the name of /boot directory [[guessed]]]),
  173. [have_with_bootdir=y],
  174. [have_with_bootdir=n])
  175. if test x$have_with_bootdir = xy; then
  176. bootdirname="$with_bootdir"
  177. else
  178. case "$host_os" in
  179. netbsd* | openbsd*)
  180. # Because /boot is used for the boot block in NetBSD and OpenBSD,
  181. bootdirname='' ;;
  182. *) bootdirname='boot' ;;
  183. esac
  184. fi
  185. AC_SUBST(bootdirname)
  186. AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
  187. [Default boot directory name]")
  188. AC_ARG_WITH([grubdir],
  189. AS_HELP_STRING([--with-grubdir=DIR],
  190. [set the name of grub directory [[guessed]]]),
  191. [grubdirname="$with_grubdir"],
  192. [grubdirname="$PACKAGE"])
  193. AC_SUBST(grubdirname)
  194. AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
  195. [Default grub directory name])
  196. #
  197. # Checks for build programs.
  198. #
  199. # Although cmp is listed in the GNU Coding Standards as a command which
  200. # can used directly, OpenBSD lacks cmp in the default installation.
  201. AC_CHECK_PROGS([CMP], [cmp])
  202. if test "x$CMP" = x; then
  203. AC_MSG_ERROR([cmp is not found])
  204. fi
  205. AC_CHECK_PROGS([YACC], [bison])
  206. if test "x$YACC" = x; then
  207. AC_MSG_ERROR([bison is not found])
  208. fi
  209. FONT_SOURCE=
  210. for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
  211. for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
  212. if test -f "$dir/unifont.$ext"; then
  213. FONT_SOURCE="$dir/unifont.$ext"
  214. break 2
  215. fi
  216. done
  217. done
  218. if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips); then
  219. AC_MSG_ERROR([qemu and loongson ports need unifont])
  220. fi
  221. AC_SUBST([FONT_SOURCE])
  222. AC_PROG_RANLIB
  223. AC_PROG_INSTALL
  224. AC_PROG_AWK
  225. AC_PROG_LEX
  226. AC_PROG_YACC
  227. AC_PROG_MAKE_SET
  228. AC_PROG_MKDIR_P
  229. AC_PROG_LN_S
  230. if test "x$LEX" = "x:"; then
  231. AC_MSG_ERROR([flex is not found])
  232. else
  233. version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
  234. if test -n "$version" -a "$version" -ge 20535; then
  235. :
  236. else
  237. AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
  238. fi
  239. fi
  240. # These are not a "must".
  241. AC_PATH_PROGS(MAKEINFO, makeinfo true)
  242. #
  243. # Checks for host programs.
  244. #
  245. AC_PROG_CC
  246. gl_EARLY
  247. AM_PROG_CC_C_O
  248. AM_PROG_AS
  249. # Must be GCC.
  250. test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
  251. AC_GNU_SOURCE
  252. AM_GNU_GETTEXT([external])
  253. AC_SYS_LARGEFILE
  254. # Identify characteristics of the host architecture.
  255. AC_C_BIGENDIAN
  256. AC_CHECK_SIZEOF(void *)
  257. AC_CHECK_SIZEOF(long)
  258. grub_apple_cc
  259. if test x$grub_cv_apple_cc = xyes ; then
  260. HOST_CPPFLAGS="$HOST_CPPFLAGS -fnested-functions"
  261. HOST_LDFLAGS="$HOST_LDFLAGS -Wl,-allow_stack_execute"
  262. fi
  263. if test x$USE_NLS = xno; then
  264. HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
  265. fi
  266. if test "x$cross_compiling" = xyes; then
  267. AC_MSG_WARN([cannot generate manual pages while cross compiling])
  268. else
  269. AC_PATH_PROG(HELP2MAN, help2man)
  270. fi
  271. # Check for functions and headers.
  272. AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
  273. AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
  274. AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
  275. #include <sys/param.h>
  276. #include <sys/mount.h>])
  277. AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
  278. #include <sys/param.h>
  279. #include <sys/mount.h>])
  280. # For opendisk() and getrawpartition() on NetBSD.
  281. # Used in util/deviceiter.c and in util/hostdisk.c.
  282. AC_CHECK_HEADER([util.h], [
  283. AC_CHECK_LIB([util], [opendisk], [
  284. LIBUTIL="-lutil"
  285. AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
  286. ])
  287. AC_CHECK_LIB([util], [getrawpartition], [
  288. LIBUTIL="-lutil"
  289. AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
  290. ])
  291. ])
  292. AC_SUBST([LIBUTIL])
  293. #
  294. # Check for host and build compilers.
  295. #
  296. HOST_CC=$CC
  297. AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
  298. [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
  299. # For gnulib.
  300. gl_INIT
  301. #
  302. # Check for target programs.
  303. #
  304. # Find tools for the target.
  305. if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
  306. tmp_ac_tool_prefix="$ac_tool_prefix"
  307. ac_tool_prefix=$target_alias-
  308. AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
  309. [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
  310. AC_CHECK_TOOL(OBJCOPY, objcopy)
  311. AC_CHECK_TOOL(STRIP, strip)
  312. AC_CHECK_TOOL(NM, nm)
  313. ac_tool_prefix="$tmp_ac_tool_prefix"
  314. else
  315. if test "x$TARGET_CC" = x; then
  316. TARGET_CC=$CC
  317. fi
  318. AC_CHECK_TOOL(OBJCOPY, objcopy)
  319. AC_CHECK_TOOL(STRIP, strip)
  320. AC_CHECK_TOOL(NM, nm)
  321. fi
  322. AC_SUBST(HOST_CC)
  323. AC_SUBST(BUILD_CC)
  324. AC_SUBST(TARGET_CC)
  325. # Test the C compiler for the target environment.
  326. tmp_CC="$CC"
  327. tmp_CFLAGS="$CFLAGS"
  328. tmp_LDFLAGS="$LDFLAGS"
  329. tmp_CPPFLAGS="$CPPFLAGS"
  330. tmp_LIBS="$LIBS"
  331. CC="$TARGET_CC"
  332. CFLAGS="$TARGET_CFLAGS"
  333. CPPFLAGS="$TARGET_CPPFLAGS"
  334. LDFLAGS="$TARGET_LDFLAGS"
  335. LIBS=""
  336. # debug flags.
  337. WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
  338. HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
  339. TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
  340. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
  341. # Force no alignment to save space on i386.
  342. if test "x$target_cpu" = xi386; then
  343. AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
  344. CFLAGS="$CFLAGS -falign-loops=1"
  345. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  346. [grub_cv_cc_falign_loop=yes],
  347. [grub_cv_cc_falign_loop=no])
  348. ])
  349. if test "x$grub_cv_cc_falign_loop" = xyes; then
  350. TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
  351. else
  352. TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
  353. fi
  354. # Some toolchains enable these features by default, but they need
  355. # registers that aren't set up properly in GRUB.
  356. TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
  357. fi
  358. # By default, GCC 4.4 generates .eh_frame sections containing unwind
  359. # information in some cases where it previously did not. GRUB doesn't need
  360. # these and they just use up vital space. Restore the old compiler
  361. # behaviour.
  362. AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
  363. SAVE_CFLAGS="$CFLAGS"
  364. CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
  365. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  366. [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
  367. [grub_cv_cc_fno_dwarf2_cfi_asm=no])
  368. CFLAGS="$SAVE_CFLAGS"
  369. ])
  370. if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
  371. TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
  372. fi
  373. # By default, GCC 4.6 generates .eh_frame sections containing unwind
  374. # information in some cases where it previously did not. GRUB doesn't need
  375. # these and they just use up vital space. Restore the old compiler
  376. # behaviour.
  377. AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
  378. SAVE_CFLAGS="$CFLAGS"
  379. CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
  380. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  381. [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
  382. [grub_cv_cc_fno_asynchronous_unwind_tables=no])
  383. CFLAGS="$SAVE_CFLAGS"
  384. ])
  385. if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
  386. TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
  387. fi
  388. grub_apple_target_cc
  389. if test x$grub_cv_apple_target_cc = xyes ; then
  390. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -fnested-functions"
  391. CFLAGS="$CFLAGS -fnested-functions"
  392. TARGET_APPLE_CC=1
  393. AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
  394. if test "x$OBJCONV" = x ; then
  395. AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
  396. fi
  397. if test "x$OBJCONV" = x ; then
  398. AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
  399. fi
  400. TARGET_IMG_LDSCRIPT=
  401. TARGET_IMG_CFLAGS="-static"
  402. TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
  403. TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
  404. TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
  405. TARGET_LDFLAGS_OLDMAGIC=""
  406. else
  407. TARGET_APPLE_CC=0
  408. TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
  409. # Use linker script if present, otherwise use builtin -N script.
  410. if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
  411. TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
  412. TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
  413. TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
  414. TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
  415. else
  416. TARGET_IMG_LDSCRIPT=
  417. TARGET_IMG_LDFLAGS='-Wl,-N'
  418. TARGET_IMG_LDFLAGS_AC='-Wl,-N'
  419. TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
  420. fi
  421. TARGET_IMG_CFLAGS=
  422. fi
  423. AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
  424. # For platforms where ELF is not the default link format.
  425. AC_MSG_CHECKING([for command to convert module to ELF format])
  426. case "${host_os}" in
  427. cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf';
  428. # FIXME: put proper test here
  429. NEED_REGISTER_FRAME_INFO=1
  430. ;;
  431. *) NEED_REGISTER_FRAME_INFO=0 ;;
  432. esac
  433. AC_MSG_RESULT([$TARGET_OBJ2ELF])
  434. AC_ARG_ENABLE([efiemu],
  435. [AS_HELP_STRING([--enable-efiemu],
  436. [build and install the efiemu runtimes (default=guessed)])])
  437. if test x"$enable_efiemu" = xno ; then
  438. efiemu_excuse="explicitly disabled"
  439. fi
  440. if test x"$target_cpu" != xi386 ; then
  441. efiemu_excuse="only available on i386"
  442. fi
  443. if test x"$platform" = xefi ; then
  444. efiemu_excuse="not available on efi"
  445. fi
  446. if test x"$efiemu_excuse" = x ; then
  447. AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
  448. SAVED_CFLAGS="$CFLAGS"
  449. CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
  450. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  451. [grub_cv_cc_efiemu=yes],
  452. [grub_cv_cc_efiemu=no])
  453. CFLAGS="$SAVED_CFLAGS"
  454. ])
  455. if test x$grub_cv_cc_efiemu = xno; then
  456. efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
  457. fi
  458. fi
  459. if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
  460. AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
  461. fi
  462. if test x"$efiemu_excuse" = x ; then
  463. enable_efiemu=yes
  464. else
  465. enable_efiemu=no
  466. fi
  467. AC_SUBST([enable_efiemu])
  468. if test "x$target_m32" = x1; then
  469. # Force 32-bit mode.
  470. TARGET_CFLAGS="$TARGET_CFLAGS -m32"
  471. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
  472. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
  473. TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
  474. TARGET_MODULE_FORMAT="elf32"
  475. fi
  476. if test "x$target_m64" = x1; then
  477. # Force 64-bit mode.
  478. TARGET_CFLAGS="$TARGET_CFLAGS -m64"
  479. TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
  480. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
  481. TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
  482. TARGET_MODULE_FORMAT="elf64"
  483. fi
  484. if test "$target_cpu"-"$platform" = x86_64-efi; then
  485. # Use large model to support 4G memory
  486. AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
  487. SAVED_CFLAGS=$CFLAGS
  488. CFLAGS="$CFLAGS -m64 -mcmodel=large"
  489. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  490. [grub_cv_cc_mcmodel=yes],
  491. [grub_cv_cc_mcmodel=no])
  492. ])
  493. if test "x$grub_cv_cc_mcmodel" = xno; then
  494. AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
  495. else
  496. TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
  497. fi
  498. # EFI writes to stack below %rsp, we must not use the red zone
  499. AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
  500. CFLAGS="$CFLAGS -m64 -mno-red-zone"
  501. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  502. [grub_cv_cc_no_red_zone=yes],
  503. [grub_cv_cc_no_red_zone=no])
  504. ])
  505. if test "x$grub_cv_cc_no_red_zone" = xno; then
  506. AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
  507. fi
  508. TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
  509. fi
  510. #
  511. # Compiler features.
  512. #
  513. # Need __enable_execute_stack() for nested function trampolines?
  514. grub_CHECK_ENABLE_EXECUTE_STACK
  515. # Position independent executable.
  516. grub_CHECK_PIE
  517. [# Need that, because some distributions ship compilers that include
  518. # `-fPIE' in the default specs.
  519. if [ x"$pie_possible" = xyes ]; then
  520. TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
  521. fi]
  522. # Position independent executable.
  523. grub_CHECK_PIC
  524. [# Need that, because some distributions ship compilers that include
  525. # `-fPIC' in the default specs.
  526. if [ x"$pic_possible" = xyes ]; then
  527. TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
  528. fi]
  529. # Smashing stack protector.
  530. grub_CHECK_STACK_PROTECTOR
  531. # Need that, because some distributions ship compilers that include
  532. # `-fstack-protector' in the default specs.
  533. if test "x$ssp_possible" = xyes; then
  534. TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
  535. fi
  536. grub_CHECK_STACK_ARG_PROBE
  537. # Cygwin's GCC uses alloca() to probe the stackframe on static
  538. # stack allocations above some threshold.
  539. if test x"$sap_possible" = xyes; then
  540. TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
  541. fi
  542. AC_ARG_ENABLE([werror],
  543. [AS_HELP_STRING([--disable-werror],
  544. [do not use -Werror when building GRUB])])
  545. if test x"$enable_werror" != xno ; then
  546. TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
  547. HOST_CFLAGS="$HOST_CFLAGS -Werror"
  548. fi
  549. TARGET_CPP="$TARGET_CC -E"
  550. TARGET_CCAS=$TARGET_CC
  551. GRUB_TARGET_CPU="${target_cpu}"
  552. GRUB_PLATFORM="${platform}"
  553. AC_SUBST(GRUB_TARGET_CPU)
  554. AC_SUBST(GRUB_PLATFORM)
  555. AC_SUBST(OBJCONV)
  556. AC_SUBST(TARGET_CPP)
  557. AC_SUBST(TARGET_CCAS)
  558. AC_SUBST(TARGET_OBJ2ELF)
  559. AC_SUBST(TARGET_APPLE_CC)
  560. AC_SUBST(TARGET_MODULE_FORMAT)
  561. AC_SUBST(TARGET_CFLAGS)
  562. AC_SUBST(TARGET_LDFLAGS)
  563. AC_SUBST(TARGET_CPPFLAGS)
  564. AC_SUBST(TARGET_CCASFLAGS)
  565. AC_SUBST(TARGET_IMG_LDSCRIPT)
  566. AC_SUBST(TARGET_IMG_LDFLAGS)
  567. AC_SUBST(TARGET_IMG_CFLAGS)
  568. AC_SUBST(TARGET_IMG_BASE_LDOPT)
  569. AC_SUBST(HOST_CFLAGS)
  570. AC_SUBST(HOST_LDFLAGS)
  571. AC_SUBST(HOST_CPPFLAGS)
  572. AC_SUBST(HOST_CCASFLAGS)
  573. # Set them to their new values for the tests below.
  574. CC="$TARGET_CC"
  575. if test "x$TARGET_APPLE_CC" = x1 ; then
  576. CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
  577. else
  578. CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
  579. fi
  580. CPPFLAGS="$TARGET_CPPFLAGS"
  581. if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
  582. LIBS=
  583. else
  584. LIBS=-lgcc
  585. fi
  586. grub_ASM_USCORE
  587. if test x$grub_cv_asm_uscore = xyes; then
  588. CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
  589. else
  590. CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
  591. fi
  592. # Check for libgcc symbols
  593. AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x __ia64_trampoline __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
  594. if test "x$TARGET_APPLE_CC" = x1 ; then
  595. CFLAGS="$TARGET_CFLAGS -nostdlib"
  596. else
  597. CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
  598. fi
  599. LIBS=""
  600. # Defined in aclocal.m4.
  601. grub_PROG_TARGET_CC
  602. if test "x$TARGET_APPLE_CC" != x1 ; then
  603. grub_PROG_OBJCOPY_ABSOLUTE
  604. fi
  605. grub_PROG_LD_BUILD_ID_NONE
  606. if test "x$target_cpu" = xi386; then
  607. if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
  608. if test ! -z "$TARGET_IMG_LDSCRIPT"; then
  609. # Check symbols provided by linker script.
  610. CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
  611. fi
  612. grub_CHECK_BSS_START_SYMBOL
  613. grub_CHECK_END_SYMBOL
  614. fi
  615. CFLAGS="$TARGET_CFLAGS"
  616. grub_I386_ASM_PREFIX_REQUIREMENT
  617. grub_I386_ASM_ADDR32
  618. fi
  619. if test "$platform" != emu; then
  620. AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
  621. SAVED_CPPFLAGS="$CPPFLAGS"
  622. CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
  623. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
  624. int va_arg_func (int fixed, va_list args);]], [[]])],
  625. [grub_cv_cc_isystem=yes],
  626. [grub_cv_cc_isystem=no])
  627. CPPFLAGS="$SAVED_CPPFLAGS"
  628. ])
  629. if test x"$grub_cv_cc_isystem" = xyes ; then
  630. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
  631. fi
  632. fi
  633. AC_CACHE_CHECK([whether -Wno-trampolines work], [grub_cv_cc_wnotrampolines], [
  634. SAVED_CFLAGS="$CFLAGS"
  635. # Test for -Wtrampolines rather than -Wno-trampolines to reduce confusion
  636. # in the event of later failures (since -Wno-* is always accepted, but
  637. # produces a diagnostic if something else is wrong).
  638. CFLAGS="$TARGET_CFLAGS -Wtrampolines"
  639. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
  640. int va_arg_func (int fixed, va_list args);]], [[]])],
  641. [grub_cv_cc_wnotrampolines=yes],
  642. [grub_cv_cc_wnotrampolines=no])
  643. CFLAGS="$SAVED_CFLAGS"
  644. ])
  645. if test x"$grub_cv_cc_wnotrampolines" = xyes ; then
  646. TARGET_CFLAGS="$TARGET_CFLAGS -Wno-trampolines"
  647. fi
  648. # Restore the flags.
  649. CC="$tmp_CC"
  650. CFLAGS="$tmp_CFLAGS"
  651. CPPFLAGS="$tmp_CPPFLAGS"
  652. LDFLAGS="$tmp_LDFLAGS"
  653. LIBS="$tmp_LIBS"
  654. #
  655. # Check for options.
  656. #
  657. # Memory manager debugging.
  658. AC_ARG_ENABLE([mm-debug],
  659. AS_HELP_STRING([--enable-mm-debug],
  660. [include memory manager debugging]),
  661. [AC_DEFINE([MM_DEBUG], [1],
  662. [Define to 1 if you enable memory manager debugging.])])
  663. AC_ARG_ENABLE([cache-stats],
  664. AS_HELP_STRING([--enable-cache-stats],
  665. [enable disk cache statistics collection]))
  666. if test x$enable_cache_stats = xyes; then
  667. DISK_CACHE_STATS=1
  668. else
  669. DISK_CACHE_STATS=0
  670. fi
  671. AC_SUBST([DISK_CACHE_STATS])
  672. AC_ARG_ENABLE([grub-emu-usb],
  673. [AS_HELP_STRING([--enable-grub-emu-usb],
  674. [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
  675. AC_ARG_ENABLE([grub-emu-sdl],
  676. [AS_HELP_STRING([--enable-grub-emu-sdl],
  677. [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
  678. AC_ARG_ENABLE([grub-emu-pci],
  679. [AS_HELP_STRING([--enable-grub-emu-pci],
  680. [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
  681. if test "$platform" = emu; then
  682. missing_ncurses=
  683. [# Check for curses libraries.]
  684. AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
  685. [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
  686. [missing_ncurses=[true]])])
  687. AC_SUBST([LIBCURSES])
  688. [if [ x"$missing_ncurses" = x ]; then ]
  689. [# Check for headers.]
  690. AC_CHECK_HEADERS([ncurses/curses.h], [],
  691. [AC_CHECK_HEADERS([ncurses.h], [],
  692. [AC_CHECK_HEADERS([curses.h], [],
  693. [missing_ncurses=[true]])])])
  694. [fi]
  695. if test x"$missing_ncurses" = xtrue ; then
  696. AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
  697. fi
  698. if test x"$enable_grub_emu_usb" != xyes ; then
  699. grub_emu_usb_excuse="not enabled"
  700. fi
  701. if test x"$enable_grub_emu_pci" = xyes ; then
  702. grub_emu_usb_excuse="conflicts with PCI support"
  703. fi
  704. [if [ x"$grub_emu_usb_excuse" = x ]; then
  705. # Check for libusb libraries.]
  706. AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
  707. [grub_emu_usb_excuse=["need libusb library"]])
  708. AC_SUBST([LIBUSB])
  709. [fi]
  710. [if [ x"$grub_emu_usb_excuse" = x ]; then
  711. # Check for headers.]
  712. AC_CHECK_HEADERS([usb.h], [],
  713. [grub_emu_usb_excuse=["need libusb headers"]])
  714. [fi]
  715. if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
  716. AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
  717. fi
  718. if test x"$grub_emu_usb_excuse" = x ; then
  719. enable_grub_emu_usb=yes
  720. else
  721. enable_grub_emu_usb=no
  722. fi
  723. if test x"$enable_grub_emu_sdl" = xno ; then
  724. grub_emu_sdl_excuse="explicitely disabled"
  725. fi
  726. [if [ x"$grub_emu_sdl_excuse" = x ]; then
  727. # Check for libSDL libraries.]
  728. AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
  729. [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
  730. AC_SUBST([LIBSDL])
  731. [fi]
  732. [if [ x"$grub_emu_sdl_excuse" = x ]; then
  733. # Check for headers.]
  734. AC_CHECK_HEADERS([SDL/SDL.h], [],
  735. [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
  736. [fi]
  737. if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
  738. AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
  739. fi
  740. if test x"$grub_emu_sdl_excuse" = x ; then
  741. enable_grub_emu_sdl=yes
  742. else
  743. enable_grub_emu_sdl=no
  744. fi
  745. if test x"$enable_grub_emu_pci" != xyes ; then
  746. grub_emu_pci_excuse="not enabled"
  747. fi
  748. if test x"$enable_grub_emu_usb" = xyes ; then
  749. grub_emu_pci_excuse="conflicts with USB support"
  750. fi
  751. [if [ x"$grub_emu_pci_excuse" = x ]; then
  752. # Check for libpci libraries.]
  753. AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
  754. [grub_emu_pci_excuse=["need libpciaccess library"]])
  755. AC_SUBST([LIBPCIACCESS])
  756. [fi]
  757. [if [ x"$grub_emu_pci_excuse" = x ]; then
  758. # Check for headers.]
  759. AC_CHECK_HEADERS([pci/pci.h], [],
  760. [grub_emu_pci_excuse=["need libpciaccess headers"]])
  761. [fi]
  762. if test x"$grub_emu_pci_excuse" = x ; then
  763. enable_grub_emu_pci=yes
  764. else
  765. enable_grub_emu_pci=no
  766. fi
  767. AC_SUBST([enable_grub_emu_sdl])
  768. AC_SUBST([enable_grub_emu_usb])
  769. AC_SUBST([enable_grub_emu_pci])
  770. fi
  771. AC_ARG_ENABLE([grub-mkfont],
  772. [AS_HELP_STRING([--enable-grub-mkfont],
  773. [build and install the `grub-mkfont' utility (default=guessed)])])
  774. if test x"$enable_grub_mkfont" = xno ; then
  775. grub_mkfont_excuse="explicitly disabled"
  776. fi
  777. if test x"$grub_mkfont_excuse" = x ; then
  778. # Check for freetype libraries.
  779. AC_CHECK_PROGS([FREETYPE], [freetype-config])
  780. if test "x$FREETYPE" = x ; then
  781. grub_mkfont_excuse=["need freetype2 library"]
  782. fi
  783. fi
  784. if test x"$grub_mkfont_excuse" = x ; then
  785. # Check for freetype libraries.
  786. freetype_cflags=`freetype-config --cflags`
  787. freetype_libs=`freetype-config --libs`
  788. SAVED_CPPFLAGS="$CPPFLAGS"
  789. CPPFLAGS="$CPPFLAGS $freetype_cflags"
  790. AC_CHECK_HEADERS([ft2build.h], [],
  791. [grub_mkfont_excuse=["need freetype2 headers"]])
  792. CPPFLAGS="$SAVED_CPPFLAGS"
  793. fi
  794. if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
  795. AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
  796. fi
  797. if test x"$grub_mkfont_excuse" = x ; then
  798. enable_grub_mkfont=yes
  799. else
  800. enable_grub_mkfont=no
  801. fi
  802. if test x"$enable_grub_mkfont" = xno && test "x$platform" = xloongson; then
  803. AC_MSG_ERROR([loongson port needs grub-mkfont])
  804. fi
  805. AC_SUBST([enable_grub_mkfont])
  806. AC_SUBST([freetype_cflags])
  807. AC_SUBST([freetype_libs])
  808. DJVU_FONT_SOURCE=
  809. starfield_excuse=
  810. if test x$enable_grub_mkfont = xno; then
  811. starfield_excuse="No grub-mkfont"
  812. fi
  813. if test x"$starfield_excuse" = x; then
  814. for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
  815. for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
  816. if test -f "$dir/DejaVuSans.$ext"; then
  817. DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
  818. break 2
  819. fi
  820. done
  821. done
  822. if test "x$DJVU_FONT_SOURCE" = x; then
  823. starfield_excuse="No DejaVu found"
  824. fi
  825. fi
  826. AC_SUBST([DJVU_FONT_SOURCE])
  827. AC_ARG_ENABLE([grub-mount],
  828. [AS_HELP_STRING([--enable-grub-mount],
  829. [build and install the `grub-mount' utility (default=guessed)])])
  830. if test x"$enable_grub_mount" = xno ; then
  831. grub_mount_excuse="explicitly disabled"
  832. fi
  833. if test x"$grub_mount_excuse" = x ; then
  834. AC_CHECK_LIB([fuse], [fuse_main_real], [],
  835. [grub_mount_excuse="need FUSE library"])
  836. fi
  837. if test x"$grub_mount_excuse" = x ; then
  838. # Check for fuse headers.
  839. SAVED_CPPFLAGS="$CPPFLAGS"
  840. CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
  841. AC_CHECK_HEADERS([fuse/fuse.h], [],
  842. [grub_mount_excuse=["need FUSE headers"]])
  843. CPPFLAGS="$SAVED_CPPFLAGS"
  844. fi
  845. if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
  846. AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
  847. fi
  848. if test x"$grub_mount_excuse" = x ; then
  849. enable_grub_mount=yes
  850. else
  851. enable_grub_mount=no
  852. fi
  853. AC_SUBST([enable_grub_mount])
  854. AC_ARG_ENABLE([device-mapper],
  855. [AS_HELP_STRING([--enable-device-mapper],
  856. [enable Linux device-mapper support (default=guessed)])])
  857. if test x"$enable_device_mapper" = xno ; then
  858. device_mapper_excuse="explicitly disabled"
  859. fi
  860. if test x"$device_mapper_excuse" = x ; then
  861. # Check for device-mapper header.
  862. AC_CHECK_HEADER([libdevmapper.h], [],
  863. [device_mapper_excuse="need libdevmapper header"])
  864. fi
  865. if test x"$device_mapper_excuse" = x ; then
  866. # Check for device-mapper library.
  867. AC_CHECK_LIB([devmapper], [dm_task_create], [],
  868. [device_mapper_excuse="need devmapper library"])
  869. fi
  870. if test x"$device_mapper_excuse" = x ; then
  871. # Check for device-mapper library.
  872. AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
  873. [],
  874. [device_mapper_excuse="need devmapper library"])
  875. fi
  876. if test x"$device_mapper_excuse" = x ; then
  877. LIBDEVMAPPER="-ldevmapper";
  878. AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
  879. [Define to 1 if you have the devmapper library.])
  880. fi
  881. AC_SUBST([LIBDEVMAPPER])
  882. LIBGEOM=
  883. if test x$host_kernel = xkfreebsd; then
  884. AC_CHECK_LIB([geom], [geom_gettree], [],
  885. [AC_MSG_ERROR([Your platform requires libgeom])])
  886. LIBGEOM="-lgeom"
  887. fi
  888. AC_SUBST([LIBGEOM])
  889. AC_CHECK_LIB([lzma], [lzma_code],
  890. [LIBLZMA="-llzma"
  891. AC_DEFINE([HAVE_LIBLZMA], [1],
  892. [Define to 1 if you have the LZMA library.])],)
  893. AC_SUBST([LIBLZMA])
  894. AC_ARG_ENABLE([libzfs],
  895. [AS_HELP_STRING([--enable-libzfs],
  896. [enable libzfs integration (default=guessed)])])
  897. if test x"$enable_libzfs" = xno ; then
  898. libzfs_excuse="explicitly disabled"
  899. fi
  900. if test x"$libzfs_excuse" = x ; then
  901. # Only check for system headers if libzfs support has not been disabled.
  902. AC_CHECK_HEADERS(libzfs.h libnvpair.h)
  903. fi
  904. if test x"$libzfs_excuse" = x ; then
  905. AC_CHECK_LIB([zfs], [libzfs_init],
  906. [],
  907. [libzfs_excuse="need zfs library"])
  908. fi
  909. if test x"$libzfs_excuse" = x ; then
  910. AC_CHECK_LIB([nvpair], [nvlist_print],
  911. [],
  912. [libzfs_excuse="need nvpair library"])
  913. fi
  914. if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
  915. AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
  916. fi
  917. if test x"$libzfs_excuse" = x ; then
  918. # We need both libzfs and libnvpair for a successful build.
  919. LIBZFS="-lzfs"
  920. AC_DEFINE([HAVE_LIBZFS], [1],
  921. [Define to 1 if you have the ZFS library.])
  922. LIBNVPAIR="-lnvpair"
  923. AC_DEFINE([HAVE_LIBNVPAIR], [1],
  924. [Define to 1 if you have the NVPAIR library.])
  925. fi
  926. AC_SUBST([LIBZFS])
  927. AC_SUBST([LIBNVPAIR])
  928. LIBS=""
  929. AC_SUBST([FONT_SOURCE])
  930. AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
  931. [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
  932. AS_IF([test x$TARGET_APPLE_CC = x1],
  933. [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
  934. AC_SUBST(HAVE_ASM_USCORE)
  935. AC_SUBST(ADDR32)
  936. AC_SUBST(DATA32)
  937. AC_SUBST(BSS_START_SYMBOL)
  938. AC_SUBST(END_SYMBOL)
  939. AC_SUBST(PACKAGE)
  940. AC_SUBST(VERSION)
  941. AC_SUBST(NEED_ENABLE_EXECUTE_STACK)
  942. AC_SUBST(NEED_REGISTER_FRAME_INFO)
  943. #
  944. # Automake conditionals
  945. #
  946. AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
  947. AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
  948. AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
  949. AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
  950. AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
  951. AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
  952. AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
  953. AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
  954. AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
  955. AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
  956. AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
  957. AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
  958. AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
  959. AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
  960. AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
  961. AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
  962. AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
  963. AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
  964. AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
  965. AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
  966. AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
  967. AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
  968. AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
  969. AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
  970. AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
  971. AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
  972. AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
  973. AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
  974. AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
  975. AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
  976. AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
  977. AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
  978. AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
  979. AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
  980. AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
  981. AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
  982. AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin])
  983. AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
  984. # Output files.
  985. cpudir="${target_cpu}"
  986. if test x${cpudir} = xmipsel; then
  987. cpudir=mips;
  988. fi
  989. grub_CHECK_LINK_DIR
  990. if test x"$link_dir" = xyes ; then
  991. AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
  992. if test "$platform" != emu ; then
  993. AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
  994. fi
  995. else
  996. mkdir -p include/grub 2>/dev/null
  997. rm -rf include/grub/cpu
  998. cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
  999. if test "$platform" != emu ; then
  1000. rm -rf include/grub/machine
  1001. cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
  1002. fi
  1003. fi
  1004. AC_CONFIG_FILES([Makefile])
  1005. AC_CONFIG_FILES([grub-core/Makefile])
  1006. AC_CONFIG_FILES([grub-core/gnulib/Makefile])
  1007. AC_CONFIG_FILES([po/Makefile.in])
  1008. AC_CONFIG_FILES([docs/Makefile])
  1009. AC_CONFIG_FILES([util/bash-completion.d/Makefile])
  1010. AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
  1011. AC_CONFIG_FILES([config.h])
  1012. AC_OUTPUT
  1013. [
  1014. echo "*******************************************************"
  1015. echo GRUB2 will be compiled with following components:
  1016. echo Platform: "$target_cpu"-"$platform"
  1017. if [ x"$platform" = xemu ]; then
  1018. if [ x"$grub_emu_usb_excuse" = x ]; then
  1019. echo USB support for grub-emu: Yes
  1020. else
  1021. echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
  1022. fi
  1023. if [ x"$grub_emu_sdl_excuse" = x ]; then
  1024. echo SDL support for grub-emu: Yes
  1025. else
  1026. echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
  1027. fi
  1028. if [ x"$grub_emu_pci_excuse" = x ]; then
  1029. echo PCI support for grub-emu: Yes
  1030. else
  1031. echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
  1032. fi
  1033. fi
  1034. if test x"$device_mapper_excuse" = x ; then
  1035. echo With devmapper support: Yes
  1036. else
  1037. echo With devmapper support: No "($device_mapper_excuse)"
  1038. fi
  1039. if [ x"$enable_mm_debug" = xyes ]; then
  1040. echo With memory debugging: Yes
  1041. else
  1042. echo With memory debugging: No
  1043. fi
  1044. if [ x"$enable_cache_stats" = xyes ]; then
  1045. echo With disk cache statistics: Yes
  1046. else
  1047. echo With disk cache statistics: No
  1048. fi
  1049. if [ x"$efiemu_excuse" = x ]; then
  1050. echo efiemu runtime: Yes
  1051. else
  1052. echo efiemu runtime: No "($efiemu_excuse)"
  1053. fi
  1054. if [ x"$grub_mkfont_excuse" = x ]; then
  1055. echo grub-mkfont: Yes
  1056. else
  1057. echo grub-mkfont: No "($grub_mkfont_excuse)"
  1058. fi
  1059. if [ x"$grub_mount_excuse" = x ]; then
  1060. echo grub-mount: Yes
  1061. else
  1062. echo grub-mount: No "($grub_mount_excuse)"
  1063. fi
  1064. if [ x"$starfield_excuse" = x ]; then
  1065. echo starfield theme: Yes
  1066. else
  1067. echo starfield theme: No "($starfield_excuse)"
  1068. fi
  1069. if [ x"$libzfs_excuse" = x ]; then
  1070. echo With libzfs support: Yes
  1071. else
  1072. echo With libzfs support: No "($libzfs_excuse)"
  1073. fi
  1074. echo "*******************************************************"
  1075. ]