OSDN Git Service

6003d8ce5d4e1fa1d3123ca48df31b3fce9cf547
[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(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 ]
50 )
51
52 dnl convert a yes/no variable to 1/0 for C code
53 var_yn_to_10() {
54         if eval test \"\$$1\" = yes ; then
55                 eval $1=1
56         else
57                 eval $1=0
58         fi
59 }
60
61 AC_ARG_ENABLE(got-check,
62         [ --disable-got-check - disable check for GOT (needed on H8) ],
63         [ got_check=$enableval ],
64         [ got_check=yes ]
65 )
66 var_yn_to_10 got_check
67
68 AC_ARG_ENABLE(emit-relocs,
69         [ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option ],
70         [ emit_relocs=$enableval ],
71         [ emit_relocs=yes ]
72 )
73 var_yn_to_10 emit_relocs
74
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 ],
78         [ emit_ctor_dtor=no ]
79 )
80 var_yn_to_10 emit_ctor_dtor
81
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 ],
85         [
86         case $target in
87                 bfin*) always_reloc_text=yes;;
88                 *)     always_reloc_text=no;;
89         esac
90         ]
91 )
92 var_yn_to_10 always_reloc_text
93
94 AC_CANONICAL_HOST
95 AC_CANONICAL_TARGET
96
97 dnl Checks for programs.
98 AC_PROG_CC
99 AC_USE_SYSTEM_EXTENSIONS
100 AC_PROG_INSTALL
101
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"
107 fi
108
109 dnl Checks for libraries.
110 if test "$ac_libiberty" = "NONE"; then
111   AC_CHECK_LIB(iberty, objalloc_create)
112   ac_libiberty=auto
113 else
114   LIBS="$ac_libiberty $LIBS"
115 fi
116 if test "$ac_libbfd" = "NONE"; then
117   AC_CHECK_LIB(bfd, bfd_openr)
118   ac_libbfd=auto
119 else
120   LIBS="$ac_libbfd $LIBS"
121 fi
122 if test "$ac_zlib_prefix" = "NONE"; then
123   AC_CHECK_LIB(z, deflate)
124 else
125   LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
126 fi
127
128 bfd_include_dir=
129 if test "$ac_bfd_include_dir" != "NONE"; then
130   bfd_include_dir="-I$ac_bfd_include_dir"
131 fi
132
133 binutils_include_dir=
134 if test "$ac_binutils_include_dir" != "NONE"; then
135   binutils_include_dir="-I$ac_binutils_include_dir"
136 fi
137
138 zlib_include_dir=
139 if test "$ac_zlib_prefix" != "NONE"; then
140   zlib_include_dir="-I$ac_zlib_prefix/include"
141 fi
142
143 binutils_ldscript_dir=
144 if test "$ac_binutils_ldscript_dir" = "NONE"; then
145   ac_binutils_ldscript_dir="\${TOOLDIR}/../${target_alias}/lib"
146 fi
147 binutils_ldscript_dir="$ac_binutils_ldscript_dir"
148
149 if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then
150         AC_MSG_ERROR([
151
152 You need to specify the location of the libfd.a and libiberty.a
153 host libraries from the binutils package.
154         
155 Run configure again specifying these options:
156         
157   ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
158 ])
159 fi
160
161 if test "$ac_bfd_include_dir" = "NONE" ; then
162         AC_MSG_ERROR([
163
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.
168
169 Run configure again specifying these options:
170
171   ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
172 ])
173 fi
174
175 SYMBOL_PREFIX=
176 case $target in
177         h8300|bfin*)
178                 SYMBOL_PREFIX=_
179                 ;;
180 esac
181
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")
188
189 dnl Checks for header files.
190 AC_HEADER_STDC
191 AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h)
192
193 dnl Checks for typedefs, structures, and compiler characteristics.
194 AC_C_CONST
195
196 dnl Checks for library functions.
197 AC_FUNC_VPRINTF
198
199 AC_CHECK_FUNCS([ \
200         dcgettext \
201         getline \
202         libintl_dgettext \
203         strsignal \
204 ])
205
206 test "$GCC" = yes && CFLAGS="-Wall $CFLAGS"
207
208 dnl Subsitute values
209 AC_SUBST(target)
210 AC_SUBST(target_alias)
211 AC_SUBST(target_cpu)
212 AC_SUBST(target_os)
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)
219 AC_SUBST(got_check)
220 AC_SUBST(emit_relocs)
221 AC_SUBST(emit_ctor_dtor)
222 AC_SUBST(always_reloc_text)
223 AC_SUBST(SYMBOL_PREFIX)
224
225 AC_OUTPUT(ld-elf2flt.sh:ld-elf2flt.in Makefile elf2flt.ld)
226