Unix Programming - How to stop make for loop when compile error

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2006 > How to stop make for loop when compile error





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to stop make for loop when compile error
dspfun

2006-10-18, 1:29 pm

Hi,

I have about 200 files spread over 15 directories, and in the top
directory there is a makefile which has a for loop which loops through
all the directories and compiles each c-file. Whenever the compilation
goes wrong for any of the c-files, make continues compiling the
remaining files. So when finally make is done, 199 files have compiled,
and 1 hasn't and then it is time consuming to search through the make
log for the file that contained the error.

What I would like to do is to stop the make program immediately
whenever any file doesn't compile correctly, make exits.
Anyone knows how to do this?

The compile line for each c-file looks like this:
$(BUILDDIR)/%.o:$(SOURCEDIR)/%.c
$(CC) $(CCFLAGS) $(GCC_FLAGS) $(BUILD_TYPE_FLAGS) -c $< -o

So I would like to do something like this:
$(BUILDDIR)/%.o:$(SOURCEDIR)/%.c
ifneq($(CC) $(CCFLAGS) $(GCC_FLAGS) $(BUILD_TYPE_FLAGS) -c $< -o, 0)
exit out of make!!
endif

BRs!

toby

2006-10-18, 1:29 pm


dspfun wrote:
> Hi,
>
> I have about 200 files spread over 15 directories, and in the top
> directory there is a makefile which has a for loop which loops through
> all the directories and compiles each c-file.


Firstly I wouldn't do this. I'd make one target depend on the
compilation results of all files and let make schedule the
compilations. You can use wildcards to help build the source list.

> Whenever the compilation
> goes wrong for any of the c-files, make continues compiling the
> remaining files. ...
> What I would like to do is to stop the make program immediately
> whenever any file doesn't compile correctly, ...


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com