Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jul 2000 15:35:09 -0700 (PDT)
From:      nm@web.am
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/19959: new variable modifiers for make(1)
Message-ID:  <20000715223509.38D6437BF44@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         19959
>Category:       bin
>Synopsis:       new variable modifiers for make(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 15 15:40:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Gaspar Chilingarov
>Release:        -current
>Organization:
WEB Ltd., http://www.web.am/
>Environment:
-current

>Description:
Here is some little patch to allow usage of :U and :L modifiers
for make variables - it's used in OpenBSDish makefiles (isakmpd for example)

usage: 
--cut--
@nightmar /tmp/c# cat Makefile
STR=FooBar
L=${STR:L}
D=${STR:U}
all:
        @echo ${STR}
        @echo ${L}
        @echo ${D}
@nightmar /tmp/c# ./make
FooBar
foobar
FOOBAR
@nightmar /tmp/c#
--cut--



>How-To-Repeat:
Try to compile isakmpd distribution with FBSD make - it simply dont convert feautures list to defines correctly. 


>Fix:
apply this patch in /usr/src/usr.bin/make 

--cutline--
--- make.1.orig	Sun Jul 16 03:34:44 2000
+++ make.1	Sun Jul 16 03:38:05 2000
@@ -595,6 +595,8 @@
 Replaces each word in the variable with its suffix.
 .It Cm H
 Replaces each word in the variable with everything but the last component.
+.It Cm L
+Converts variable to lower-case letters.
 .It Cm M Ns Ar pattern
 Select only those words that match the rest of the modifier.
 The standard shell wildcard characters
@@ -684,6 +686,8 @@
 .Ar old_string
 to be replaced in
 .Ar new_string
+.It Cm U
+Converts variable to upper-case letters.
 .El
 .Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS
 Directives, conditionals, and for loops reminiscent
--- var.c.orig	Sun Jul 16 02:57:12 2000
+++ var.c	Sun Jul 16 03:33:21 2000
@@ -1428,6 +1428,10 @@
      *  	  	    	(pathname minus the suffix).
      *	    	  :lhs=rhs  	Like :S, but the rhs goes to the end of
      *	    	    	    	the invocation.
+     *            :Q		Quotes every shell meta-character in the
+     * 		 	        variable
+     *  	  :U		Converts variable to UPPER-CASE
+     *            :L		Converts variable to lower-case
      */
     if ((str != (char *)NULL) && haveModifier) {
 	/*
@@ -1442,6 +1446,42 @@
 		printf("Applying :%c to \"%s\"\n", *tstr, str);
 	    }
 	    switch (*tstr) {
+		case 'U': 
+		    if (tstr[1] == endc || tstr[1] == ':') {
+		    /* XXX are there more effective way of doing the 
+			   same thing ?*/
+		    Buffer        buf;
+    		    buf = Buf_Init (MAKE_BSIZE);
+		    for (cp = str; *cp; cp++)
+        		Buf_AddByte(buf, (Byte)toupper(*cp));
+
+    		    Buf_AddByte(buf, (Byte) '\0');
+    		    newStr = (char *)Buf_GetAll (buf, (int *)NULL);
+    		    Buf_Destroy (buf, FALSE);
+
+   		    cp = tstr + 1;
+		    termc = *cp;
+		    break;
+		}
+		/*FALLTHRU*/
+		case 'L': 
+		    if (tstr[1] == endc || tstr[1] == ':') {
+		    /* XXX are there more effective way of doing the 
+			   same thing ?*/
+		    Buffer        buf;
+    		    buf = Buf_Init (MAKE_BSIZE);
+		    for (cp = str; *cp; cp++)
+        		Buf_AddByte(buf, (Byte)tolower(*cp));
+
+    		    Buf_AddByte(buf, (Byte) '\0');
+    		    newStr = (char *)Buf_GetAll (buf, (int *)NULL);
+    		    Buf_Destroy (buf, FALSE);
+
+   		    cp = tstr + 1;
+		    termc = *cp;
+		    break;
+		}
+		/*FALLTHRU*/
 		case 'N':
 		case 'M':
 		{
--cutline--




>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000715223509.38D6437BF44>