TARGET = Hoge.exe
ARCH =
SRCS = $(wildcard ../src/*.cpp)
OBJS = $(notdir $(subst .cpp,.o,$(SRCS)))
LIBS = -lsocket -lnsl -lpthread
VPATH = ../src
INCLUDE_PATH = -I../include
LIBRARY_PATH = -L/usr/lib -L/usr/local/lib
RM := rm
MV := mv
CXX := g++
CC := g++
AR := ar
RANLIB := ranlib
SED := sed
CXXFLAGS = -D_POSIX
CPPFLAGS = $(INCLUDE_PATH)
LDFLAGS = $(LIBRARY_PATH)
dependencies = $(subst .o,.d,$(OBJS))
$(ARCH): $(OBJS)
$(AR) r $(ARCH) $(OBJS)
$(RANLIB) $(ARCH)
$(TARGET): $(OBJS)
$(LINK.cpp) $(TARGET) $(OBJS) $(LIBS)
.PHONY: all clean
all: $(ARCH) $(TARGET)
clean:
$(RM) $(ARCH) $(TARGET) $(OBJS) $(dependencies) 2> /dev/null
ifneq "$(MAKECMDGOALS)" "clean"
include $(dependencies)
endif
%.d: %.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M $< | \
$(SED) 's,\($(notdir $*)\.o\) *:,$(dir $@) \1 $@: ,' > $@.tmp
$(MV) $@.tmp $@