# ZNet/Makefile
# Makefile for ZNet, requires GNU "make"

BINNAME := $(DIST)/libZNet.a
ifeq ($(TARGET),debug)
	BINNAME := $(subst .a,_d.a, $(BINNAME))
endif

SRC := \
	ZNetBandwidthMeter.cpp \
	ZNetClient.cpp \
	ZNetHost.cpp \
	ZNetPacketChannel.cpp \
	ZNetPeer.cpp \
	ZNetPrivate.cpp \
	ZNetServer.cpp

OBJ := $(addprefix obj/$(ARCH)/$(TARGET)/,$(subst .cpp,.o,$(SRC)) ) 

$(shell mkdir -p obj/$(ARCH)/$(TARGET))

$(BINNAME): $(OBJ)
	$(AR) cru $@ $+
	$(RANLIB) $@

# CLEAN
clean:
	@-rm -r -f obj $(DIST)/libZNet*.a
	

# *.cpp files to *.o files
obj/$(ARCH)/$(TARGET)/%.o: %.cpp
	@echo CXX $@
	@$(CXX) $(CXXFLAGS) -c $*.cpp -o obj/$(ARCH)/$(TARGET)/$*.o
