TARGET = xxx
SRCDIRS = .
SRCEXTS := .c .cpp
SRC = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
OBJ = $(foreach x,$(SRCEXTS), $(patsubst %$(x),%.o,$(filter %$(x),$(SRC))))
CFLAGS += -Wall -g \
-I../libjson/include/ \
-I../mylib \
CPPFLAGS += $(CFLAGS)
CXXFLAGS += $(CFLAGS)
LDLIBS += -lm \
../libjson/lib/$(CROSS)/libjson.a \
../netzip_build/lib/libz.a
$(TARGET): $(OBJ)
$(CXX) -o $(TARGET) $(OBJ) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LDLIBS)
%.o: %.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o [email protected]
%.o: %.cpp
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o [email protected]
%.d: %.c
@set -e; rm -f [email protected]; \
$(CC) -MM $(CFLAGS) $< > [email protected]$$$$; \
sed ‘s,\($*\)\.o[ :]*,\1.o [email protected] : ,g‘ < [email protected]$$$$ > [email protected]; \
rm -f [email protected]$$$$
%.d: %.cpp
@set -e; rm -f [email protected]; \
$(CXX) -MM $(CPPFLAGS) $< > [email protected]$$$$; \
sed ‘s,\($*\)\.o[ :]*,\1.o [email protected] : ,g‘ < [email protected]$$$$ > [email protected]; \
rm -f [email protected]$$$$
include $(OBJ:.o=.d)
install:
cp $(TARGET) /srv/nfs
clean:
rm -f $(TARGET)
rm -f $(OBJ)