Given a directory ./src that has an arbitrary number of .cpp files, and a
directory ./obj that will contain the object files, I am trying to create a
Makefile that will automatically create all of the .o files, regardless of
what files are added/removed from ./src.

My thought is to use an included Makefile that has the rules to create each
of the .o files.

To create the .o files I use g++ -MM src/*cpp > Makefile.obj to create the
included file.

My Makefile looks like this:

target : ...

Makefile.obj : dummy
   g++ -MM src/*cpp > Makefile.obj

.PHONY : dummy
dummy :
   -@ ls > /dev/null 2> /dev/null

include Makefile.obj



I'm trying to make sure that Makefile.obj is recreated each time that make
is run.  The dummy target is the only way I can think of making sure that
the Makefile.obj target is always run, but this seems like a really bad way
of doing this.  The problem (not a big deal in this case) is that the
Makefile.obj target gets run 2-3 times.

Also, on a sidenote, this creates a file with the format:
file.o: file.cpp ...

I'm also trying to figure out how to prepend "obj/" to each line in the
file.
--------------------
BYU Unix Users Group http://uug.byu.edu/
The opinions expressed in this message are the responsibility of their
author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG. ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to