OSDN Git Service

Make varargs debug macros GCC-2.x compatible.
[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_CANONICAL_HOST
83 AC_CANONICAL_TARGET
84
85 dnl Checks for programs.
86 AC_PROG_CC
87 AC_USE_SYSTEM_EXTENSIONS
88 AC_PROG_INSTALL
89
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"
95 fi
96
97 dnl Checks for libraries.
98 if test "$ac_libiberty" = "NONE"; then
99   AC_CHECK_LIB(iberty, objalloc_create)
100   ac_libiberty=auto
101 else
102   LIBS="$ac_libiberty $LIBS"
103 fi
104 if test "$ac_libbfd" = "NONE"; then
105   AC_CHECK_LIB(bfd, bfd_openr)
106   ac_libbfd=auto
107 else
108   LIBS="$ac_libbfd $LIBS"
109 fi
110 if test "$ac_zlib_prefix" = "NONE"; then
111   AC_CHECK_LIB(z, deflate)
112 else
113   LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
114 fi
115
116 bfd_include_dir=
117 if test "$ac_bfd_include_dir" != "NONE"; then
118   bfd_include_dir="-I$ac_bfd_include_dir"
119 fi
120
121 binutils_include_dir=
122 if test "$ac_binutils_include_dir" != "NONE"; then
123   binutils_include_dir="-I$ac_binutils_include_dir"
124 fi
125
126 zlib_include_dir=
127 if test "$ac_zlib_prefix" != "NONE"; then
128   zlib_include_dir="-I$ac_zlib_prefix/include"
129 fi
130
131 binutils_ldscript_dir=
132 if test "$ac_binutils_ldscript_dir" = "NONE"; then
133   ac_binutils_ldscript_dir="\${TOOLDIR}/../${target_alias}/lib"
134 fi
135 binutils_ldscript_dir="$ac_binutils_ldscript_dir"
136
137 if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then
138         AC_MSG_ERROR([
139
140 You need to specify the location of the libfd.a and libiberty.a
141 host libraries from the binutils package.
142         
143 Run configure again specifying these options:
144         
145   ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
146 ])
147 fi
148
149 if test "$ac_bfd_include_dir" = "NONE" ; then
150         AC_MSG_ERROR([
151
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.
156
157 Run configure again specifying these options:
158
159   ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
160 ])
161 fi
162
163 SYMBOL_PREFIX=
164 case $target in
165         h8300|bfin*)
166                 SYMBOL_PREFIX=_
167                 ;;
168 esac
169
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")
176
177 dnl Checks for header files.
178 AC_HEADER_STDC
179 AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h)
180
181 dnl Checks for typedefs, structures, and compiler characteristics.
182 AC_C_CONST
183
184 dnl Checks for library functions.
185 AC_FUNC_VPRINTF
186
187 AC_CHECK_FUNCS([ \
188         dcgettext \
189         getline \
190         libintl_dgettext \
191         strsignal \
192 ])
193
194 test "$GCC" = yes && CFLAGS="-Wall $CFLAGS"
195
196 dnl Subsitute values
197 AC_SUBST(target)
198 AC_SUBST(target_alias)
199 AC_SUBST(target_cpu)
200 AC_SUBST(target_os)
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)
207 AC_SUBST(got_check)
208 AC_SUBST(emit_relocs)
209 AC_SUBST(emit_ctor_dtor)
210 AC_SUBST(SYMBOL_PREFIX)
211
212 AC_OUTPUT(ld-elf2flt.sh:ld-elf2flt.in Makefile elf2flt.ld)
213