bugmake - Bugs: bug #60811, Add long-form aliases for...

 
 

bug #60811: Add long-form aliases for automatic variables

Submitter:  Gwyneth Morgan <gwymor>
Submitted:  Wed 23 Jun 2021 03:53:55 AM UTC
   
 
Severity:  3 - Normal Priority:  5 - Normal
Item Group:  Enhancement Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Component Version:  None
Operating System:  None Fixed Release:  None
Triage Status:  None
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Sun 12 Mar 2023 01:02:28 AM UTC, comment #3: 

Will this patch be considered? This would simplify writing understandable Makefiles that work across implementations.

If long-form aliases like this are unwanted, adding $> as an alias to $^ would work as well.

original submission:

> BSD Make has several long-form aliases for automatic variables, such as `${.TARGET}` for `$@`. These are helpful for readability.
>
> GNU Make and BSD Make both have automatic variables for all prerequisites, but they differ (`$^` in GNU, `$>` or `${.ALLSRC}` in BSD), which makes writing portable makefiles tricky. Adding `${.ALLSRC}` as an alias for `$^` makes portability easier.
>
> Introduce these automatic variable aliases for easier readability and portability:
>


> .IMPSRC = $<
> .PREFIX = $*
> .TARGET = $@
> .MEMBER = $%
> .ALLSRC = $^        # $> in BSD Make
> .OODATE = $?


>
> Pass --directory=src when applying patch with git.

Gwyneth Morgan <gwymor>
Sat 26 Jun 2021 12:02:05 AM UTC, comment #2: 

BSD Make already has $<, $@, etc, which have corresponding long-form names like .IMPSRC, .TARGET, etc. However, $> in BSD Make is $^ in GNU Make, which makes it difficult to write makefiles usable in both BSD/GNU Make.

GNU Make's $^ is unportable already, so adding .ALLSRC would make it more portable as then you could use this in both BSD/GNU Make.

If not long-form aliases, we could add $> to GNU Make as an alias to $^. Adding new variables to BSD Make would be more difficult, because I believe there isn't one single "BSD Make", but each BSD has its own, so I would need to convince each BSD to add a new variable to their make rather than adding it in one place. Each of these BSD Make variants support $>, so I think adding it to gmake would improve the portability.

Gwyneth Morgan <gwymor>
Wed 23 Jun 2021 01:33:08 PM UTC, comment #1: 

$<, $@, etc are the portable automatic variables. These are standardized by posix and supported by other unix makes, e.g. sun and ibm makes.
On the other hand, .IMPSRC, etc are not portable.
Introduction of .IMPSRC to gmake cannot improve portability, it can only hinder it.
Have you considered adding $<, etc to bsd make to improve portability?

In regards to readability, i like this

%.o: %.c
    cc -o $@ -c $<

much better than this

%.o: %.c
    cc -o $(.TARGET) -c $(.IMPSRC)

Dmitry Goncharov <dgoncharov>
Wed 23 Jun 2021 03:53:55 AM UTC, original submission:  

BSD Make has several long-form aliases for automatic variables, such as `${.TARGET}` for `$@`. These are helpful for readability.

GNU Make and BSD Make both have automatic variables for all prerequisites, but they differ (`$^` in GNU, `$>` or `${.ALLSRC}` in BSD), which makes writing portable makefiles tricky. Adding `${.ALLSRC}` as an alias for `$^` makes portability easier.

Introduce these automatic variable aliases for easier readability and portability:


.IMPSRC = $<
.PREFIX = $*
.TARGET = $@
.MEMBER = $%
.ALLSRC = $^        # $> in BSD Make
.OODATE = $?


Pass --directory=src when applying patch with git.

Gwyneth Morgan <gwymor>

 

Attached Files

Attached Files
file #51593:  bmake-automatic-vars.patch added by gwymor (1.7KiB - text/x-patch)

(Note: upload size limit is set to 4.0MiB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

Carbon-Copy List
  • -email is unavailable- added by dgoncharov (Posted a comment)
  • -email is unavailable- added by gwymor (Submitted the item)
  •  

    Votes

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

    History

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-06-23 gwymor Attached File- Added bmake-automatic-vars.patch, #51593

    Back to the top

    Powered by Savane 3.16-598c.
    Corresponding source code