TOPDIR:=.
TGT:=./restproxy

DIR=$(TOPDIR)
SRCS=$(foreach dir, $(DIR), $(wildcard $(dir)/*.c))
OBJS:=$(patsubst %.c,%.o,$(SRCS))



DIR_LIBEVENT = ./third-lib/libevent/include/
DIR_JSON = ./third-lib/json-lib/inc/
DIR_CURL = ./third-lib/libcurl/include/curl/

INCDIR = $(foreach dir, $(DIR), -I $(dir)/ )
INCDIR += -I $(DIR_LIBEVENT)
INCDIR += -I $(DIR_JSON)
INCDIR += -I $(DIR_CURL)

LIBS = /usr/lib/x86_64-linux-gnu/libidn.a ./third-lib/libcurl/lib/libcurl.a -lrt -lcrypto -lssl -lpthread ./third-lib/libevent/lib/libevent.a ./third-lib/json-lib/libmjson.a


CFLAGS = -Wall -g -DX86_64 -DTEST_RESTPROXY $(LIBS)

CC = gcc

$(TGT):$(OBJS)
	$(CC) -o $(TGT) $(CFLAGS) $(SRCS) $(INCDIR) $(LIBS)
	chmod a+x $(TGT)

$(OBJS):%.o:%.c
	$(CC) $(CFLAGS) -c -o $@ $< $(INCDIR)
clean:
	rm -rf $(OBJS) $(TGT)
