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


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

Submitted by:  Gwyneth Morgan <gwymor>
Submitted on:  Wed 23 Jun 2021 03:53:55 AM UTC
Severity:  3 - 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

Add a New Comment (Rich Markup)

Comment Type & Canned Response:
       No canned response available


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>


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

Attach Files:

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


Depends on the following items: None found

Items that depend on this one: None found


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

    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.





    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.9