views:

323

answers:

2

I have a makefile (using nmake & VC++ 2005):

CPP_OBJS = $(CPP_SOURCE:.cpp=.obj)


$(TARGET) : $(CPP_OBJS)
    $(link) $(ldebug) $(lflags) /DLL \
    $(LIBPATHS) \
    $out:$@ $(CPP_OBJS) $(conlibs)

The problem is link step fails because $(CPP_OBJS) are expanded into the list of files where each filename is prepended with a folder name (that way it was generated from CPP_SOURCE) . And since all of the .obj files are in the current folder (results of the compilation) - the link.exe fails to locate .objs.

I need something like: (I found it here: http://uw714doc.sco.com/cgi-bin/info2html?%28make.info%29File%2520Name%2520Functions&lang=en)

`$(notdir NAMES...)' Extracts all but the directory-part of each file name in NAMES. If the file name contains no slash, it is left unchanged. Otherwise, everything through the last slash is removed from it.

but that thing does not seem to be working for NMAKE which comes with VC++ 2005.

Any ideas how to overcome this issue are greatly appreciated. Thank you.

A: 
Beta
A: 

Since nmake doesn't support '$(notdir NAMES...)' and its macro substitution doesn't support easy removal of the folder hierarchy from the source file name(s), would it be possible to change the compilation to output the object file(s) into the same folder(s) as the source?

cpp.obj:
    $(CC) $(CFLAGS) /c /Fo $*.obj $*.cpp

I'm no nmake expert, but I believe this may help you to overcome this issue.

jschmier