delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/05/11/00:06:48

From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <10305110406.AA11655@clio.rice.edu>
Subject: Re: DXE3 in DJGPP CVS breaks cross-compiling
To: djgpp-workers AT delorie DOT com
Date: Sat, 10 May 2003 23:06:49 -0500 (CDT)
Cc: dborca AT yahoo DOT com
In-Reply-To: <10305110209.AA23962@clio.rice.edu> from "Charles Sandmann" at May 10, 2003 09:09:51 PM
X-Mailer: ELM [version 2.5 PL2]
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Proposed patch for dxe3gen.c - doesn't fix endian issues, but does allow
the program to compile on a sparc with GCC 2.95.2, so it appears include
clean.  (Also need to remove the -I ../../include in the current makefile).
I think this should allow a cross build on Linux/x86 (or Alpha ...).
(yes, I know it could be more defensive on buffer sizes, but I've been
up for over 24 hours straight right now flying back from europe and I
really don't care ;-P

The test suite runs and passes also.

--- dxe3gen.c_	Sat May 10 22:42:10 2003
+++ dxe3gen.c	Sat May 10 22:38:56 2003
@@ -16,15 +16,16 @@
 */
 
-#include <coff.h>
 #include <ctype.h>
-#include <process.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <libc/unconst.h>
-#include <sys/dxe.h>
 
-#ifndef DXE_LD
+#ifndef DXE_LD			/* Cross compile ld name/location */
 #define DXE_LD "ld"
+#include <sys/dxe.h>
+#include <coff.h>
+#else
+#include "../../include/sys/dxe.h"
+#include "../../include/coff.h"
 #endif
 
@@ -343,5 +344,16 @@
 }
 
-
+static int myspawn(const char **argv)
+{
+  char cmd[10240];
+  strcpy(cmd, argv[0]);
+  argv++;
+  while (argv[0]) {
+    strcat(cmd, " ");
+    strcat(cmd, argv[0]);
+    argv++;
+  };
+  return system(cmd);
+}
 
 /* Desc: run linker to obtain relocatable output
@@ -357,5 +369,5 @@
  FILE *f;
 
- if ((rv = spawnvp(P_WAIT, DXE_LD, unconst(argv, char *const *))) != 0) {
+ if ((rv = myspawn(argv)) != 0) {
     if (rv == -1) {
        perror(DXE_LD);
@@ -457,5 +469,5 @@
        argv[i] = NULL;
 
-       rv = spawnvp(P_WAIT, DXE_LD, unconst(argv, char *const *));
+       rv = myspawn(argv);
 
        if (init > 0) {
@@ -894,4 +906,5 @@
  char basename_org[FILENAME_MAX];
  dxe3_header dh;
+ char cmdbuf[512];
  FILE *implib, *f = open_dxe_file(opt.dxefile, &dh);
 
@@ -911,17 +924,19 @@
  if (opt.autoresolve) {
     /* Fire the resolver. It should take care of the dependencies (if any) */
-    if ((rv = spawnlp(P_WAIT, "dxe3res.exe", "dxe3res", "-o", "$$dxe$$.c", opt.dxefile, NULL)) != 0) {
+    strcpy(cmdbuf, "dxe3res -o $$dxe$$.c ");
+    strcat(cmdbuf, opt.dxefile);
+    if ((rv = system(cmdbuf)) != 0) {
        if (rv == -1) {
-          perror("dxe3res.exe");
+          perror("dxe3res");
        }
        exit(rv);
     }
 
-    /* Pre-compile the resolver's output. Too bad DOS gcc doesn't smoke (pipe) */
-    rv = spawnlp(P_WAIT, "gcc.exe", "gcc", "-o", TEMP_S_FILE, "-O2", "-S", "$$dxe$$.c", NULL);
+    /* Pre-compile the resolver's output. */
+    rv = system("gcc -o "TEMP_S_FILE" -O2 -S $$dxe$$.c");
     remove("$$dxe$$.c");
     if (rv != 0) {
        if (rv == -1) {
-          perror("gcc.exe");
+          perror("gcc");
        }
        exit(rv);
@@ -1003,7 +1018,7 @@
 
  /* Allright, now run the assembler on the resulting file */
- if ((rv = spawnlp(P_WAIT, "as.exe", "as", "-o", TEMP_O_FILE, TEMP_S_FILE, NULL)) != 0) {
+ if ((rv = system("as -o "TEMP_O_FILE" "TEMP_S_FILE)) != 0) {
     if (rv == -1) {
-       perror("as.exe");
+       perror("as");
     }
     exit(rv);
@@ -1011,7 +1026,8 @@
 
  /* Okey-dokey, let's stuff the object file into the archive */
- if ((rv = spawnlp(P_WAIT, "ar.exe", "ar", "crs", opt.implib, TEMP_O_FILE, NULL)) != 0) {
+ sprintf(cmdbuf, "ar crs %s "TEMP_O_FILE, opt.implib);
+ if ((rv = system(cmdbuf)) != 0) {
     if (rv == -1) {
-       perror("ar.exe");
+       perror("ar");
     }
     exit(rv);

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019