[Novices] If / then in a makefile?
Bruce Smith
bruce at armintl.com
Tue Feb 7 09:01:54 EST 2006
> #!/bin/bash
> make &> /dev/null # <-- attempt a compile, hiding errors
> if [ "$?" = "0" ]; then
if [ $? -eq 0 ]; then # try this instead.
> When I do this:
> [steve at rosie test]$ make andrun
> it gets through the compile, but chokes on the if / then. Is there a
> way to get make to interpret the if / then statement correctly? Or can
> it somehow be passed out to bash and interpreted there? Or am I wasting
> my time altogether and there's a better way to do it that I just haven't
> read about? :)
You might want to redirect the output & errors of the make command to a
temporary file instead of rerunning make. That way you only have to
look at the output, and it's there in case you want to look at the
output from a successful compile. Plus it's faster/more-efficient.
- BS
More information about the Novices
mailing list