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
85 dnl Checks for programs.
87 AC_USE_SYSTEM_EXTENSIONS
90 if test "$ac_binutils_build_dir" != "NONE"; then
91 test "$ac_libbfd" = "NONE" && ac_libbfd="$ac_binutils_build_dir/bfd/libbfd.a"
92 test "$ac_libiberty" = "NONE" && ac_libiberty="$ac_binutils_build_dir/libiberty/libiberty.a"
93 test "$ac_bfd_include_dir" = "NONE" && ac_bfd_include_dir="$ac_binutils_build_dir/bfd"
94 test "$ac_binutils_include_dir" = "NONE" && ac_binutils_include_dir="$ac_binutils_build_dir/include"
97 dnl Checks for libraries.
98 if test "$ac_libiberty" = "NONE"; then
99 AC_CHECK_LIB(iberty, objalloc_create)
102 LIBS="$ac_libiberty $LIBS"
104 if test "$ac_libbfd" = "NONE"; then
105 AC_CHECK_LIB(bfd, bfd_openr)
108 LIBS="$ac_libbfd $LIBS"
110 if test "$ac_zlib_prefix" = "NONE"; then
111 AC_CHECK_LIB(z, deflate)
113 LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
117 if test "$ac_bfd_include_dir" != "NONE"; then
118 bfd_include_dir="-I$ac_bfd_include_dir"
121 binutils_include_dir=
122 if test "$ac_binutils_include_dir" != "NONE"; then
123 binutils_include_dir="-I$ac_binutils_include_dir"
127 if test "$ac_zlib_prefix" != "NONE"; then
128 zlib_include_dir="-I$ac_zlib_prefix/include"
131 binutils_ldscript_dir=
132 if test "$ac_binutils_ldscript_dir" = "NONE"; then
133 ac_binutils_ldscript_dir="\${TOOLDIR}/../${target_alias}/lib"
135 binutils_ldscript_dir="$ac_binutils_ldscript_dir"
137 if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then
140 You need to specify the location of the libfd.a and libiberty.a
141 host libraries from the binutils package.
143 Run configure again specifying these options:
145 ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
149 if test "$ac_bfd_include_dir" = "NONE" ; then
152 You need to specify the location of the bfd.h header from a
153 configured/compiled version of the binutils package for your target.
154 Without this your elf2flt may crash as it will try to use the
155 systems bfd.h which may be from a different binutils package.
157 Run configure again specifying these options:
159 ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
170 dnl Make sure we resolve system symbols before libiberty/libbfd ones.
171 dnl Otherwise, things like getopt get screwed up because the system headers
172 dnl redirect some functions to the system symbols, but other local symbols
173 dnl come from libiberty/libbfd.
174 dnl int getopt(int, char * const [], const char *) __asm("_" "getopt" "$UNIX2003");
175 AC_CHECK_LIB(c, malloc, LIBS="-lc $LIBS")
177 dnl Checks for header files.
179 AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h)
181 dnl Checks for typedefs, structures, and compiler characteristics.
184 dnl Checks for library functions.
194 test "$GCC" = yes && CFLAGS="-Wall $CFLAGS"
198 AC_SUBST(target_alias)
201 AC_SUBST(target_vendor)
202 AC_SUBST(bfd_include_dir)
203 AC_SUBST(binutils_include_dir)
204 AC_SUBST(zlib_include_dir)
205 AC_SUBST(binutils_ldscript_dir)
206 AC_SUBST(use_ld_elf2flt_binary)
208 AC_SUBST(emit_relocs)
209 AC_SUBST(emit_ctor_dtor)
210 AC_SUBST(SYMBOL_PREFIX)
212 AC_OUTPUT(ld-elf2flt.sh:ld-elf2flt.in Makefile elf2flt.ld)