make giving error after make clean

Although Make is working fine but by default it only compiling those files that have been changed, even when I run make all. It say like Nothing to Do.

One scenario where I neeed to compile all the files is when I change something in a header file which is being accessed in multiple .c files. But make does not recognize it until I open any .c file any save & quit again.

Makefile contents can be seen in this post :

Questions about Makefile - what is "$+" & where are .c files/dependencies called here ?

Although this is also a problem but actual problem I want to discuss here is something different.

In order to compile all files what I did was that I ran make clean which indeed removed all object files and then I ran make again but this time it gives an error :-

 ....
 mec/gen_crc32table > mec/crc32table.h
 mec/gen_crc32table: 1: mec/gen_crc32table: Syntax error: end of file unexpected    
 (expecting ")")
 make: *** [mec/crc32table.h] Error 2

I checked contents of crc32table.h but file is empty. So, I copy crc32table.h from my backup of previous code and now its running successfully. Now I run make clean and 'make' again to check it but this time it is working fine.

I do not know what the mystery here ?

I guess these lines are doing something which I am not able to understand ? Please help me on this.

crc32.o: mec/crc32table.h mec/crc32.c
$(CC) -o $@ -c -I. $(CFLAGS) mec/crc32.c

mec/crc32table.h: mec/gen_crc32table
mec/gen_crc32table > mec/crc32table.h 

Answers


The issue is this snippet:

mec/crc32table.h: mec/gen_crc32table
    mec/gen_crc32table > mec/crc32table.h 

Ask yourself "What happens if the gen_crc32table command exits with an error?" Make stops (good) but leaves behind a corrupt crc32table.h (bad). Two choices: (i) re-write gen_crc32table so that it accepts a -o parameter; (ii) shell trickery.

(i)

mec/crc32table.h: mec/gen_crc32table
    mec/gen_crc32table -o mec/crc32table.h 

(ii)

mec/crc32table.h: mec/gen_crc32table
    mec/gen_crc32table >temp-file-with-an-obscure-name
    mv temp-file-with-an-obscure-name $@

The mv will not happen if gen_crc32table errors.


Need Your Help

Typeface.js not rendering in Internet Explorer

javascript html css typeface.js

just wodering if anyone has experience with Typeface.js ( http://typeface.neocracy.org ) and fixing issues of the font not being rendered in Internet Explorer ( 6, 7 and 8 ).

How do I send GPS coordinates to the web server?

iphone web-services gps

I'm using Xcode to build my first iPhone app. Basically, I want to track my GPS location and based on that, get data from a web service. Then I want to display that data. Actually, I want to have a...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.