Article View: gnu.utils.bug
Article #642using conditionals inside define/enddef with gmake
From: J.T. Conklin
Date: Wed, 26 Aug 1992 07:43
Date: Wed, 26 Aug 1992 07:43
124 lines
3368 bytes
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';
Technical Details
Message-ID:
<9208262143.AA20195@rangoon.gain.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!gain.COM!jtcShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!gain.COM!jtc From: jtc@gain.COM (J.T. Conklin) Subject: using conditionals inside define/enddef with gmake Message-ID: <9208262143.AA20195@rangoon.gain.com> Sender: gnulists@ai.mit.edu Reply-To: jtc@gain.com Organization: GAIN Technology Inc., Palo Alto, CA Distribution: gnu Date: Wed, 26 Aug 1992 07:43:54 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 127