]>
Commit | Line | Data |
---|---|---|
63f745e8 | 1 | dnl Redefine AC_LANG_PROGRAM with a "-Wstrict-prototypes -Werror"-friendly |
2 | dnl version. Patch submitted to bug-autoconf in 2009-09-16. | |
3 | m4_define([AC_LANG_PROGRAM(C)], | |
4 | [$1 | |
5 | int | |
6 | main (void) | |
7 | { | |
8 | dnl Do *not* indent the following line: there may be CPP directives. | |
9 | dnl Don't move the `;' right after for the same reason. | |
10 | $2 | |
11 | ; | |
12 | return 0; | |
13 | }]) | |
14 | ||
15 | ||
f6130a12 | 16 | dnl Check whether target compiler is working |
fc9e5810 | 17 | AC_DEFUN([grub_PROG_TARGET_CC], |
f6130a12 | 18 | [AC_MSG_CHECKING([whether target compiler is working]) |
19 | AC_CACHE_VAL(grub_cv_prog_target_cc, | |
26586d98 | 20 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
b2cab848 | 21 | asm (".globl start; start:"); |
26586d98 | 22 | int main (void); |
23 | ]], [[]])], | |
eb73121d | 24 | [grub_cv_prog_target_cc=yes], |
25 | [grub_cv_prog_target_cc=no]) | |
f6130a12 | 26 | ]) |
27 | AC_MSG_RESULT([$grub_cv_prog_target_cc]) | |
28 | ||
29 | if test "x$grub_cv_prog_target_cc" = xno; then | |
30 | AC_MSG_ERROR([cannot compile for the target]) | |
31 | fi | |
32 | ]) | |
33 | ||
34 | ||
4b13b216 | 35 | dnl grub_ASM_USCORE checks if C symbols get an underscore after |
6a161fa9 | 36 | dnl compiling to assembler. |
37 | dnl Written by Pavel Roskin. Based on grub_ASM_EXT_C written by | |
38 | dnl Erich Boleyn and modified by Yoshinori K. Okuji. | |
fc9e5810 | 39 | AC_DEFUN([grub_ASM_USCORE], |
6a161fa9 | 40 | [AC_REQUIRE([AC_PROG_CC]) |
9da94e05 | 41 | AC_REQUIRE([AC_PROG_EGREP]) |
6a161fa9 | 42 | AC_MSG_CHECKING([if C symbols get an underscore after compilation]) |
4b13b216 | 43 | AC_CACHE_VAL(grub_cv_asm_uscore, |
6a161fa9 | 44 | [cat > conftest.c <<\EOF |
63f745e8 | 45 | int func (int *); |
6a161fa9 | 46 | int |
47 | func (int *list) | |
48 | { | |
49 | *list = 0; | |
50 | return *list; | |
51 | } | |
52 | EOF | |
53 | ||
54 | if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -S conftest.c]) && test -s conftest.s; then | |
55 | true | |
56 | else | |
57 | AC_MSG_ERROR([${CC-cc} failed to produce assembly code]) | |
58 | fi | |
59 | ||
9da94e05 | 60 | if $EGREP '(^|[^_[:alnum]])_func' conftest.s >/dev/null 2>&1; then |
742f9232 | 61 | HAVE_ASM_USCORE=1 |
4b13b216 | 62 | grub_cv_asm_uscore=yes |
6a161fa9 | 63 | else |
742f9232 | 64 | HAVE_ASM_USCORE=0 |
4b13b216 | 65 | grub_cv_asm_uscore=no |
6a161fa9 | 66 | fi |
67 | ||
68 | rm -f conftest*]) | |
69 | ||
4b13b216 | 70 | AC_MSG_RESULT([$grub_cv_asm_uscore]) |
6a161fa9 | 71 | ]) |
72 | ||
73 | ||
74 | dnl Some versions of `objcopy -O binary' vary their output depending | |
75 | dnl on the link address. | |
fc9e5810 | 76 | AC_DEFUN([grub_PROG_OBJCOPY_ABSOLUTE], |
fc97214f | 77 | [AC_MSG_CHECKING([whether ${TARGET_OBJCOPY} works for absolute addresses]) |
4b13b216 | 78 | AC_CACHE_VAL(grub_cv_prog_objcopy_absolute, |
6a161fa9 | 79 | [cat > conftest.c <<\EOF |
63f745e8 | 80 | void cmain (void); |
6a161fa9 | 81 | void |
82 | cmain (void) | |
83 | { | |
84 | *((int *) 0x1000) = 2; | |
85 | } | |
86 | EOF | |
87 | ||
88 | if AC_TRY_EVAL(ac_compile) && test -s conftest.o; then : | |
89 | else | |
90 | AC_MSG_ERROR([${CC-cc} cannot compile C source code]) | |
91 | fi | |
4b13b216 | 92 | grub_cv_prog_objcopy_absolute=yes |
c926e1d5 | 93 | for link_addr in 0x2000 0x8000 0x7C00; do |
2d465fb0 | 94 | if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then : |
6a161fa9 | 95 | else |
96 | AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr]) | |
97 | fi | |
fc97214f | 98 | if AC_TRY_COMMAND([${TARGET_OBJCOPY-objcopy} --only-section=.text -O binary conftest.exec conftest]); then : |
6a161fa9 | 99 | else |
fc97214f | 100 | AC_MSG_ERROR([${TARGET_OBJCOPY-objcopy} cannot create binary files]) |
6a161fa9 | 101 | fi |
102 | if test ! -f conftest.old || AC_TRY_COMMAND([cmp -s conftest.old conftest]); then | |
103 | mv -f conftest conftest.old | |
104 | else | |
4b13b216 | 105 | grub_cv_prog_objcopy_absolute=no |
6a161fa9 | 106 | break |
107 | fi | |
108 | done | |
109 | rm -f conftest*]) | |
4b13b216 | 110 | AC_MSG_RESULT([$grub_cv_prog_objcopy_absolute]) |
6a161fa9 | 111 | |
4b13b216 | 112 | if test "x$grub_cv_prog_objcopy_absolute" = xno; then |
113 | AC_MSG_ERROR([GRUB requires a working absolute objcopy; upgrade your binutils]) | |
6a161fa9 | 114 | fi |
115 | ]) | |
116 | ||
117 | ||
cb71ba20 | 118 | dnl Supply --build-id=none to ld if building modules. |
119 | dnl This suppresses warnings from ld on some systems | |
fc9e5810 | 120 | AC_DEFUN([grub_PROG_LD_BUILD_ID_NONE], |
cb71ba20 | 121 | [AC_MSG_CHECKING([whether linker accepts --build-id=none]) |
122 | AC_CACHE_VAL(grub_cv_prog_ld_build_id_none, | |
123 | [save_LDFLAGS="$LDFLAGS" | |
124 | LDFLAGS="$LDFLAGS -Wl,--build-id=none" | |
eb73121d | 125 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
126 | [grub_cv_prog_ld_build_id_none=yes], | |
127 | [grub_cv_prog_ld_build_id_none=no]) | |
cb71ba20 | 128 | LDFLAGS="$save_LDFLAGS" |
129 | ]) | |
130 | AC_MSG_RESULT([$grub_cv_prog_ld_build_id_none]) | |
131 | ||
132 | if test "x$grub_cv_prog_ld_build_id_none" = xyes; then | |
5ec9740b | 133 | TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,--build-id=none" |
cb71ba20 | 134 | fi |
135 | ]) | |
136 | ||
20aea949 VS |
137 | dnl Check nm |
138 | AC_DEFUN([grub_PROG_NM_WORKS], | |
139 | [AC_MSG_CHECKING([whether nm works]) | |
140 | AC_CACHE_VAL(grub_cv_prog_nm_works, | |
141 | [ | |
142 | nm_works_tmp_dir="$(mktemp -d "./confXXXXXX")" | |
143 | AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]], [[]])]) | |
144 | $TARGET_CC $TARGET_CFLAGS -c conftest.c -o "$nm_works_tmp_dir/ef" | |
5757a93e | 145 | if $TARGET_NM "$nm_works_tmp_dir/ef" > /dev/null; then |
20aea949 VS |
146 | grub_cv_prog_nm_works=yes |
147 | else | |
148 | grub_cv_prog_nm_minus_p=no | |
149 | fi | |
150 | rm "$nm_works_tmp_dir/ef" | |
151 | rmdir "$nm_works_tmp_dir" | |
152 | ]) | |
153 | AC_MSG_RESULT([$grub_cv_prog_nm_works]) | |
154 | ||
155 | if test "x$grub_cv_prog_nm_works" != xyes; then | |
156 | AC_MSG_ERROR([nm does not work]) | |
157 | fi | |
158 | ]) | |
159 | ||
fc97214f VS |
160 | dnl Supply -P to nm |
161 | AC_DEFUN([grub_PROG_NM_MINUS_P], | |
162 | [AC_MSG_CHECKING([whether nm accepts -P]) | |
163 | AC_CACHE_VAL(grub_cv_prog_nm_minus_p, | |
164 | [ | |
165 | nm_minus_p_tmp_dir="$(mktemp -d "./confXXXXXX")" | |
166 | AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]], [[]])]) | |
20aea949 | 167 | $TARGET_CC $TARGET_CFLAGS -c conftest.c -o "$nm_minus_p_tmp_dir/ef" |
fc97214f VS |
168 | if $TARGET_NM -P "$nm_minus_p_tmp_dir/ef" 2>&1 > /dev/null; then |
169 | grub_cv_prog_nm_minus_p=yes | |
170 | else | |
171 | grub_cv_prog_nm_minus_p=no | |
172 | fi | |
173 | rm "$nm_minus_p_tmp_dir/ef" | |
20aea949 | 174 | rmdir "$nm_minus_p_tmp_dir" |
fc97214f VS |
175 | ]) |
176 | AC_MSG_RESULT([$grub_cv_prog_nm_minus_p]) | |
177 | ||
178 | if test "x$grub_cv_prog_nm_minus_p" = xyes; then | |
179 | TARGET_NMFLAGS_MINUS_P="-P" | |
180 | else | |
181 | TARGET_NMFLAGS_MINUS_P= | |
182 | fi | |
183 | ]) | |
184 | ||
185 | dnl Supply --defined-only to nm | |
186 | AC_DEFUN([grub_PROG_NM_DEFINED_ONLY], | |
187 | [AC_MSG_CHECKING([whether nm accepts --defined-only]) | |
188 | AC_CACHE_VAL(grub_cv_prog_nm_defined_only, | |
189 | [ | |
190 | nm_defined_only_tmp_dir="$(mktemp -d "./confXXXXXX")" | |
191 | AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]], [[]])]) | |
20aea949 | 192 | $TARGET_CC $TARGET_CFLAGS -c conftest.c -o "$nm_defined_only_tmp_dir/ef" |
fc97214f VS |
193 | if $TARGET_NM --defined-only "$nm_defined_only_tmp_dir/ef" 2>&1 > /dev/null; then |
194 | grub_cv_prog_nm_defined_only=yes | |
195 | else | |
196 | grub_cv_prog_nm_defined_only=no | |
197 | fi | |
198 | rm "$nm_defined_only_tmp_dir/ef" | |
20aea949 | 199 | rmdir "$nm_defined_only_tmp_dir" |
fc97214f VS |
200 | ]) |
201 | AC_MSG_RESULT([$grub_cv_prog_nm_defined_only]) | |
202 | ||
203 | if test "x$grub_cv_prog_nm_defined_only" = xyes; then | |
204 | TARGET_NMFLAGS_DEFINED_ONLY=--defined-only | |
205 | else | |
206 | TARGET_NMFLAGS_DEFINED_ONLY= | |
207 | fi | |
208 | ]) | |
209 | ||
cb71ba20 | 210 | |
6a161fa9 | 211 | dnl Mass confusion! |
212 | dnl Older versions of GAS interpret `.code16' to mean ``generate 32-bit | |
213 | dnl instructions, but implicitly insert addr32 and data32 bytes so | |
214 | dnl that the code works in real mode''. | |
215 | dnl | |
216 | dnl Newer versions of GAS interpret `.code16' to mean ``generate 16-bit | |
217 | dnl instructions,'' which seems right. This requires the programmer | |
218 | dnl to explicitly insert addr32 and data32 instructions when they want | |
219 | dnl them. | |
220 | dnl | |
221 | dnl We only support the newer versions, because the old versions cause | |
222 | dnl major pain, by requiring manual assembly to get 16-bit instructions into | |
223 | dnl asm files. | |
fc9e5810 | 224 | AC_DEFUN([grub_I386_ASM_ADDR32], |
6a161fa9 | 225 | [AC_REQUIRE([AC_PROG_CC]) |
4b13b216 | 226 | AC_REQUIRE([grub_I386_ASM_PREFIX_REQUIREMENT]) |
6a161fa9 | 227 | AC_MSG_CHECKING([for .code16 addr32 assembler support]) |
4b13b216 | 228 | AC_CACHE_VAL(grub_cv_i386_asm_addr32, |
6a161fa9 | 229 | [cat > conftest.s.in <<\EOF |
230 | .code16 | |
231 | l1: @ADDR32@ movb %al, l1 | |
232 | EOF | |
233 | ||
4b13b216 | 234 | if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then |
6a161fa9 | 235 | sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s |
236 | else | |
237 | sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s | |
238 | fi | |
239 | ||
05f3a0d7 | 240 | if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then |
4b13b216 | 241 | grub_cv_i386_asm_addr32=yes |
6a161fa9 | 242 | else |
4b13b216 | 243 | grub_cv_i386_asm_addr32=no |
6a161fa9 | 244 | fi |
245 | ||
246 | rm -f conftest*]) | |
247 | ||
4b13b216 | 248 | AC_MSG_RESULT([$grub_cv_i386_asm_addr32])]) |
6a161fa9 | 249 | |
6a161fa9 | 250 | dnl Later versions of GAS requires that addr32 and data32 prefixes |
251 | dnl appear in the same lines as the instructions they modify, while | |
252 | dnl earlier versions requires that they appear in separate lines. | |
fc9e5810 | 253 | AC_DEFUN([grub_I386_ASM_PREFIX_REQUIREMENT], |
6a161fa9 | 254 | [AC_REQUIRE([AC_PROG_CC]) |
255 | AC_MSG_CHECKING(dnl | |
256 | [whether addr32 must be in the same line as the instruction]) | |
4b13b216 | 257 | AC_CACHE_VAL(grub_cv_i386_asm_prefix_requirement, |
6a161fa9 | 258 | [cat > conftest.s <<\EOF |
259 | .code16 | |
260 | l1: addr32 movb %al, l1 | |
261 | EOF | |
262 | ||
05f3a0d7 | 263 | if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then |
4b13b216 | 264 | grub_cv_i386_asm_prefix_requirement=yes |
6a161fa9 | 265 | else |
4b13b216 | 266 | grub_cv_i386_asm_prefix_requirement=no |
6a161fa9 | 267 | fi |
268 | ||
269 | rm -f conftest*]) | |
270 | ||
4b13b216 | 271 | if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then |
272 | grub_tmp_addr32="addr32" | |
273 | grub_tmp_data32="data32" | |
6a161fa9 | 274 | else |
4b13b216 | 275 | grub_tmp_addr32="addr32;" |
276 | grub_tmp_data32="data32;" | |
6a161fa9 | 277 | fi |
278 | ||
742f9232 VS |
279 | ADDR32=$grub_tmp_addr32 |
280 | DATA32=$grub_tmp_data32 | |
6a161fa9 | 281 | |
4b13b216 | 282 | AC_MSG_RESULT([$grub_cv_i386_asm_prefix_requirement])]) |
6a161fa9 | 283 | |
284 | ||
6a161fa9 | 285 | dnl Check what symbol is defined as a bss start symbol. |
286 | dnl Written by Michael Hohmoth and Yoshinori K. Okuji. | |
fc9e5810 | 287 | AC_DEFUN([grub_CHECK_BSS_START_SYMBOL], |
6a161fa9 | 288 | [AC_REQUIRE([AC_PROG_CC]) |
289 | AC_MSG_CHECKING([if __bss_start is defined by the compiler]) | |
4b13b216 | 290 | AC_CACHE_VAL(grub_cv_check_uscore_uscore_bss_start_symbol, |
eb73121d | 291 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], |
292 | [[asm ("incl __bss_start")]])], | |
293 | [grub_cv_check_uscore_uscore_bss_start_symbol=yes], | |
294 | [grub_cv_check_uscore_uscore_bss_start_symbol=no])]) | |
6a161fa9 | 295 | |
4b13b216 | 296 | AC_MSG_RESULT([$grub_cv_check_uscore_uscore_bss_start_symbol]) |
6a161fa9 | 297 | |
298 | AC_MSG_CHECKING([if edata is defined by the compiler]) | |
4b13b216 | 299 | AC_CACHE_VAL(grub_cv_check_edata_symbol, |
eb73121d | 300 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], |
301 | [[asm ("incl edata")]])], | |
302 | [grub_cv_check_edata_symbol=yes], | |
303 | [grub_cv_check_edata_symbol=no])]) | |
6a161fa9 | 304 | |
4b13b216 | 305 | AC_MSG_RESULT([$grub_cv_check_edata_symbol]) |
6a161fa9 | 306 | |
307 | AC_MSG_CHECKING([if _edata is defined by the compiler]) | |
4b13b216 | 308 | AC_CACHE_VAL(grub_cv_check_uscore_edata_symbol, |
eb73121d | 309 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], |
310 | [[asm ("incl _edata")]])], | |
311 | [grub_cv_check_uscore_edata_symbol=yes], | |
312 | [grub_cv_check_uscore_edata_symbol=no])]) | |
6a161fa9 | 313 | |
4b13b216 | 314 | AC_MSG_RESULT([$grub_cv_check_uscore_edata_symbol]) |
6a161fa9 | 315 | |
4b13b216 | 316 | if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" = xyes; then |
742f9232 | 317 | BSS_START_SYMBOL=__bss_start |
4b13b216 | 318 | elif test "x$grub_cv_check_edata_symbol" = xyes; then |
742f9232 | 319 | BSS_START_SYMBOL=edata |
4b13b216 | 320 | elif test "x$grub_cv_check_uscore_edata_symbol" = xyes; then |
742f9232 | 321 | BSS_START_SYMBOL=_edata |
6a161fa9 | 322 | else |
323 | AC_MSG_ERROR([none of __bss_start, edata or _edata is defined]) | |
324 | fi | |
325 | ]) | |
326 | ||
327 | dnl Check what symbol is defined as an end symbol. | |
328 | dnl Written by Yoshinori K. Okuji. | |
fc9e5810 | 329 | AC_DEFUN([grub_CHECK_END_SYMBOL], |
6a161fa9 | 330 | [AC_REQUIRE([AC_PROG_CC]) |
331 | AC_MSG_CHECKING([if end is defined by the compiler]) | |
4b13b216 | 332 | AC_CACHE_VAL(grub_cv_check_end_symbol, |
eb73121d | 333 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], |
334 | [[asm ("incl end")]])], | |
335 | [grub_cv_check_end_symbol=yes], | |
336 | [grub_cv_check_end_symbol=no])]) | |
6a161fa9 | 337 | |
4b13b216 | 338 | AC_MSG_RESULT([$grub_cv_check_end_symbol]) |
6a161fa9 | 339 | |
340 | AC_MSG_CHECKING([if _end is defined by the compiler]) | |
4b13b216 | 341 | AC_CACHE_VAL(grub_cv_check_uscore_end_symbol, |
eb73121d | 342 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], |
343 | [[asm ("incl _end")]])], | |
344 | [grub_cv_check_uscore_end_symbol=yes], | |
345 | [grub_cv_check_uscore_end_symbol=no])]) | |
6a161fa9 | 346 | |
4b13b216 | 347 | AC_MSG_RESULT([$grub_cv_check_uscore_end_symbol]) |
6a161fa9 | 348 | |
4b13b216 | 349 | if test "x$grub_cv_check_end_symbol" = xyes; then |
742f9232 | 350 | END_SYMBOL=end |
4b13b216 | 351 | elif test "x$grub_cv_check_uscore_end_symbol" = xyes; then |
742f9232 | 352 | END_SYMBOL=_end |
6a161fa9 | 353 | else |
354 | AC_MSG_ERROR([neither end nor _end is defined]) | |
355 | fi | |
356 | ]) | |
5aded270 | 357 | |
baa2a121 | 358 | \f |
359 | dnl Check if the C compiler supports `-fstack-protector'. | |
fc9e5810 | 360 | AC_DEFUN([grub_CHECK_STACK_PROTECTOR],[ |
baa2a121 | 361 | [# Smashing stack protector. |
362 | ssp_possible=yes] | |
363 | AC_MSG_CHECKING([whether `$CC' accepts `-fstack-protector']) | |
364 | # Is this a reliable test case? | |
ab178c08 SJ |
365 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[ |
366 | void foo (void) { volatile char a[8]; a[3]; } | |
367 | ]])]) | |
baa2a121 | 368 | [# `$CC -c -o ...' might not be portable. But, oh, well... Is calling |
369 | # `ac_compile' like this correct, after all? | |
370 | if eval "$ac_compile -S -fstack-protector -o conftest.s" 2> /dev/null; then] | |
371 | AC_MSG_RESULT([yes]) | |
372 | [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? | |
373 | rm -f conftest.s | |
374 | else | |
375 | ssp_possible=no] | |
376 | AC_MSG_RESULT([no]) | |
377 | [fi] | |
378 | ]) | |
2a8a80e4 | 379 | |
380 | dnl Check if the C compiler supports `-mstack-arg-probe' (Cygwin). | |
fc9e5810 | 381 | AC_DEFUN([grub_CHECK_STACK_ARG_PROBE],[ |
2a8a80e4 | 382 | [# Smashing stack arg probe. |
383 | sap_possible=yes] | |
384 | AC_MSG_CHECKING([whether `$CC' accepts `-mstack-arg-probe']) | |
ab178c08 SJ |
385 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[ |
386 | void foo (void) { volatile char a[8]; a[3]; } | |
387 | ]])]) | |
b35ec299 | 388 | [if eval "$ac_compile -S -mstack-arg-probe -Werror -o conftest.s" 2> /dev/null; then] |
2a8a80e4 | 389 | AC_MSG_RESULT([yes]) |
390 | [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? | |
391 | rm -f conftest.s | |
392 | else | |
393 | sap_possible=no] | |
394 | AC_MSG_RESULT([no]) | |
395 | [fi] | |
396 | ]) | |
1f4147aa | 397 | |
398 | dnl Check if ln can handle directories properly (mingw). | |
fc9e5810 | 399 | AC_DEFUN([grub_CHECK_LINK_DIR],[ |
1f4147aa | 400 | AC_MSG_CHECKING([whether ln can handle directories properly]) |
401 | [mkdir testdir 2>/dev/null | |
402 | case $srcdir in | |
403 | [\\/$]* | ?:[\\/]* ) reldir=$srcdir/include/grub/util ;; | |
404 | *) reldir=../$srcdir/include/grub/util ;; | |
405 | esac | |
406 | if ln -s $reldir testdir/util 2>/dev/null ; then] | |
407 | AC_MSG_RESULT([yes]) | |
408 | [link_dir=yes | |
409 | else | |
410 | link_dir=no] | |
411 | AC_MSG_RESULT([no]) | |
412 | [fi | |
413 | rm -rf testdir] | |
414 | ]) | |
93a81088 | 415 | |
416 | dnl Check if the C compiler supports `-fPIE'. | |
fc9e5810 | 417 | AC_DEFUN([grub_CHECK_PIE],[ |
93a81088 | 418 | [# Position independent executable. |
419 | pie_possible=yes] | |
420 | AC_MSG_CHECKING([whether `$CC' has `-fPIE' as default]) | |
421 | # Is this a reliable test case? | |
ab178c08 | 422 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[ |
93a81088 | 423 | #ifdef __PIE__ |
424 | int main() { | |
425 | return 0; | |
426 | } | |
427 | #else | |
428 | #error NO __PIE__ DEFINED | |
429 | #endif | |
ab178c08 | 430 | ]])]) |
93a81088 | 431 | |
432 | [# `$CC -c -o ...' might not be portable. But, oh, well... Is calling | |
433 | # `ac_compile' like this correct, after all? | |
434 | if eval "$ac_compile -S -o conftest.s" 2> /dev/null; then] | |
435 | AC_MSG_RESULT([yes]) | |
436 | [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? | |
437 | rm -f conftest.s | |
438 | else | |
439 | pie_possible=no] | |
440 | AC_MSG_RESULT([no]) | |
441 | [fi] | |
442 | ]) | |
7bd8b0c7 VS |
443 | |
444 | dnl Check if the C compiler supports `-fPIC'. | |
445 | AC_DEFUN([grub_CHECK_PIC],[ | |
446 | [# Position independent executable. | |
447 | pic_possible=yes] | |
448 | AC_MSG_CHECKING([whether `$CC' has `-fPIC' as default]) | |
449 | # Is this a reliable test case? | |
450 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[ | |
451 | #ifdef __PIC__ | |
452 | int main() { | |
453 | return 0; | |
454 | } | |
455 | #else | |
456 | #error NO __PIC__ DEFINED | |
457 | #endif | |
458 | ]])]) | |
459 | ||
460 | [# `$CC -c -o ...' might not be portable. But, oh, well... Is calling | |
461 | # `ac_compile' like this correct, after all? | |
462 | if eval "$ac_compile -S -o conftest.s" 2> /dev/null; then] | |
463 | AC_MSG_RESULT([yes]) | |
464 | [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? | |
465 | rm -f conftest.s | |
466 | else | |
467 | pic_possible=no] | |
468 | AC_MSG_RESULT([no]) | |
469 | [fi] | |
470 | ]) | |
fd49ceb3 CW |
471 | |
472 | dnl Create an output variable with the transformed name of a GRUB utility | |
473 | dnl program. | |
474 | AC_DEFUN([grub_TRANSFORM],[dnl | |
475 | AC_SUBST(AS_TR_SH([$1]), [`AS_ECHO([$1]) | sed "$program_transform_name"`])dnl | |
476 | ]) |