CC=gcc
AR = ar
ARFLAGS = ru
RANLIB = ranlib
CFLAGS= -g
SRCS= client.c server.c
LIBS = -L./SocketLibrary/

all:: threadpool_test socketlib client server example_thread

socketlib:
	cd SocketLibrary && make

example_thread: example_thread.o
	$(CC) -g -o example_thread example_thread.o -lpthread

client: client.o common.o
	$(CC) -g -o client client.o common.o $(LIBS) -lsock -lpthread

server: server.o common.o
	$(CC) -g -o server server.o common.o threadpool.o $(LIBS) -lsock -lpthread -lrt mythread/libthread.so

threadpool_test: threadpool_test.o threadpool.o
	$(CC) -g -o threadpool_test threadpool_test.o threadpool.o -lpthread mythread/libthread.so

client.o: client.c common.h
	$(CC) -g -o client.o -c client.c

server.o: server.c common.h
	$(CC) -g -o server.o -c server.c

common.o: common.c
	$(CC) -g -o common.o -c common.c

example_thread.o: example_thread.c
	$(CC) -g -o example_thread.o -c example_thread.c

threadpool.o: threadpool.c
	$(CC) -g -o threadpool.o -c threadpool.c

threadpool_test.o: threadpool_test.c threadpool.h
	$(CC) -g -o threadpool_test.o -c threadpool_test.c

clean:
	/bin/rm -f client server example_thread threadpool_test *.o core *~ #*
	cd SocketLibrary && make clean
