I'm trying to use the patsubst function in my makefile. I have a directory with
the following in it:
Makefile
src/apple.cpp
objs/release
bin/
and here is the Makefile:
TARGET = test
SRC = apple.cpp
VPATH = src
SRC_DIR = src
CC = g++
OBJ_RELEASE_DIR = release
OBJ_DIR = ../$(TARGET)/objs
BIN_DIR = bin
OBJS = $(patsubst %.cpp,$(OBJ_DIR)/$(OBJ_RELEASE_DIR)/%.o,$(SRC))
all:
$(MAKE) $(BIN_DIR)/$(TARGET)
$(OBJS): $(patsubst %.o,%.cpp,$(notdir $@))
$(CC) -c $^ -o $@
$(CC) -c $(SRC_DIR)/$(*F).cpp -o $@
$(BIN_DIR)/$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $@
The first rule for $(OBJS) doesn't work; the second works only because of an
implicit rule match (not because of what I'm trying to do). The problem with
that is it only works if I do a make clean and then build everything (i.e. I
have multiple cpp files I'm dependent on). It doesn't detect if a single source
file is newer than it's associated object file.
I'm using GNU make 3.81 on Solaris, but get the same problems on Red Hat linux.
Any help would be appreciated.
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make