pico-http/http/Makefile
adgundersen 1b54b78416 Fix Makefiles and add README
The http/ and hashtable/ Makefiles named sources that do not exist
(test.c, net.c, net.h in http/; http.h in hashtable/) and had no way to
find the sibling hashtable/llist sources they link against, so neither
directory built at all. Both now compile those sources with explicit
recipes.

VPATH would be the terser fix but is deliberately avoided: it searches
for targets as well as sources, so a stale ../llist/test.o gets linked
in place of a freshly compiled one, and hashtable/test silently runs the
linked-list suite instead of its own.

llist/Makefile built fine; its .PHONY read "all," with a comma, making
that the literal target name, and test.o was missing its llist.h
dependency.

README covers layout, build, run, the use()/Handler routing API, and the
library tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 20:53:09 +00:00

33 lines
822 B
Makefile

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