CC   = gcc
OPTS = -g -Wall

all: mfs.o functions.o udp.o libmfs.so main server client

main: functions.o mfs.o udp.o libmfs.so
	gcc -g -lmfs -L. -o main main.c -Wall -Werror

mfs.o: mfs.c  
	gcc -g -c -fPIC mfs.c -Wall -Werror

functions.o: functions.c
	gcc -g -c -fPIC functions.c -Wall -Werror

udp.o: udp.h
	gcc -g -c -fPIC udp.c -Wall -Werror

libmfs.so: mfs.o functions.o udp.o
	gcc -g -shared -o libmfs.so mfs.o functions.o udp.o

# this generates the target executables
server: server.o udp.o
	$(CC) -g -o server server.o udp.o mfs.o functions.o

client: client.o udp.o
	$(CC) -g -o client client.o udp.o mfs.o functions.o

# this is a generic rule for .o files 
%.o: %.c 
	$(CC) $(OPTS) -c $< -o $@

clean:
	rm -f mfs.o functions.o main.o libmfs.so main server.o udp.o client.o server client



