views:

98

answers:

3

I am using non-gnu C compiler which doesn't support dependency generation option (-MM in gcc).

In this software, they are not using makefiles. They are using some ancient windows batch files to compiler and link the code.

These batch files doesn't have incremental building. I traced the batch files and I find that at the end it execute these commands:

compiler.exe -option1 -option2 *.c linker.exe -foo -bar *.obj

compilation takes loong time, because you have to compile all the files again even if you don't have any modified files!

I am searching for a stand-alone tool which generate dependencies from C files. But I didn't find any one.

EDIT: It seems that I wasn't clear enough. I can't change the batch files to makefiles, this is something BIG. I just want minor change to support incremental building.

EDIT: The required tool is a stand-alone tool which generates dependencies from c files.

A: 

Why not get Make (under Cygwin) and create Makefiles that use your compiler.exe as CC ?

SF.
There's no need to use cygwin if you just want to use make or gcc.
anon
I found Windows to be terribly inadequate development environment without Cygwin. Of course you can run Make without it, but why would you?
SF.
The problem is not in the makefile. The problem is in dependency generation which is done using gcc -MM.
Yousf
A: 

The dependency information GCC produces is actually generated by GNU make, called by the gcc driver. You can get a version of GNU make for windows from lots of places, including http://www.mingw.org/wiki/msys. You might also consider using GCC on Windows - you can get the MinGW version at http://tdragon.net/recentgcc.

anon
I just want to be sure, how can you generate dependencies without gcc?Ofcourse I can use GCC to just generate dependencies, but if there is stand-alone tool it will be better.
Yousf
+1  A: 

You have two dependencies in your project.

  1. The C files are compiled to OBJ files.
  2. The C files include header files. Changed header files require compilation of the C including files.

First topic can be written with a inference rule in your makefile. That allows to just enumerate the OBJ files, that will be used for linking.

The second topic is to find the header files that are included. I dont know a standalone tool. But you could try to write your own using the C preprocessor. You need to parse the output of this command:

cl -E -I<your_include_path> *.c | find "#line"

The file names surrounden in quotation marks gives the dependencies. If the file name ends with .c it's a target. Elsewhere it's a dependency.

harper
sorry, I mis-understand it first. I will try this :)
Yousf