kux 55 Junior Poster

ok, long story make it short

I have a quite large project, a makefile and gnu make. All runs fine.
Trying to port the project to windows, and building with mingw32-make I come accross some problems... One of it is that i can't use sed for automatic dependeny generation as described in the gnu make manual, so I tried to find a workarround, writing a more simple automatic dependency "generator"

So, this is a dummy project:

add.h
int add ( int x, int y );

add.cpp

#include "add.h"
int add ( int x, int y) { return x+y; }

main.cpp

#include "add.h" 
#include <iostream>
using namespace std;
int main( int argc, char* argv[] )
{
	cout<<endl<<add(3,4)<<endl;
}

and the makefile:

SOURCES = main.cpp add.cpp
DEPS = main.d add.d
OBJS = main.o add.o

PRG = prg

MAKE = mingw32-make

CC = g++

.DEFAULT_GOAL: all

all:
	$(MAKE) deldep
	$(MAKE) $(PRG)

$(PRG): $(OBJS)
	$(CC) -o $(PRG) $(OBJS)
	
%.o:%.cpp
	$(CC) -c "$<" 
	
deldep:
#	rm -f $(DEPS)
	del *.d /q
	
%.d:%.cpp 
	$(CC) -E -M -MF "$@" -c "$<"

-include $(DEPS)
	
clean:
#	rm -f $(OBJS) $(PRG) $(DEPS)
	del *.d *.o prg /q

the deal is I want all .d dependency files to be recreated each time i run make. This is done via deldep target that deletes all the .d files. When all target is the dependeny files don't exist (beacause of $(MAKE) deldep ), they are created, and then the .o files and exe file are built using these dependencys. It all runs very fine on linux with gnu make, but when i port it on win I end up in an infinite loop:

D:\portmake>mingw32-make
g++ -E -M -MF "add.d" -c "add.cpp"
g++ -E -M -MF "main.d" -c "main.cpp"
g++ -E -M -MF "add.d" -c "add.cpp"
g++ -E -M -MF "main.d" -c "main.cpp"
g++ -E -M -MF "add.d" -c "add.cpp"
g++ -E -M -MF "main.d" -c "main.cpp"
g++ -E -M -MF "add.d" -c "add.cpp"
g++ -E -M -MF "main.d" -c "main.cpp"
g++ -E -M -MF "add.d" -c "add.cpp"
g++ -E -M -MF "main.d" -c "main.cpp"
g++ -E -M -MF "add.d" -c "add.cpp"
g++ -E -M -MF "main.d" -c "main.cpp"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.