delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2015/06/05/03:32:12

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:date:message-id:subject:from:to:content-type;
bh=lgVeXsE+ktl6WZS7kpHCT2Stcbm8Nz/f4wK+IBMnIrE=;
b=ziR3e3ZzaM8RbjpnfeXwXE0e1mKRwUhZCQefWBEhZOUIzTgQtM4YLBQ1uO1HpG0uKZ
bSaUP/u2X3Gh6tFIWGG5Ite7RmkosMRCxGyibyxqT2BsTQsF2F8TVis2kmcozIxIKb65
UvUbGj+ExNvpO8eKkWxzuo+U/nXgqbDAtcYYBQL2Lp3xHKR0xAFptxJaDFDGk6vyEbOx
EQHukVFT3rbXYSZli9UUw3aknPi3S6o9tvTxaMZZ6CveRejAQsD1VaYmtnboNK+uxusc
ikbqKQS0PHzwBTpI/4PP56kLHr1jAQCj94aXgAvK/hhPx4jTHJ6JMObq228pfka2h2LH
TBvw==
MIME-Version: 1.0
X-Received: by 10.50.61.241 with SMTP id t17mr10589682igr.34.1433489517766;
Fri, 05 Jun 2015 00:31:57 -0700 (PDT)
Date: Fri, 5 Jun 2015 10:31:57 +0300
Message-ID: <CAA2C=vAsibDAvdNkdGMFC_HeEoEGdrCX_1xTk1yDqbSgebnXdA@mail.gmail.com>
Subject: dxe3gen patch
From: "Ozkan Sezer (sezeroz AT gmail DOT com)" <djgpp AT delorie DOT com>
To: djgpp <djgpp AT delorie DOT com>
Reply-To: djgpp AT delorie DOT com

The following patch allows users of dxe3gen to customize the
build tools they use through DXE_* environment variables.
OK for CVS HEAD?  OK for 2.05?

Index: src/dxe/makefile
===================================================================
RCS file: /cvs/djgpp/djgpp/src/dxe/makefile,v
retrieving revision 1.8
diff -u -r1.8 makefile
--- src/dxe/makefile	21 Jul 2013 12:25:58 -0000	1.8
+++ src/dxe/makefile	28 May 2015 19:12:06 -0000
@@ -33,7 +33,7 @@
 	$(EXE)

 $(HOSTBIN)/dxegen.exe : dxe3gen.c init1.h init2.h init3.h init4.h
init5.h fini1.h fini2.h fini3.h fini4.h fini5.h
-	$(GCC) -DDXE_LD=\"$(CROSS_LD)\" dxe3gen.c -o $@
+	$(GCC) dxe3gen.c -o $@

 clean ::
 	@-$(MISC) rm *.o *.h $(HOSTBIN)/dxegen.exe
Index: src/libemu/makefile
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libemu/makefile,v
retrieving revision 1.3
diff -u -r1.3 makefile
--- src/libemu/makefile	6 Sep 1999 11:37:39 -0000	1.3
+++ src/libemu/makefile	28 May 2015 19:12:07 -0000
@@ -8,11 +8,17 @@
 LIBNAME=emu

 include $(TOP)/../makefile.lib
+DXE_SC=../../lib/dxe.ld
+export DXE_SC
+ifeq ($(CROSS_BUILD),1)
+DXE_LD=$(CROSS_LD)
+export DXE_LD
+endif

 all ::	$(BIN)/emu387.dxe

 $(BIN)/emu387.dxe : src/emu387.o src/emudummy.o
 	$(HOSTBIN)/dxegen.exe $(BIN)/emu387.dxe __emu_entry src/emu387.o
id_emu.o src/emudummy.o -L../../lib $(LIBGCCA) -lc $(LIBGCCA)
-	
+
 clean ::
 	$(MISC) rm makefile.sub
Index: src/dxe/dxe3gen.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/dxe/dxe3gen.c,v
retrieving revision 1.20
diff -u -r1.20 dxe3gen.c
--- src/dxe/dxe3gen.c	23 May 2015 08:20:05 -0000	1.20
+++ src/dxe/dxe3gen.c	28 May 2015 19:12:06 -0000
@@ -165,10 +165,6 @@
 #endif  /*  !DEBUG_SUPPORT_PRINT_RELOCATION_DIRECTIVES  */


-#ifndef DXE_LD
-/* Cross compile ld name/location */
-#define DXE_LD  "ld"
-#endif
 #ifdef _POSIX_SOURCE
 /* Linux violates POSIX.1 and defines this, but it shouldn't.. */
 #undef _POSIX_SOURCE
@@ -297,6 +293,15 @@
 };


+static char *libdir;
+/* build tools */
+static char *dxe_cc; /* default: "gcc" */
+static char *dxe_as; /* default: "as" */
+static char *dxe_ar; /* default: "ar" */
+static char *dxe_ld; /* default: "ld" */
+/* linker script */
+static char *dxe_sc; /* default: "dxe.ld" */
+

 /* Desc: replaces backslash with slash in a path
  *
@@ -410,6 +415,45 @@



+/* Desc: process the DXE_?? environment variables
+ */
+static void process_env(void)
+{
+  const char *e;
+
+  if ((e = getenv("DXE_CC")) != NULL)
+       dxe_cc = strdup(e);
+  else dxe_cc = strdup("gcc");
+
+  if ((e = getenv("DXE_AS")) != NULL)
+       dxe_as = strdup(e);
+  else dxe_as = strdup("as");
+
+  if ((e = getenv("DXE_AR")) != NULL)
+       dxe_ar = strdup(e);
+  else dxe_ar = strdup("ar");
+
+  if ((e = getenv("DXE_LD")) != NULL)
+       dxe_ld = strdup(e);
+  else dxe_ld = strdup("ld");
+
+  if ((e = getenv("DXE_SC")) != NULL)
+       dxe_sc = strdup(e);
+  else dxe_sc = strdup("dxe.ld");
+
+  if ((e = getenv("DXE_LD_LIBRARY_PATH")) != NULL)
+       libdir = strdup(e);
+  else if ((e = getenv("DJDIR")) != NULL) {
+       size_t sz = strlen(e) + 5U;
+       libdir = malloc(sz);
+       strcpy(libdir, e);
+       strcat(libdir, "/lib");
+       canonicalize_path(libdir);
+  }
+  else libdir = NULL;
+}
+
+
 /* Desc: process command line args
  *
  * In  : no of arguments, argument list, ptr to store linker args
@@ -419,30 +463,15 @@
  */
 static void process_args(int argc, char *argv[], const char *new_argv[])
 {
-  static char libdir[FILENAME_MAX];
-  char *p;
   int i, new_argc = NUMBER_OF_LINKER_ARGS;

-  p = getenv("DXE_LD_LIBRARY_PATH");
-  if (p)
-    strcpy(libdir, p);
-  else
+  if (!libdir)
   {
-    p = getenv("DJDIR");
-    if (p)
-    {
-      strcpy(libdir, p);
-      strcat(libdir, "/lib");
-      canonicalize_path(libdir);
-    }
-    else
-    {
       fprintf(stderr, "Error: neither DXE_LD_LIBRARY_PATH nor DJDIR
are set in environment\n");
       exit(1);
-    }
   }

-  new_argv[0] = DXE_LD;
+  new_argv[0] = dxe_ld;
   new_argv[1] = "-X";
   new_argv[2] = "-S";
   new_argv[3] = "-r";
@@ -451,7 +480,7 @@
   new_argv[6] = "-L";
   new_argv[7] = libdir;
   new_argv[8] = "-T";
-  new_argv[9] = "dxe.ld";
+  new_argv[9] = dxe_sc;

   if (!strcmp(base_name(argv[0]), "dxegen"))
     /* invoked as `dxegen' */
@@ -736,7 +765,7 @@
   if ((rv = my_spawn(argv)) != 0)
   {
     if (rv == -1)
-      perror(DXE_LD);
+      perror("ld");
     exit(rv);
   }

@@ -861,7 +890,7 @@
       if (rv)
       {
         if (rv == -1)
-          perror(DXE_LD);
+          perror("ld");
         exit(rv);
       }

@@ -1336,7 +1365,8 @@
     }

     /* Pre-compile the resolver's output. */
-    rv = system("gcc -o "TEMP_S_FILE" -O2 -S "TEMP_BASE".c");
+    sprintf(cmdbuf, "%s -o %s -O2 -S %s.c", dxe_cc, TEMP_S_FILE, TEMP_BASE);
+    rv = system(cmdbuf);
     remove(TEMP_BASE".c");
     if (rv != 0)
     {
@@ -1420,7 +1450,8 @@
   atexit(exit_cleanup);

   /* Allright, now run the assembler on the resulting file */
-  if ((rv = system("as -o "TEMP_O_FILE" "TEMP_S_FILE)) != 0)
+  sprintf(cmdbuf, "%s -o %s %s", dxe_as, TEMP_O_FILE, TEMP_S_FILE);
+  if ((rv = system(cmdbuf)) != 0)
   {
     if (rv == -1)
       perror("as");
@@ -1428,7 +1459,7 @@
   }

   /* Okey-dokey, let's stuff the object file into the archive */
-  sprintf(cmdbuf, "ar crs %s "TEMP_O_FILE, opt.implib);
+  sprintf(cmdbuf, "%s crs %s "TEMP_O_FILE, dxe_ar, opt.implib);
   if ((rv = system(cmdbuf)) != 0)
   {
     if (rv == -1)
@@ -1512,6 +1543,7 @@
   progname = argv[0];
   /* Prepare the command line for ld */
   new_argv = (const char **)malloc((argc - 1 + NUMBER_OF_LINKER_ARGS
+ NUMBER_OF_ADDITIONAL_LOADED_LIBS + 2 + 1) * sizeof(char *));
+  process_env();
   process_args(argc, argv, new_argv);

   if (opt.showdep || opt.showexp || opt.showunres)

--
O.S.

- Raw text -


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