🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by J.T. Conklin Wed, 26 Aug 1992 07:43
using conditionals inside define/enddef with gmake
#642
Author: J.T. Conklin
Date: Wed, 26 Aug 1992 07:43
124 lines
3368 bytes
It would be useful to be able to use conditionals for slight
variations needed between different architectures.  The following
patch allows you to do so.

*** ../make-3.62/read.c	Thu Oct 10 13:20:54 1991
--- read.c	Thu Jul 23 18:00:04 1992
***************
*** 73,80 ****

  static struct conditionals toplevel_conditionals;
  static struct conditionals *conditionals = &toplevel_conditionals;
-

  /* Default directories to search for include files in  */

  static char *default_include_directories[] =
--- 73,80 ----

  static struct conditionals toplevel_conditionals;
  static struct conditionals *conditionals = &toplevel_conditionals;

+
  /* Default directories to search for include files in  */

  static char *default_include_directories[] =
***************
*** 605,610 ****
--- 605,611 ----
    char *definition = (char *) xmalloc (100);
    register unsigned int idx = 0;
    register char *p;
+   int ignoring = 0;

    initbuffer (&lb);
    while (!feof (infile))
***************
*** 613,618 ****
--- 614,640 ----
        nlines = readline (&lb, infile, filename);
        p = next_token (lb.buffer);

+
+ #define	word1eq(s, l) 	((p[l] == '\0' || isblank (p[l])) && \
+ 			 !strncmp (s, p, l))
+
+       if (word1eq ("ifdef", 5) || word1eq ("ifndef", 6)
+ 	  || word1eq ("ifeq", 4) || word1eq ("ifneq", 5)
+ 	  || word1eq ("else", 4) || word1eq ("endif", 5))
+ 	{
+ 	  int i = conditional_line (p, filename, lineno);
+ 	  if (i >= 0)
+ 	    {
+ 	      ignoring = i;
+ 	      continue;
+ 	    }
+ 	  else
+ 	    makefile_fatal (filename, lineno,
+ 			    "invalid syntax in conditional");
+ 	}
+       if (ignoring)
+ 	continue;
+
        if ((p[5] == '\0' || isblank (p[5])) && !strncmp (p, "endef", 5))
  	{
  	  p += 5;
***************
*** 647,655 ****
  	  definition[idx++] = '\n';
  	}
      }

!   /* No `endef'!!  */
!   makefile_fatal (filename, lineno, "missing `endef', unterminated `define'");
    return 0;
  }
  
--- 669,681 ----
  	  definition[idx++] = '\n';
  	}
      }
+ #undef word1eq

!   /* No `endif' or `endef'  */
!   if (ignoring)
!     makefile_fatal (filename, lineno, "missing `endif'");
!   else
!     makefile_fatal (filename, lineno, "missing `endef', unterminated `define'");
    return 0;
  }
  
***************
*** 1005,1011 ****
  		d->name = savestring (buffer, o - buffer);
  	      }
  	  }
!
        if (!two_colon)
  	{
  	  /* Single-colon.  Combine these dependencies
--- 1031,1037 ----
  		d->name = savestring (buffer, o - buffer);
  	      }
  	  }
!
        if (!two_colon)
  	{
  	  /* Single-colon.  Combine these dependencies
***************
*** 1354,1360 ****
  	  else
  	    break;
  	}
!
        if (!backslash)
  	{
  	  p[-1] = '\0';
--- 1380,1386 ----
  	  else
  	    break;
  	}
!
        if (!backslash)
  	{
  	  p[-1] = '\0';
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads