|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
[bug #18335] Addition of $(math ...) functionsURL: <http://savannah.gnu.org/bugs/?18335> Summary: Addition of $(math ...) functions Project: make Submitted by: dgtlrift Submitted on: Tuesday 11/21/2006 at 13:47 Severity: 3 - Normal Item Group: Enhancement Status: None Privacy: Public Assigned to: None Open/Closed: Open Component Version: 3.81 Operating System: Any Fixed Release: None _______________________________________________________ Details: I've been using a make function library that allows for math processing within a makefile (GMSL,) however, we use these fuctions on every rule and found that it slows the build chain by about 25%. It would seem much more efficient to do the math processing native within make with some function like $(math $(VAL)+($(FOO)/4)) These functions could be used in all areas of a build from formating text to dynamic creation of linker scripts. _______________________________________________________ Carbon-Copy List: CC Address | Comment ------------------------------------+----------------------------- Available only the item webpage | _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?18335> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@... http://lists.gnu.org/mailman/listinfo/bug-make |
|
|
[bug #18335] Addition of $(math ...) functionsFollow-up Comment #1, bug #18335 (project make): Funnily enough, I was volunteering to write code to move gmsl functions into native code in make itself just the other day: http://lists.gnu.org/archive/html/help-make/2006-11/msg00039.html Ping Paul? I could take on this one too, but it's all dependent on getting at least your in-theory consent to accepting such a series of patches. cheers, DaveK _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?18335> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@... http://lists.gnu.org/mailman/listinfo/bug-make |
|
|
[bug #18335] Addition of $(math ...) functionsFollow-up Comment #2, bug #18335 (project make): Oh, BTW, I would suggest ... $(math $(VAL)+($(FOO)/4)) ... that a lisp-like (non-reverse Polish) notation might be more consistent with the general style of make here: $(plus $(VAL),$(divide $(FOO),4)) cheers, DaveK _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?18335> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@... http://lists.gnu.org/mailman/listinfo/bug-make |
|
|
[bug #18335] Addition of $(math ...) functionsFollow-up Comment #3, bug #18335 (project make): My intention was to leave the math functions to the Guile integration. I'm open to discussion on this point. If we do decide to create a built-in math section for GNU make, I wouldn't want to see it using the kind of Lisp-like syntax described by Dave. While I do agree that might be more consistent with make function style, I think it's unnecessarily complicated for the user to have to write it out like that. I would prefer to see a new function $(expr ...) that takes a math expression and evaluates to the result of the expression... similar to the way the expr(1) program works in the shell. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?18335> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@... http://lists.gnu.org/mailman/listinfo/bug-make |
|
|
[bug #18335] Addition of $(math ...) functionsFollow-up Comment #4, bug #18335 (project make): The make program does a lot of work by generating shell script fragments and running them. Not only are the lines of rule bodies shell scripts, but GNU makefiles make other uses of shell features. For instance, calling the find utility to locate targets and such. Adding math functions to make is a false optimization, and a self-indulgent hack. You can easily generate $(( expr )) shell syntax and have the shell evaluate it. Look. Makefile to print two plus two: .PHONY: all FOUR := $(shell echo $$(( 2 + 2)) ) all: echo "$(FOUR)" And yes, it's clumsy to type $(shell echo $$(( <expr> ))) instead of just $(expr <expr>). That's what GNU make macros are for. With macros, you can get it down to $(call expr, <expr>). If that's too inconvenient, maybe you're stuffing way too much math into the Makefile and not enough of the normal stuff to make things. .PHONY: all define expr $(shell echo $$(( $1 )) ) endef X := 10 Y := 30 all: echo $(call expr, $(X) + $(Y)) $ make echo 40 40 If you want to optimize make by moving computation out of sub-shells into the make process, this is a poor place to start, because it's not the common case. You idiots want to put a Scheme interpreter into make? Given that half of the make syntax is really shell syntax, which is farmed out to a sub-process, it would be a much better idea to combine make with a shell implementation. That way, when make processes something like: target: case $@ in ) *.blah ... <complicateed shell script> spanning dozens of lines with lots of nested if and while, and for esac it could be interpreted without forking off a process. This would actually benefit the reams of makefiles which are already written. Then $(shell ...) could be entirely built in, and, therefore so would the $(( expr )) syntax. At that point, you could implement a shortcut to access that syntax, like $(expr <expr>). It would be icing on the cake. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?18335> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@... http://lists.gnu.org/mailman/listinfo/bug-make |
|
|
[bug #18335] Addition of $(math ...) functionsFollow-up Comment #5, bug #18335 (project make): No one is suggesting integrating Guile just to provide math functions. There are a lot of operations which are not covered by the current suite of make functions (take a look at the various enhancement requests, etc. for new ones) and I'm not interested in writing an entirely new procedural language in make. There certainly would be some performance savings from an "embedded shell", but perhaps not as much as you'd expect since /bin/sh needs to still run programs such as sed, awk, etc. to do most of its work. As well, while you might save an exec call per instance, even an embedded shell interpreter would have to do a lot of forking: that's just how the shell works. Probably, to preserve current semantics, it would need to fork for every rule it ran. On some systems forks are cheap, but definitely not all. Guile is the standard embedded scripting language for GNU. It also has a syntax that meshes well with make's syntax, which already relies on parens etc. Having shell syntax embedded in a makefile involves a lot more escaping of parenthesis, dollar signs, etc. And finally, as far as I'm aware there is no embeddable shell interpreter available anywhere, and I'm sure not interested in writing my own. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?18335> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@... http://lists.gnu.org/mailman/listinfo/bug-make |
| Free embeddable forum powered by Nabble | Forum Help |