1 dnl Process this file with autoconf to produce a configure script.
4 AC_ARG_WITH(zlib-prefix,
5 [ --with-zlib-prefix=<dir> path to installed zlib ],
6 [ ac_zlib_prefix=$withval ],
7 [ ac_zlib_prefix=NONE ]
11 [ --with-libbfd=<file> path to libbfd.a library to use ],
12 [ ac_libbfd=$withval ],
16 AC_ARG_WITH(libiberty,
17 [ --with-libiberty=<file> path to libiberty.a library to use ],
18 [ ac_libiberty=$withval ],
22 AC_ARG_WITH(bfd-include-dir,
23 [ --with-bfd-include-dir=<dir> include path for correct bfd.h ],
24 [ ac_bfd_include_dir=$withval ],
25 [ ac_bfd_include_dir=NONE ]
28 AC_ARG_WITH(binutils-include-dir,
29 [ --with-binutils-include-dir=<dir> include path for binutils headers ],
30 [ ac_binutils_include_dir=$withval ],
31 [ ac_binutils_include_dir=NONE ]
34 AC_ARG_WITH(binutils-ldscript-dir,
35 [ --with-binutils-ldscript-dir=<dir> path to install elf2flt.ld ],
36 [ ac_binutils_ldscript_dir=$withval ],
37 [ ac_binutils_ldscript_dir=NONE ]
40 AC_ARG_WITH(binutils-build-dir,
41 [ --with-binutils-build-dir=<dir> path to compiled binutils tree ],
42 [ ac_binutils_build_dir=$withval ],
43 [ ac_binutils_build_dir=NONE ]
46 AC_ARG_ENABLE(ld-elf2flt-binary,
47 AS_HELP_STRING([--disable-ld-elf2flt-binary], [use ld-elf2flt shell script]),
48 [ use_ld_elf2flt_binary=$enableval ],
49 [ use_ld_elf2flt_binary=yes ]
52 dnl convert a yes/no variable to 1/0 for C code
54 if eval test \"\$$1\" = yes ; then
61 AC_ARG_ENABLE(got-check,
62 [ --disable-got-check - disable check for GOT (needed on H8) ],
63 [ got_check=$enableval ],
66 var_yn_to_10 got_check
68 AC_ARG_ENABLE(emit-relocs,
69 [ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option ],
70 [ emit_relocs=$enableval ],
73 var_yn_to_10 emit_relocs
75 AC_ARG_ENABLE(emit-ctor-dtor,
76 AS_HELP_STRING([--enable-emit-ctor-dtor], [manually create ctor/dtor list]),
77 [ emit_ctor_dtor=$enableval ],
80 var_yn_to_10 emit_ctor_dtor
82 AC_ARG_ENABLE(always-reloc-text,
83 AS_HELP_STRING([--enable-always-reloc-text], [always process text relocs ignoring pic/got (needed on Blackfin)]),
84 [ always_reloc_text=$enableval ],
87 bfin*) always_reloc_text=yes;;
88 *) always_reloc_text=no;;
92 var_yn_to_10 always_reloc_text
97 dnl Checks for programs.
99 AC_USE_SYSTEM_EXTENSIONS
102 if test "$ac_binutils_build_dir" != "NONE"; then
103 test "$ac_libbfd" = "NONE" && ac_libbfd="$ac_binutils_build_dir/bfd/libbfd.a"
104 test "$ac_libiberty" = "NONE" && ac_libiberty="$ac_binutils_build_dir/libiberty/libiberty.a"
105 test "$ac_bfd_include_dir" = "NONE" && ac_bfd_include_dir="$ac_binutils_build_dir/bfd"
106 test "$ac_binutils_include_dir" = "NONE" && ac_binutils_include_dir="$ac_binutils_build_dir/include"
109 dnl Checks for libraries.
110 if test "$ac_libiberty" = "NONE"; then
111 AC_CHECK_LIB(iberty, objalloc_create)
114 LIBS="$ac_libiberty $LIBS"
116 if test "$ac_libbfd" = "NONE"; then
117 AC_CHECK_LIB(bfd, bfd_openr)
120 LIBS="$ac_libbfd $LIBS"
122 if test "$ac_zlib_prefix" = "NONE"; then
123 AC_CHECK_LIB(z, deflate)
125 LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
129 if test "$ac_bfd_include_dir" != "NONE"; then
130 bfd_include_dir="-I$ac_bfd_include_dir"
133 binutils_include_dir=
134 if test "$ac_binutils_include_dir" != "NONE"; then
135 binutils_include_dir="-I$ac_binutils_include_dir"
139 if test "$ac_zlib_prefix" != "NONE"; then
140 zlib_include_dir="-I$ac_zlib_prefix/include"
143 binutils_ldscript_dir=
144 if test "$ac_binutils_ldscript_dir" = "NONE"; then
145 ac_binutils_ldscript_dir="\${TOOLDIR}/../${target_alias}/lib"
147 binutils_ldscript_dir="$ac_binutils_ldscript_dir"
149 if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then
152 You need to specify the location of the libfd.a and libiberty.a
153 host libraries from the binutils package.
155 Run configure again specifying these options:
157 ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
161 if test "$ac_bfd_include_dir" = "NONE" ; then
164 You need to specify the location of the bfd.h header from a
165 configured/compiled version of the binutils package for your target.
166 Without this your elf2flt may crash as it will try to use the
167 systems bfd.h which may be from a different binutils package.
169 Run configure again specifying these options:
171 ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
182 dnl Make sure we resolve system symbols before libiberty/libbfd ones.
183 dnl Otherwise, things like getopt get screwed up because the system headers
184 dnl redirect some functions to the system symbols, but other local symbols
185 dnl come from libiberty/libbfd.
186 dnl int getopt(int, char * const [], const char *) __asm("_" "getopt" "$UNIX2003");
187 AC_CHECK_LIB(c, malloc, LIBS="-lc $LIBS")
189 dnl Checks for header files.
191 AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h)
193 dnl Checks for typedefs, structures, and compiler characteristics.
196 dnl Checks for library functions.
206 test "$GCC" = yes && CFLAGS="-Wall $CFLAGS"
210 AC_SUBST(target_alias)
213 AC_SUBST(target_vendor)
214 AC_SUBST(bfd_include_dir)
215 AC_SUBST(binutils_include_dir)
216 AC_SUBST(zlib_include_dir)
217 AC_SUBST(binutils_ldscript_dir)
218 AC_SUBST(use_ld_elf2flt_binary)
220 AC_SUBST(emit_relocs)
221 AC_SUBST(emit_ctor_dtor)
222 AC_SUBST(always_reloc_text)
223 AC_SUBST(SYMBOL_PREFIX)
225 AC_OUTPUT(ld-elf2flt.sh:ld-elf2flt.in Makefile elf2flt.ld)