diff --git a/Makefile b/Makefile index 8271ab1..561a726 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,29 @@ + +CFLAGS = -ggdb +LFLAGS = + +ifeq ($(shell uname -s),Linux) + EXT = +else + EXT = .exe + LFLAGS += -lws2_32 +endif + +HTTPS ?= 0 +ifneq ($(HTTPS),0) + CFLAGS += -DHTTPS_ENABLED + LFLAGS += -lcrypto -lssl +endif + .PHONY: all clean example -all: chttp.c chttp.h simple_client simple_server +all: chttp.c chttp.h simple_client$(EXT) simple_server$(EXT) chttp.c chttp.h: $(wildcard src/*.c src/*.h) misc/amalg.py Makefile python misc/amalg.py -%: examples/%.c chttp.c chttp.h - gcc $< chttp.c -o $@ -ggdb +%$(EXT): examples/%.c chttp.c chttp.h + gcc $< chttp.c -o $@ $(CFLAGS) $(LFLAGS) clean: - rm chttp.c chttp.h + rm chttp.c chttp.h simple_client simple_client.exe simple_server simple_server.exe diff --git a/examples/simple_server.c b/examples/simple_server.c index 3ce3d34..5bf0777 100644 --- a/examples/simple_server.c +++ b/examples/simple_server.c @@ -20,13 +20,13 @@ int main(void) for (;;) { - void *ptrs[HTTP_SERVER_CAPACITY+3]; - struct pollfd polled[HTTP_SERVER_CAPACITY+3]; + void *ptrs[HTTP_SERVER_POLL_CAPACITY]; + struct pollfd polled[HTTP_SERVER_POLL_CAPACITY]; EventRegister reg = { .ptrs=ptrs, .polled=polled, - .max_polled=HTTP_SERVER_CAPACITY+3, + .max_polled=HTTP_SERVER_POLL_CAPACITY, .num_polled=0, };