Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NMake Pattern Rules

Hi I decided to try and learn how to build programs via the command line and makefiles instead of relying on Visual Studio to do it for me. After familiarizing myself with the process of compiling into .obj files and linking, I moved onto NMake. I've written a basic makefile to try and compile source files located in multiple folders into .obj files, link each folder of .obj files into .lib files and then link the .lib files into a .exe file.

CC=cl /c /EHsc /Fo
LIB=lib /OUT:
LINKER=link /OUT:
EXEC_NAME=Test.exe
DEL=del
MAKE=nmake
OUT=.\out

all: $(OUT)\*.lib
    $(LINKER)$(EXEC_NAME) *.lib

clean:
    $(DEL) $(OUT)

rebuild:
    $(MAKE) clean
    $(MAKE) all

$(OUT)%.lib: $(OUT)\%\*.obj
    $(LIB)%.lib $(OUT)%\*.obj

%(OUT)\%\:
    $(CC)$(OUT)\%\ .\%\*.cpp

When I try to run it with nmake all it tells me: NMAKE : fatal error U1073: don't know how to make '.\out\*.lib'

Thanks in advance.

like image 644
deebee396 Avatar asked Oct 06 '12 12:10

deebee396


1 Answers

This question was understandably ignored for a year-and-a-half but has lately attracted 4 upvotes.

No question is actually stated but the implied question is: Why can't nmake follow the %-pattern rules in my makefile?

The answer to that is MS nmake does not support %-pattern rules at all. The documentation of MS nmake and of its inference rules is easily found.

GNU make and some other make tools support %-pattern rules. The makefile here would also fail in GNU make due to obvious blunders.

like image 91
Mike Kinghan Avatar answered Nov 04 '22 06:11

Mike Kinghan