make question

bridged with qdn.public.devtools
Post Reply
Bill Caroselli (Q-TPS)

make question

Post by Bill Caroselli (Q-TPS) » Tue Jul 09, 2002 9:44 pm

I have a makefile that looks something like this:

----------------------
DIRS: x y z

all:
for DIR in ${DIRS} ; do ( cd $$DIR ; make ) ; done
----------------------

If one of the nested makes fails I want this outer make to abort. I have
tried all kinds of gimicks but can't seem to find the magic.

What is the trick to make this outer make abort if an inner make fails?

Kris Warkentin

Re: make question

Post by Kris Warkentin » Wed Jul 10, 2002 12:37 pm

There may be better ways to do it but what I might try doing is checking the
return value of make within your script. If make fails, you just exit the
loop. The other option which you'll find fairly educational is to look at
our recursive makefile stuff. Take a look at /usr/include/recurse.mk to see
how it's done. The O'Reilly Make book is really good too.

cheers,

Kris

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agfl61$rh6$1@inn.qnx.com...
I have a makefile that looks something like this:

----------------------
DIRS: x y z

all:
for DIR in ${DIRS} ; do ( cd $$DIR ; make ) ; done
----------------------

If one of the nested makes fails I want this outer make to abort. I have
tried all kinds of gimicks but can't seem to find the magic.

What is the trick to make this outer make abort if an inner make fails?


Bill Caroselli (Q-TPS)

Re: make question

Post by Bill Caroselli (Q-TPS) » Wed Jul 10, 2002 1:13 pm

My makefile is fashioned after the PhAB makefiles.

The "for; do ; done" below is a shell script line I know. But it is in a
makefile, not in a shell script. I just can't seam to find the right place
to test the return of the nested make and force an abort in the outer make.

"Kris Warkentin" <kewarken@qnx.com> wrote in message
news:agh9o8$ah1$1@nntp.qnx.com...
There may be better ways to do it but what I might try doing is checking
the
return value of make within your script. If make fails, you just exit the
loop. The other option which you'll find fairly educational is to look at
our recursive makefile stuff. Take a look at /usr/include/recurse.mk to
see
how it's done. The O'Reilly Make book is really good too.

cheers,

Kris

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agfl61$rh6$1@inn.qnx.com...
I have a makefile that looks something like this:

----------------------
DIRS: x y z

all:
for DIR in ${DIRS} ; do ( cd $$DIR ; make ) ; done
----------------------

If one of the nested makes fails I want this outer make to abort. I
have
tried all kinds of gimicks but can't seem to find the magic.

What is the trick to make this outer make abort if an inner make fails?




Bill Caroselli (Q-TPS)

Re: make question

Post by Bill Caroselli (Q-TPS) » Wed Jul 10, 2002 1:19 pm

In QNX4 I don't have a /usr/include/recurse.mk file. Where should it be?

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:aghbka$7nu$1@inn.qnx.com...
My makefile is fashioned after the PhAB makefiles.

The "for; do ; done" below is a shell script line I know. But it is in a
makefile, not in a shell script. I just can't seam to find the right
place
to test the return of the nested make and force an abort in the outer
make.

"Kris Warkentin" <kewarken@qnx.com> wrote in message
news:agh9o8$ah1$1@nntp.qnx.com...
There may be better ways to do it but what I might try doing is checking
the
return value of make within your script. If make fails, you just exit
the
loop. The other option which you'll find fairly educational is to look
at
our recursive makefile stuff. Take a look at /usr/include/recurse.mk to
see
how it's done. The O'Reilly Make book is really good too.

cheers,

Kris

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agfl61$rh6$1@inn.qnx.com...
I have a makefile that looks something like this:

----------------------
DIRS: x y z

all:
for DIR in ${DIRS} ; do ( cd $$DIR ; make ) ; done
----------------------

If one of the nested makes fails I want this outer make to abort. I
have
tried all kinds of gimicks but can't seem to find the magic.

What is the trick to make this outer make abort if an inner make
fails?






Kevin Caporaso

Re: make question

Post by Kevin Caporaso » Wed Jul 10, 2002 1:31 pm

Bill,
I have attached it for you.
I found it under QNX 6.2NC in /usr/include/



"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:aghc03$7t6$1@inn.qnx.com...
In QNX4 I don't have a /usr/include/recurse.mk file. Where should it be?

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:aghbka$7nu$1@inn.qnx.com...
My makefile is fashioned after the PhAB makefiles.

The "for; do ; done" below is a shell script line I know. But it is in
a
makefile, not in a shell script. I just can't seam to find the right
place
to test the return of the nested make and force an abort in the outer
make.

"Kris Warkentin" <kewarken@qnx.com> wrote in message
news:agh9o8$ah1$1@nntp.qnx.com...
There may be better ways to do it but what I might try doing is
checking
the
return value of make within your script. If make fails, you just exit
the
loop. The other option which you'll find fairly educational is to
look
at
our recursive makefile stuff. Take a look at /usr/include/recurse.mk
to
see
how it's done. The O'Reilly Make book is really good too.

cheers,

Kris

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agfl61$rh6$1@inn.qnx.com...
I have a makefile that looks something like this:

----------------------
DIRS: x y z

all:
for DIR in ${DIRS} ; do ( cd $$DIR ; make ) ; done
----------------------

If one of the nested makes fails I want this outer make to abort. I
have
tried all kinds of gimicks but can't seem to find the magic.

What is the trick to make this outer make abort if an inner make
fails?








begin 666 recurse.mk
M(PT*(PE'96YE<F%L;'D@=7-E9G5L(')E8W5R<VEV92!M86ME9FEL92X-"B,-
M"B,)1FEN9',@86YY('-U8F1I<F5C=&]R:65S('=I=&@@(DUA:V5F:6QE(B!I
M;B!T:&5M+"!A;F0-"B,)<F5C=7)S97,@:6YT;R!T:&5M+"!I<W-U:6YG(")M
M86ME(B!W:71H('1H92!S<&5C:69I960-"B,)=&%R9V5T+B!$;R!N;W0@<F5C
M=7)S92!I;G1O(&$@9&ER96-T;W)Y(&EF('1H97)E(&ES( T*(R @(&$@(DUA
M:V5F:6QE+F1N;2(@9FEL92!P<F5S96YT+@T*(PT*#0IE>'!O<G0-"G5N97AP
M;W)T(%!71 T*=6YE>'!O<G0@3$E35 T*=6YE>'!O<G0@;6%K96QI<W0-"G5N
M97AP;W)T(&UA:V5F:6QE<PT*=6YE>'!O<G0@;6MF:6QE#0IU;F5X<&]R="!F
M;W)C95]D:7)S#0IU;F5X<&]R="!Q8F1I<@T*=6YE>'!O<G0@9FER<W1D:7(-
M"G5N97AP;W)T(')E<W1D:7(-"G5N97AP;W)T('-E< T*=6YE>'!O<G0@;6%K
M96-M9 T*=6YE>'!O<G0@:6Y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DQ97T1)4E,I("0H3$%415]$25)3*2P@)"AM86ME;&ES="DI("0H9FEL
M=&5R("0H3$%415]$25)3*2PD*&UA:V5L:7-T*2D-"F9I<G-T9&ER.CTD*&9I
M<G-T=V]R9" D*&UA:V5L:7-T*2D-"G)E<W1D:7(@.CTD*&9I;'1E<BUO=70@
M)"AF:7)S=&1I<BDL("0H;6%K96QI<W0I*0T*#0II9FYE<2 H)"AF:6YD<W1R
M:6YG(&LL)"A-1DQ!1U,I*2PI#0IS97 Z/3L-"F5L<V4-"G-E<#H])B8-"F5N
M9&EF#0H-"FUA:V5C;60@/2 D*$U!2T4I("UJ("0H9FER<W1W;W)D("0H2DQ%
M5D5,*2 Q*2 M0R0H9&ER*2 M9B0H;6MF:6QE*2 D*&EF("0H34%+14--1$=/
M04Q3*2PD0"D-"@T*)"AF:6QT97(M;W5T(&%L;"P@)"A-04M%0TU$1T]!3%,I
M*2!A;&PZ#0H))"AF;W)E86-H(&1I<BP@)"AF:7)S=&1I<BDL("0H;6%K96-M
M9"DI)"AF;W)E86-H(&1I<BP@)"AR97-T9&ER*2P@)"AS97 I("0H;6%K96-M
%9"DI#0H`
`
end

Bill Caroselli (Q-TPS)

Re: make question

Post by Bill Caroselli (Q-TPS) » Wed Jul 10, 2002 1:54 pm

Thank you. That gives my some ideas.

"Kevin Caporaso" <kcaporaso@pillardata.com> wrote in message
news:aghcrq$csa$1@nntp.qnx.com...
Bill,
I have attached it for you.
I found it under QNX 6.2NC in /usr/include/



"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:aghc03$7t6$1@inn.qnx.com...
In QNX4 I don't have a /usr/include/recurse.mk file. Where should it
be?

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:aghbka$7nu$1@inn.qnx.com...
My makefile is fashioned after the PhAB makefiles.

The "for; do ; done" below is a shell script line I know. But it is
in
a
makefile, not in a shell script. I just can't seam to find the right
place
to test the return of the nested make and force an abort in the outer
make.

"Kris Warkentin" <kewarken@qnx.com> wrote in message
news:agh9o8$ah1$1@nntp.qnx.com...
There may be better ways to do it but what I might try doing is
checking
the
return value of make within your script. If make fails, you just
exit
the
loop. The other option which you'll find fairly educational is to
look
at
our recursive makefile stuff. Take a look at
/usr/include/recurse.mk
to
see
how it's done. The O'Reilly Make book is really good too.

cheers,

Kris

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agfl61$rh6$1@inn.qnx.com...
I have a makefile that looks something like this:

----------------------
DIRS: x y z

all:
for DIR in ${DIRS} ; do ( cd $$DIR ; make ) ; done
----------------------

If one of the nested makes fails I want this outer make to abort.
I
have
tried all kinds of gimicks but can't seem to find the magic.

What is the trick to make this outer make abort if an inner make
fails?











Kris Warkentin

Re: make question

Post by Kris Warkentin » Wed Jul 10, 2002 5:23 pm

I didn't test this but something like this might do the trick. It seems to
me that make must invoke a shell to execute the commands under 'all:' so if
you caused that shell to exit with an error code, it should cause the make
to abort.

DIRS: x y z
all:
for DIR in ${DIRS} ; do ( cd $$DIR ; if ! make ; then exit 1 ; fi ) ;
done

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:aghbka$7nu$1@inn.qnx.com...
My makefile is fashioned after the PhAB makefiles.

The "for; do ; done" below is a shell script line I know. But it is in a
makefile, not in a shell script. I just can't seam to find the right
place
to test the return of the nested make and force an abort in the outer
make.

David Bacon

Re: make question

Post by David Bacon » Wed Jul 10, 2002 5:29 pm

You should probably invoke make as $(MAKE) too, so that "make -n" will work.

dB

"Kris Warkentin" <kewarken@qnx.com> wrote in message
news:aghqhd$n5q$1@nntp.qnx.com...
I didn't test this but something like this might do the trick. It seems
to
me that make must invoke a shell to execute the commands under 'all:' so
if
you caused that shell to exit with an error code, it should cause the make
to abort.

DIRS: x y z
all:
for DIR in ${DIRS} ; do ( cd $$DIR ; if ! make ; then exit 1 ; fi ) ;
done

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:aghbka$7nu$1@inn.qnx.com...
My makefile is fashioned after the PhAB makefiles.

The "for; do ; done" below is a shell script line I know. But it is in
a
makefile, not in a shell script. I just can't seam to find the right
place
to test the return of the nested make and force an abort in the outer
make.


Bill Caroselli (Q-TPS)

Re: make question

Post by Bill Caroselli (Q-TPS) » Thu Jul 11, 2002 6:55 pm

Hi Kris

Thanks for all of your help. You've gone way above and beyond with all your
help both here and through e-mail.

The QNX4 make lacks a few features that the RTP make has that made most of
the suggestions unusable. They did however all give me good ideas.

I wanted to post the final makefile that I'm using in case anyone else wants
to do this. Here it is:
-------------------
DIRS := $(shell ls -D)

firstdir := $(firstword $(DIRS))
restdir := $(filter-out $(firstdir), $(DIRS))

ifneq ($(findstring k,$(MFLAGS)),)
sep := ;
else
sep := &&
endif

..PHONY: all
all:
cd $(firstdir) && $(MAKE) --no-print-directory $(MAKEFLAGS) \
$(foreach dir, $(restdir), $(sep) \
cd ../$(dir) && $(MAKE) --no-print-directory $(MAKEFLAGS) )

..PHONY: clean
clean:
cd $(firstdir) && $(MAKE) --no-print-directory $(MAKEFLAGS) clean \
$(foreach dir, $(restdir), $(sep) \
cd ../$(dir) && $(MAKE) --no-print-directory $(MAKEFLAGS) clean )

..PHONY: uncond
uncond: clean all

Kris Warkentin

Re: make question

Post by Kris Warkentin » Thu Jul 11, 2002 7:10 pm

Looks like you went from zero to make expert in 60 seconds flat.

;-)

Kris

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agkk1j$nvr$1@inn.qnx.com...
Hi Kris

Thanks for all of your help. You've gone way above and beyond with all
your
help both here and through e-mail.

The QNX4 make lacks a few features that the RTP make has that made most of
the suggestions unusable. They did however all give me good ideas.

I wanted to post the final makefile that I'm using in case anyone else
wants
to do this. Here it is:
-------------------
DIRS := $(shell ls -D)

firstdir := $(firstword $(DIRS))
restdir := $(filter-out $(firstdir), $(DIRS))

ifneq ($(findstring k,$(MFLAGS)),)
sep := ;
else
sep := &&
endif

.PHONY: all
all:
cd $(firstdir) && $(MAKE) --no-print-directory $(MAKEFLAGS) \
$(foreach dir, $(restdir), $(sep) \
cd ../$(dir) && $(MAKE) --no-print-directory $(MAKEFLAGS) )

.PHONY: clean
clean:
cd $(firstdir) && $(MAKE) --no-print-directory $(MAKEFLAGS) clean \
$(foreach dir, $(restdir), $(sep) \
cd ../$(dir) && $(MAKE) --no-print-directory $(MAKEFLAGS) clean )

.PHONY: uncond
uncond: clean all


Bill Caroselli (Q-TPS)

Re: make question

Post by Bill Caroselli (Q-TPS) » Thu Jul 11, 2002 7:39 pm

Well, thank you. But I like to think I didn't start at zero. I had written
some pretty fancy makefiles in my time. I've posted some of them. I like
to write makefiles that don't need to be updated ever as new modules are
added to a project.

So now I have four kinds of makefiles.
1. makes all source files in a directory into a library
2. makes all source files in a directory into a single executable
3. makes all source files in a directory each into it's own executable
4. make files for parent directories

"Kris Warkentin" <kewarken@qnx.com> wrote in message
news:agkl5r$hf$1@nntp.qnx.com...
Looks like you went from zero to make expert in 60 seconds flat.

;-)

Kris

Mario Charest

Re: make question

Post by Mario Charest » Thu Jul 11, 2002 8:31 pm

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agkmjn$puu$1@inn.qnx.com...
Well, thank you. But I like to think I didn't start at zero. I had
written
some pretty fancy makefiles in my time. I've posted some of them. I like
to write makefiles that don't need to be updated ever as new modules are
added to a project.

So now I have four kinds of makefiles.
1. makes all source files in a directory into a library
2. makes all source files in a directory into a single executable
3. makes all source files in a directory each into it's own executable
4. make files for parent directories
I use the same makefile for both 1 and 2. The makefile checks for presence
of "exe" directory and/or "lib" directory
"Kris Warkentin" <kewarken@qnx.com> wrote in message
news:agkl5r$hf$1@nntp.qnx.com...
Looks like you went from zero to make expert in 60 seconds flat.

;-)

Kris


Bill Caroselli (Q-TPS)

Re: make question

Post by Bill Caroselli (Q-TPS) » Thu Jul 11, 2002 8:46 pm

Ah! But my working bin and lib directories are not within the normal
directory structure. They are stored on a Hugh RAM disk for speed. An
'install' goal copies the files to hard drive directories.

"Mario Charest" <postmaster@127.0.0.1> wrote in message
news:agkpn4$s9v$1@inn.qnx.com...
"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agkmjn$puu$1@inn.qnx.com...

So now I have four kinds of makefiles.
1. makes all source files in a directory into a library
2. makes all source files in a directory into a single executable
3. makes all source files in a directory each into it's own executable
4. make files for parent directories

I use the same makefile for both 1 and 2. The makefile checks for
presence
of "exe" directory and/or "lib" directory

Mario Charest

Re: make question

Post by Mario Charest » Fri Jul 12, 2002 12:14 am

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agkqgo$sto$1@inn.qnx.com...
Ah! But my working bin and lib directories are not within the normal
directory structure. They are stored on a Hugh RAM disk for speed. An
'install' goal copies the files to hard drive directories.
So what, just create dummy directory or even file to let the make
know what type to build of target to build. Where the target goes is
irrelevent.

Personnaly I've inspired myself from QNX common makefiles.
Creating directory x86/o will generate an executable.
Creating directory x86/a will generate a library
Creating directory x86/so will generate a share object
Creating directory x86/o.d will generate a debugged executable
....

For know I don't support anything else then x86 cause that's all I need ;-)
I one project I added support for qnx4/o, qnx4/a, ... The same makefile
and source can be use for both QNX6 and QNX4.

..
"Mario Charest" <postmaster@127.0.0.1> wrote in message
news:agkpn4$s9v$1@inn.qnx.com...

"Bill Caroselli (Q-TPS)" <QTPS@EarthLink.net> wrote in message
news:agkmjn$puu$1@inn.qnx.com...

So now I have four kinds of makefiles.
1. makes all source files in a directory into a library
2. makes all source files in a directory into a single executable
3. makes all source files in a directory each into it's own executable
4. make files for parent directories

I use the same makefile for both 1 and 2. The makefile checks for
presence
of "exe" directory and/or "lib" directory


Post Reply

Return to “qdn.public.devtools”