problems with recursive make target

2009-06-29 Thread johnwohlbier
I need separate targets to build tests and to execute tests, so check-local  
alone is not enough. Our machines allow compiling on the "frontend" and  
running on the "backend," so I'd like a recursive make target  
called "tests" that only compiles the tests, then I'll use check-local for  
test execution with autotest. Following this  
http://www.freesoftwaremagazine.com/books/agaal/catalog_of_reusable_solutions  
I tried the following.


My directory structure is
top/
top/lib
top/lib/pika_comm
top/lib/pika_comm/test
top/lib/pika_utilities
top/lib/pika_utilities/test

in top/Makefile.am
SUBDIRS = ${CELLDIR} lib
# provide a separate recursive target for making tests
tests : all
for dir in $(SUBDIRS); do \
cd $$dir && $(MAKE) $(AM_MAKEFLAGS) $@ || exit 1; \
done

.PHONY : tests

in top/lib/Makefile.am
SUBDIRS = pika_comm pika_utilities
# provide a separate recursive target for making tests
tests : all
echo `pwd`;
for dir in $(SUBDIRS); do \
cd $$dir && $(MAKE) $(AM_MAKEFLAGS) $@ || exit 1; \
done
echo `pwd`;
.PHONY : tests

in top/lib/pika_comm/Makefile.am
tests : all
cd test && $(MAKE) $(AM_MAKEFLAGS) $@ || exit 1;
.PHONY : tests

in top/lib/pika_comm/test/Makefile.am (note the absence of $@ in this make  
command, as I just want this to do "make" on the test sources)

tests :
$(MAKE) $(AM_MAKEFLAGS) || exit 1
.PHONY : tests

and similarly for top/lib/pika_utilities(/test)

For some reason this is not working. I believe what is happening is that  
when I issue make tests (after properly building all, if needed) it  
descends down into pika_comm/test, makes the test executables, but then  
does not properly change back to top/lib/. Here is some make output showing  
this (all has already been built so isn't built again):


[wohlb...@rr-dev-fe build]$ make tests
Making all in lib
make[1]: Entering directory `/users/wohlbier/MPMC/pika/build/lib'
Making all in pika_comm
make[2]: Entering directory `/users/wohlbier/MPMC/pika/build/lib/pika_comm'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/users/wohlbier/MPMC/pika/build/lib/pika_comm'
Making all in pika_utilities
make[2]: Entering directory  
`/users/wohlbier/MPMC/pika/build/lib/pika_utilities'

make[2]: Nothing to be done for `all'.
make[2]: Leaving directory  
`/users/wohlbier/MPMC/pika/build/lib/pika_utilities'

make[2]: Entering directory `/users/wohlbier/MPMC/pika/build/lib'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/users/wohlbier/MPMC/pika/build/lib'
make[1]: Leaving directory `/users/wohlbier/MPMC/pika/build/lib'
make[1]: Entering directory `/users/wohlbier/MPMC/pika/build'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/users/wohlbier/MPMC/pika/build'
for dir in lib; do \
cd $dir && make tests || exit 1; \
done
make[1]: Entering directory `/users/wohlbier/MPMC/pika/build/lib'
Making all in pika_comm
make[2]: Entering directory `/users/wohlbier/MPMC/pika/build/lib/pika_comm'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/users/wohlbier/MPMC/pika/build/lib/pika_comm'
Making all in pika_utilities
make[2]: Entering directory  
`/users/wohlbier/MPMC/pika/build/lib/pika_utilities'

make[2]: Nothing to be done for `all'.
make[2]: Leaving directory  
`/users/wohlbier/MPMC/pika/build/lib/pika_utilities'

make[2]: Entering directory `/users/wohlbier/MPMC/pika/build/lib'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/users/wohlbier/MPMC/pika/build/lib'
echo `pwd`;
/users/wohlbier/MPMC/pika/build/lib
for dir in pika_comm pika_utilities; do \
cd $dir && make tests || exit 1; \
done
make[2]: Entering directory `/users/wohlbier/MPMC/pika/build/lib/pika_comm'
cd test && make tests || exit 1;
make[3]: Entering directory  
`/users/wohlbier/MPMC/pika/build/lib/pika_comm/test'

make || exit 1
make[4]: Entering directory  
`/users/wohlbier/MPMC/pika/build/lib/pika_comm/test'

make[4]: Nothing to be done for `all'.
make[4]: Leaving directory  
`/users/wohlbier/MPMC/pika/build/lib/pika_comm/test'
make[3]: Leaving directory  
`/users/wohlbier/MPMC/pika/build/lib/pika_comm/test'

make[2]: Leaving directory `/users/wohlbier/MPMC/pika/build/lib/pika_comm'
/bin/sh: line 1: cd: pika_utilities: No such file or directory
make[1]: *** [tests] Error 1
make[1]: Leaving directory `/users/wohlbier/MPMC/pika/build/lib'
make: *** [tests] Error 1
[wohlb...@rr-dev-fe build]$


Any ideas anyone?


Re: problems with recursive make target

2009-06-29 Thread Ralf Wildenhues
Hello John,

* johnwohlb...@gmail.com wrote on Mon, Jun 29, 2009 at 09:36:09PM CEST:
> in top/lib/Makefile.am
> SUBDIRS = pika_comm pika_utilities
> # provide a separate recursive target for making tests
> tests : all
> echo `pwd`;
> for dir in $(SUBDIRS); do \
> cd $$dir && $(MAKE) $(AM_MAKEFLAGS) $@ || exit 1; \
> done
> echo `pwd`;
> .PHONY : tests

You don't ever 'cd' back out of the first subdirectory, so you can't
find the second:

> make[2]: Leaving directory `/users/wohlbier/MPMC/pika/build/lib/pika_comm'
> /bin/sh: line 1: cd: pika_utilities: No such file or directory
> make[1]: *** [tests] Error 1

Cheers,
Ralf




Re: Re: problems with recursive make target

2009-06-29 Thread johnwohlbier

On Jun 29, 2009 1:44pm, Ralf Wildenhues  wrote:

Hello John,
* johnwohlb...@gmail.com wrote on Mon, Jun 29, 2009 at 09:36:09PM CEST:
> in top/lib/Makefile.am
> SUBDIRS = pika_comm pika_utilities
> # provide a separate recursive target for making tests
> tests : all
> echo `pwd`;
> for dir in $(SUBDIRS); do \
> cd $$dir && $(MAKE) $(AM_MAKEFLAGS) $@ || exit 1; \
> done
> echo `pwd`;
> .PHONY : tests



You don't ever 'cd' back out of the first subdirectory, so you can't
find the second:


> make[2]: Leaving directory  
`/users/wohlbier/MPMC/pika/build/lib/pika_comm'

> /bin/sh: line 1: cd: pika_utilities: No such file or directory
> make[1]: *** [tests] Error 1
Cheers,



Ralf



Thanks Ralf. I feel pretty dumb. You know I suspected that was the problem,  
and was trying to cd ../. But now I realize I was putting the cd ../ in the  
wrong place. After my wrongly placed cd ../ didn't work (which I thought  
was rightly placed) I thought maybe that the example code at  
http://www.freesoftwaremagazine.com/books/agaal/catalog_of_reusable_solutions  
was correct and make would handle the cd'ing for me. Maybe I should file a  
documentation bug report with John Calcote!


jgw


Re: problems with recursive make target

2009-06-29 Thread John Calcote

Hi John,

On 6/29/2009 1:44 PM, Ralf Wildenhues wrote:

Hello John,

* johnwohlb...@gmail.com wrote on Mon, Jun 29, 2009 at 09:36:09PM CEST:
   

in top/lib/Makefile.am
SUBDIRS = pika_comm pika_utilities
# provide a separate recursive target for making tests
tests : all
echo `pwd`;
for dir in $(SUBDIRS); do \
cd $$dir&&  $(MAKE) $(AM_MAKEFLAGS) $@ || exit 1; \
done
echo `pwd`;
.PHONY : tests
 


You don't ever 'cd' back out of the first subdirectory, so you can't
find the second:
   
Ralf is correct, of course. In my online catalog of solutions, I'd 
copied and modified this code from an Automake-generated Makefile. But I 
inadvertently left the parentheses off the cd command line, which would 
have invoked the entire line in a sub-shell:


for dir in $(SUBDIRS); do \
  (cd $$dir&&  $(MAKE) $(AM_MAKEFLAGS) $@ || exit 1) \
done


Sorry for the confusion.

John



Re: Circular dependency dropped warning from make in relating to CUDA code

2009-06-29 Thread Adam Mercer
On Sat, Jun 27, 2009 at 05:33, Ralf Wildenhues wrote:

Ralf

> Why not name the product file CudaChisq.c rather than CudaChisq.cu.c?
> The problem here is that the other half of the circle comes from the
> make-internal rule `%: %.c' for compiling single-source programs.
> I guess you can also avoid it with `make -r', but that may have other,
> unwanted consequences.
>
> (Note also that using $< in target rules is not portable to non-GNU
> make).

Is there a more portable version?

> Here's what I would do:
>
> NVCC = nvcc
> NVCFLAGS = -cuda --host-compilation=c
> SUFFIXES = .cu .c
> .cu.c:
>        $(NVCC) $(NVCFLAGS) $(INCLUDES) $(CPPFLAGS) --output-file $@ $<
>
> and then list *.cu files in automake *_SOURCES variables instead of the
> *.c files.  You can list *.c files in EXTRA_DIST if you want to have
> them distributed (which implies that the output of nvcc should be
> portable, which I don't know whether it is the case).
>
> Hope that helps.

Thanks, that's got rid of the warning!

Cheers

Adam




Re: problems with recursive make target

2009-06-29 Thread John Calcote

John,

On 6/29/2009 2:00 PM, johnwohlb...@gmail.com wrote:

On Jun 29, 2009 1:44pm, Ralf Wildenhues  wrote:
Hello John, Thanks Ralf. I feel pretty dumb. You know I suspected 
that was the problem, and was trying to cd ../. But now I realize I 
was putting the cd ../ in the wrong place. After my wrongly placed cd 
../ didn't work (which I thought was rightly placed) I thought maybe 
that the example code at 
http://www.freesoftwaremagazine.com/books/agaal/catalog_of_reusable_solutions 
was correct and make would handle the cd'ing for me. Maybe I should 
file a documentation bug report with John Calcote!

Fixed! Thanks!

John




Re: Circular dependency dropped warning from make in relating to CUDA code

2009-06-29 Thread Ralf Wildenhues
* Adam Mercer wrote on Mon, Jun 29, 2009 at 10:19:59PM CEST:
> On Sat, Jun 27, 2009 at 05:33, Ralf Wildenhues wrote:
> 
> > (Note also that using $< in target rules is not portable to non-GNU
> > make).
> 
> Is there a more portable version?

Using $< in inference rules, as in my example, is portable.
In target rules, you can spell out the input file name
(including an eventual vpath prefix).

> > Here's what I would do:
> >
> > NVCC = nvcc
> > NVCFLAGS = -cuda --host-compilation=c
> > SUFFIXES = .cu .c
> > .cu.c:
> >        $(NVCC) $(NVCFLAGS) $(INCLUDES) $(CPPFLAGS) --output-file $@ $<
> >

Cheers,
Ralf




Re: Circular dependency dropped warning from make in relating to CUDA code

2009-06-29 Thread Adam Mercer
On Mon, Jun 29, 2009 at 20:29, Ralf Wildenhues wrote:

> Using $< in inference rules, as in my example, is portable.
> In target rules, you can spell out the input file name
> (including an eventual vpath prefix).

Thanks for the clarification.

Cheers

Adam