diff options
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 30 | ||||
-rw-r--r-- | binutils/Makefile.am | 9 | ||||
-rw-r--r-- | binutils/Makefile.in | 12 | ||||
-rw-r--r-- | binutils/config.in | 3 | ||||
-rwxr-xr-x | binutils/configure | 114 | ||||
-rw-r--r-- | binutils/configure.in | 2 | ||||
-rw-r--r-- | binutils/dlltool.c | 285 | ||||
-rw-r--r-- | binutils/dllwrap.c | 215 | ||||
-rw-r--r-- | binutils/resrc.c | 34 |
9 files changed, 523 insertions, 181 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 75a6a79..94daa90 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,33 @@ +1999-06-22 Ian Lance Taylor <ian@zembu.com> + + Based on patches from Mumit Khan <khan@xraylith.wisc.EDU>: + * configure.in: Define EXECUTABLE_SUFFIX. + * dlltool.c: Include "dyn-string.h". Include <stdarg.h> based on + ANSI_PROTOTYPES, not __STDC__. + (outfile): Remove. + (gen_exp_file): Change uses of outfile to use alloca. + (make_one_lib_file, make_head, make_tail): Likewise. + (gen_lib_file): Likewise. + (look_for_prog): New static function. + (deduce_name): Rewrite to use look_for_prog. + (mcore_elf_gen_out_file): Use dyn_string_t rather than outfile. + * dllwrap.c: Don't include <stdio.h>, <errno.h>, <string.h>, + <stdlib.h>, or <unistd.h>. Include <sys/stat.h> and either + <stdarg.h> or <varargs.h>. + (driver_name): Initialize to NULL, not "gcc". + (dlltool_name): Initialize to NULL, not "dlltool". + (display, inform, look_for_prog, deduce_name): New static + functions. + (usage): Mention -mno-cygwin. + (OPTION_MNO_CYGWIN): Define. + (main): Handle -mno-cygwin. Deduce driver_name and dlltool_name. + * resrc.c (look_for_default): Make static. Remove unused local + path. Check using EXECUTABLE_SUFFIX. + (read_rc_file): Allocate enough space to hold EXECUTABLE_SUFFIX. + * Makefile.am: Rebuild dependencies. + (dllwrap_LDADD): Add $(INTLLIBS). + * configure, Makefile.in, config.in: Rebuild. + Mon Jun 21 16:49:11 1999 Jeffrey A Law (law@cygnus.com) * readelf.c (dump_relocations): Use elf_hppa_reloc_type instead of diff --git a/binutils/Makefile.am b/binutils/Makefile.am index f24ad92..4d9940a 100644 --- a/binutils/Makefile.am +++ b/binutils/Makefile.am @@ -260,7 +260,7 @@ windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.l \ windres_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS) dllwrap_SOURCES = dllwrap.c dyn-string.c -dllwrap_LDADD = $(LIBIBERTY) +dllwrap_LDADD = $(LIBIBERTY) $(INTLLIBS) DISTSTUFF = arparse.c arparse.h arlex.c nlmheader.c sysinfo.c sysinfo.h \ @@ -381,7 +381,8 @@ debug.o: debug.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ debug.h dlltool.o: dlltool.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/libiberty.h bucomm.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/getopt.h $(INCDIR)/demangle.h dlltool.h + $(INCDIR)/getopt.h $(INCDIR)/demangle.h dyn-string.h \ + dlltool.h filemode.o: filemode.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ bucomm.h config.h $(INCDIR)/fopen-same.h ieee.o: ieee.c ../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/ieee.h \ @@ -462,8 +463,8 @@ readelf.o: readelf.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/elf/sparc.h $(INCDIR)/elf/m32r.h $(INCDIR)/elf/d10v.h \ $(INCDIR)/elf/d30v.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/mn10200.h \ $(INCDIR)/elf/mn10300.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/arc.h \ - $(INCDIR)/elf/fr30.h bucomm.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/getopt.h + $(INCDIR)/elf/fr30.h $(INCDIR)/elf/mcore.h $(INCDIR)/elf/i960.h \ + bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/getopt.h resres.o: resres.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ windres.h winduni.h diff --git a/binutils/Makefile.in b/binutils/Makefile.in index 5479616..f90f487 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -282,7 +282,7 @@ windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.l \ windres_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS) dllwrap_SOURCES = dllwrap.c dyn-string.c -dllwrap_LDADD = $(LIBIBERTY) +dllwrap_LDADD = $(LIBIBERTY) $(INTLLIBS) DISTSTUFF = arparse.c arparse.h arlex.c nlmheader.c sysinfo.c sysinfo.h \ syslex.c deflex.c defparse.h defparse.c rclex.c rcparse.h rcparse.c @@ -412,7 +412,7 @@ configure.in deflex.c defparse.c nlmheader.c rclex.c rcparse.c DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best SOURCES = $(nlmconv_SOURCES) $(srconv_SOURCES) $(sysdump_SOURCES) $(coffdump_SOURCES) $(dlltool_SOURCES) $(windres_SOURCES) $(dllwrap_SOURCES) $(size_SOURCES) $(objdump_SOURCES) $(ar_SOURCES) $(strings_SOURCES) $(ranlib_SOURCES) $(c__filt_SOURCES) $(objcopy_SOURCES) $(addr2line_SOURCES) $(readelf_SOURCES) $(nm_new_SOURCES) $(strip_new_SOURCES) OBJECTS = $(nlmconv_OBJECTS) $(srconv_OBJECTS) $(sysdump_OBJECTS) $(coffdump_OBJECTS) $(dlltool_OBJECTS) $(windres_OBJECTS) $(dllwrap_OBJECTS) $(size_OBJECTS) $(objdump_OBJECTS) $(ar_OBJECTS) $(strings_OBJECTS) $(ranlib_OBJECTS) $(c__filt_OBJECTS) $(objcopy_OBJECTS) $(addr2line_OBJECTS) $(readelf_OBJECTS) $(nm_new_OBJECTS) $(strip_new_OBJECTS) @@ -1134,7 +1134,6 @@ nlmconv.o: nlmconv.c $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h ldname=`echo ld | sed '$(transform)'`; \ $(COMPILE) -c -DLD_NAME="\"$${ldname}\"" @NLMCONV_DEFS@ $(srcdir)/nlmconv.c - diststuff: $(DISTSTUFF) info # Targets to rebuild dependencies in this Makefile. @@ -1240,7 +1239,8 @@ debug.o: debug.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ debug.h dlltool.o: dlltool.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/libiberty.h bucomm.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/getopt.h $(INCDIR)/demangle.h dlltool.h + $(INCDIR)/getopt.h $(INCDIR)/demangle.h dyn-string.h \ + dlltool.h filemode.o: filemode.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ bucomm.h config.h $(INCDIR)/fopen-same.h ieee.o: ieee.c ../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/ieee.h \ @@ -1321,8 +1321,8 @@ readelf.o: readelf.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/elf/sparc.h $(INCDIR)/elf/m32r.h $(INCDIR)/elf/d10v.h \ $(INCDIR)/elf/d30v.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/mn10200.h \ $(INCDIR)/elf/mn10300.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/arc.h \ - $(INCDIR)/elf/fr30.h bucomm.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/getopt.h + $(INCDIR)/elf/fr30.h $(INCDIR)/elf/mcore.h $(INCDIR)/elf/i960.h \ + bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/getopt.h resres.o: resres.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ windres.h winduni.h diff --git a/binutils/config.in b/binutils/config.in index 38272dd..4f630b8 100644 --- a/binutils/config.in +++ b/binutils/config.in @@ -151,6 +151,9 @@ /* Define as 1 if you have gettext and don't want to use GNU gettext. */ #undef HAVE_GETTEXT +/* Suffix used for executables, if any. */ +#undef EXECUTABLE_SUFFIX + /* Is the type time_t defined in <time.h>? */ #undef HAVE_TIME_T_IN_TIME_H diff --git a/binutils/configure b/binutils/configure index a8469ff..d441fff 100755 --- a/binutils/configure +++ b/binutils/configure @@ -4174,6 +4174,10 @@ test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext} echo "$ac_t""${ac_cv_exeext}" 1>&6 ac_exeext=$EXEEXT +cat >> confdefs.h <<EOF +#define EXECUTABLE_SUFFIX "${EXEEXT}" +EOF + # host-specific stuff: @@ -4187,7 +4191,7 @@ AR=${AR-ar} # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4191: checking for $ac_word" >&5 +echo "configure:4195: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4226,7 +4230,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:4230: checking for a BSD compatible install" >&5 +echo "configure:4234: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4293,7 +4297,7 @@ if test "x$cross_compiling" = "xno"; then EXEEXT_FOR_BUILD='$(EXEEXT)' else echo $ac_n "checking for build system executable suffix""... $ac_c" 1>&6 -echo "configure:4297: checking for build system executable suffix" >&5 +echo "configure:4301: checking for build system executable suffix" >&5 if eval "test \"`echo '$''{'bfd_cv_build_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4318,17 +4322,17 @@ for ac_hdr in string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4322: checking for $ac_hdr" >&5 +echo "configure:4326: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4327 "configure" +#line 4331 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4332: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4336: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4355,12 +4359,12 @@ fi done echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:4359: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:4363: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4364 "configure" +#line 4368 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/wait.h> @@ -4376,7 +4380,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:4380: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4384: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -4399,19 +4403,19 @@ fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:4403: checking for working alloca.h" >&5 +echo "configure:4407: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4408 "configure" +#line 4412 "configure" #include "confdefs.h" #include <alloca.h> int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:4415: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4419: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -4432,12 +4436,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:4436: checking for alloca" >&5 +echo "configure:4440: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4441 "configure" +#line 4445 "configure" #include "confdefs.h" #ifdef __GNUC__ @@ -4465,7 +4469,7 @@ int main() { char *p = (char *) alloca(1); ; return 0; } EOF -if { (eval echo configure:4469: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -4497,12 +4501,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:4501: checking whether alloca needs Cray hooks" >&5 +echo "configure:4505: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4506 "configure" +#line 4510 "configure" #include "confdefs.h" #if defined(CRAY) && ! defined(CRAY2) webecray @@ -4527,12 +4531,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4531: checking for $ac_func" >&5 +echo "configure:4535: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4536 "configure" +#line 4540 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -4555,7 +4559,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:4559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4582,7 +4586,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:4586: checking stack direction for C alloca" >&5 +echo "configure:4590: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4590,7 +4594,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <<EOF -#line 4594 "configure" +#line 4598 "configure" #include "confdefs.h" find_stack_direction () { @@ -4609,7 +4613,7 @@ main () exit (find_stack_direction() < 0); } EOF -if { (eval echo configure:4613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -4633,12 +4637,12 @@ fi for ac_func in sbrk utimes do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4637: checking for $ac_func" >&5 +echo "configure:4641: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4642 "configure" +#line 4646 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -4661,7 +4665,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:4665: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4689,14 +4693,14 @@ done # Some systems have frexp only in -lm, not in -lc. echo $ac_n "checking for library containing frexp""... $ac_c" 1>&6 -echo "configure:4693: checking for library containing frexp" >&5 +echo "configure:4697: checking for library containing frexp" >&5 if eval "test \"`echo '$''{'ac_cv_search_frexp'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_func_search_save_LIBS="$LIBS" ac_cv_search_frexp="no" cat > conftest.$ac_ext <<EOF -#line 4700 "configure" +#line 4704 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4707,7 +4711,7 @@ int main() { frexp() ; return 0; } EOF -if { (eval echo configure:4711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4715: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_frexp="none required" else @@ -4718,7 +4722,7 @@ rm -f conftest* test "$ac_cv_search_frexp" = "no" && for i in -lm; do LIBS="-l$i $ac_func_search_save_LIBS" cat > conftest.$ac_ext <<EOF -#line 4722 "configure" +#line 4726 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4729,7 +4733,7 @@ int main() { frexp() ; return 0; } EOF -if { (eval echo configure:4733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4737: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_frexp="-l$i" break @@ -4751,19 +4755,19 @@ else : fi echo $ac_n "checking for time_t in time.h""... $ac_c" 1>&6 -echo "configure:4755: checking for time_t in time.h" >&5 +echo "configure:4759: checking for time_t in time.h" >&5 if eval "test \"`echo '$''{'bu_cv_decl_time_t_time_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4760 "configure" +#line 4764 "configure" #include "confdefs.h" #include <time.h> int main() { time_t i; ; return 0; } EOF -if { (eval echo configure:4767: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4771: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bu_cv_decl_time_t_time_h=yes else @@ -4784,19 +4788,19 @@ EOF fi echo $ac_n "checking for time_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:4788: checking for time_t in sys/types.h" >&5 +echo "configure:4792: checking for time_t in sys/types.h" >&5 if eval "test \"`echo '$''{'bu_cv_decl_time_t_types_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4793 "configure" +#line 4797 "configure" #include "confdefs.h" #include <sys/types.h> int main() { time_t i; ; return 0; } EOF -if { (eval echo configure:4800: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4804: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bu_cv_decl_time_t_types_h=yes else @@ -4819,12 +4823,12 @@ fi # Under Next 3.2 <utime.h> apparently does not define struct utimbuf # by default. echo $ac_n "checking for utime.h""... $ac_c" 1>&6 -echo "configure:4823: checking for utime.h" >&5 +echo "configure:4827: checking for utime.h" >&5 if eval "test \"`echo '$''{'bu_cv_header_utime_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4828 "configure" +#line 4832 "configure" #include "confdefs.h" #include <sys/types.h> #ifdef HAVE_TIME_H @@ -4835,7 +4839,7 @@ int main() { struct utimbuf s; ; return 0; } EOF -if { (eval echo configure:4839: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bu_cv_header_utime_h=yes else @@ -4856,12 +4860,12 @@ EOF fi echo $ac_n "checking whether fprintf must be declared""... $ac_c" 1>&6 -echo "configure:4860: checking whether fprintf must be declared" >&5 +echo "configure:4864: checking whether fprintf must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_fprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4865 "configure" +#line 4869 "configure" #include "confdefs.h" #include <stdio.h> @@ -4882,7 +4886,7 @@ int main() { char *(*pfn) = (char *(*)) fprintf ; return 0; } EOF -if { (eval echo configure:4886: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4890: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_fprintf=no else @@ -4903,12 +4907,12 @@ EOF fi echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6 -echo "configure:4907: checking whether strstr must be declared" >&5 +echo "configure:4911: checking whether strstr must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_strstr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4912 "configure" +#line 4916 "configure" #include "confdefs.h" #include <stdio.h> @@ -4929,7 +4933,7 @@ int main() { char *(*pfn) = (char *(*)) strstr ; return 0; } EOF -if { (eval echo configure:4933: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4937: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_strstr=no else @@ -4950,12 +4954,12 @@ EOF fi echo $ac_n "checking whether sbrk must be declared""... $ac_c" 1>&6 -echo "configure:4954: checking whether sbrk must be declared" >&5 +echo "configure:4958: checking whether sbrk must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_sbrk'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4959 "configure" +#line 4963 "configure" #include "confdefs.h" #include <stdio.h> @@ -4976,7 +4980,7 @@ int main() { char *(*pfn) = (char *(*)) sbrk ; return 0; } EOF -if { (eval echo configure:4980: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4984: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_sbrk=no else @@ -4997,12 +5001,12 @@ EOF fi echo $ac_n "checking whether getenv must be declared""... $ac_c" 1>&6 -echo "configure:5001: checking whether getenv must be declared" >&5 +echo "configure:5005: checking whether getenv must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_getenv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5006 "configure" +#line 5010 "configure" #include "confdefs.h" #include <stdio.h> @@ -5023,7 +5027,7 @@ int main() { char *(*pfn) = (char *(*)) getenv ; return 0; } EOF -if { (eval echo configure:5027: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5031: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_getenv=no else @@ -5044,12 +5048,12 @@ EOF fi echo $ac_n "checking whether environ must be declared""... $ac_c" 1>&6 -echo "configure:5048: checking whether environ must be declared" >&5 +echo "configure:5052: checking whether environ must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_environ'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5053 "configure" +#line 5057 "configure" #include "confdefs.h" #include <stdio.h> @@ -5070,7 +5074,7 @@ int main() { char *(*pfn) = (char *(*)) environ ; return 0; } EOF -if { (eval echo configure:5074: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5078: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_environ=no else diff --git a/binutils/configure.in b/binutils/configure.in index 7da8ab6..5e7bd3f 100644 --- a/binutils/configure.in +++ b/binutils/configure.in @@ -44,6 +44,8 @@ CY_GNU_GETTEXT AM_MAINTAINER_MODE AC_EXEEXT +AC_DEFINE_UNQUOTED(EXECUTABLE_SUFFIX, "${EXEEXT}", + [Suffix used for executables, if any.]) # host-specific stuff: diff --git a/binutils/dlltool.c b/binutils/dlltool.c index aa596c9..144fd90 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -221,11 +221,14 @@ #include "bucomm.h" #include "getopt.h" #include "demangle.h" +#include "dyn-string.h" #include "dlltool.h" #include <ctype.h> #include <time.h> -#ifdef __STDC__ +#include <sys/stat.h> + +#ifdef ANSI_PROTOTYPES #include <stdarg.h> #else #include <varargs.h> @@ -236,9 +239,9 @@ #include "coff/internal.h" #endif - /* Forward references. */ -static char * deduce_name (char *); +static char *look_for_prog PARAMS ((const char *, const char *, int)); +static char *deduce_name PARAMS ((const char *)); #ifdef DLLTOOL_MCORE_ELF static void mcore_elf_cache_filename (char *); @@ -456,12 +459,6 @@ static const unsigned char ppc_jtab[] = static bfd_vma ppc_glue_insn = 0x80410004; #endif -/* The outfile array must be big enough to contain a fully - qualified path name, plus an arbitary series of command - line switches. We hope that PATH_MAX times two will be - enough. */ -static char outfile [PATHMAX * 2]; - struct mac { const char *type; @@ -1686,6 +1683,7 @@ gen_exp_file () int i; export_type *exp; dlist_type *dl; + char *cmd; /* xgettext:c-format */ inform (_("Generating export file: %s\n"), exp_name); @@ -1903,15 +1901,17 @@ gen_exp_file () fclose (f); /* assemble the file */ - sprintf (outfile, "%s -o %s %s", as_flags, exp_name, TMP_ASM); + cmd = (char *) alloca (strlen (as_flags) + strlen (exp_name) + + sizeof TMP_ASM + 50); + sprintf (cmd, "%s -o %s %s", as_flags, exp_name, TMP_ASM); #ifdef DLLTOOL_ARM if (machine == MARM_INTERWORK || machine == MTHUMB) - strcat (outfile, " -mthumb-interwork"); + strcat (cmd, " -mthumb-interwork"); #endif - - run (as_name, outfile); - + + run (as_name, cmd); + if (dontdeltemps == 0) unlink (TMP_ASM); @@ -2091,10 +2091,14 @@ make_one_lib_file (exp, i) { #if 0 { + char *name; FILE *f; - char *prefix="d"; - sprintf (outfile, "%ss%05d.s", prefix, i); - f = fopen (outfile, FOPEN_WT); + const char *prefix = "d"; + char *cmd; + + name = (char *) alloca (strlen (prefix) + 10); + sprintf (name, "%ss%05d.s", prefix, i); + f = fopen (name, FOPEN_WT); fprintf (f, "\t.text\n"); fprintf (f, "\t%s\t%s%s\n", ASM_GLOBAL, ASM_PREFIX, exp->name); fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name); @@ -2129,15 +2133,16 @@ make_one_lib_file (exp, i) fclose (f); - sprintf (outfile, "%s -o %ss%05d.o %ss%d.s", + cmd = (char *) alloca (strlen (as_flags) + 2 * strlen (prefix) + 50); + sprintf (cmd, "%s -o %ss%05d.o %ss%d.s", as_flags, prefix, i, prefix, i); #ifdef DLLTOOL_ARM if (machine == MARM_INTERWORK || machine == MTHUMB) - strcat (outfile, " -mthumb-interwork"); + strcat (cmd, " -mthumb-interwork"); #endif - run (as_name, outfile); + run (as_name, cmd); } #else /* if 0 */ { @@ -2550,7 +2555,8 @@ make_one_lib_file (exp, i) static bfd * make_head () { - FILE * f = fopen (TMP_HEAD_S, FOPEN_WT); + FILE *f = fopen (TMP_HEAD_S, FOPEN_WT); + char *cmd; if (f == NULL) { @@ -2601,22 +2607,25 @@ make_head () fclose (f); - sprintf (outfile, "%s -o %s %s", as_flags, TMP_HEAD_O, TMP_HEAD_S); + cmd = (char *) alloca (strlen (as_flags) + sizeof TMP_HEAD_O + + sizeof TMP_HEAD_S + 50); + sprintf (cmd, "%s -o %s %s", as_flags, TMP_HEAD_O, TMP_HEAD_S); #ifdef DLLTOOL_ARM if (machine == MARM_INTERWORK || machine == MTHUMB) - strcat (outfile, " -mthumb-interwork"); + strcat (cmd, " -mthumb-interwork"); #endif - run (as_name, outfile); + run (as_name, cmd); - return bfd_openr (TMP_HEAD_O, HOW_BFD_TARGET); + return bfd_openr (TMP_HEAD_O, HOW_BFD_TARGET); } static bfd * make_tail () { - FILE * f = fopen (TMP_TAIL_S, FOPEN_WT); + FILE *f = fopen (TMP_TAIL_S, FOPEN_WT); + char *cmd; if (f == NULL) { @@ -2667,14 +2676,16 @@ make_tail () fclose (f); - sprintf (outfile, "%s -o %s %s", as_flags, TMP_TAIL_O, TMP_TAIL_S); + cmd = (char *) alloca (strlen (as_flags) + sizeof TMP_TAIL_O + + sizeof TMP_TAIL_S + 50); + sprintf (cmd, "%s -o %s %s", as_flags, TMP_TAIL_O, TMP_TAIL_S); #ifdef DLLTOOL_ARM if (machine == MARM_INTERWORK || MTHUMB) - strcat (outfile, " -mthumb-interwork"); + strcat (cmd, " -mthumb-interwork"); #endif - run (as_name, outfile); + run (as_name, cmd); return bfd_openr (TMP_TAIL_O, HOW_BFD_TARGET); } @@ -2749,12 +2760,15 @@ gen_lib_file () if (dontdeltemps < 2) { + char *name; + + name = (char *) alloca (sizeof TMP_STUB + 10); for (i = 0, exp = d_exports; exp; i++, exp = exp->next) { - sprintf (outfile, "%s%05d.o", TMP_STUB, i); - if (unlink (outfile) < 0) + sprintf (name, "%s%05d.o", TMP_STUB, i); + if (unlink (name) < 0) /* xgettext:c-format */ - warn (_("cannot delete %s: %s\n"), outfile, strerror (errno)); + warn (_("cannot delete %s: %s\n"), name, strerror (errno)); } } @@ -3305,36 +3319,127 @@ main (ac, av) return 0; } +/* Look for the program formed by concatenating PROG_NAME and the + string running from PREFIX to END_PREFIX. If the concatenated + string contains a '/', try appending EXECUTABLE_SUFFIX if it is + defined. */ + +static char * +look_for_prog (prog_name, prefix, end_prefix) + const char *prog_name; + const char *prefix; + int end_prefix; +{ + struct stat s; + char *cmd; + + cmd = xmalloc (strlen (prefix) + + strlen (prog_name) +#ifdef EXECUTABLE_SUFFIX + + strlen (EXECUTABLE_SUFFIX) +#endif + + 10); + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s", prog_name); + + if (strchr (cmd, '/') != NULL) + { + int found; + + found = (stat (cmd, &s) == 0 +#ifdef EXECUTABLE_SUFFIX + || stat (strcat (cmd, EXECUTABLE_SUFFIX), &s) == 0 +#endif + ); + + if (! found) + { + /* xgettext:c-format */ + inform (_("Tried file: %s"), cmd); + free (cmd); + return NULL; + } + } + + /* xgettext:c-format */ + inform (_("Using file: %s"), cmd); + + return cmd; +} + /* Deduce the name of the program we are want to invoke. PROG_NAME is the basic name of the program we want to run, eg "as" or "ld". The catch is that we might want actually - run "i386-pe-as" or "ppc-pe-ld". We detect this case by - examining the name used to invoke dlltool itself. If - dlltool is actually called <foo>-<bar>-dlltool then we - prepend <foo>-<bar> to the default name. */ + run "i386-pe-as" or "ppc-pe-ld". + + If argv[0] contains the full path, then try to find the program + in the same place, with and then without a target-like prefix. + + Given, argv[0] = /usr/local/bin/i586-cygwin32-dlltool, + deduce_name("as") uses the following search order: + + /usr/local/bin/i586-cygwin32-as + /usr/local/bin/as + as + + If there's an EXECUTABLE_SUFFIX, it'll use that as well; for each + name, it'll try without and then with EXECUTABLE_SUFFIX. + + Given, argv[0] = i586-cygwin32-dlltool, it will not even try "as" + as the fallback, but rather return i586-cygwin32-as. + + Oh, and given, argv[0] = dlltool, it'll return "as". + + Returns a dynamically allocated string. */ + static char * -deduce_name (char * prog_name) +deduce_name (prog_name) + const char *prog_name; { - /* Use our own static array to hold the constructed name - rather than the outfile[] array, as that array may - already be in use. */ - static char new_name[32]; - char * p; + char *cmd; + char *dash, *slash, *cp; - p = strrchr (program_name, '-'); - - if (p == NULL) - return prog_name; + dash = NULL; + slash = NULL; + for (cp = program_name; *cp != '\0'; ++cp) + { + if (*cp == '-') + dash = cp; + if ( +#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__) + *cp == ':' || *cp == '\\' || +#endif + *cp == '/') + { + slash = cp; + dash = NULL; + } + } - /* assert (strlen (program_name) < 32); */ - - strcpy (new_name, program_name); - - new_name [(p - program_name) + 1] = 0; + cmd = NULL; - strcat (new_name, prog_name); + if (dash != NULL) + { + /* First, try looking for a prefixed PROG_NAME in the + PROGRAM_NAME directory, with the same prefix as PROGRAM_NAME. */ + cmd = look_for_prog (prog_name, program_name, dash - program_name + 1); + } - return new_name; + if (slash != NULL && cmd == NULL) + { + /* Next, try looking for a PROG_NAME in the same directory as + that of this program. */ + cmd = look_for_prog (prog_name, program_name, slash - program_name + 1); + } + + if (cmd == NULL) + { + /* Just return PROG_NAME as is. */ + cmd = xstrdup (prog_name); + } + + return cmd; } #ifdef DLLTOOL_MCORE_ELF @@ -3371,79 +3476,85 @@ static void mcore_elf_gen_out_file (void) { fname_cache * ptr; + dyn_string_t ds; /* Step one. Run 'ld -r' on the input object files in order to resolve any internal references and to generate a single .exports section. */ ptr = & fnames; - strcpy (outfile, "-r "); + ds = dyn_string_new (100); + dyn_string_append (ds, "-r "); if (mcore_elf_linker_flags != NULL) - strcat (outfile, mcore_elf_linker_flags); + dyn_string_append (ds, mcore_elf_linker_flags); while (ptr->next != NULL) { - /* Check for overrun: what the hell, it's only cpu cycles... */ - if (strlen (outfile) + strlen (ptr->filename) + 2 >= sizeof (outfile)) - { - fatal (_("buffer overflow\n")); - return; - } - - strcat (outfile, ptr->filename); - strcat (outfile, " "); + dyn_string_append (ds, ptr->filename); + dyn_string_append (ds, " "); ptr = ptr->next; } - strcat (outfile, "-o "); - strcat (outfile, MCORE_ELF_TMP_OBJ); + dyn_string_append (ds, "-o "); + dyn_string_append (ds, MCORE_ELF_TMP_OBJ); if (mcore_elf_linker == NULL) mcore_elf_linker = deduce_name ("ld"); - run (mcore_elf_linker, outfile); + run (mcore_elf_linker, ds->s); + + dyn_string_delete (ds); /* Step two. Create a .exp file and a .lib file from the temporary file. Do this by recursively invoking dlltool....*/ - sprintf (outfile, "-S %s", as_name); + ds = dyn_string_new (100); + + dyn_string_append (ds, "-S "); + dyn_string_append (ds, as_name); - strcat (outfile, " -e "); - strcat (outfile, MCORE_ELF_TMP_EXP); - strcat (outfile, " -l "); - strcat (outfile, MCORE_ELF_TMP_LIB); - strcat (outfile, " " ); - strcat (outfile, MCORE_ELF_TMP_OBJ); + dyn_string_append (ds, " -e "); + dyn_string_append (ds, MCORE_ELF_TMP_EXP); + dyn_string_append (ds, " -l "); + dyn_string_append (ds, MCORE_ELF_TMP_LIB); + dyn_string_append (ds, " " ); + dyn_string_append (ds, MCORE_ELF_TMP_OBJ); if (verbose) - strcat (outfile, " -v"); + dyn_string_append (ds, " -v"); if (dontdeltemps) { - strcat (outfile, " -n"); + dyn_string_append (ds, " -n"); if (dontdeltemps > 1) - strcat (outfile, " -n"); + dyn_string_append (ds, " -n"); } /* XXX - FIME: ought to check/copy other command line options as well. */ - run (program_name, outfile); + run (program_name, ds->s); + + dyn_string_delete (ds); /* Step four. Feed the .exp and object files to ld -shared to create the dll. */ - strcpy (outfile, "-shared "); + ds = dyn_string_new (100); + + dyn_string_append (ds, "-shared "); if (mcore_elf_linker_flags) - strcat (outfile, mcore_elf_linker_flags); + dyn_string_append (ds, mcore_elf_linker_flags); + + dyn_string_append (ds, " "); + dyn_string_append (ds, MCORE_ELF_TMP_EXP); + dyn_string_append (ds, " "); + dyn_string_append (ds, MCORE_ELF_TMP_OBJ); + dyn_string_append (ds, " -o "); + dyn_string_append (ds, mcore_elf_out_file); - strcat (outfile, " "); - strcat (outfile, MCORE_ELF_TMP_EXP); - strcat (outfile, " "); - strcat (outfile, MCORE_ELF_TMP_OBJ); - strcat (outfile, " -o "); - strcat (outfile, mcore_elf_out_file); + run (mcore_elf_linker, ds->s); - run (mcore_elf_linker, outfile); + dyn_string_delete (ds); if (dontdeltemps == 0) unlink (MCORE_ELF_TMP_EXP); diff --git a/binutils/dllwrap.c b/binutils/dllwrap.c index 574611b..235b5da 100644 --- a/binutils/dllwrap.c +++ b/binutils/dllwrap.c @@ -26,21 +26,10 @@ #endif #endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <stdio.h> -#include <errno.h> -#include <string.h> -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - #include "bfd.h" #include "libiberty.h" #include "bucomm.h" @@ -49,6 +38,13 @@ #include <ctype.h> #include <time.h> +#include <sys/stat.h> + +#ifdef ANSI_PROTOTYPES +#include <stdarg.h> +#else +#include <varargs.h> +#endif #ifdef HAVE_SYS_WAIT_H #include <sys/wait.h> @@ -83,7 +79,7 @@ #endif /* ! HAVE_SYS_WAIT_H */ static char *program_version = "0.2.4"; -static char *driver_name = "gcc"; +static char *driver_name = NULL; static char *cygwin_driver_flags = "-Wl,--dll -nostartfiles"; static char *mingw32_driver_flags = "-mdll"; @@ -91,7 +87,7 @@ static char *generic_driver_flags = "-Wl,--dll"; static char *entry_point; -static char *dlltool_name = "dlltool"; +static char *dlltool_name = NULL; static char *target = TARGET; @@ -122,11 +118,186 @@ static int delete_def_file = 1; static int run PARAMS ((const char *, char *)); static void usage PARAMS ((FILE *, int)); +static void display PARAMS ((const char *, va_list)); +static void inform PARAMS ((const char *, ...)); +static char *look_for_prog PARAMS ((const char *, const char *, int)); +static char *deduce_name PARAMS ((const char *)); static void delete_temp_files PARAMS ((void)); static void cleanup_and_exit PARAMS ((int status)); /**********************************************************************/ +/* Please keep the following 4 routines in sync with dlltool.c: + display () + inform () + look_for_prog () + deduce_name () + It's not worth the hassle to break these out since dllwrap will + (hopefully) soon be retired in favor of `ld --shared. */ + +static void +display (message, args) + const char * message; + va_list args; +{ + if (program_name != NULL) + fprintf (stderr, "%s: ", program_name); + + vfprintf (stderr, message, args); + + if (message [strlen (message) - 1] != '\n') + fputc ('\n', stderr); +} + + +static void +#ifdef __STDC__ +inform (const char * message, ...) +#else +inform (message, va_alist) + const char * message; + va_dcl +#endif +{ + va_list args; + + if (!verbose) + return; + +#ifdef __STDC__ + va_start (args, message); +#else + va_start (args); +#endif + + display (message, args); + + va_end (args); +} + +/* Look for the program formed by concatenating PROG_NAME and the + string running from PREFIX to END_PREFIX. If the concatenated + string contains a '/', try appending EXECUTABLE_SUFFIX if it is + defined. */ + +static char * +look_for_prog (prog_name, prefix, end_prefix) + const char *prog_name; + const char *prefix; + int end_prefix; +{ + struct stat s; + char *cmd; + + cmd = xmalloc (strlen (prefix) + + strlen (prog_name) +#ifdef EXECUTABLE_SUFFIX + + strlen (EXECUTABLE_SUFFIX) +#endif + + 10); + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s", prog_name); + + if (strchr (cmd, '/') != NULL) + { + int found; + + found = (stat (cmd, &s) == 0 +#ifdef EXECUTABLE_SUFFIX + || stat (strcat (cmd, EXECUTABLE_SUFFIX), &s) == 0 +#endif + ); + + if (! found) + { + /* xgettext:c-format */ + inform (_("Tried file: %s"), cmd); + free (cmd); + return NULL; + } + } + + /* xgettext:c-format */ + inform (_("Using file: %s"), cmd); + + return cmd; +} + +/* Deduce the name of the program we are want to invoke. + PROG_NAME is the basic name of the program we want to run, + eg "as" or "ld". The catch is that we might want actually + run "i386-pe-as" or "ppc-pe-ld". + + If argv[0] contains the full path, then try to find the program + in the same place, with and then without a target-like prefix. + + Given, argv[0] = /usr/local/bin/i586-cygwin32-dlltool, + deduce_name("as") uses the following search order: + + /usr/local/bin/i586-cygwin32-as + /usr/local/bin/as + as + + If there's an EXECUTABLE_SUFFIX, it'll use that as well; for each + name, it'll try without and then with EXECUTABLE_SUFFIX. + + Given, argv[0] = i586-cygwin32-dlltool, it will not even try "as" + as the fallback, but rather return i586-cygwin32-as. + + Oh, and given, argv[0] = dlltool, it'll return "as". + + Returns a dynamically allocated string. */ + +static char * +deduce_name (prog_name) + const char *prog_name; +{ + char *cmd; + char *dash, *slash, *cp; + + dash = NULL; + slash = NULL; + for (cp = program_name; *cp != '\0'; ++cp) + { + if (*cp == '-') + dash = cp; + if ( +#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__) + *cp == ':' || *cp == '\\' || +#endif + *cp == '/') + { + slash = cp; + dash = NULL; + } + } + + cmd = NULL; + + if (dash != NULL) + { + /* First, try looking for a prefixed PROG_NAME in the + PROGRAM_NAME directory, with the same prefix as PROGRAM_NAME. */ + cmd = look_for_prog (prog_name, program_name, dash - program_name + 1); + } + + if (slash != NULL && cmd == NULL) + { + /* Next, try looking for a PROG_NAME in the same directory as + that of this program. */ + cmd = look_for_prog (prog_name, program_name, slash - program_name + 1); + } + + if (cmd == NULL) + { + /* Just return PROG_NAME as is. */ + cmd = xstrdup (prog_name); + } + + return cmd; +} + static void delete_temp_files () { @@ -341,6 +512,7 @@ usage (file, status) fprintf (file, " --image-base <base> Specify image base address\n"); fprintf (file, " --target <machine> i386-cygwin32 or i386-mingw32\n"); fprintf (file, " --dry-run Show what needs to be run\n"); + fprintf (file, " --mno-cygwin Create Mingw DLL\n"); fprintf (file, " Options passed to DLLTOOL:\n"); fprintf (file, " --machine <machine>\n"); fprintf (file, " --output-exp <outname> Generate export file.\n"); @@ -381,9 +553,10 @@ usage (file, status) #define OPTION_ENTRY (OPTION_DLLTOOL_NAME + 1) #define OPTION_IMAGE_BASE (OPTION_ENTRY + 1) #define OPTION_TARGET (OPTION_IMAGE_BASE + 1) +#define OPTION_MNO_CYGWIN (OPTION_TARGET + 1) /* DLLTOOL options. */ -#define OPTION_NODELETE (OPTION_TARGET + 1) +#define OPTION_NODELETE (OPTION_MNO_CYGWIN + 1) #define OPTION_DLLNAME (OPTION_NODELETE + 1) #define OPTION_NO_IDATA4 (OPTION_DLLNAME + 1) #define OPTION_NO_IDATA5 (OPTION_NO_IDATA4 + 1) @@ -568,6 +741,9 @@ main (argc, argv) case OPTION_TARGET: target = optarg; break; + case OPTION_MNO_CYGWIN: + target = "i386-mingw32"; + break; case OPTION_BASE_FILE: base_file_name = optarg; delete_base_file = 0; @@ -614,7 +790,7 @@ main (argc, argv) } } } - + /* sanity checks. */ if (! dll_name && ! dll_file_name) { @@ -631,7 +807,14 @@ main (argc, argv) { dll_file_name = xstrdup (dll_name); } - + + /* Deduce driver-name and dlltool-name from our own. */ + if (driver_name == NULL) + driver_name = deduce_name ("gcc"); + + if (dlltool_name == NULL) + dlltool_name = deduce_name ("dlltool"); + if (! def_file_seen) { char *fileprefix = choose_temp_base (); diff --git a/binutils/resrc.c b/binutils/resrc.c index 41c9cca..ed6a36a 100644 --- a/binutils/resrc.c +++ b/binutils/resrc.c @@ -1,5 +1,5 @@ /* resrc.c -- read and write Windows rc files. - Copyright 1997, 1998 Free Software Foundation, Inc. + Copyright 1997, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GNU Binutils. @@ -112,6 +112,8 @@ static int icons; /* Local functions. */ +static FILE *look_for_default PARAMS ((char *, const char *, int, + const char *, const char *)); static void close_pipe PARAMS ((void)); static void unexpected_eof PARAMS ((const char *)); static int get_word PARAMS ((FILE *, const char *)); @@ -122,41 +124,44 @@ static void define_fontdirs PARAMS ((void)); /* look for the preprocessor program */ -FILE * +static FILE * look_for_default (cmd, prefix, end_prefix, preprocargs, filename) char *cmd; - char *prefix; + const char *prefix; int end_prefix; - char *preprocargs; - char *filename; + const char *preprocargs; + const char *filename; { - char *path = getenv ("PATH"); char *space; int found; struct stat s; strcpy (cmd, prefix); - sprintf (cmd+end_prefix, "%s", DEFAULT_PREPROCESSOR); - space = strchr (cmd+end_prefix, ' '); + sprintf (cmd + end_prefix, "%s", DEFAULT_PREPROCESSOR); + space = strchr (cmd + end_prefix, ' '); if (space) *space = 0; if (strchr (cmd, '/')) { - found = stat (cmd, &s); + found = (stat (cmd, &s) == 0 +#ifdef EXECUTABLE_SUFFIX + || stat (strcat (cmd, EXECUTABLE_SUFFIX), &s) == 0 +#endif + ); - if (found < 0) + if (! found) { if (verbose) fprintf (stderr, "Tried `%s'\n", cmd); - return 0; + return NULL; } } strcpy (cmd, prefix); - sprintf (cmd+end_prefix, "%s %s %s", + sprintf (cmd + end_prefix, "%s %s %s", DEFAULT_PREPROCESSOR, preprocargs, filename); if (verbose) @@ -202,11 +207,14 @@ read_rc_file (filename, preprocessor, preprocargs, language) + strlen (preprocessor) + strlen (preprocargs) + strlen (filename) +#ifdef EXECUTABLE_SUFFIX + + strlen (EXECUTABLE_SUFFIX) +#endif + 10); dash = slash = 0; - for (cp=program_name; *cp; cp++) + for (cp = program_name; *cp; cp++) { if (*cp == '-') dash = cp; |