OSDN Git Service

Due to shell portability issues (which is to say shell scripts are not
[uclinux-h8/elf2flt.git] / configure.in
index d6e9d44..8c4ebdb 100644 (file)
@@ -37,25 +37,63 @@ AC_ARG_WITH(binutils-ldscript-dir,
        [ ac_binutils_ldscript_dir=NONE ]
 )
 
+AC_ARG_WITH(binutils-build-dir,
+       [ --with-binutils-build-dir=<dir>  path to compiled binutils tree ],
+       [ ac_binutils_build_dir=$withval ],
+       [ ac_binutils_build_dir=NONE ]
+)
+
+AC_ARG_ENABLE(ld-elf2flt-binary,
+       AS_HELP_STRING([--disable-ld-elf2flt-binary], [use ld-elf2flt shell script]),
+       [ use_ld_elf2flt_binary=$enableval ],
+       [ use_ld_elf2flt_binary=yes ]
+)
+
+dnl convert a yes/no variable to 1/0 for C code
+var_yn_to_10() {
+       if eval test \"\$$1\" = yes ; then
+               eval $1=1
+       else
+               eval $1=0
+       fi
+}
+
 AC_ARG_ENABLE(got-check,
        [ --disable-got-check - disable check for GOT (needed on H8) ],
        [ got_check=$enableval ],
        [ got_check=yes ]
 )
+var_yn_to_10 got_check
 
-AC_ARG_ENABLE(emit_relocs,
+AC_ARG_ENABLE(emit-relocs,
        [ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option ],
        [ emit_relocs=$enableval ],
        [ emit_relocs=yes ]
 )
+var_yn_to_10 emit_relocs
+
+AC_ARG_ENABLE(emit-ctor-dtor,
+       AS_HELP_STRING([--enable-emit-ctor-dtor], [manually create ctor/dtor list]),
+       [ emit_ctor_dtor=$enableval ],
+       [ emit_ctor_dtor=no ]
+)
+var_yn_to_10 emit_ctor_dtor
 
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 
 dnl Checks for programs.
 AC_PROG_CC
+AC_USE_SYSTEM_EXTENSIONS
 AC_PROG_INSTALL
 
+if test "$ac_binutils_build_dir" != "NONE"; then
+  test "$ac_libbfd"               = "NONE" && ac_libbfd="$ac_binutils_build_dir/bfd/libbfd.a"
+  test "$ac_libiberty"            = "NONE" && ac_libiberty="$ac_binutils_build_dir/libiberty/libiberty.a"
+  test "$ac_bfd_include_dir"      = "NONE" && ac_bfd_include_dir="$ac_binutils_build_dir/bfd"
+  test "$ac_binutils_include_dir" = "NONE" && ac_binutils_include_dir="$ac_binutils_build_dir/include"
+fi
+
 dnl Checks for libraries.
 if test "$ac_libiberty" = "NONE"; then
   AC_CHECK_LIB(iberty, objalloc_create)
@@ -122,6 +160,20 @@ Run configure again specifying these options:
 ])
 fi
 
+SYMBOL_PREFIX=
+case $target in
+       h8300|bfin*)
+               SYMBOL_PREFIX=_
+               ;;
+esac
+
+dnl Make sure we resolve system symbols before libiberty/libbfd ones.
+dnl Otherwise, things like getopt get screwed up because the system headers
+dnl redirect some functions to the system symbols, but other local symbols
+dnl come from libiberty/libbfd.
+dnl int getopt(int, char * const [], const char *) __asm("_" "getopt" "$UNIX2003");
+AC_CHECK_LIB(c, malloc, LIBS="-lc $LIBS")
+
 dnl Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h)
@@ -132,7 +184,14 @@ AC_C_CONST
 dnl Checks for library functions.
 AC_FUNC_VPRINTF
 
-AC_CHECK_FUNCS(dcgettext libintl_dgettext)
+AC_CHECK_FUNCS([ \
+       dcgettext \
+       getline \
+       libintl_dgettext \
+       strsignal \
+])
+
+test "$GCC" = yes && CFLAGS="-Wall $CFLAGS"
 
 dnl Subsitute values
 AC_SUBST(target)
@@ -144,8 +203,11 @@ AC_SUBST(bfd_include_dir)
 AC_SUBST(binutils_include_dir)
 AC_SUBST(zlib_include_dir)
 AC_SUBST(binutils_ldscript_dir)
+AC_SUBST(use_ld_elf2flt_binary)
 AC_SUBST(got_check)
 AC_SUBST(emit_relocs)
+AC_SUBST(emit_ctor_dtor)
+AC_SUBST(SYMBOL_PREFIX)
 
-AC_OUTPUT(Makefile ld-elf2flt)
+AC_OUTPUT(ld-elf2flt.sh:ld-elf2flt.in Makefile elf2flt.ld)