include ./../../../linux.mk
L := $(notdir $(realpath $(CURDIR)/..))
M := libweb_server
O := $(LIB_REL)/$(M).a
S := $(SRC_ROOT_DIR)/$(L)/libweb_server/src
I := -I$(SRC_ROOT_DIR)/$(L)/libweb_server/inc \
     -I$(SRC_ROOT_DIR)/$(L)/inc \
     -I$(SRC_ROOT_DIR)/protocol/libmongoose/inc \
     -I$(SRC_ROOT_DIR)/public/libdatacenter/inc \
     -I$(SRC_ROOT_DIR)/public/liblog/inc \
     -I$(SRC_ROOT_DIR)/public/libfunc/inc \
     -I$(SRC_ROOT_DIR)/public/libcmd/inc \
     -I$(SRC_ROOT_DIR)/public/libtask/inc \
     -I$(SRC_ROOT_DIR)/public/libcJSON/inc
B := $(CURDIR)/$(M)/obj
SRCS := $(wildcard $(S)/*.cpp)
OBJS := $(patsubst $(S)/%.cpp, $(B)/%.o, $(SRCS))
F := $(CXX_FLAGS) $(I)

.PHONY: all
all:
	@mkdir -p $(ROOT_DIR)/release/inc
	@$(MAKE) $(O)

$(O): $(OBJS)
	@mkdir -p $(dir $@)
	$(AR) rcs $@ $^
	@echo "[$(M)] built"

$(B)/%.o: $(S)/%.cpp
	@mkdir -p $(dir $@)
	$(CXX) $(F) -c $< -o $@

.PHONY: clean
clean:
	rm -rf $(B) $(O)

.PHONY: rebuild
rebuild: clean all
