[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Makefiles: difficulty with syntax for inference rule with obj files in s
From: |
LiquidEyes |
Subject: |
Makefiles: difficulty with syntax for inference rule with obj files in subdirectory (Make newbie) |
Date: |
Sun, 21 Jan 2007 22:48:18 -0000 |
One last Make question (for now!)
******************
IN BRIEF:
I'm having difficulty with the ".cpp.obj" style syntax for automatically
creating any required .obj file from its corresponding .cpp file.
I'm trying to change this:
$(FULL_LIST_OF_OBJECT_FILES_WITH_PATHS) : $(OUTPUT_PATH)/%.obj: %.cpp
#works
to something like this:
{}.cpp{$(OUTPUT_PATH)}.obj:
#doesn't work
So I'm hoping somebody can please help me with the syntax...!
******************
IN DETAIL:
I'm building a set of object files in a subdirectory from a set of .cpp
files in the current directory. I've got it working fine by explicitly
listing the object files:
#####################################
# this works a treat:
OUTPUT_PATH = ./Subfolder
TARGET_EXE = ./Subfolder/Foo.exe
FULL_OBJ_LIST = ./Subfolder/Foo.obj\
./Subfolder/Bar.obj\
./Subfolder/Another.obj
# ...
# link step
$(TARGET_EXE) : $(FULL_OBJ_LIST)
link /OUT:$(TARGET_EXE) $(FULL_OBJ_LIST)
# compile step
$(FULL_OBJ_LIST) : $(OUTPUT_PATH)/%.obj: %.cpp
$(CC) $(SWITCHES) $*.cpp
#####################################
This works absolutely fine. (Took me ages to get to this stage!) ;)
Now I've been experimenting with implicit/inference rules (not quite sure of
the terminology? -- the .cpp.obj style syntax) to achieve the same thing
without having to refer to FULL_OBJ_LIST in the compile step ... but without
any luck. :(
Here are my best attempts:
#####################################
# ATTEMPT A:
#####################################
# alternative compile step
{}.cpp{$(OUTPUT_PATH)}.obj:
$(CC) $(SWITCHES) $*.cpp
# error:
# target `{}.cpp{./Subfolder}.obj' doesn't match the target pattern
#####################################
#####################################
# ATTEMPT B:
#####################################
# alternative compile step
{}.cpp{$(OUTPUT_PATH)}.obj: $(OUTPUT_PATH)/%.obj:
$(CC) $(SWITCHES) $*.cpp
# error:
# No rule to make target `Subfolder/Foo.obj', needed by `Subfolder/Foo.exe'.
#####################################
Any idea what I'm doing wrong?
Thanks in advance!
Andy
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Makefiles: difficulty with syntax for inference rule with obj files in subdirectory (Make newbie),
LiquidEyes <=