OSDN Git Service

5ab89837113cd410e8acc168da50838ce5945b29
[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_CANONICAL_HOST
59 AC_CANONICAL_TARGET
60
61 dnl Checks for programs.
62 AC_PROG_CC
63 AC_PROG_INSTALL
64
65 if test "$ac_binutils_build_dir" != "NONE"; then
66   test "$ac_libbfd"               = "NONE" && ac_libbfd="$ac_binutils_build_dir/bfd/libbfd.a"
67   test "$ac_libiberty"            = "NONE" && ac_libiberty="$ac_binutils_build_dir/libiberty/libiberty.a"
68   test "$ac_bfd_include_dir"      = "NONE" && ac_bfd_include_dir="$ac_binutils_build_dir/bfd"
69   test "$ac_binutils_include_dir" = "NONE" && ac_binutils_include_dir="$ac_binutils_build_dir/include"
70 fi
71
72 dnl Checks for libraries.
73 if test "$ac_libiberty" = "NONE"; then
74   AC_CHECK_LIB(iberty, objalloc_create)
75   ac_libiberty=auto
76 else
77   LIBS="$ac_libiberty $LIBS"
78 fi
79 if test "$ac_libbfd" = "NONE"; then
80   AC_CHECK_LIB(bfd, bfd_openr)
81   ac_libbfd=auto
82 else
83   LIBS="$ac_libbfd $LIBS"
84 fi
85 if test "$ac_zlib_prefix" = "NONE"; then
86   AC_CHECK_LIB(z, deflate)
87 else
88   LIBS="-L$ac_zlib_prefix/lib -lz $LIBS"
89 fi
90
91 bfd_include_dir=
92 if test "$ac_bfd_include_dir" != "NONE"; then
93   bfd_include_dir="-I$ac_bfd_include_dir"
94 fi
95
96 binutils_include_dir=
97 if test "$ac_binutils_include_dir" != "NONE"; then
98   binutils_include_dir="-I$ac_binutils_include_dir"
99 fi
100
101 zlib_include_dir=
102 if test "$ac_zlib_prefix" != "NONE"; then
103   zlib_include_dir="-I$ac_zlib_prefix/include"
104 fi
105
106 binutils_ldscript_dir=
107 if test "$ac_binutils_ldscript_dir" = "NONE"; then
108   ac_binutils_ldscript_dir="\${TOOLDIR}/../${target_alias}/lib"
109 fi
110 binutils_ldscript_dir="$ac_binutils_ldscript_dir"
111
112 if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then
113         AC_MSG_ERROR([
114
115 You need to specify the location of the libfd.a and libiberty.a
116 host libraries from the binutils package.
117         
118 Run configure again specifying these options:
119         
120   ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
121 ])
122 fi
123
124 if test "$ac_bfd_include_dir" = "NONE" ; then
125         AC_MSG_ERROR([
126
127 You need to specify the location of the bfd.h header from a
128 configured/compiled version of the binutils package for your target.
129 Without this your elf2flt may crash as it will try to use the
130 systems bfd.h which may be from a different binutils package.
131
132 Run configure again specifying these options:
133
134   ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
135 ])
136 fi
137
138 dnl Make sure we resolve system symbols before libiberty/libbfd ones.
139 dnl Otherwise, things like getopt get screwed up because the system headers
140 dnl redirect some functions to the system symbols, but other local symbols
141 dnl come from libiberty/libbfd.
142 dnl int getopt(int, char * const [], const char *) __asm("_" "getopt" "$UNIX2003");
143 AC_CHECK_LIB(c, malloc, LIBS="-lc $LIBS")
144
145 dnl Checks for header files.
146 AC_HEADER_STDC
147 AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h)
148
149 dnl Checks for typedefs, structures, and compiler characteristics.
150 AC_C_CONST
151
152 dnl Checks for library functions.
153 AC_FUNC_VPRINTF
154
155 AC_CHECK_FUNCS(dcgettext libintl_dgettext)
156
157 dnl Subsitute values
158 AC_SUBST(target)
159 AC_SUBST(target_alias)
160 AC_SUBST(target_cpu)
161 AC_SUBST(target_os)
162 AC_SUBST(target_vendor)
163 AC_SUBST(bfd_include_dir)
164 AC_SUBST(binutils_include_dir)
165 AC_SUBST(zlib_include_dir)
166 AC_SUBST(binutils_ldscript_dir)
167 AC_SUBST(got_check)
168 AC_SUBST(emit_relocs)
169
170 AC_OUTPUT(Makefile ld-elf2flt)
171