Re: sh embedding
On Mon, 2012-07-23 at 11:59 -0700, icegood wrote: .PHONEY: all all: if [ \( $$(ls *.lock 2/dev/null) == \) ]; then \ touch $@.lock; \ if [ \( ! -e $@ \) -o \( ../$(tag_fn) -nt $@ \) ]; then \ echo $@ done; \ else \ touch $@; \ fi; \ rm -f $@.lock; \ else \ sleep 1; \ fi; The code as you've shown it looks fine to me (except you misspelled .PHONY). When I run it, it works as expected; no errors. So obviously there's something different about your environment that you haven't shown us. For example, you don't show what the value of the tag_fn variable is here. If it contains special characters that could explain it. You probably want to quote it (along with all other variables like $@, etc., just to be safe). What does make print out to the screen when you run the makefile? If you examine that carefully you should be able to see the problem; that's what make sends to the shell and the shell is the one that's complaining. ___ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make
Re: sh embedding
On Mon, Jul 23, 2012 at 11:59 AM, icegood icegood1...@gmail.com wrote: from newer version of gnu make (3.81 under kubuntu 12.04) .PHONEY: all all: if [ \( $$(ls *.lock 2/dev/null) == \) ]; then \ The '==' operator is a bash extension that is supported by many but not all shells. Perhaps the shell seen by make on your kubuntu system is one that doesn't support it? The portable (30+ years!) equality operator is =. (The '==' operator was an extension that improved usability but added no new functionality and instead reduced portability; thanks, bash maintainers, for screwing everyone by making that tradeoff!) touch $@.lock; \ This check for lock file, if it doesn't exist then create it operation is *not* 100% safe! If two makes are run at almost the same time, they may both see the file doesn't exist and then both touch the lock file and continue, so the lock file is not actually guaranteeing that only one copy is running. You should see if there's a real atomic lock file program on your system that you can use for this. For example, I see a flock program on a Redhat system that could be used, those the usage is a bit different. if [ \( ! -e $@ \) -o \( ../$(tag_fn) -nt $@ \) ]; then \ echo $@ done; \ else \ touch $@; \ fi; \ Isn't this the same as making $(tag_fn) a dependency of 'all' and having 'all' *not* be PHONY? rm -f $@.lock; \ else \ sleep 1; \ fi; If the lock cannot be obtained, you just sleep a second and then return success? Why not at least exit 1 there so that the caller can tell that the make failed in a consistent fashion? Philip Guenther ___ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make
Re: sh embedding
Philip Guenther-2 wrote: The '==' operator is a bash extension... Yes! Indeed! I checked. The problem was in '=='. I simply use 'c' much more than bash, that why i used it. Since main question is closed we can now flud about others :) So, about locks. You understand idea of locks in right way. And they indeed was created to prevent dublication of making. And, of course, it's not atomic, i know. Nothing actually atomic in make. Only rule chains are well synchronized. All i have. Full template lib code is: http://old.nabble.com/file/p34202354/common_lib.mak common_lib.mak where 1) real library has own folder, make inside that looks like this: library:=... src:=... # template classes are not included into output library templ_class_src:= sublibraries:=other libs with same make and same common template include ../common_lib.mak and maybe some inner library dependencies: foo: bar 2) other variables (like compiler) are defined in root make So. idea of parallel making was not only prevent double make but also allow other make process to continue building process without waiting sibling one. That's why i don't use any 'exit 1' cases. I hasn't found better way to allow continue building of sibling process without building all files. But at least it works. In nonparallel case everything works, of course, too, but it's not interest case. -- View this message in context: http://old.nabble.com/sh-embedding-tp34201839p34202354.html Sent from the Gnu - Make - Bugs mailing list archive at Nabble.com. ___ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make