From: Martin Str|mberg Message-Id: <199807070510.HAA07007@sister.ludd.luth.se> Subject: dxegen patch To: djgpp-workers AT delorie DOT com (DJGPP-WORKERS) Date: Tue, 7 Jul 1998 07:10:51 +0200 (MET DST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk Ok, I have sorted out the troubles with dxegen, patch follow. Shortly, to find out where libgcc.a is we ask gcc. Then we must call the right GCC. I've posted the patch to makefile.inc before, but as this has to do the the making I thought I'd better post that part again. This Mortal Coil, Blood, MartinS diff -ru src.org/dxe/dxegen.c src/dxe/dxegen.c --- src.org/dxe/dxegen.c Sat May 30 19:51:10 1998 +++ src/dxe/dxegen.c Tue Jul 7 04:01:18 1998 @@ -8,6 +8,8 @@ #include "../../include/coff.h" #include "../../include/sys/dxe.h" +#define DXE_MAXLEN (1024) + /* This next function is needed for cross-compiling when the machine isn't little-endian like the i386 */ @@ -85,7 +87,7 @@ dosswap(&fh, "sslllss"); if (fh.f_nscns != 1 || argc > 4) { - char command[1024], *libdir; + char command[DXE_MAXLEN], *libdir; fclose(input_f); #ifdef DXE_LD @@ -107,6 +109,48 @@ } strcat(command, libdir); strcat(command, "/lib "); +#if 1 + { + char gcc_command[DXE_MAXLEN]; + char gcc_libdir_name[DXE_MAXLEN]; + char format[DXE_MAXLEN]; + char *pos; + +#ifdef DXE_GCC + sprintf(gcc_command, DXE_GCC); +#else + sprintf(gcc_command, "gcc"); +#endif + strcat(gcc_command, " --print-libgcc-file-name"); + input_f = popen(gcc_command, "r"); + if(!input_f) + { + fprintf(stderr, "Error: tried to run command '%s', which failed. This is needed to find 'libgcc.a'.\n", gcc_command); + exit(1); + } + sprintf(format, "%%%d[^\n]", DXE_MAXLEN); + if(fscanf(input_f, format, gcc_libdir_name) == 0) + { + fprintf(stderr, "Error: tried to run command '%s', which generated no output. This is needed to find 'libgcc.a'.\n", gcc_command); + exit(1); + } + pclose(input_f); + gcc_libdir_name[DXE_MAXLEN - 1] = 0; + pos = strrchr(gcc_libdir_name, '\\'); + if(!pos) + { + pos = strrchr(gcc_libdir_name, '/'); + } + if(pos) + { + *pos = 0; + } + strcat(command, " -L"); + strcat(command, gcc_libdir_name); + strcat(command, " "); + } +#endif + for(i=3;argv[i];i++) { strcat(command, argv[i]); diff -ru src.org/dxe/makefile src/dxe/makefile --- src.org/dxe/makefile Thu Jan 1 23:25:10 1998 +++ src/dxe/makefile Tue Jul 7 04:01:20 1998 @@ -16,7 +16,7 @@ $(XLGCC) dxegen.c -o $@ $(HOSTBIN)/dxegen.exe : dxegen.c - $(GCC) -DDXE_LD=\"$(CROSS_LD)\" dxegen.c -o $@ + $(GCC) -DDXE_LD=\"$(CROSS_LD)\" -DDXE_GCC=\"$(CROSS_GCC)\" dxegen.c -o $@ clean :: @-$(MISC) rm *.o $(HOSTBIN)/dxegen.exe diff -ru src.org/makefile.inc src/makefile.inc --- src.org/makefile.inc Sat May 30 21:33:24 1998 +++ src/makefile.inc Tue Jul 7 04:46:14 1998 @@ -54,7 +54,7 @@ C = $(LIB)/crt0.o L = $(LIB)/libc.a -LINK = $(CROSS_LD) -s $(LDFLAGS) $(filter %.o,$^) $(filter-out %.o,$^) -o $@ ${LIB}/libgcc.a -T ${TOP}/../../lib/djgpp.djl +LINK = $(CROSS_GCC) -s $(LDFLAGS) -nostartfiles $(filter %.o,$^) $(filter-out %.o,$^) -o $@ EXE = $(HOSTBIN)/stubify.exe $@ OBJS := $(addsuffix .o, $(basename $(SRC))) @@ -74,10 +74,12 @@ $(HOSTBIN)/%.exe : % $(GCC) -o $@ $^ -all :: $(OBJS) $(EXTRA_OBJS) $(EXTRA_FILES) makefile.oh +all :: $(OBJS) $(EXTRA_OBJS) $(EXTRA_FILES) $(NOP) ifneq ($(MAKEFILE_LIB),1) +all :: makefile.oh + makefile.oh : makefile @$(MISC) echo - building new response file @$(MISC) echo makefile.oh $(addprefix \&/,$(OBJS))