I am trying to modify a makefile that builds cpp to a c file, but I am running into some string substitution problem. I wonder if someone can point out the mistake.
here's a piece of the file:
SOURCES := \
lz4.c \
lz4frame.c \
lz4hc.cpp \
xxhash.c
OBJECTS := $(addprefix $(OBJ_DIR)/,$(subst .c,.o,$(SOURCES)))
DEPENDS := $(addprefix $(OBJ_DIR)/,$(subst .c,.d,$(SOURCES)))
all: $(OUT_DIR)/$(LIB_NAME)
clean:
rm -rf $(OBJ_DIR)
rm -rf $(OUT_DIR)
$(OUT_DIR)/$(LIB_NAME): $(OBJECTS)
@rm -f $@
$(AR) cr $@ $^
$(OBJECTS): $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(@D)
$(CXX) -MMD -MF $(OBJ_DIR)/$*.d -MP -MT'$(OBJ_DIR)/$*.o $(OBJ_DIR)/$*.d' -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
.PHONY: all clean
-include $(DEPENDS)
but when I typed make clean I get this:
Makefile:38: target `Release64/obj/lz4hc.opp' doesn't match the target pattern
or when I try to build I get this:
g++-4.6 -MMD -MF ./Release64/obj/Release64/obj/lz4hc.opp.d -MP -MT'./Release64/obj/Release64/obj/lz4hc.opp.o ./Release64/obj/Release64/obj/lz4hc.opp.d' -c -I../../../include -I../../../thirdparty/include/lz4 -std=c++0x -fPIC -O2 -m64 -o Release64/obj/lz4hc.opp
g++-4.6: fatal error: no input files
compilation terminated.
I think the issue is with this line, but I can't figure out the problem:
OBJECTS := $(addprefix $(OBJ_DIR)/,$(subst .c,.o,$(SOURCES)))
DEPENDS := $(addprefix $(OBJ_DIR)/,$(subst .c,.d,$(SOURCES)))
thx!