OSDN Git Service

When the relocs are larger than 16bits, incorrect values are written when
[uclinux-h8/elf2flt.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(elf2flt.c)
3
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 ]
8 )
9
10 AC_ARG_WITH(libbfd,
11         [ --with-libbfd=<file>  path to libbfd.a library to use ],
12         [ ac_libbfd=$withval ],
13         [ ac_libbfd=NONE ]
14 )
15
16 AC_ARG_WITH(libiberty,
17         [ --with-libiberty=<file>  path to libiberty.a library to use ],
18         [ ac_libiberty=$withval ],
19         [ ac_libiberty=NONE ]
20 )
21
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 ]
26 )
27
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 ]
32 )
33
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 ]
38 )
39
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 ]
44 )
45
46 AC_ARG_ENABLE(got-check,
47         [ --disable-got-check - disable check for GOT (needed on H8) ],
48         [ got_check=$enableval ],
49         [ got_check=yes ]
50 )
51
52 AC_ARG_ENABLE(emit-relocs,
53         [ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option ],
54         [ emit_relocs=$enableval ],
55         [ emit_relocs=yes ]
56 )
57
58 AC_ARG_ENABLE(emit-ctor-dtor,
59         AS_HELP_STRING([--enable-emit-ctor-dtor], [manually create ctor/dtor list]),
60         [ emit_ctor_dtor=$enableval ],
61         [ emit_ctor_dtor=no ]
62 )
63
64 AC_CANONICAL_HOST
65 AC_CANONICAL_TARGET
66
67 dnl Checks for programs.
68 AC_PROG_CC
69 AC_PROG_INSTALL
70
71 if test "$ac_binutils_build_dir" != "NONE"; then
72   test "$ac_libbfd"               = "NONE" && ac_libbfd="$ac_binutils_build_dir/bfd/libbfd.a"
73   test "$ac_libiberty"            = "NONE" && ac_libiberty="$ac_binutils_build_dir/libiberty/libiberty.a"
74   test "$ac_bfd_include_dir"      = "NONE" && ac_bfd_include_dir="$ac_binutils_build_dir/bfd"
75   test "$ac_binutils_include_dir" = "NONE" && ac_binutils_include_dir="$ac_binutils_build_dir/include"
76 fi
77
78 dnl Checks for libraries.
79 if test "$ac_libiberty" = "NONE"; then
80   AC_CHECK_LIB(iberty, objalloc_create)
81   ac_libiberty=auto
82 else
83   LIBS="$ac_libiberty $LIBS"
84 fi
85 if test "$ac_libbfd" = "NONE"; then
86   AC_CHECK_LIB(bfd, bfd_openr)
87   ac_libbfd=auto
88 else
89   LIBS="$ac_libbfd $LIBS"
90 fi
91 if test "$ac_zlib_prefix" = "NONE"; then
92   AC_CHECK_LIB(z, deflate)
93 else
94   LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
95 fi
96
97 bfd_include_dir=
98 if test "$ac_bfd_include_dir" != "NONE"; then
99   bfd_include_dir="-I$ac_bfd_include_dir"
100 fi
101
102 binutils_include_dir=
103 if test "$ac_binutils_include_dir" != "NONE"; then
104   binutils_include_dir="-I$ac_binutils_include_dir"
105 fi
106
107 zlib_include_dir=
108 if test "$ac_zlib_prefix" != "NONE"; then
109   zlib_include_dir="-I$ac_zlib_prefix/include"
110 fi
111
112 binutils_ldscript_dir=
113 if test "$ac_binutils_ldscript_dir" = "NONE"; then
114   ac_binutils_ldscript_dir="\${TOOLDIR}/../${target_alias}/lib"
115 fi
116 binutils_ldscript_dir="$ac_binutils_ldscript_dir"
117
118 if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then
119         AC_MSG_ERROR([
120
121 You need to specify the location of the libfd.a and libiberty.a
122 host libraries from the binutils package.
123         
124 Run configure again specifying these options:
125         
126   ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
127 ])
128 fi
129
130 if test "$ac_bfd_include_dir" = "NONE" ; then
131         AC_MSG_ERROR([
132
133 You need to specify the location of the bfd.h header from a
134 configured/compiled version of the binutils package for your target.
135 Without this your elf2flt may crash as it will try to use the
136 systems bfd.h which may be from a different binutils package.
137
138 Run configure again specifying these options:
139
140   ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
141 ])
142 fi
143
144 SYMBOL_PREFIX=
145 case $target in
146         bfin*)
147                 SYMBOL_PREFIX=_
148                 ;;
149 esac
150
151 dnl Make sure we resolve system symbols before libiberty/libbfd ones.
152 dnl Otherwise, things like getopt get screwed up because the system headers
153 dnl redirect some functions to the system symbols, but other local symbols
154 dnl come from libiberty/libbfd.
155 dnl int getopt(int, char * const [], const char *) __asm("_" "getopt" "$UNIX2003");
156 AC_CHECK_LIB(c, malloc, LIBS="-lc $LIBS")
157
158 dnl Checks for header files.
159 AC_HEADER_STDC
160 AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h)
161
162 dnl Checks for typedefs, structures, and compiler characteristics.
163 AC_C_CONST
164
165 dnl Checks for library functions.
166 AC_FUNC_VPRINTF
167
168 AC_CHECK_FUNCS(dcgettext libintl_dgettext)
169
170 dnl Subsitute values
171 AC_SUBST(target)
172 AC_SUBST(target_alias)
173 AC_SUBST(target_cpu)
174 AC_SUBST(target_os)
175 AC_SUBST(target_vendor)
176 AC_SUBST(bfd_include_dir)
177 AC_SUBST(binutils_include_dir)
178 AC_SUBST(zlib_include_dir)
179 AC_SUBST(binutils_ldscript_dir)
180 AC_SUBST(got_check)
181 AC_SUBST(emit_relocs)
182 AC_SUBST(emit_ctor_dtor)
183 AC_SUBST(SYMBOL_PREFIX)
184
185 AC_OUTPUT(Makefile ld-elf2flt elf2flt.ld)
186