configure.ac 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. # Process this file with autoconf to produce a configure script.
  2. # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
  3. #
  4. # This configure.ac is free software; the author
  5. # gives unlimited permission to copy and/or distribute it,
  6. # with or without modifications, as long as this notice is preserved.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  10. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11. # PARTICULAR PURPOSE.
  12. dnl This configure script is complicated, because GRUB needs to deal
  13. dnl with three potentially different types:
  14. dnl
  15. dnl build -- the environment for building GRUB
  16. dnl host -- the environment for running utilities
  17. dnl target -- the environment for running GRUB
  18. dnl
  19. dnl In addition, GRUB needs to deal with a platform specification
  20. dnl which specifies the system running GRUB, such as firmware.
  21. dnl This is necessary because the target type in autoconf does not
  22. dnl describe such a system very well.
  23. dnl
  24. dnl The current strategy is to use variables with no prefix (such as
  25. dnl CC, CFLAGS, etc.) for the host type as well as the build type,
  26. dnl because GRUB does not need to use those variables for the build
  27. dnl type, so there is no conflict. Variables with the prefix "TARGET_"
  28. dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
  29. dnl type.
  30. AC_INIT([BURG],[1.98],[bean123ch@gmail.com])
  31. AC_PREREQ(2.60)
  32. AC_CONFIG_SRCDIR([include/grub/dl.h])
  33. AC_CONFIG_HEADER([config.h])
  34. # Checks for host and target systems.
  35. AC_CANONICAL_HOST
  36. AC_CANONICAL_TARGET
  37. # Program name transformations
  38. AC_ARG_PROGRAM
  39. AM_INIT_AUTOMAKE()
  40. # Optimization flag. Allow user to override.
  41. if test "x$TARGET_CFLAGS" = x; then
  42. TARGET_CFLAGS="$TARGET_CFLAGS -Os"
  43. fi
  44. case "$target_cpu" in
  45. i[[3456]]86) target_cpu=i386 ;;
  46. amd64) target_cpu=x86_64 ;;
  47. sparc) target_cpu=sparc64 ;;
  48. mipsel|mips64el)
  49. target_cpu=mips;
  50. TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPSEL=1";
  51. CFLAGS="$CFLAGS -DGRUB_CPU_MIPSEL=1";
  52. ;;
  53. mips|mips64)
  54. target_cpu=mips;
  55. TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPS=1";
  56. CFLAGS="$CFLAGS -DGRUB_CPU_MIPS=1";
  57. ;;
  58. esac
  59. # Specify the platform (such as firmware).
  60. AC_ARG_WITH([platform],
  61. AS_HELP_STRING([--with-platform=PLATFORM],
  62. [select the host platform [[guessed]]]))
  63. # Guess the platform if not specified.
  64. if test "x$with_platform" = x; then
  65. case "$target_cpu"-"$target_vendor" in
  66. i386-apple) platform=efi ;;
  67. i386-*) platform=pc ;;
  68. x86_64-apple) platform=efi ;;
  69. x86_64-*) platform=pc ;;
  70. powerpc-*) platform=ieee1275 ;;
  71. powerpc64-*) platform=ieee1275 ;;
  72. sparc64-*) platform=ieee1275 ;;
  73. mips-*) platform=yeeloong ;;
  74. *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
  75. esac
  76. else
  77. platform="$with_platform"
  78. fi
  79. # Adjust CPU unless target was explicitly specified.
  80. if test -z "$target_alias"; then
  81. case "$target_cpu"-"$platform" in
  82. x86_64-efi) ;;
  83. x86_64-emu) ;;
  84. x86_64-*) target_cpu=i386 ;;
  85. powerpc64-ieee1275) target_cpu=powerpc ;;
  86. esac
  87. fi
  88. # Check if the platform is supported, make final adjustments.
  89. case "$target_cpu"-"$platform" in
  90. i386-efi) ;;
  91. x86_64-efi) ;;
  92. i386-pc) ;;
  93. i386-multiboot) ;;
  94. i386-coreboot) ;;
  95. i386-linuxbios) platform=coreboot ;;
  96. i386-ieee1275) ;;
  97. i386-qemu) ;;
  98. powerpc-ieee1275) ;;
  99. sparc64-ieee1275) ;;
  100. mips-qemu-mips) ;;
  101. mips-yeeloong) ;;
  102. *-emu) ;;
  103. *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
  104. esac
  105. case "$target_cpu" in
  106. i386 | powerpc) target_m32=1 ;;
  107. x86_64 | sparc64) target_m64=1 ;;
  108. esac
  109. case "$host_os" in
  110. mingw32*) host_os=cygwin ;;
  111. esac
  112. # This normalizes the names, and creates a new variable ("host_kernel")
  113. # while at it, since the mapping is not always 1:1 (e.g. different OSes
  114. # using the same kernel type).
  115. case "$host_os" in
  116. gnu*) host_kernel=hurd ;;
  117. linux*) host_kernel=linux ;;
  118. freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
  119. netbsd*) host_kernel=netbsd ;;
  120. cygwin) host_kernel=windows ;;
  121. esac
  122. case "$platform" in
  123. coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
  124. multiboot) machine_CFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;;
  125. efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
  126. ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
  127. qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
  128. pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
  129. emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
  130. yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
  131. qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
  132. esac
  133. case "$target_cpu" in
  134. mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
  135. sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
  136. esac
  137. CFLAGS="$CFLAGS $machine_CFLAGS"
  138. TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
  139. TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
  140. AC_SUBST(host_cpu)
  141. AC_SUBST(host_os)
  142. AC_SUBST(host_kernel)
  143. AC_SUBST(target_cpu)
  144. AC_SUBST(platform)
  145. # Specify the shell.
  146. AC_ARG_WITH([shell],
  147. AS_HELP_STRING([--with-shell=SHELL],
  148. [select the shell for Makefile]))
  149. shell="$with_shell"
  150. AC_SUBST(shell)
  151. #
  152. # Checks for build programs.
  153. #
  154. # Although cmp is listed in the GNU Coding Standards as a command which
  155. # can used directly, OpenBSD lacks cmp in the default installation.
  156. AC_CHECK_PROGS([CMP], [cmp])
  157. if test "x$CMP" = x; then
  158. AC_MSG_ERROR([cmp is not found])
  159. fi
  160. AC_CHECK_PROGS([YACC], [bison])
  161. if test "x$YACC" = x; then
  162. AC_MSG_ERROR([bison is not found])
  163. fi
  164. for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz /usr/share/fonts/unifont/unifont.pcf.gz; do
  165. if test -e $file ; then
  166. AC_SUBST([FONT_SOURCE], [$file])
  167. break
  168. fi
  169. done
  170. AC_PROG_INSTALL
  171. AC_PROG_AWK
  172. AC_PROG_LEX
  173. AC_PROG_MAKE_SET
  174. AC_PROG_MKDIR_P
  175. if test "x$LEX" = x; then
  176. AC_MSG_ERROR([flex is not found])
  177. else
  178. version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
  179. if test -n "$version" -a "$version" -ge 20535; then
  180. :
  181. else
  182. AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
  183. fi
  184. fi
  185. # These are not a "must".
  186. AC_PATH_PROG(RUBY, ruby)
  187. AC_PATH_PROG(MAKEINFO, makeinfo)
  188. #
  189. # Checks for host programs.
  190. #
  191. AC_PROG_CC
  192. # Must be GCC.
  193. test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
  194. AC_GNU_SOURCE
  195. AM_GNU_GETTEXT([external])
  196. AC_SYS_LARGEFILE
  197. # Identify characteristics of the host architecture.
  198. AC_C_BIGENDIAN
  199. AC_CHECK_SIZEOF(void *)
  200. AC_CHECK_SIZEOF(long)
  201. grub_apple_cc
  202. if test x$grub_cv_apple_cc = xyes ; then
  203. CFLAGS="$CFLAGS -DAPPLE_CC=1"
  204. ASFLAGS="$ASFLAGS -DAPPLE_CC=1"
  205. fi
  206. if test "x$cross_compiling" = xyes; then
  207. AC_MSG_WARN([cannot generate manual pages while cross compiling])
  208. else
  209. AC_PATH_PROG(HELP2MAN, help2man)
  210. fi
  211. # Check for functions.
  212. AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf)
  213. # For grub-mkisofs
  214. AC_HEADER_MAJOR
  215. AC_HEADER_DIRENT
  216. AC_CHECK_FUNCS(memmove sbrk strdup lstat getuid getgid)
  217. AC_CHECK_HEADERS(sys/mkdev.h sys/sysmacros.h malloc.h termios.h sys/types.h)
  218. AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h limits.h)
  219. # For opendisk() and getrawpartition() on NetBSD.
  220. # Used in util/deviceiter.c and in util/hostdisk.c.
  221. AC_CHECK_HEADER([util.h], [
  222. AC_CHECK_LIB([util], [opendisk], [
  223. LIBUTIL="-lutil"
  224. AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
  225. ])
  226. AC_CHECK_LIB([util], [getrawpartition], [
  227. LIBUTIL="-lutil"
  228. AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
  229. ])
  230. ])
  231. AC_SUBST([LIBUTIL])
  232. #
  233. # Check for target programs.
  234. #
  235. # Find tools for the target.
  236. if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
  237. tmp_ac_tool_prefix="$ac_tool_prefix"
  238. ac_tool_prefix=$target_alias-
  239. AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
  240. [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
  241. AC_CHECK_TOOL(STRIP, strip)
  242. AC_CHECK_TOOL(NM, nm)
  243. ac_tool_prefix="$tmp_ac_tool_prefix"
  244. else
  245. if test "x$TARGET_CC" = x; then
  246. TARGET_CC=$CC
  247. fi
  248. AC_CHECK_TOOL(STRIP, strip)
  249. AC_CHECK_TOOL(NM, nm)
  250. fi
  251. AC_SUBST(TARGET_CC)
  252. LDFLAGS="$LDFLAGS $LIBINTL $LIBS"
  253. AC_SUBST(AS)
  254. # Test the C compiler for the target environment.
  255. tmp_CC="$CC"
  256. tmp_CFLAGS="$CFLAGS"
  257. tmp_LDFLAGS="$LDFLAGS"
  258. tmp_CPPFLAGS="$CPPFLAGS"
  259. tmp_LIBS="$LIBS"
  260. CC="$TARGET_CC"
  261. CFLAGS="$TARGET_CFLAGS"
  262. CPPFLAGS="$TARGET_CPPFLAGS"
  263. LDFLAGS="$TARGET_LDFLAGS"
  264. LIBS=""
  265. # debug flags.
  266. TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
  267. -Wundef -Wstrict-prototypes -fno-strict-aliasing -g"
  268. # Force no alignment to save space on i386.
  269. if test "x$target_cpu" = xi386; then
  270. AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
  271. CFLAGS="$CFLAGS -falign-loops=1"
  272. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  273. [grub_cv_cc_falign_loop=yes],
  274. [grub_cv_cc_falign_loop=no])
  275. ])
  276. if test "x$grub_cv_cc_falign_loop" = xyes; then
  277. TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
  278. else
  279. TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
  280. fi
  281. # Some toolchains enable these features by default, but they need
  282. # registers that aren't set up properly in GRUB.
  283. TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
  284. fi
  285. # By default, GCC 4.4 generates .eh_frame sections containing unwind
  286. # information in some cases where it previously did not. GRUB doesn't need
  287. # these and they just use up vital space. Restore the old compiler
  288. # behaviour.
  289. AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
  290. SAVE_CFLAGS="$CFLAGS"
  291. CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
  292. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  293. [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
  294. [grub_cv_cc_fno_dwarf2_cfi_asm=no])
  295. CFLAGS="$SAVE_CFLAGS"
  296. ])
  297. if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
  298. TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
  299. fi
  300. TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
  301. TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
  302. grub_apple_target_cc
  303. if test x$grub_cv_apple_target_cc = xyes ; then
  304. TARGET_CFLAGS="$TARGET_CFLAGS -DAPPLE_CC=1"
  305. CFLAGS="$CFLAGS -DAPPLE_CC=1"
  306. TARGET_ASFLAGS="$TARGET_ASFLAGS -DAPPLE_CC=1"
  307. TARGET_APPLE_CC=1
  308. else
  309. TARGET_APPLE_CC=0
  310. fi
  311. AC_SUBST(TARGET_IMG_LDSCRIPT)
  312. AC_SUBST(TARGET_IMG_LDFLAGS)
  313. AC_SUBST(TARGET_IMG_CFLAGS)
  314. # For platforms where ELF is not the default link format.
  315. AC_MSG_CHECKING([for command to convert module to ELF format])
  316. case "${host_os}" in
  317. cygwin) TARGET_OBJ2ELF='grub-pe2elf';
  318. # FIXME: put proper test here
  319. AC_DEFINE([NEED_REGISTER_FRAME_INFO], 1,
  320. [Define to 1 if GCC generates calls to __register_frame_info()])
  321. ;;
  322. *) ;;
  323. esac
  324. AC_SUBST(TARGET_OBJ2ELF)
  325. AC_MSG_RESULT([$TARGET_OBJ2ELF])
  326. if test "x$target_m32" = x1; then
  327. # Force 32-bit mode.
  328. TARGET_CFLAGS="$TARGET_CFLAGS -m32"
  329. TARGET_ASFLAGS="$TARGET_CFLAGS -m32"
  330. TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
  331. fi
  332. if test "x$target_m64" = x1; then
  333. # Force 64-bit mode.
  334. TARGET_CFLAGS="$TARGET_CFLAGS -m64"
  335. TARGET_ASFLAGS="$TARGET_ASFLAGS -m64"
  336. TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
  337. fi
  338. if test "$target_cpu"-"$platform" = x86_64-efi; then
  339. # mingw-w64 always generate PIC code, although it would issue a warning if
  340. # -fPIC is used.
  341. case "$target_os" in
  342. mingw32) ;;
  343. cygwin) ;;
  344. *)
  345. AC_CACHE_CHECK([whether option -fPIC works], grub_cv_cc_pic, [
  346. CFLAGS="$CFLAGS -m64 -fPIC"
  347. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  348. [grub_cv_cc_pic=yes],
  349. [grub_cv_cc_pic=no])
  350. ])
  351. if test "x$grub_cv_cc_pic" = xno; then
  352. AC_MSG_ERROR([-fPIC not supported, upgrade your gcc])
  353. fi
  354. TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
  355. ;;
  356. esac
  357. # EFI writes to stack below %rsp, we must not use the red zone
  358. AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
  359. CFLAGS="$CFLAGS -m64 -mno-red-zone"
  360. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  361. [grub_cv_cc_no_red_zone=yes],
  362. [grub_cv_cc_no_red_zone=no])
  363. ])
  364. if test "x$grub_cv_cc_no_red_zone" = xno; then
  365. AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
  366. fi
  367. TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
  368. fi
  369. #
  370. # Compiler features.
  371. #
  372. # Need __enable_execute_stack() for nested function trampolines?
  373. #grub_CHECK_ENABLE_EXECUTE_STACK
  374. # Position independent executable.
  375. grub_CHECK_PIE
  376. [# Need that, because some distributions ship compilers that include
  377. # `-fPIE' in the default specs.
  378. if [ x"$pie_possible" = xyes ]; then
  379. TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
  380. fi]
  381. # Smashing stack protector.
  382. grub_CHECK_STACK_PROTECTOR
  383. # Need that, because some distributions ship compilers that include
  384. # `-fstack-protector' in the default specs.
  385. if test "x$ssp_possible" = xyes; then
  386. TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
  387. fi
  388. grub_CHECK_STACK_ARG_PROBE
  389. # Cygwin's GCC uses alloca() to probe the stackframe on static
  390. # stack allocations above some threshold.
  391. if test x"$sap_possible" = xyes; then
  392. TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
  393. fi
  394. grub_CHECK_RETURNS_TWICE
  395. AC_ARG_ENABLE([werror],
  396. [AS_HELP_STRING([--disable-werror],
  397. [do not use -Werror when building GRUB])])
  398. if test x"$enable_werror" != xno ; then
  399. TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
  400. fi
  401. AC_SUBST(TARGET_CFLAGS)
  402. AC_SUBST(TARGET_APPLE_CC)
  403. AC_SUBST(TARGET_ASFLAGS)
  404. AC_SUBST(TARGET_CPPFLAGS)
  405. AC_SUBST(TARGET_LDFLAGS)
  406. # Set them to their new values for the tests below.
  407. CC="$TARGET_CC"
  408. grub_PROG_LD_DEFSYM
  409. if test "x$grub_cv_prog_ld_defsym" = xyes; then
  410. CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
  411. else
  412. CFLAGS="$TARGET_CFLAGS -nostdlib"
  413. fi
  414. LIBS=""
  415. grub_ASM_USCORE
  416. # Defined in aclocal.m4.
  417. grub_PROG_TARGET_CC
  418. grub_PROG_LD_BUILD_ID_NONE
  419. if test "x$target_cpu" = xi386; then
  420. CFLAGS="$TARGET_CFLAGS"
  421. grub_I386_ASM_PREFIX_REQUIREMENT
  422. grub_I386_ASM_ADDR32
  423. grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
  424. #else
  425. # AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
  426. fi
  427. #AH_BOTTOM([#if defined(__i386__) && !defined(GRUB_UTIL)
  428. #define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1)))
  429. #else
  430. #define NESTED_FUNC_ATTR
  431. #endif])
  432. AC_ARG_ENABLE([efiemu],
  433. [AS_HELP_STRING([--enable-efiemu],
  434. [build and install the efiemu runtimes (default=guessed)])])
  435. if test x"$enable_efiemu" = xno ; then
  436. efiemu_excuse="explicitly disabled"
  437. fi
  438. if test x"$efiemu_excuse" = x ; then
  439. AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
  440. CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
  441. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  442. [grub_cv_cc_efiemu=yes],
  443. [grub_cv_cc_efiemu=no])
  444. ])
  445. if test x$grub_cv_cc_efiemu = xno; then
  446. efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
  447. fi
  448. fi
  449. if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
  450. AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
  451. fi
  452. if test x"$efiemu_excuse" = x ; then
  453. enable_efiemu=yes
  454. else
  455. enable_efiemu=no
  456. fi
  457. AC_SUBST([enable_efiemu])
  458. if test "$platform" != emu; then
  459. AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
  460. SAVED_CPPFLAGS="$CPPFLAGS"
  461. CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
  462. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
  463. int va_arg_func (int fixed, va_list args);]], [[]])],
  464. [grub_cv_cc_isystem=yes],
  465. [grub_cv_cc_isystem=no])
  466. CPPFLAGS="$SAVED_CPPFLAGS"
  467. ])
  468. if test x"$grub_cv_cc_isystem" = xyes ; then
  469. TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
  470. fi
  471. fi
  472. # Restore the flags.
  473. CC="$tmp_CC"
  474. CFLAGS="$tmp_CFLAGS"
  475. CPPFLAGS="$tmp_CPPFLAGS"
  476. LDFLAGS="$tmp_LDFLAGS"
  477. LIBS="$tmp_LIBS"
  478. #
  479. # Check for options.
  480. #
  481. # Memory manager debugging.
  482. AC_ARG_ENABLE([mm-debug],
  483. AS_HELP_STRING([--enable-mm-debug],
  484. [include memory manager debugging]),
  485. [AC_DEFINE([MM_DEBUG], [1],
  486. [Define to 1 if you enable memory manager debugging.])])
  487. AC_ARG_ENABLE([grub-emu-usb],
  488. [AS_HELP_STRING([--enable-grub-emu-usb],
  489. [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
  490. AC_ARG_ENABLE([grub-emu-sdl],
  491. [AS_HELP_STRING([--enable-grub-emu-sdl],
  492. [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
  493. AC_ARG_ENABLE([grub-emu-pci],
  494. [AS_HELP_STRING([--enable-grub-emu-pci],
  495. [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
  496. AC_ARG_ENABLE([grub-emu-modules],
  497. [AS_HELP_STRING([--enable-grub-emu-modules],
  498. [Support module loading in `grub-emu' debugging utility (default=no)])])
  499. if test "$platform" = emu; then
  500. missing_ncurses=
  501. [# Check for curses libraries.]
  502. AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
  503. [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
  504. [missing_ncurses=[true]])])
  505. AC_SUBST([LIBCURSES])
  506. [if [ x"$missing_ncurses" = x ]; then ]
  507. [# Check for headers.]
  508. AC_CHECK_HEADERS([ncurses/curses.h], [],
  509. [AC_CHECK_HEADERS([ncurses.h], [],
  510. [AC_CHECK_HEADERS([curses.h], [],
  511. [missing_ncurses=[true]])])])
  512. [fi]
  513. if test x"$missing_ncurses" = xtrue ; then
  514. AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
  515. fi
  516. if test x"$enable_grub_emu_modules" = xyes ; then
  517. TARGET_NO_MODULES=no
  518. else
  519. TARGET_NO_MODULES=yes
  520. fi
  521. AC_SUBST(TARGET_NO_MODULES)
  522. if test "$TARGET_NO_MODULES" = yes ; then
  523. # Do not convert modules, otherwise linkage may fail (Cygwin only).
  524. # FIXME: Should be checked above before TARGET_OBJ2ELF is set first.
  525. TARGET_OBJ2ELF=
  526. fi
  527. if test x"$enable_grub_emu_usb" = xno ; then
  528. grub_emu_usb_excuse="explicitly disabled"
  529. fi
  530. if test x"$enable_grub_emu_pci" = xyes ; then
  531. grub_emu_usb_excuse="conflicts with PCI support"
  532. fi
  533. [if [ x"$grub_emu_usb_excuse" = x ]; then
  534. # Check for libusb libraries.]
  535. AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
  536. [grub_emu_usb_excuse=["need libusb library"]])
  537. AC_SUBST([LIBUSB])
  538. [fi]
  539. [if [ x"$grub_emu_usb_excuse" = x ]; then
  540. # Check for headers.]
  541. AC_CHECK_HEADERS([usb.h], [],
  542. [grub_emu_usb_excuse=["need libusb headers"]])
  543. [fi]
  544. if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
  545. AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
  546. fi
  547. if test x"$grub_emu_usb_excuse" = x ; then
  548. enable_grub_emu_usb=yes
  549. else
  550. enable_grub_emu_usb=no
  551. fi
  552. if test x"$enable_grub_emu_sdl" = xno ; then
  553. grub_emu_sdl_excuse="explicitely disabled"
  554. fi
  555. [if [ x"$grub_emu_sdl_excuse" = x ]; then
  556. # Check for libSDL libraries.]
  557. AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL=`sdl-config --libs`],
  558. [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
  559. AC_SUBST([LIBSDL])
  560. [fi]
  561. [if [ x"$grub_emu_sdl_excuse" = x ]; then
  562. # Check for headers.]
  563. AC_CHECK_HEADERS([SDL/SDL.h], [INCSDL=`sdl-config --cflags`],
  564. [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
  565. AC_SUBST([INCSDL])
  566. [fi]
  567. if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
  568. AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
  569. fi
  570. if test x"$grub_emu_sdl_excuse" = x ; then
  571. enable_grub_emu_sdl=yes
  572. else
  573. enable_grub_emu_sdl=no
  574. fi
  575. if test x"$enable_grub_emu_pci" != xyes ; then
  576. grub_emu_pci_excuse="not enabled"
  577. fi
  578. if test x"$enable_grub_emu_usb" = xyes ; then
  579. grub_emu_pci_excuse="conflicts with USB support"
  580. fi
  581. [if [ x"$grub_emu_pci_excuse" = x ]; then
  582. # Check for libpci libraries.]
  583. AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
  584. [grub_emu_pci_excuse=["need libpciaccess library"]])
  585. AC_SUBST([LIBPCIACCESS])
  586. [fi]
  587. [if [ x"$grub_emu_pci_excuse" = x ]; then
  588. # Check for headers.]
  589. AC_CHECK_HEADERS([pci/pci.h], [],
  590. [grub_emu_pci_excuse=["need libpciaccess headers"]])
  591. [fi]
  592. if test x"$grub_emu_pci_excuse" = x ; then
  593. enable_grub_emu_pci=yes
  594. else
  595. enable_grub_emu_pci=no
  596. fi
  597. AC_SUBST([enable_grub_emu_sdl])
  598. AC_SUBST([enable_grub_emu_usb])
  599. AC_SUBST([enable_grub_emu_pci])
  600. fi
  601. AC_ARG_ENABLE([grub-fstest],
  602. [AS_HELP_STRING([--enable-grub-fstest],
  603. [build and install the `grub-fstest' debugging utility (default=guessed)])])
  604. if test x"$enable_grub_fstest" = xno ; then
  605. grub_fstest_excuse="explicitly disabled"
  606. fi
  607. if test x"$grub_fstest_excuse" = x ; then
  608. enable_grub_fstest=yes
  609. else
  610. enable_grub_fstest=no
  611. fi
  612. AC_SUBST([enable_grub_fstest])
  613. AC_ARG_ENABLE([grub-mkfont],
  614. [AS_HELP_STRING([--enable-grub-mkfont],
  615. [build and install the `grub-mkfont' utility (default=guessed)])])
  616. if test x"$enable_grub_mkfont" = xno ; then
  617. grub_mkfont_excuse="explicitly disabled"
  618. fi
  619. if test x"$grub_mkfont_excuse" = x ; then
  620. # Check for freetype libraries.
  621. AC_CHECK_PROGS([FREETYPE], [freetype-config])
  622. if test "x$FREETYPE" = x ; then
  623. grub_mkfont_excuse=["need freetype2 library"]
  624. fi
  625. freetype_cflags=`freetype-config --cflags`
  626. freetype_libs=`freetype-config --libs`
  627. fi
  628. if test x"$grub_mkfont_excuse" = x ; then
  629. # Check for freetype libraries.
  630. SAVED_CPPFLAGS="$CPPFLAGS"
  631. CPPFLAGS="$CPPFLAGS $freetype_cflags"
  632. AC_CHECK_HEADERS([ft2build.h], [],
  633. [grub_mkfont_excuse=["need freetype2 headers"]])
  634. CPPFLAGS="$SAVED_CPPFLAGS"
  635. fi
  636. if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
  637. AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
  638. fi
  639. if test x"$grub_mkfont_excuse" = x ; then
  640. enable_grub_mkfont=yes
  641. else
  642. enable_grub_mkfont=no
  643. fi
  644. AC_SUBST([enable_grub_mkfont])
  645. AC_SUBST([freetype_cflags])
  646. AC_SUBST([freetype_libs])
  647. AC_SUBST(ASFLAGS)
  648. # Output files.
  649. grub_CHECK_LINK_DIR
  650. if test x"$link_dir" = xyes ; then
  651. AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu])
  652. if test "$platform" != emu ; then
  653. AC_CONFIG_LINKS([include/grub/machine:include/grub/$target_cpu/$platform])
  654. fi
  655. else
  656. mkdir -p include/grub 2>/dev/null
  657. rm -rf include/grub/cpu
  658. cp -rp $srcdir/include/grub/$target_cpu include/grub/cpu 2>/dev/null
  659. if test "$platform" != emu ; then
  660. rm -rf include/grub/machine
  661. cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
  662. fi
  663. fi
  664. AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
  665. AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
  666. AC_OUTPUT
  667. [
  668. echo "*******************************************************"
  669. echo BURG will be compiled with following components:
  670. echo Platform: "$target_cpu"-"$platform"
  671. if [ x"$platform" = xemu ]; then
  672. if [ x"$grub_emu_usb_excuse" = x ]; then
  673. echo USB support for grub-emu: Yes
  674. else
  675. echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
  676. fi
  677. if [ x"$grub_emu_sdl_excuse" = x ]; then
  678. echo SDL support for grub-emu: Yes
  679. else
  680. echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
  681. fi
  682. if [ x"$grub_emu_pci_excuse" = x ]; then
  683. echo PCI support for grub-emu: Yes
  684. else
  685. echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
  686. fi
  687. if [ x"$TARGET_NO_MODULES" = xno ]; then
  688. echo Module support for grub-emu: Yes
  689. else
  690. echo Module support for grub-emu: No
  691. fi
  692. fi
  693. if [ x"$enable_mm_debug" = xyes ]; then
  694. echo With memory debugging: Yes
  695. else
  696. echo With memory debugging: No
  697. fi
  698. if [ x"$efiemu_excuse" = x ]; then
  699. echo efiemu runtime: Yes
  700. else
  701. echo efiemu runtime: No "($efiemu_excuse)"
  702. fi
  703. if [ x"$grub_fstest_excuse" = x ]; then
  704. echo grub-fstest: Yes
  705. else
  706. echo grub-fstest: No "($grub_fstest_excuse)"
  707. fi
  708. if [ x"$grub_mkfont_excuse" = x ]; then
  709. echo grub-mkfont: Yes
  710. else
  711. echo grub-mkfont: No "($grub_mkfont_excuse)"
  712. fi
  713. echo "*******************************************************"
  714. ]