CC=gcc
CFLAGS=-Wall -Wextra -I. -I../hashtable -I../llist

BIN=pico-http
OBJS=main.o http.o listen.o hashtable.o llist.o

all: $(BIN)

$(BIN): $(OBJS)
	$(CC) -o $@ $^

# hashtable.c and llist.c live in sibling directories and are compiled into
# this one. Explicit recipes rather than VPATH: VPATH also searches for
# *targets*, so a stale sibling .o would get linked in place of a fresh build.
main.o: main.c http.h
	$(CC) $(CFLAGS) -c -o $@ $<

http.o: http.c http.h listen.h ../hashtable/hashtable.h
	$(CC) $(CFLAGS) -c -o $@ $<

listen.o: listen.c listen.h
	$(CC) $(CFLAGS) -c -o $@ $<

hashtable.o: ../hashtable/hashtable.c ../hashtable/hashtable.h ../llist/llist.h
	$(CC) $(CFLAGS) -c -o $@ $<

llist.o: ../llist/llist.c ../llist/llist.h
	$(CC) $(CFLAGS) -c -o $@ $<

clean:
	rm -f $(OBJS) $(BIN)

.PHONY: all clean
